Tests: add email-gating API coverage; robust task-uncancel seeding; re-quarantine flaky onboarding e2e
Android UI Tests / ui-tests (push) Has been cancelled
Android UI Tests / ui-tests (push) Has been cancelled
- Issue 2 (coverage gap): add HoneyDueAPITests/AuthGatingAPITests — verifies the backend's RequireVerified gate (unverified -> 403, verified -> 200) at the API layer, since UI-test mode bypasses verification. NOTE: surfaced that the gate is applied to only the share-code routes, not residence/task routes — unverified users are NOT broadly blocked (flagged for product/backend). - Issue 4: TaskCRUDUITests seedAccountPreconditions now guarantees a residence (no silent early-return), so the cancelled-task precondition always populates; XCTUnwrap replaces the misleading "not seeded" skip. The two uncancel tests now skip with the ACCURATE reason: cancelled tasks are intentionally hidden from the Tasks Kanban and the iOS Tasks view has no "show cancelled" surface (product gap). - Issue 3: re-quarantine testF110 after a hardening attempt — the register->verify transition is irreducibly flaky; coverage is redundant with OnboardingTaskCache + the F-series. Skip reason is now precise, with a TODO to stabilize the handoff. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -129,22 +129,30 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
/// create account → verify email — then confirms the app lands on main tabs,
|
||||
/// which indicates the residence was bootstrapped during onboarding.
|
||||
func testF110_startFreshCreatesResidenceAfterVerification() throws {
|
||||
// QUARANTINED: this end-to-end onboarding flow (register → Kratos verify →
|
||||
// home-profile → first-task → main tabs) is flaky at the verify handoff,
|
||||
// failing at different points across runs. Its unique coverage — a
|
||||
// residence being auto-created during onboarding — is already proven by
|
||||
// OnboardingTaskCacheUITests (register → verify → tasks on residence
|
||||
// detail) and the F101–F108/F111 navigation tests. TODO: harden the
|
||||
// verify-screen handoff and re-enable.
|
||||
throw XCTSkip("Flaky end-to-end onboarding flow; coverage provided by OnboardingTaskCacheUITests + F-series. TODO: harden and re-enable.")
|
||||
// QUARANTINED (after a hardening attempt): the full Start-Fresh → Kratos
|
||||
// verify → main-tabs flow is irreducibly flaky at the register→verify
|
||||
// transition (the verification screen intermittently doesn't appear after
|
||||
// the create-account submit; failures land at different points across
|
||||
// runs). The SAME transition is exercised reliably by
|
||||
// OnboardingTaskCacheUITests (register → verify → tasks), and onboarding
|
||||
// navigation is covered by F101–F108/F111 — so this test's coverage is
|
||||
// fully redundant. Skipping is preferred over a flaky red in the suite.
|
||||
// TODO: stabilize the register→verify handoff (likely an app-side timing
|
||||
// issue between Kratos identity creation and the verify-screen navigation)
|
||||
// and re-enable.
|
||||
throw XCTSkip("Flaky register→verify transition; coverage provided by OnboardingTaskCacheUITests + F-series.")
|
||||
|
||||
try? XCTSkipIf(
|
||||
!TestAccountAPIClient.isBackendReachable(),
|
||||
"Local backend is not reachable — skipping ONB-005"
|
||||
)
|
||||
|
||||
// Generate unique credentials so we don't collide with other test runs
|
||||
// Generate unique credentials so we don't collide with other test runs.
|
||||
// Capture the registered email ONCE into a local `let` and reuse it for
|
||||
// BOTH registration and the Mailpit verification-code lookup — the two
|
||||
// must be byte-for-byte identical or the code read will miss.
|
||||
let creds = TestAccountManager.uniqueCredentials(prefix: "onb005")
|
||||
let email = creds.email
|
||||
let uniqueResidenceName = "ONB005 Home \(Int(Date().timeIntervalSince1970))"
|
||||
|
||||
// Step 1: Navigate Start Fresh flow to the Create Account screen
|
||||
@@ -167,7 +175,7 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
onbUsernameField.focusAndType(creds.username, app: app)
|
||||
|
||||
onbEmailField.waitForExistenceOrFail(timeout: defaultTimeout)
|
||||
onbEmailField.focusAndType(creds.email, app: app)
|
||||
onbEmailField.focusAndType(email, app: app)
|
||||
|
||||
onbPasswordField.waitForExistenceOrFail(timeout: defaultTimeout)
|
||||
onbPasswordField.focusAndType(creds.password, app: app)
|
||||
@@ -181,11 +189,19 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
createAccountButton.waitForExistenceOrFail(timeout: defaultTimeout)
|
||||
createAccountButton.forceTap()
|
||||
|
||||
// Step 4: Verify email with the debug code
|
||||
// Step 4: Verify email with the real Kratos code from Mailpit.
|
||||
//
|
||||
// This handoff is the historically flaky part. Mirror the proven-robust
|
||||
// sequence from OnboardingTaskCacheUITests: wait for the verification
|
||||
// screen to actually LOAD before reading anything, give the screen's own
|
||||
// onAppear sendCode a brief settle to fire, then read the live code from
|
||||
// Mailpit for the captured `email`.
|
||||
let verificationScreen = VerificationScreen(app: app)
|
||||
// If the create account button was disabled (password fields didn't fill),
|
||||
// we won't reach verification. Check before asserting.
|
||||
let verificationLoaded = verificationScreen.codeField.waitForExistence(timeout: loginTimeout)
|
||||
// Wait for the screen to load (code field OR verify button). If we never
|
||||
// reach it, the form submission stalled (e.g. password fields didn't fill).
|
||||
verificationScreen.waitForLoad(timeout: loginTimeout)
|
||||
let verificationLoaded = verificationScreen.codeField.waitForExistence(timeout: navigationTimeout)
|
||||
|| verificationScreen.verifyButton.waitForExistence(timeout: navigationTimeout)
|
||||
guard verificationLoaded else {
|
||||
// Check if the create account button is still visible (form submission failed)
|
||||
if createAccountButton.exists {
|
||||
@@ -194,15 +210,20 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
XCTFail("Expected verification screen to load")
|
||||
return
|
||||
}
|
||||
|
||||
// The app's onboarding registration uses Kratos's real email verification
|
||||
// flow (NOT the API's DEBUG fixed code). The verify screen's onAppear fires
|
||||
// its OWN sendCode (a fresh Kratos flow), invalidating any earlier code — so
|
||||
// read the live code from Mailpit AFTER the screen has appeared and sent it.
|
||||
// read the live code from Mailpit AFTER the screen has appeared and had a
|
||||
// beat to send it. Reuse the SAME `email` captured at registration so the
|
||||
// lookup addresses the identical inbox.
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(2.0))
|
||||
guard let realCode = TestAccountAPIClient.latestVerificationCode(for: creds.email) else {
|
||||
throw XCTSkip("Could not read Kratos verification code from Mailpit for \(creds.email)")
|
||||
}
|
||||
verificationScreen.enterCode(realCode)
|
||||
let code = TestAccountAPIClient.latestVerificationCode(for: email) ?? ""
|
||||
XCTAssertFalse(
|
||||
code.isEmpty,
|
||||
"No Kratos verification code arrived in Mailpit for \(email)"
|
||||
)
|
||||
verificationScreen.enterCode(code)
|
||||
|
||||
// The Onboarding Verify button is disabled until the 6-digit code commits;
|
||||
// wait for it to enable, then tap. Fall back to the generic submit helper.
|
||||
@@ -238,6 +259,9 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
// which fires the residence-create POST and navigates to the First Task step.
|
||||
// The in-screen "Continue" button has no accessibility identifier and isn't
|
||||
// reliably discoverable, so drive the flow via the identified Skip button.
|
||||
// The skip button can briefly be non-hittable during the verify→homeProfile
|
||||
// screen-in transition, so confirm existence then forceTap() to bypass the
|
||||
// strict hittable check (mirrors OnboardingTaskCacheUITests).
|
||||
let skipButton = app.buttons[AccessibilityIdentifiers.Onboarding.skipButton]
|
||||
if skipButton.waitForExistence(timeout: loginTimeout) {
|
||||
skipButton.forceTap()
|
||||
@@ -247,6 +271,8 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
}
|
||||
|
||||
// Step 5b: First Task — Skip again to complete onboarding and land on main tabs.
|
||||
// A single slow transition shouldn't fail the test: re-confirm the skip
|
||||
// button each time and forceTap, falling back to the submit-tasks button.
|
||||
if firstTaskTitle.waitForExistence(timeout: navigationTimeout) {
|
||||
if skipButton.waitForExistence(timeout: navigationTimeout) {
|
||||
skipButton.forceTap()
|
||||
@@ -255,6 +281,17 @@ final class OnboardingUITests: BaseUITestCase {
|
||||
}
|
||||
}
|
||||
|
||||
// Defensive retry: if a slow transition left us still on the First Task
|
||||
// step, try the skip/submit once more so timing alone doesn't fail us.
|
||||
if firstTaskTitle.waitForExistence(timeout: navigationTimeout)
|
||||
&& !mainTabs.exists && !tabBar.exists {
|
||||
if skipButton.exists {
|
||||
skipButton.forceTap()
|
||||
} else if submitTasksButton.exists {
|
||||
submitTasksButton.forceTap()
|
||||
}
|
||||
}
|
||||
|
||||
let reachedMain = mainTabs.waitForExistence(timeout: loginTimeout)
|
||||
|| tabBar.waitForExistence(timeout: 5)
|
||||
let onbVisible = app.otherElements[UITestID.Root.onboarding].exists
|
||||
|
||||
Reference in New Issue
Block a user