1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00
Files
app/tests/ui/StartupTest.swift
Nico Verbruggen 5e3e0c087b 👌 Read configuration from JSON file
This allows us to alter the configuration prior to launching the app,
which allows for additional flexibility during testing.
2022-10-16 14:35:19 +02:00

58 lines
1.6 KiB
Swift

//
// StartupTest.swift
// UI Tests
//
// Created by Nico Verbruggen on 14/10/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import XCTest
final class StartupTest: UITestCase {
override func setUpWithError() throws {
continueAfterFailure = false
}
override func tearDownWithError() throws {}
func testApplicationCanLaunchWithTestConfigurationAndIdles() throws {
let app = XCPMApplication()
app.withConfiguration(TestableConfigurations.working)
app.launch()
sleep(5)
}
func testApplicationCanLaunchWithTestConfigurationAndThrowsAlert() throws {
var configuration = TestableConfigurations.working
configuration.filesystem["/opt/homebrew/bin/php"] = nil // PHP binary must be missing
let app = XCPMApplication()
app.withConfiguration(configuration)
app.launch()
// Dialog 1: "PHP is not correctly installed"
assertAllExist([
app.dialogs["Notice"],
app.staticTexts["PHP is not correctly installed"],
app.buttons["OK"],
])
click(app.buttons["OK"])
// Dialog 2: PHP Monitor failed to start
assertAllExist([
app.dialogs["Notice"],
app.staticTexts["PHP Monitor cannot start due to a problem with your system configuration"],
app.buttons["Retry"],
app.buttons["Quit"]
])
click(app.buttons["Retry"])
// Dialog 1 again
assertExists(app.staticTexts["PHP is not correctly installed"])
// At this point, we can terminate the test
app.terminate()
}
}