mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-01 17:20:09 +02:00
♻️ Refactor preference override (for tests)
This commit is contained in:
@@ -198,7 +198,7 @@ class TestableConfigurations {
|
||||
"/opt/homebrew/bin/php -r echo ini_get('post_max_size');": "512M"
|
||||
],
|
||||
preferenceOverrides: [
|
||||
.automaticBackgroundUpdateCheck: false
|
||||
.automaticBackgroundUpdateCheck: .bool(false)
|
||||
],
|
||||
phpVersions: [
|
||||
VersionNumber(major: 8, minor: 4, patch: 5),
|
||||
|
||||
@@ -14,16 +14,25 @@ final class SettingsTest: UITestCase {
|
||||
continueAfterFailure = false
|
||||
}
|
||||
|
||||
/**
|
||||
In this test, we start with the app configured with the English override.
|
||||
After opening the domains window, we switch to Japanese.
|
||||
*/
|
||||
final func test_changing_language_closes_other_windows() throws {
|
||||
let app = launch(openMenu: true)
|
||||
var configuration = TestableConfigurations.working
|
||||
|
||||
// Our default starting point is to use the system default language
|
||||
configuration.preferenceOverrides[.languageOverride] = .string("en")
|
||||
|
||||
let app = launch(openMenu: true, with: configuration)
|
||||
|
||||
// First, open the domains window
|
||||
app.mainMenuItem(withText: "mi_domain_list".localized).click()
|
||||
let domainsWindow = app.windows["domain_list.title".localized]
|
||||
app.mainMenuItem(withText: "mi_domain_list".localized(for: "en")).click()
|
||||
let domainsWindow = app.windows["domain_list.title".localized(for: "en")]
|
||||
assertExists(domainsWindow, 2.0)
|
||||
|
||||
// Press the menu button again
|
||||
app.statusItems.firstMatch.click() // press the menu button again
|
||||
app.statusItems.firstMatch.click()
|
||||
|
||||
// This time, open the preferences window
|
||||
app.mainMenuItem(withText: "mi_preferences".localized).click()
|
||||
@@ -31,7 +40,7 @@ final class SettingsTest: UITestCase {
|
||||
.containing(.button, identifier: "prefs.tabs.general".localized(for: "en"))
|
||||
.firstMatch
|
||||
assertExists(settingsWindow, 2.0)
|
||||
assertExists(app.buttons["prefs.tabs.general".localized(for: "en")], 2.0)
|
||||
assertExists(app.buttons["prefs.tabs.general".localized(for: "en")])
|
||||
|
||||
// In the languages pop-up, click on it
|
||||
let languagePopup = settingsWindow.popUpButtons.element(boundBy: 0)
|
||||
@@ -45,12 +54,12 @@ final class SettingsTest: UITestCase {
|
||||
.containing(.button, identifier: "prefs.tabs.general".localized(for: "ja"))
|
||||
.firstMatch
|
||||
assertExists(settingsWindowJa, 2.0)
|
||||
assertExists(app.buttons["prefs.tabs.general".localized(for: "ja")], 2.0)
|
||||
assertExists(settingsWindowJa.staticTexts["prefs.language".localized(for: "ja")], 2.0)
|
||||
assertExists(app.buttons["prefs.tabs.general".localized(for: "ja")])
|
||||
assertExists(settingsWindowJa.staticTexts["prefs.language".localized(for: "ja")])
|
||||
|
||||
// Switch back to the original language
|
||||
// Switch back to English
|
||||
let resetPopup = settingsWindowJa.popUpButtons.element(boundBy: 0)
|
||||
resetPopup.click()
|
||||
resetPopup.menuItems["System Default"].click()
|
||||
resetPopup.menuItems["English"].click()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ final class StartupTest: UITestCase {
|
||||
assertAllExist([
|
||||
app.dialogs["generic.notice".localized],
|
||||
app.staticTexts["startup.errors.php_binary.title".localized],
|
||||
app.buttons["generic.ok".localized]
|
||||
app.buttons["startup.fix_manually".localized]
|
||||
])
|
||||
click(app.buttons["generic.ok".localized])
|
||||
click(app.buttons["startup.fix_manually".localized])
|
||||
|
||||
// Dialog 2: PHP Monitor failed to start
|
||||
assertAllExist([
|
||||
@@ -72,6 +72,6 @@ final class StartupTest: UITestCase {
|
||||
)
|
||||
|
||||
assertExists(app.staticTexts["startup.errors.valet_version_not_supported.title".localized], 3.0)
|
||||
click(app.buttons["generic.ok".localized])
|
||||
click(app.buttons["startup.fix_manually".localized])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ final class UpdateCheckTest: UITestCase {
|
||||
var configuration = TestableConfigurations.working
|
||||
|
||||
// Ensure automatic check is enabled
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = true
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = .bool(true)
|
||||
|
||||
// Ensure an update is available
|
||||
configuration.apiGetResponses[url("\(Constants.Urls.UpdateCheckEndpoint.absoluteString)")] = FakeWebApiResponse(
|
||||
@@ -64,7 +64,7 @@ final class UpdateCheckTest: UITestCase {
|
||||
var configuration = TestableConfigurations.working
|
||||
|
||||
// Ensure automatic check is disabled
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = false
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = .bool(false)
|
||||
|
||||
// Ensure an update is available
|
||||
configuration.apiGetResponses[url("\(Constants.Urls.UpdateCheckEndpoint.absoluteString)")] = FakeWebApiResponse(
|
||||
@@ -98,7 +98,7 @@ final class UpdateCheckTest: UITestCase {
|
||||
var configuration = TestableConfigurations.working
|
||||
|
||||
// Ensure automatic check is disabled
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = false
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = .bool(false)
|
||||
|
||||
// Ensure an update is available
|
||||
configuration.apiGetResponses[url("\(Constants.Urls.UpdateCheckEndpoint.absoluteString)")] = FakeWebApiResponse(
|
||||
@@ -135,7 +135,7 @@ final class UpdateCheckTest: UITestCase {
|
||||
var configuration = TestableConfigurations.working
|
||||
|
||||
// Ensure automatic check is disabled
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = false
|
||||
configuration.preferenceOverrides[.automaticBackgroundUpdateCheck] = .bool(false)
|
||||
|
||||
// Ensure an update is available
|
||||
configuration.apiGetResponses[url("\(Constants.Urls.UpdateCheckEndpoint.absoluteString)")] = FakeWebApiResponse(
|
||||
|
||||
Reference in New Issue
Block a user