fix(editor): e2e setup retries a GoTrue 500 step-up, drops late replays

This commit is contained in:
bchanot committed 2026-11-14 19:01:21 +01:00
1 parent dca80cb006
commit 0ea94602d1
5 files changed
+110 -11

No files matched your search

+2 -1
View File
@@ -22,6 +22,7 @@ import {
savedLine,
saveDraft,
saveLine,
closeSecondSession,
secondSession,
selectionTag,
selectTab,
@@ -361,7 +362,7 @@ test.describe('editor journey (owner trial steps)', () => {
await clickDialog(again, dict['editor.draft.conflict.keep'])
await expect(again).toBeHidden()
await expect(saveLine(page)).toHaveText(savedLine(dict, 5))
await second.context.close()
await closeSecondSession(second)
await selectTab(page, dict, 'verification')
+25 -4
View File
@@ -2,7 +2,11 @@ import { fr } from '@/i18n/fr'
import type { Locator, Page, TestInfo } from '@playwright/test'
import { rpc } from '../../../../packages/supabase/tests/sandbox/stack'
import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
FAKE_SUPABASE_ORIGIN,
dropLateReplays,
routeToSandbox,
} from '../support/sandbox'
import {
type Actor,
copyKeyOf,
@@ -26,7 +30,7 @@ import {
UNSAVED_LINE,
} from '../support/editor'
import { stepUpAdmin } from '../support/admin'
import { secondSession } from '../support/editor'
import { closeSecondSession, secondSession } from '../support/editor'
import { signIn } from '../support/shell'
// V1-2.6 recovery and concurrency (contract C27 to C30, owner 2026-11-04): two sessions
@@ -134,7 +138,7 @@ test.describe('editor recovery and concurrency', () => {
// The reloaded session then saves without a conflict.
await commitText(nameFr(other.page), 'Seconde session, reprise')
await saveDraft(other.page, dict, 3)
await other.context.close()
await closeSecondSession(other)
})
test('an older copy restored then saved: conflict, then « Garder ma version » after the confirmation', async ({
@@ -254,6 +258,23 @@ test.describe('editor recovery and concurrency', () => {
await expect(nameFr(page)).toBeEditable()
})
test('a second session closed with a read in flight fails nothing (verifier 10)', async ({
browser,
baseURL,
}) => {
// Gate final3: a replay of the closed context's last read rejected with « Request
// context disposed » inside the route callback, which failed the test.
const other = await secondSession(browser, baseURL ?? '', 'fr-FR')
await other.page.goto('/login')
const replayed = other.page.waitForRequest(/\/rest\/v1\/species/)
// Many reads, so some replays are still running when the context closes.
await other.page.evaluate((url) => {
for (let i = 0; i < 60; i += 1) void fetch(`${url}&n=${i}`).catch(() => 0)
}, `${FAKE_SUPABASE_ORIGIN}/rest/v1/species?select=id`)
await replayed
await closeSecondSession(other)
})
test('the conflict read in progress can be left with Escape', async ({
page,
browser,
@@ -268,7 +289,7 @@ test.describe('editor recovery and concurrency', () => {
await signInAgain(other.page, actor, seed.sheetId)
await commitText(nameFr(other.page), 'Devant')
await saveDraft(other.page, dict, 2)
await other.context.close()
await closeSecondSession(other)
let release = () => {}
const gate = new Promise<void>((resolve) => (release = resolve))
@@ -1,7 +1,9 @@
import { fr } from '@/i18n/fr'
import type { Page, TestInfo } from '@playwright/test'
import { expect, test } from '../support/browser'
import { sessionAal, stepUpAdmin } from '../support/admin'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import { signIn } from '../support/shell'
import {
TABS,
closeFinding,
@@ -284,4 +286,27 @@ test.describe('editor shell journeys (H)', () => {
.replace('{revision}', String(seed.revision + 1))
await expect(saveLine(page)).toHaveText(new RegExp(`^${timed}$`))
})
test('the step-up of the setup survives one GoTrue verify failure (verifier 10)', async ({
page,
}) => {
// Under the eight-worker sweep GoTrue answered a verify HTTP 500 (gate final.log):
// the step-up shows « indisponible » and the setup must try again, never stop there.
const actor = await editorActor('fr')
let failed = false
await page.route('**/auth/v1/factors/*/verify', (route) => {
if (failed) return route.fallback()
failed = true
return route.fulfill({
status: 500,
contentType: 'application/json',
body: JSON.stringify({ code: 500, error_code: 'unexpected_failure' }),
})
})
await signIn(page, actor.account, dict)
await page.goto('/app/admin')
await stepUpAdmin(page, dict, actor.secret)
expect(failed).toBe(true)
expect(await sessionAal(page)).toBe('aal2')
})
})