Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Normal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
NormalUITests.swift,
NormalUITestsLaunchTests.swift,
RecoveryUITests.swift,
TabNavigation.swift,
UnblockDurationsUITests.swift,
);
target = 2F58EFFE2EC9C5DF00A38180 /* NormalUITests */;
Expand All @@ -131,6 +132,7 @@
NormalUITests.swift,
NormalUITestsLaunchTests.swift,
RecoveryUITests.swift,
TabNavigation.swift,
UnblockDurationsUITests.swift,
);
target = 2F58EFE72EC9C5DE00A38180 /* Normal */;
Expand Down
11 changes: 6 additions & 5 deletions NormalUITests/BlockingUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ final class BlockingUITests: XCTestCase {

override func setUpWithError() throws {
continueAfterFailure = false
XCUIDevice.shared.orientation = .portrait
}

private func launch(_ extra: [String] = []) -> XCUIApplication {
Expand Down Expand Up @@ -81,7 +82,7 @@ final class BlockingUITests: XCTestCase {
let app = launch()
blockViaBypass(app)

app.tabBars.buttons["Keys"].tap()
app.mainTab("Keys").tap()
require(
app.staticTexts["Unblock all apps to add or delete keys."],
"Keys tab should show the locked footer while blocked"
Expand Down Expand Up @@ -177,7 +178,7 @@ final class BlockingUITests: XCTestCase {

func testGroupBlockThenUnblockRepresentsKeyAndDurationSheets() {
let app = launch(["-uiTestSeedGroupKey"])
app.tabBars.buttons["Groups"].tap()
app.mainTab("Groups").tap()

let blockButton = app.buttons["group.blockButton"]
require(blockButton, "Group block button should render")
Expand Down Expand Up @@ -245,15 +246,15 @@ final class BlockingUITests: XCTestCase {
func testSeededScheduleAppears() {
let app = launch(["-uiTestSeedSchedule"])

app.tabBars.buttons["Schedules"].tap()
app.mainTab("Schedules").tap()
require(app.staticTexts["Test Schedule"], "Seeded schedule card should render")
XCTAssertTrue(app.switches["schedule.enabledToggle"].exists, "Schedule enable toggle should exist")
}

func testDuplicateScheduleAddsDisabledCopy() {
let app = launch(["-uiTestSeedSchedule"])

app.tabBars.buttons["Schedules"].tap()
app.mainTab("Schedules").tap()
let original = app.staticTexts["Test Schedule"]
require(original, "Seeded schedule card should render")
original.press(forDuration: 1)
Expand All @@ -272,7 +273,7 @@ final class BlockingUITests: XCTestCase {
func testDuplicateScheduleUnavailableWhileBlocked() {
let app = launch(["-uiTestSeedSchedule", "-uiTestStartBlocked"])

app.tabBars.buttons["Schedules"].tap()
app.mainTab("Schedules").tap()
let original = app.staticTexts["Test Schedule"]
require(original, "Seeded schedule card should render")
original.press(forDuration: 1)
Expand Down
1 change: 1 addition & 0 deletions NormalUITests/DonationUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ final class DonationUITests: XCTestCase {

override func setUpWithError() throws {
continueAfterFailure = false
XCUIDevice.shared.orientation = .portrait
}

private func launch() -> XCUIApplication {
Expand Down
17 changes: 9 additions & 8 deletions NormalUITests/NormalUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ final class NormalUITests: XCTestCase {

override func setUpWithError() throws {
continueAfterFailure = false
XCUIDevice.shared.orientation = .portrait
}

private func launch(_ arguments: [String]) -> XCUIApplication {
Expand Down Expand Up @@ -34,7 +35,7 @@ final class NormalUITests: XCTestCase {
require(skip, "Welcome skip button should exist")
skip.tap()

require(app.tabBars.buttons["Keys"], "Main tab bar should be visible after skipping onboarding")
require(app.mainTab("Keys"), "Main tab bar should be visible after skipping onboarding")
XCTAssertFalse(app.staticTexts["Welcome to Normal"].exists, "Onboarding should be dismissed")
}

Expand Down Expand Up @@ -86,7 +87,7 @@ final class NormalUITests: XCTestCase {
func testAddKeyViaScanCreatesKey() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding"])

let keysTab = app.tabBars.buttons["Keys"]
let keysTab = app.mainTab("Keys")
require(keysTab, "Keys tab should be reachable when onboarding is skipped")
keysTab.tap()

Expand Down Expand Up @@ -116,7 +117,7 @@ final class NormalUITests: XCTestCase {
func testAddLocationKeyCreatesKey() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding"])

let keysTab = app.tabBars.buttons["Keys"]
let keysTab = app.mainTab("Keys")
require(keysTab, "Keys tab should be reachable when onboarding is skipped")
keysTab.tap()

Expand Down Expand Up @@ -156,7 +157,7 @@ final class NormalUITests: XCTestCase {
func testLocationPickerShowsMapAndCurrentLocationControl() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding"])

let keysTab = app.tabBars.buttons["Keys"]
let keysTab = app.mainTab("Keys")
require(keysTab, "Keys tab should be reachable when onboarding is skipped")
keysTab.tap()

Expand All @@ -183,7 +184,7 @@ final class NormalUITests: XCTestCase {
func testCustomDomainsEditorHiddenWhenToggleOff() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding"])

let appSelectTab = app.tabBars.buttons["App Select"]
let appSelectTab = app.mainTab("App Select")
require(appSelectTab, "App Select tab should be reachable")
appSelectTab.tap()

Expand All @@ -197,7 +198,7 @@ final class NormalUITests: XCTestCase {
func testCustomDomainsEditorAddsDomainWhenToggleOn() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding", "-uiTestCustomDomains"])

let appSelectTab = app.tabBars.buttons["App Select"]
let appSelectTab = app.mainTab("App Select")
require(appSelectTab, "App Select tab should be reachable")
appSelectTab.tap()

Expand All @@ -221,7 +222,7 @@ final class NormalUITests: XCTestCase {
func testCustomDomainsEditorIsReadOnlyWhileBlocked() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding", "-uiTestCustomDomains", "-uiTestStartBlocked"])

let appSelectTab = app.tabBars.buttons["App Select"]
let appSelectTab = app.mainTab("App Select")
require(appSelectTab, "App Select tab should be reachable")
appSelectTab.tap()

Expand All @@ -240,7 +241,7 @@ final class NormalUITests: XCTestCase {
func testGroupKeyHiddenFromKeysTabAndVisibleInViewer() {
let app = launch(["-uiTestMode", "-uiTestSkipOnboarding", "-uiTestSeedGroupKey"])

let keysTab = app.tabBars.buttons["Keys"]
let keysTab = app.mainTab("Keys")
require(keysTab, "Keys tab should be reachable")
keysTab.tap()

Expand Down
9 changes: 5 additions & 4 deletions NormalUITests/RecoveryUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ final class RecoveryUITests: XCTestCase {

override func setUpWithError() throws {
continueAfterFailure = false
XCUIDevice.shared.orientation = .portrait
}

private func launch(_ extra: [String]) -> XCUIApplication {
Expand Down Expand Up @@ -96,7 +97,7 @@ final class RecoveryUITests: XCTestCase {
func testEmergencyUnblockDisablesSchedules() {
let app = launch(["-uiTestSeedSchedule"])

app.tabBars.buttons["Schedules"].tap()
app.mainTab("Schedules").tap()
let toggle = app.switches["schedule.enabledToggle"]
require(toggle, "Seeded schedule toggle should exist")
XCTAssertEqual(toggle.value as? String, "1", "Seeded schedule starts enabled")
Expand All @@ -107,7 +108,7 @@ final class RecoveryUITests: XCTestCase {
app.alerts.buttons["OK"].tap()
app.buttons["Close"].tap()

app.tabBars.buttons["Schedules"].tap()
app.mainTab("Schedules").tap()
XCTAssertEqual(
app.switches["schedule.enabledToggle"].value as? String, "0",
"Emergency unblock must toggle schedules off so they can't re-block"
Expand All @@ -117,7 +118,7 @@ final class RecoveryUITests: XCTestCase {
func testLegacyKeyWithoutScanKindShowsQRCodeLabel() {
let app = launch([])

app.tabBars.buttons["Keys"].tap()
app.mainTab("Keys").tap()
require(app.staticTexts["Test Key"].firstMatch, "Seeded key card should be visible")
require(
app.staticTexts["QR Code"].firstMatch,
Expand All @@ -128,7 +129,7 @@ final class RecoveryUITests: XCTestCase {
func testCannotDeleteLastKey() {
let app = launch([])

app.tabBars.buttons["Keys"].tap()
app.mainTab("Keys").tap()
let card = app.staticTexts["Test Key"].firstMatch
require(card, "The single seeded key card should be visible")
card.press(forDuration: 1.3)
Expand Down
10 changes: 10 additions & 0 deletions NormalUITests/TabNavigation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import XCTest

extension XCUIApplication {
func mainTab(_ label: String) -> XCUIElement {
guard UIDevice.current.userInterfaceIdiom == .pad, #available(iOS 18.0, *) else {
return tabBars.buttons[label]
}
return buttons.matching(NSPredicate(format: "label == %@", label)).firstMatch
}
}
1 change: 1 addition & 0 deletions NormalUITests/UnblockDurationsUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ final class UnblockDurationsUITests: XCTestCase {

override func setUpWithError() throws {
continueAfterFailure = false
XCUIDevice.shared.orientation = .portrait
}

private func launch(_ extra: [String] = []) -> XCUIApplication {
Expand Down
Loading