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:
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