mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✅ Add tests for domain list interaction
This commit is contained in:
@ -158,6 +158,7 @@
|
||||
C469E6FF294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
||||
C469E700294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
||||
C469E701294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; };
|
||||
C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E702294CFDF700A82AB2 /* DomainsListTest.swift */; };
|
||||
C46E206D28299B3800D909D6 /* AppUpdateChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */; };
|
||||
C46E206E28299B3800D909D6 /* AppUpdateChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */; };
|
||||
C46E20702829D27F00D909D6 /* AppUpdaterCheckTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */; };
|
||||
@ -792,6 +793,7 @@
|
||||
C464ADAE275A7A69003FCD53 /* DomainListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListVC.swift; sourceTree = "<group>"; };
|
||||
C464ADB1275A87CA003FCD53 /* DomainListCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListCellProtocol.swift; sourceTree = "<group>"; };
|
||||
C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeValetProxy.swift; sourceTree = "<group>"; };
|
||||
C469E702294CFDF700A82AB2 /* DomainsListTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainsListTest.swift; sourceTree = "<group>"; };
|
||||
C46E206C28299B3800D909D6 /* AppUpdateChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUpdateChecker.swift; sourceTree = "<group>"; };
|
||||
C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppUpdaterCheckTest.swift; sourceTree = "<group>"; };
|
||||
C46EBC4328DB95F0007ACC74 /* ShellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellProtocol.swift; sourceTree = "<group>"; };
|
||||
@ -1341,6 +1343,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C471E7BE28F9B90F0021E251 /* StartupTest.swift */,
|
||||
C469E702294CFDF700A82AB2 /* DomainsListTest.swift */,
|
||||
C4181F1028FAF9330042EA28 /* UITestCase.swift */,
|
||||
);
|
||||
path = ui;
|
||||
@ -2403,6 +2406,7 @@
|
||||
C471E7CD28F9BA600021E251 /* ShellProtocol.swift in Sources */,
|
||||
C471E7EC28F9BAC30021E251 /* Events.swift in Sources */,
|
||||
C471E7CE28F9BA600021E251 /* RealShell.swift in Sources */,
|
||||
C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */,
|
||||
C471E80F28F9BAE80021E251 /* NSMenuExtension.swift in Sources */,
|
||||
C471E80B28F9BAE80021E251 /* XibLoadable.swift in Sources */,
|
||||
C471E7F428F9BAC80021E251 /* PhpVersionNumber.swift in Sources */,
|
||||
|
@ -79,7 +79,6 @@ class AddProxyVC: NSViewController, NSTextFieldDelegate {
|
||||
)
|
||||
|
||||
Task { @MainActor in
|
||||
// TODO: Check if this can be removed
|
||||
App.shared.domainListWindowController?.contentVC.setUINotBusy()
|
||||
App.shared.domainListWindowController?.pressedReload(nil)
|
||||
}
|
||||
|
61
tests/ui/DomainsListTest.swift
Normal file
61
tests/ui/DomainsListTest.swift
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// StartupTest.swift
|
||||
// UI Tests
|
||||
//
|
||||
// Created by Nico Verbruggen on 14/10/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
final class DomainsListTest: UITestCase {
|
||||
|
||||
override func setUpWithError() throws {
|
||||
continueAfterFailure = false
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {}
|
||||
|
||||
private func getApp() -> XCPMApplication {
|
||||
let app = XCPMApplication()
|
||||
app.withConfiguration(TestableConfigurations.working)
|
||||
app.launch()
|
||||
|
||||
// Note: If this fails here, make sure the menu bar item can be displayed
|
||||
// If you use Bartender or something like this, this item may be hidden and tests will fail
|
||||
app.statusItems.firstMatch.click()
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
final func test_can_always_open_domains_list() throws {
|
||||
let app = getApp()
|
||||
|
||||
app.menuItems["mi_domain_list".localized].click()
|
||||
}
|
||||
|
||||
final func test_can_filter_domains_list() throws {
|
||||
let app = getApp()
|
||||
|
||||
app.menuItems["mi_domain_list".localized].click()
|
||||
|
||||
let window = app.windows.allElementsBoundByIndex.first { element in
|
||||
element.title == "domain_list.title".localized
|
||||
}!
|
||||
|
||||
let searchField = window.searchFields.firstMatch
|
||||
|
||||
searchField.click()
|
||||
searchField.typeText("non-existent thing")
|
||||
XCTAssertTrue(window.tables.tableRows.count == 0)
|
||||
|
||||
searchField.clearText()
|
||||
searchField.click()
|
||||
searchField.typeText("concord")
|
||||
XCTAssertTrue(window.tables.tableRows.count == 1)
|
||||
|
||||
sleep(2)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -67,8 +67,8 @@ final class StartupTest: UITestCase {
|
||||
|
||||
// Note: If this fails here, make sure the menu bar item can be displayed
|
||||
// If you use Bartender or something like this, this item may be hidden and tests will fail
|
||||
let statusBarItem = app.statusItems.firstMatch
|
||||
statusBarItem.click()
|
||||
app.statusItems.firstMatch.click()
|
||||
|
||||
assertAllExist([
|
||||
// "Switch to PHP 8.1 (php)" should be visible since it is aliased to `php`
|
||||
app.menuItems["\("mi_php_switch".localized) 8.1 (php)"],
|
||||
|
@ -28,3 +28,20 @@ class UITestCase: XCTestCase {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension XCUIElement {
|
||||
/**
|
||||
Clears all the text from a given element.
|
||||
*/
|
||||
func clearText() {
|
||||
guard let stringValue = self.value as? String else {
|
||||
return
|
||||
}
|
||||
|
||||
var deleteString = String()
|
||||
for _ in stringValue {
|
||||
deleteString += XCUIKeyboardKey.delete.rawValue
|
||||
}
|
||||
typeText(deleteString)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user