diff --git a/Normal/App/NormalApp.swift b/Normal/App/NormalApp.swift index f196d70..de65e65 100644 --- a/Normal/App/NormalApp.swift +++ b/Normal/App/NormalApp.swift @@ -41,7 +41,11 @@ struct NormalApp: App { context.insert(Key(name: "Test Key", type: .qr, rawValue: UITestSupport.stubScanValue)) } if UITestSupport.seedGroupKey { - let group = AppGroup(name: "Test Group", selection: FamilyActivitySelection()) + let group = AppGroup( + id: UITestSupport.seedGroupID, + name: "Test Group", + selection: FamilyActivitySelection() + ) context.insert(group) context.insert(Key(name: "Group Key", type: .qr, rawValue: "GROUP-VALUE", groupID: group.id)) } diff --git a/Normal/App/UITestSupport.swift b/Normal/App/UITestSupport.swift index 79d7652..d01d47e 100644 --- a/Normal/App/UITestSupport.swift +++ b/Normal/App/UITestSupport.swift @@ -20,6 +20,8 @@ enum UITestSupport { static let seedGroupKey = arguments.contains("-uiTestSeedGroupKey") + static let seedGroupID = UUID(uuidString: "6E0A1C9B-2D4F-4B7A-9C3E-5F8D1A2B3C4D")! + static let skipBypassConfirm = arguments.contains("-uiTestSkipBypassConfirm") static let unblockDurationSeconds: [Int]? = value(after: "-uiTestUnblockDurations")? diff --git a/NormalUITests/BlockingUITests.swift b/NormalUITests/BlockingUITests.swift index ca44fa6..61f0d8e 100644 --- a/NormalUITests/BlockingUITests.swift +++ b/NormalUITests/BlockingUITests.swift @@ -144,6 +144,25 @@ final class BlockingUITests: XCTestCase { require(app.buttons["group.blockButton"], "Group should be unblocked again") } + func testUnlockLinkDuringBypassConfirmationFallsBackToKeySelection() throws { + let app = launch(["-uiTestSeedGroupKey"]) + let groupID = "6E0A1C9B-2D4F-4B7A-9C3E-5F8D1A2B3C4D" + + app.open(try XCTUnwrap(URL(string: "normal://block?group=\(groupID)"))) + let bypass = app.buttons["keySelect.blockWithoutKey"] + require(bypass, "Block link should offer bypass") + bypass.tap() + let confirm = app.buttons["keySelect.confirmBlockWithoutKey"] + require(confirm, "Bypass confirmation should appear") + + app.open(try XCTUnwrap(URL(string: "normal://unlock?group=\(groupID)&duration=3600"))) + + XCTAssertTrue(confirm.waitForNonExistence(timeout: timeout), "Unlock link should dismiss the bypass confirmation") + require(app.buttons["keySelect.row.QR"], "Unlock link should ask for a key") + XCTAssertFalse(bypass.exists, "Unlock should not offer a keyless path") + XCTAssertTrue(app.buttons["group.blockButton"].exists, "Group state should be untouched") + } + func testSeededScheduleAppears() { let app = launch(["-uiTestSeedSchedule"])