Some more testing code
This commit is contained in:
parent
9204580dc4
commit
fda9af2552
@ -31,6 +31,8 @@
|
||||
7A28283327E7263B0049BDBF /* UIStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A28283227E7263B0049BDBF /* UIStackView.swift */; };
|
||||
7A28283627E74C110049BDBF /* SwiftEntryKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7A28283527E74C110049BDBF /* SwiftEntryKit */; };
|
||||
7A28283827E74D930049BDBF /* CheckController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A28283727E74D930049BDBF /* CheckController.swift */; };
|
||||
7A2B6CD427FCE93C00519F1E /* TestSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2B6CD327FCE93C00519F1E /* TestSettings.swift */; };
|
||||
7A2B6CD727FCED0500519F1E /* XCUIApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2B6CD527FCEC8600519F1E /* XCUIApplication.swift */; };
|
||||
7A36E55C27FB55570025AACB /* Testing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A36E55B27FB55570025AACB /* Testing.swift */; };
|
||||
7A36E55D27FB5A220025AACB /* ApiMethodMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A558AAA27FA3CCF001A18EE /* ApiMethodMock.swift */; };
|
||||
7A36E55E27FB5A260025AACB /* LoginMethodMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A558AA927FA3CCF001A18EE /* LoginMethodMock.swift */; };
|
||||
@ -160,6 +162,8 @@
|
||||
7A28283027E721A70049BDBF /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
|
||||
7A28283227E7263B0049BDBF /* UIStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIStackView.swift; sourceTree = "<group>"; };
|
||||
7A28283727E74D930049BDBF /* CheckController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckController.swift; sourceTree = "<group>"; };
|
||||
7A2B6CD327FCE93C00519F1E /* TestSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSettings.swift; sourceTree = "<group>"; };
|
||||
7A2B6CD527FCEC8600519F1E /* XCUIApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCUIApplication.swift; sourceTree = "<group>"; };
|
||||
7A36E55B27FB55570025AACB /* Testing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Testing.swift; sourceTree = "<group>"; };
|
||||
7A36E56227FB5BEB0025AACB /* TestError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestError.swift; sourceTree = "<group>"; };
|
||||
7A49F49F27D4061900AEAAE0 /* AutoCat2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AutoCat2.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -337,12 +341,21 @@
|
||||
path = ACTabBar;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A2B6CD827FCED6D00519F1E /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A2B6CD527FCEC8600519F1E /* XCUIApplication.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A36E55A27FB54610025AACB /* Testing */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A558AA727FA3CCF001A18EE /* Api */,
|
||||
7A36E55B27FB55570025AACB /* Testing.swift */,
|
||||
7A36E56227FB5BEB0025AACB /* TestError.swift */,
|
||||
7A2B6CD327FCE93C00519F1E /* TestSettings.swift */,
|
||||
);
|
||||
path = Testing;
|
||||
sourceTree = "<group>";
|
||||
@ -401,6 +414,7 @@
|
||||
7A49F4C227D4061B00AEAAE0 /* AutoCat2UITests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A2B6CD827FCED6D00519F1E /* Extensions */,
|
||||
7A49F4C327D4061B00AEAAE0 /* AutoCat2UITests.swift */,
|
||||
7A49F4C527D4061B00AEAAE0 /* AutoCat2UITestsLaunchTests.swift */,
|
||||
);
|
||||
@ -815,6 +829,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7A49F4C627D4061B00AEAAE0 /* AutoCat2UITestsLaunchTests.swift in Sources */,
|
||||
7A2B6CD727FCED0500519F1E /* XCUIApplication.swift in Sources */,
|
||||
7A49F4C427D4061B00AEAAE0 /* AutoCat2UITests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -850,6 +865,7 @@
|
||||
7A49F51527D40C6100AEAAE0 /* AutoCat2.xcdatamodeld in Sources */,
|
||||
929EDE7F27F89C3000E55F65 /* VEngine.swift in Sources */,
|
||||
929EDE8727F8E11E00E55F65 /* VOsago.swift in Sources */,
|
||||
7A2B6CD427FCE93C00519F1E /* TestSettings.swift in Sources */,
|
||||
7A49F50E27D406CB00AEAAE0 /* User.swift in Sources */,
|
||||
7A36E56127FB5A330025AACB /* ApiMethodMockProtocol.swift in Sources */,
|
||||
7A36E56027FB5A2F0025AACB /* MockURLProtocol.swift in Sources */,
|
||||
|
||||
@ -9,57 +9,59 @@
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>AutoCat2.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>AutoCatCore.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>7</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>DifferenceKit (Playground) 1.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>DifferenceKit (Playground) 2.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>3</integer>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
<key>DifferenceKit (Playground).xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>SwiftDate (Playground) 1.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>5</integer>
|
||||
<integer>6</integer>
|
||||
</dict>
|
||||
<key>SwiftDate (Playground) 2.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>6</integer>
|
||||
<integer>7</integer>
|
||||
</dict>
|
||||
<key>SwiftDate (Playground).xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>4</integer>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
<key>AutoCat2UITests.testExample.xcscheme</key>
|
||||
<dict>
|
||||
<key>isShown</key>
|
||||
<false />
|
||||
<key>orderHint</key>
|
||||
<integer>8</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
||||
@ -24,7 +24,6 @@ class CoreDataSource<Item: NSManagedObject & Dated & Differentiable, Cell: Confi
|
||||
|
||||
private let cellIdentifier: String
|
||||
private let tableView: UITableView
|
||||
//private let dataSource: UITableViewDiffableDataSource<DateSection<Item>, Item>
|
||||
private let fetchedResults: NSFetchedResultsController<Item>
|
||||
private var sections: [DateSection<Item>] = []
|
||||
|
||||
@ -32,13 +31,6 @@ class CoreDataSource<Item: NSManagedObject & Dated & Differentiable, Cell: Confi
|
||||
self.tableView = tableView
|
||||
self.cellIdentifier = cellIdentifier
|
||||
|
||||
// self.dataSource = UITableViewDiffableDataSource(tableView: tableView) { tv, ip, item in
|
||||
// let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier,
|
||||
// for: ip) as? Cell
|
||||
// cell?.configure(with: item)
|
||||
// return cell
|
||||
// }
|
||||
|
||||
if let fetchRequest = Item.fetchRequest() as? NSFetchRequest<Item> {
|
||||
fetchRequest.sortDescriptors = []
|
||||
self.fetchedResults = NSFetchedResultsController(fetchRequest: fetchRequest,
|
||||
@ -51,7 +43,7 @@ class CoreDataSource<Item: NSManagedObject & Dated & Differentiable, Cell: Confi
|
||||
|
||||
super.init()
|
||||
|
||||
self.tableView.dataSource = self //self.dataSource
|
||||
self.tableView.dataSource = self
|
||||
self.tableView.reloadData()
|
||||
|
||||
self.fetchedResults.delegate = self
|
||||
@ -67,9 +59,7 @@ class CoreDataSource<Item: NSManagedObject & Dated & Differentiable, Cell: Confi
|
||||
let newSections = items.groupedByDate()
|
||||
let changeset = StagedChangeset(source: self.sections, target: newSections)
|
||||
DispatchQueue.main.async {
|
||||
print("reloading tableView")
|
||||
self.tableView.reload(using: changeset, with: .fade) { newSects in
|
||||
print("updating sections")
|
||||
self.sections = newSects
|
||||
}
|
||||
}
|
||||
@ -78,11 +68,6 @@ class CoreDataSource<Item: NSManagedObject & Dated & Differentiable, Cell: Confi
|
||||
|
||||
// MARK: - NSFetchedResultsControllerDelegate
|
||||
|
||||
// func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) {
|
||||
//
|
||||
// let snapshotBridged = snapshot as NSDiffableDataSourceSnapshot<DateSection<Item>, Item>
|
||||
// dataSource.apply(snapshotBridged)
|
||||
// }
|
||||
|
||||
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ class MainTabController: UITabBarController, UITabBarControllerDelegate {
|
||||
settingsController.tabBarItem = UITabBarItem(title: "Settings", image: UIImage(systemName: "gear"), selectedImage: nil)
|
||||
|
||||
addController.tabBarItem = UITabBarItem(title: "New", image: UIImage(systemName: "plus"), selectedImage: nil)
|
||||
addController.tabBarItem.accessibilityIdentifier = "NewCheckButton"
|
||||
|
||||
self.viewControllers = [historyNavController, addController, settingsController]
|
||||
}
|
||||
|
||||
@ -29,16 +29,6 @@ class AutoCat2UITests: XCTestCase {
|
||||
app.launchEnvironment["testKind"] = Testing.TestKind.addNumberSuccess.rawValue
|
||||
app.launch()
|
||||
|
||||
let loginButton = app.buttons["loginButton"]
|
||||
guard loginButton.waitForExistence(timeout: 5) else {
|
||||
XCTFail("Login button not found")
|
||||
return
|
||||
}
|
||||
|
||||
app.textFields["emailTextField"].tap()
|
||||
app.textFields["emailTextField"].typeText(testLogin)
|
||||
app.secureTextFields["passwordTextField"].tap()
|
||||
app.secureTextFields["passwordTextField"].typeText(testPassword)
|
||||
loginButton.tap()
|
||||
app.auth(login: testLogin, password: testPassword)
|
||||
}
|
||||
}
|
||||
|
||||
30
AutoCat2UITests/Extensions/XCUIApplication.swift
Normal file
30
AutoCat2UITests/Extensions/XCUIApplication.swift
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// XCUIApplication.swift
|
||||
// AutoCat2UITests
|
||||
//
|
||||
// Created by Selim Mustafaev on 06.04.2022.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
extension XCUIApplication {
|
||||
|
||||
func auth(login: String, password: String) {
|
||||
|
||||
let loginButton = buttons["loginButton"]
|
||||
guard loginButton.waitForExistence(timeout: 3) else {
|
||||
XCTFail("Login button not found")
|
||||
return
|
||||
}
|
||||
|
||||
textFields["emailTextField"].tap()
|
||||
textFields["emailTextField"].typeText(login)
|
||||
secureTextFields["passwordTextField"].tap()
|
||||
secureTextFields["passwordTextField"].typeText(password)
|
||||
loginButton.tap()
|
||||
|
||||
let newButtonFound = buttons["NewCheckButton"].waitForExistence(timeout: 3)
|
||||
XCTAssert(newButtonFound, "New button not found")
|
||||
}
|
||||
}
|
||||
@ -13,9 +13,8 @@ public protocol SettingsProtocol {
|
||||
|
||||
public class Settings: ObservableObject, SettingsProtocol {
|
||||
private let defaults: UserDefaults
|
||||
public static let shared = Settings()
|
||||
public static var shared: SettingsProtocol = Testing.isUITesting ? TestSettings() : Settings()
|
||||
|
||||
@Published
|
||||
public var user: User {
|
||||
didSet {
|
||||
if let json = try? JSONEncoder().encode(self.user) {
|
||||
|
||||
@ -18,7 +18,6 @@ public class StorageService: StorageServiceProtocol {
|
||||
if let instance = StorageService.instance {
|
||||
return instance
|
||||
} else {
|
||||
print("!!!!!!!!!!!!!!!!!!!!!!!!! StorageService init")
|
||||
let service = StorageService()
|
||||
try await service.loadPersistentStores()
|
||||
StorageService.instance = service
|
||||
|
||||
18
AutoCatCore/Testing/TestSettings.swift
Normal file
18
AutoCatCore/Testing/TestSettings.swift
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// TestSettings.swift
|
||||
// AutoCatCore
|
||||
//
|
||||
// Created by Selim Mustafaev on 06.04.2022.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class TestSettings: SettingsProtocol {
|
||||
|
||||
public var user: User = User()
|
||||
public var recognizeAlternativeOrder: Bool = false
|
||||
public var recognizeShortenedNumbers: Bool = false
|
||||
public var defaultRegion: String = ""
|
||||
public var recordBeep: Bool = false
|
||||
public var showDebugInfo: Bool = false
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user