mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Make LinkNewDeviceScreen fall back to the App Lock PIN code when there's no passcode. (#5794)
* Fall back to the AppLock PIN code when there's no passcode. * Add extra tests on the LinkNewDeviceFlowCoordinator. * Misc tweaks for clarification. * Regenerate snapshots.
This commit is contained in:
@@ -13,6 +13,9 @@ class LinkNewDeviceTests: XCTestCase {
|
||||
static let selectDevice = 1
|
||||
static let linkMobileDevice = 2
|
||||
static let linkDesktopComputer = 3
|
||||
static let appLockPIN = 4
|
||||
static let logoutAlert = 5
|
||||
static let forcedLogout = 6
|
||||
static let dismissed = 99
|
||||
}
|
||||
|
||||
@@ -45,4 +48,57 @@ class LinkNewDeviceTests: XCTestCase {
|
||||
cancelButton.tap()
|
||||
try await app.assertScreenshot(step: Step.dismissed)
|
||||
}
|
||||
|
||||
func testAppLockPINVerification() async throws {
|
||||
// Root screen
|
||||
let app = Application.launch(.linkNewDeviceWithAppLockPIN)
|
||||
try await app.assertScreenshot(step: Step.selectDevice)
|
||||
|
||||
// Linking requires verifying the device owner with the App Lock PIN.
|
||||
let mobileDeviceButton = app.buttons[A11yIdentifiers.linkNewDeviceScreen.mobileDevice]
|
||||
mobileDeviceButton.tap()
|
||||
try await app.assertScreenshot(step: Step.appLockPIN)
|
||||
|
||||
// Cancelling verification returns to the root screen.
|
||||
app.buttons[A11yIdentifiers.appLockScreen.cancel].tap()
|
||||
try await app.assertScreenshot(step: Step.selectDevice)
|
||||
|
||||
// Entering the correct PIN continues to generate the QR code.
|
||||
mobileDeviceButton.tap()
|
||||
try await app.assertScreenshot(step: Step.appLockPIN)
|
||||
enterPIN(app)
|
||||
try await app.assertScreenshot(step: Step.linkMobileDevice)
|
||||
}
|
||||
|
||||
func testForceLogout() async throws {
|
||||
// Root screen
|
||||
let app = Application.launch(.linkNewDeviceWithAppLockPIN)
|
||||
|
||||
// Linking requires verifying the device owner with the App Lock PIN.
|
||||
app.buttons[A11yIdentifiers.linkNewDeviceScreen.mobileDevice].tap()
|
||||
try await app.assertScreenshot(step: Step.appLockPIN)
|
||||
|
||||
// Entering the wrong PIN three times signs the user out.
|
||||
enterWrongPIN(app)
|
||||
enterWrongPIN(app)
|
||||
enterWrongPIN(app)
|
||||
try await app.assertScreenshot(step: Step.logoutAlert)
|
||||
app.alerts.element.buttons[A11yIdentifiers.alertInfo.primaryButton].firstMatch.tap()
|
||||
try await app.assertScreenshot(step: Step.forcedLogout)
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func enterPIN(_ app: XCUIApplication) {
|
||||
app.buttons[A11yIdentifiers.appLockScreen.numpad(2)].tap()
|
||||
app.buttons[A11yIdentifiers.appLockScreen.numpad(0)].tap()
|
||||
app.buttons[A11yIdentifiers.appLockScreen.numpad(2)].tap()
|
||||
app.buttons[A11yIdentifiers.appLockScreen.numpad(3)].tap()
|
||||
}
|
||||
|
||||
private func enterWrongPIN(_ app: XCUIApplication) {
|
||||
for _ in 0..<4 {
|
||||
app.buttons[A11yIdentifiers.appLockScreen.numpad(0)].tap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:86177b8a2db758a936a2a11a0f531bfb45511ca6c95b534d14946fd7543725e0
|
||||
size 158276
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d73df700e470e40b07a5dfdcb250fec206c2ab5ace9203847a5b0f4126b89b82
|
||||
size 190553
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:14451bd62aa2ac5ddee3eab2db4aee40d82f5a8b05950f4d03417ef315650774
|
||||
size 111945
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a2abf3877cb363cae2d674fa3d11e059a62a60fc4a4e3eb8099f25c3187fe71e
|
||||
size 115280
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2c8b2704da62a90ce7a558f8d2a4f8d42e7622c439976432dbbe00beeded4d28
|
||||
size 164780
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d4f7231a3b4291a370d0c2507c522012f4edeb9878cd9fbb468f36c91d671e99
|
||||
size 128890
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:14451bd62aa2ac5ddee3eab2db4aee40d82f5a8b05950f4d03417ef315650774
|
||||
size 111945
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6678652d0e5a48dd7cfa197d52ff161cdcad75108c183a2748eb37099aedcda5
|
||||
size 203737
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aaee386193e4980a9ff49b4f06ab4f9885839153fadbca373b92182aff59e62e
|
||||
size 123853
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d4f7231a3b4291a370d0c2507c522012f4edeb9878cd9fbb468f36c91d671e99
|
||||
size 128890
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4fa4bb4e82f027e6a716ce28e49269718291b141f649bbd389dab45ecad16bc6
|
||||
size 280901
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:32951bca5d167c6ce1523037cd31404f223b0ba2214247e68fedf6371f1d2d70
|
||||
size 148086
|
||||
Reference in New Issue
Block a user