137 lines
4.6 KiB
Swift
137 lines
4.6 KiB
Swift
//
|
|
// MenuBarUITests.swift
|
|
// GazeUITests
|
|
//
|
|
// Created by Mike Freno on 1/8/26.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
@MainActor
|
|
final class MenuBarUITests: XCTestCase {
|
|
|
|
var app: XCUIApplication!
|
|
|
|
override func setUpWithError() throws {
|
|
continueAfterFailure = false
|
|
app = XCUIApplication()
|
|
app.launchArguments.append("--skip-onboarding")
|
|
app.launch()
|
|
}
|
|
|
|
override func tearDownWithError() throws {
|
|
app = nil
|
|
}
|
|
|
|
func testMenuBarExtraExists() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
XCTAssertTrue(menuBar.waitForExistence(timeout: 5))
|
|
}
|
|
|
|
func testMenuBarCanBeOpened() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let gazeTitle = app.staticTexts["Gaze"]
|
|
XCTAssertTrue(gazeTitle.waitForExistence(timeout: 2) || app.staticTexts.count > 0)
|
|
}
|
|
}
|
|
|
|
func testMenuBarHasTimerStatus() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let activeTimersText = app.staticTexts["Active Timers"]
|
|
let hasTimerInfo = activeTimersText.exists || app.staticTexts.count > 3
|
|
|
|
XCTAssertTrue(hasTimerInfo)
|
|
}
|
|
}
|
|
|
|
func testMenuBarHasPauseResumeControl() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let pauseButton = app.buttons.containing(NSPredicate(format: "label CONTAINS 'Pause' OR label CONTAINS 'Resume'")).firstMatch
|
|
XCTAssertTrue(pauseButton.waitForExistence(timeout: 2))
|
|
}
|
|
}
|
|
|
|
func testMenuBarHasSettingsButton() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let settingsButton = app.buttons["Settings"]
|
|
let settingsMenuItem = app.menuItems["Settings"]
|
|
|
|
XCTAssertTrue(settingsButton.exists || settingsMenuItem.exists)
|
|
}
|
|
}
|
|
|
|
func testMenuBarHasQuitButton() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let quitButton = app.buttons.containing(NSPredicate(format: "label CONTAINS 'Quit'")).firstMatch
|
|
XCTAssertTrue(quitButton.waitForExistence(timeout: 2))
|
|
}
|
|
}
|
|
|
|
func testPauseResumeToggle() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let pauseButton = app.buttons.containing(NSPredicate(format: "label CONTAINS 'Pause'")).firstMatch
|
|
let resumeButton = app.buttons.containing(NSPredicate(format: "label CONTAINS 'Resume'")).firstMatch
|
|
|
|
if pauseButton.exists && pauseButton.isHittable {
|
|
pauseButton.tap()
|
|
XCTAssertTrue(resumeButton.waitForExistence(timeout: 2))
|
|
} else if resumeButton.exists && resumeButton.isHittable {
|
|
resumeButton.tap()
|
|
XCTAssertTrue(pauseButton.waitForExistence(timeout: 2))
|
|
}
|
|
}
|
|
}
|
|
|
|
func testCompleteOnboardingButtonVisibleWhenOnboardingIncomplete() throws {
|
|
// Relaunch app without skip-onboarding flag
|
|
app.terminate()
|
|
let newApp = XCUIApplication()
|
|
newApp.launchArguments.append("--reset-onboarding")
|
|
newApp.launch()
|
|
|
|
let menuBar = newApp.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let completeOnboardingButton = newApp.buttons["Complete Onboarding"]
|
|
XCTAssertTrue(
|
|
completeOnboardingButton.waitForExistence(timeout: 2),
|
|
"Complete Onboarding button should be visible when onboarding is incomplete"
|
|
)
|
|
}
|
|
|
|
newApp.terminate()
|
|
}
|
|
|
|
func testCompleteOnboardingButtonNotVisibleWhenOnboardingComplete() throws {
|
|
let menuBar = app.menuBarItems.firstMatch
|
|
if menuBar.waitForExistence(timeout: 5) {
|
|
menuBar.click()
|
|
|
|
let completeOnboardingButton = app.buttons["Complete Onboarding"]
|
|
XCTAssertFalse(
|
|
completeOnboardingButton.exists,
|
|
"Complete Onboarding button should not be visible when onboarding is complete"
|
|
)
|
|
}
|
|
}
|
|
}
|