Enhance test coverage: sign-in, account changes and session recovery #473
No reviewers
Labels
No labels
app
app
bug
app
enhancement
client side exclusive
closed
completed
closed
duplicate
closed
invalid
closed
not open grind
closed
not planned
closed
question
🗳️ community vote
⚠️ critical
discussion
docs
emulator
help wanted
paywalled
bypassable
paywalled
non-bypassable
paywalled
unconfirmed
pr/dubious
question
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
open-grind/open-grind!473
Loading…
Reference in a new issue
No description provided.
Delete branch "Enucatl/open-grind:test/auth-session-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Cover CAPTCHA retries and failures, successful sign-in, account state
cleanup, reconnect recovery, duplicate deliveries and expired sessions.
Exercise client behavior through controlled native and API responses
without requiring a device or live account.
This is how far we can go, together with the existing coverage, to contribute to #51 without using live accounts and emulators.
Thank you!
@ -0,0 +66,5 @@await Promise.all([import("@testing-library/svelte"),import("$lib/chat/conversations-context.svelte"),import("../../routes/(protected)/(navbar)/settings/(me)/SignOutButton.svelte"),import("../../routes/auth/sign-in/SignInForm.svelte"),The only
$libtest that imports routes, and there's noaccount-switchmodule here. It drives SignOutButton, SignInForm and the protected layout: move it next to SignOutButton.svelte, e.g.SignOutButton.account-switch.svelte.test.tslikeMediaImage.retry.svelte.test.ts.Moved the test next to
SignOutButton.svelteasSignOutButton.account-switch.svelte.test.ts. Updated its imports.@ -0,0 +287,15 @@await assertSecondAccount(app);});it("keeps the first account's data and notifications when the Google account switch is cancelled", async () => {const { render, fireEvent, screen } = testing;const app = await firstAccount();const { consumeGoogleHandoff } = await import("./google-handoff");const { default: Confirm } =await import("$lib/components/feedback/GoogleHandoffConfirmAlert.svelte");render(Confirm);const switching = consumeGoogleHandoff();await fireEvent.click(await screen.findByRole("button", { name: "Cancel" }),);await switching;google-handoff.test.ts "keeps the current account and discards the handoff when the switch is declined" already shows nothing gets signed out. Run the confirmed switch end to end instead: the mock answers
sign_in_with_google_handoff(line 118), but no test reaches it.Replaced the cancelled-switch case with a confirmed Google switch. The test clicks Continue, calls
sign_in_with_google_handoff, and checks the new account and the removal of the previous account data.@ -0,0 +132,5 @@});}function reconnect() {clock += 3_000;3_000only means "pastTHROTTLE_MS(2000) in reconcile.ts". Name it. Same at 180 and 245.Named the interval
PAST_RECONCILE_THROTTLE_MSand used it for all three clock advances.@ -0,0 +169,7 @@).toEqual(ids);}beforeAll(async () => {emit("ws:connected");await Promise.resolve();});This uses up the reconciler's first-connect skip (
#firstConnectin reconcile.ts). With the comment gone nothing says so, move it into a helper whose name does.Moved the initial connection into
consumeFirstConnectSkip()and used that helper inbeforeAll.@ -0,0 +251,4 @@),).toHaveLength(2),);await new Promise((resolve) => setTimeout(resolve, 0));Use
microtasks()from conversations-test-helpers. Same at 314 and 392.Replaced all three zero-delay waits with
microtasks()fromconversations-test-helpers.@ -249,0 +300,6 @@"completes %s sign-in and drops the previous profile before navigating",async (vendor) => {await cachePreviousProfile();gotoMock.mockImplementation(() => {expect(isProfileCached(123)).toBe(false);});If this expect fails, it throws inside
finishSignIn, which reports it as a sign-in failure, so the test fails ontoastMock.errorinstead of here. RecordisProfileCached(123)and assert it after.The test now records
isProfileCached(123)when navigation starts. It checks the recorded value after sign-in completes.@ -249,0 +351,4 @@kind: "restriction",restriction,});expect(isProfileCached(123)).toBe(true);Nothing needs the old profile to stay cached here: the restriction popup signs out on close. Drop it.
Removed the old-profile cache setup and the cache assertion from the restriction test.
@ -249,0 +400,5 @@},);it.each([false, new Error("Assignment check failed")])("reports wrong credentials when the CAPTCHA assignment is unavailable (%j)",%jprints the Error row as({}). Name the rows and use%s.Named the rows
disabledandcheck failed. The test title now uses%s.@ -249,0 +444,4 @@"grindrMissing","The reCAPTCHA helper needs the Grindr app installed to verify this sign-in.",],["executionFailed", "Captcha verification failed. Try again."],No such reason.
RecaptchaErrorin src-tauri/src/api/recaptcha/error.rs sendsmintFailed,noToken,failedand others, use a real one for the fallback.Replaced
executionFailedwithfailed, which is a realRecaptchaErrorreason.dd31fd1a3bc1bcdb67e1In reply to the review:
Renamed the recovery test to
conversation-state-recovery.svelte.test.ts. All nine inline requests are fixed, with a reply in each thread.Rebased onto
upstream/main, squashed the changes into one signed commit, and force-pushed c1bcdb67.Validation passed in disposable containers: 4,156 frontend tests, 803 Rust tests, 750 browser cases, and 40 layout guards. Formatting, lint, types, shared config, Rust formatting, and Clippy passed.
Five browser cases passed on retry. Three live Rust tests and one macOS-only browser case were skipped.