mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Add UI tests for optional app lock setup. (#2046)
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import ElementX
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class AppLockSetupUITests: XCTestCase {
|
||||
func testScreen() async throws {
|
||||
let app = Application.launch(.appLockSetupFlow)
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
@MainActor
|
||||
class AppLockSetupUITests: XCTestCase {
|
||||
var app: XCUIApplication!
|
||||
|
||||
@MainActor enum Step {
|
||||
static let createPIN = 0
|
||||
static let confirmPIN = 1
|
||||
static let setupBiometrics = 2
|
||||
static let settings = 3
|
||||
|
||||
/// iPad shows the settings screen behind the modal, iPhone doesn't.
|
||||
static let changePIN = isPhone ? createPIN : 4
|
||||
/// iPad shows the settings screen behind the modal, iPhone doesn't.
|
||||
static let confirmChangePIN = isPhone ? confirmPIN : 5
|
||||
|
||||
/// Not part of the flow, only to verify the stack is cleared.
|
||||
static let clearedStack = 99
|
||||
|
||||
static var isPhone: Bool { UIDevice.current.userInterfaceIdiom == .phone }
|
||||
}
|
||||
|
||||
func testCreateFlow() async throws {
|
||||
app = Application.launch(.appLockSetupFlow)
|
||||
|
||||
// Create PIN screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.createPIN)
|
||||
|
||||
enterPIN()
|
||||
|
||||
// Confirm PIN screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.confirmPIN)
|
||||
|
||||
enterPIN()
|
||||
|
||||
// Setup biometrics screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.setupBiometrics)
|
||||
|
||||
app.buttons[A11yIdentifiers.appLockSetupBiometricsScreen.allow].tap()
|
||||
|
||||
// Settings screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.settings)
|
||||
|
||||
app.buttons[A11yIdentifiers.appLockSetupSettingsScreen.changePIN].tap()
|
||||
|
||||
// Change PIN (create).
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.changePIN)
|
||||
|
||||
enterDifferentPIN()
|
||||
|
||||
// Change PIN (confirm).
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.confirmChangePIN)
|
||||
|
||||
enterDifferentPIN()
|
||||
|
||||
// Settings screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.settings)
|
||||
|
||||
app.buttons[A11yIdentifiers.appLockSetupSettingsScreen.removePIN].tap()
|
||||
app.alerts.element.buttons[A11yIdentifiers.alertInfo.primaryButton].tap()
|
||||
|
||||
// Pop the stack returning to whatever was last presented.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.clearedStack)
|
||||
}
|
||||
|
||||
func testUnlockFlow() async throws {
|
||||
app = Application.launch(.appLockSetupFlowUnlock)
|
||||
|
||||
// Create PIN screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlowUnlock)
|
||||
|
||||
enterPIN()
|
||||
|
||||
// Settings screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.settings)
|
||||
|
||||
app.buttons[A11yIdentifiers.appLockSetupSettingsScreen.removePIN].tap()
|
||||
app.alerts.element.buttons[A11yIdentifiers.alertInfo.primaryButton].tap()
|
||||
|
||||
// Pop the stack returning to whatever was last presented.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.clearedStack)
|
||||
}
|
||||
|
||||
func testCancel() async throws {
|
||||
app = Application.launch(.appLockSetupFlowUnlock)
|
||||
|
||||
// Create PIN screen.
|
||||
try await app.assertScreenshot(.appLockSetupFlowUnlock)
|
||||
|
||||
app.buttons[A11yIdentifiers.appLockSetupPINScreen.cancel].tap()
|
||||
|
||||
// Return to whatever was last presented.
|
||||
try await app.assertScreenshot(.appLockSetupFlow, step: Step.clearedStack)
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private func enterPIN() {
|
||||
app.keys["2"].tap()
|
||||
app.keys["0"].tap()
|
||||
app.keys["2"].tap()
|
||||
app.keys["3"].tap()
|
||||
}
|
||||
|
||||
private func enterDifferentPIN() {
|
||||
app.keys["2"].tap()
|
||||
app.keys["2"].tap()
|
||||
app.keys["3"].tap()
|
||||
app.keys["3"].tap()
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bf66d4809566af646252cf16b7582ef3bbb56b55308041d264902de44ea91463
|
||||
size 164655
|
||||
oid sha256:3fa48241f385c2b3753523823d29471f4ecae890021ec47b01e739783d955a2b
|
||||
size 165984
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bfe62fbf4c949e2d67b1920a9df0a1bb7cfd6f2587cf4073a491ae94fc6839d5
|
||||
size 165645
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:98fb37018e18b24257791b5e4f67db1ff3701b3ef4afe9d1afcd62323c135bf0
|
||||
size 118118
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9981e05d8e7b867dd804efeaa97d312b70925d23d959dedfed4e4bc97781eb0a
|
||||
size 74989
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:26ffbeae8df9be41d80be48d111ef47fac633bf8c575db6028597c7c5faec2b4
|
||||
size 181587
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4256ee8ceb61e8cd34c8c06cfb97c134b5122ce28de9747cee2b1bf2ed0ff418
|
||||
size 181244
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7d09d2089cd5d540e12aaa823da60e20806c25202f0f3b60bfd4cebc8978e8a9
|
||||
size 58054
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f4b8b221641b9d86d3f7e32a650a262cc4a51dbc7cf3b7c65253d6c71d5bb454
|
||||
size 99772
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1b0e2fe4e868bce1a4c758c8cc7026c17604bfe666c284ef83859ad0ac0aa001
|
||||
size 138452
|
||||
oid sha256:f65a97c728faec3735d6fcb51b482af57c7158193734a011e703936d14f50ed3
|
||||
size 137591
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:62b02511b19c2ede3866f769eea6e1d65e267ae3da2c8faede3df9b3f18b825e
|
||||
size 137206
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a46bf902af6a4220639073f83ff1db87a4ac8187521b7ae296639c56d7a85367
|
||||
size 96519
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:881928cca9fe3a67e50e6c332fac59508e886bc34b1ca762b53e8764382c3e10
|
||||
size 83140
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6038391cadd1f8d589f07d21a743a6ad708295ebe127a45c13720ddd464e1bfd
|
||||
size 55754
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:05500566e71142c4c80b9781f3cb3fe20412690c9bcc11156d14fbbb1ac3812c
|
||||
size 81393
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fee0ecd3529882e1799122602775c15cc0eb1f766885998b35cf078a06396640
|
||||
size 184338
|
||||
oid sha256:44c3f9224626c915af17c0c9358b5049490b4fdfc56e1a0f132ee138a7cd0f3f
|
||||
size 187197
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ce09ad0d0ef60d14807709fd9194ba1ea7863280545c6bcf183534411bab850c
|
||||
size 186740
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ee6a9bf60a1d58da80cfe07847586917d9d7220eff61072c9ca1c975b3054d10
|
||||
size 134319
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0cbfbd855a17721fc7ec0886127154971225f4fb7aefcfd8e334ef49a0ee17c1
|
||||
size 79354
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:88a548c90dcc19b981719b92648cb017b803c2e6c367c9614a06d59e5da83c72
|
||||
size 203681
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5f4094e6baaebfd781e8cf5bc3f6dfbc8f1e51b16d875e1812248e71c57b92be
|
||||
size 203186
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e4f8dfd9c3e7bf9c5b7fe6ccd94c7a710b331ee9920a658c664287fa4d6403f7
|
||||
size 58873
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:869f30858095d8e245a2efc84ef996ddcf11864112123b68e4a784c55770e618
|
||||
size 101543
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:01d584c4c83f2abded3b6d929cf4ef3781c18c1ee2a1d6d88174458a1b117e12
|
||||
size 168409
|
||||
oid sha256:1d5cb48de5d8d0c1f04a0a12488249871c128b87e3dffe4e025ded9a26fc8555
|
||||
size 168378
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6501ff36b6204c2083c0121468fcdeef5e0d5a873c86693c1a8757091ece7915
|
||||
size 168194
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a7c4ca0ea8597654e7974ca38e5a1e17b8dd07b0660dc3c6082357fcd871976e
|
||||
size 120377
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2a33cdbdc0917ca8ac04e03e0fb2998de93a769ddf2fa553d8a4eb7894ce8890
|
||||
size 87382
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b6f97fa428f0cccd0b72f2033c3b7c54c5f15f80a7293fb1b58da88704cf91b7
|
||||
size 60147
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4ea1cbd5eb3bd03cfe2fb1358c796634de153bf6b492c9e8602ec4a1d27e4ad4
|
||||
size 82102
|
||||
Reference in New Issue
Block a user