mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
OH14 — e2e: offline RSC guard allowlist + strict-mode flakes
- Extend failure guard with path prefixes and RSC prefetch allowance - Scope WebAuthn empty-state to main; territories use .first()
This commit is contained in:
parent
35c5ffd990
commit
512776314b
5 changed files with 56 additions and 15 deletions
|
|
@ -6,7 +6,11 @@ import {
|
||||||
} from './fixtures/campaignE2EFixtures.js'
|
} from './fixtures/campaignE2EFixtures.js'
|
||||||
|
|
||||||
/** Offline specs intentionally hit blocked network resources — allowlist for the guard. */
|
/** Offline specs intentionally hit blocked network resources — allowlist for the guard. */
|
||||||
test.use({ expectedRequestFailurePaths: ['/campanha/api/ops-sync', '/favicon.ico'] })
|
test.use({
|
||||||
|
expectedRequestFailurePaths: ['/campanha/api/ops-sync', '/favicon.ico'],
|
||||||
|
expectedRequestFailurePathPrefixes: ['/campanha'],
|
||||||
|
allowOfflineRscPrefetchErrors: true,
|
||||||
|
})
|
||||||
|
|
||||||
/** OH6 — flaky-network outbox for estimateVotes. */
|
/** OH6 — flaky-network outbox for estimateVotes. */
|
||||||
test.describe('OH6 estimate outbox', () => {
|
test.describe('OH6 estimate outbox', () => {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ import {
|
||||||
} from './fixtures/campaignE2EFixtures.js'
|
} from './fixtures/campaignE2EFixtures.js'
|
||||||
|
|
||||||
/** Offline specs intentionally hit blocked network resources — allowlist for the guard. */
|
/** Offline specs intentionally hit blocked network resources — allowlist for the guard. */
|
||||||
test.use({ expectedRequestFailurePaths: ['/campanha/api/ops-sync', '/favicon.ico'] })
|
test.use({
|
||||||
|
expectedRequestFailurePaths: ['/campanha/api/ops-sync', '/favicon.ico'],
|
||||||
|
expectedRequestFailurePathPrefixes: ['/campanha'],
|
||||||
|
allowOfflineRscPrefetchErrors: true,
|
||||||
|
})
|
||||||
|
|
||||||
/** OH9/OH11/OH12 — dual-path municipality detail + offline journey + list Local. */
|
/** OH9/OH11/OH12 — dual-path municipality detail + offline journey + list Local. */
|
||||||
test.describe('OH9/OH11 campaign ops offline', () => {
|
test.describe('OH9/OH11 campaign ops offline', () => {
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ test.describe('Territórios de Identidade', () => {
|
||||||
|
|
||||||
await campaign.login(page, coordinator.email!, coordinator.password)
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
||||||
await page.goto('/campanha/territorios')
|
await page.goto('/campanha/territorios')
|
||||||
await expect(page.getByText(/27 territórios encontrados/)).toBeVisible()
|
await expect(page.getByText(/27 territórios encontrados/).first()).toBeVisible()
|
||||||
|
|
||||||
await page.getByRole('link', { name: 'Ir para a página 2' }).click()
|
await page.getByRole('link', { name: 'Ir para a página 2' }).click()
|
||||||
await expect(page).toHaveURL(/\/campanha\/territorios\?page=2/)
|
await expect(page).toHaveURL(/\/campanha\/territorios\?page=2/)
|
||||||
await expect(page.getByText(/27 territórios encontrados/)).toBeVisible()
|
await expect(page.getByText(/27 territórios encontrados/).first()).toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('parent territory rows expose hash anchor ids for deep links', async ({
|
test('parent territory rows expose hash anchor ids for deep links', async ({
|
||||||
|
|
@ -61,8 +61,8 @@ test.describe('Territórios de Identidade', () => {
|
||||||
await campaign.login(page, email, password)
|
await campaign.login(page, email, password)
|
||||||
await page.goto('/campanha/territorios')
|
await page.goto('/campanha/territorios')
|
||||||
|
|
||||||
await expect(page.locator('#ti-irece')).toBeVisible()
|
await expect(page.locator('#ti-irece').first()).toBeVisible()
|
||||||
await expect(page.locator('#ti-velho-chico')).toBeVisible()
|
await expect(page.locator('#ti-velho-chico').first()).toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('leader cannot open the territories page', async ({ campaign, page }) => {
|
test('leader cannot open the territories page', async ({ campaign, page }) => {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ test('enrolls a passkey, signs in with it, then revokes it', async ({
|
||||||
await expectCampaignBiometricsReady(page)
|
await expectCampaignBiometricsReady(page)
|
||||||
await page.goto('/campanha/perfil')
|
await page.goto('/campanha/perfil')
|
||||||
|
|
||||||
await expect(page.getByText('Nenhum aparelho cadastrado ainda.')).toBeVisible()
|
await expect(page.getByRole('main').getByText('Nenhum aparelho cadastrado ainda.')).toBeVisible()
|
||||||
|
|
||||||
const deviceLabel = page.getByLabel('Nome deste aparelho')
|
const deviceLabel = page.getByLabel('Nome deste aparelho')
|
||||||
await expect(deviceLabel).toBeVisible()
|
await expect(deviceLabel).toBeVisible()
|
||||||
|
|
@ -82,7 +82,7 @@ test('enrolls a passkey, signs in with it, then revokes it', async ({
|
||||||
await page.getByRole('button', { name: 'Ativar neste aparelho' }).click()
|
await page.getByRole('button', { name: 'Ativar neste aparelho' }).click()
|
||||||
|
|
||||||
await expect(page.getByText('Celular da assessora')).toBeVisible({ timeout: CEREMONY_TIMEOUT })
|
await expect(page.getByText('Celular da assessora')).toBeVisible({ timeout: CEREMONY_TIMEOUT })
|
||||||
await expect(page.getByText('Nenhum aparelho cadastrado ainda.')).toBeHidden()
|
await expect(page.getByRole('main').getByText('Nenhum aparelho cadastrado ainda.')).toBeHidden()
|
||||||
|
|
||||||
// 2. Password-less sign-in issues the 14-day cookie — enrolling the device IS
|
// 2. Password-less sign-in issues the 14-day cookie — enrolling the device IS
|
||||||
// the "remember me" opt-in, so there is no checkbox in this path.
|
// the "remember me" opt-in, so there is no checkbox in this path.
|
||||||
|
|
@ -103,7 +103,7 @@ test('enrolls a passkey, signs in with it, then revokes it', async ({
|
||||||
// the profile and it has to actually stop the credential.
|
// the profile and it has to actually stop the credential.
|
||||||
await page.goto('/campanha/perfil')
|
await page.goto('/campanha/perfil')
|
||||||
await page.getByRole('button', { name: 'Remover Celular da assessora' }).click()
|
await page.getByRole('button', { name: 'Remover Celular da assessora' }).click()
|
||||||
await expect(page.getByText('Nenhum aparelho cadastrado ainda.')).toBeVisible()
|
await expect(page.getByRole('main').getByText('Nenhum aparelho cadastrado ainda.')).toBeVisible()
|
||||||
|
|
||||||
await context.clearCookies()
|
await context.clearCookies()
|
||||||
await page.goto('/campanha/login')
|
await page.goto('/campanha/login')
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ type E2EFailureGuardFixtures = {
|
||||||
* mid-test.
|
* mid-test.
|
||||||
*/
|
*/
|
||||||
expectedRequestFailurePaths: string[]
|
expectedRequestFailurePaths: string[]
|
||||||
|
/** Pathname prefix allowlist for intentional offline prefetch failures. */
|
||||||
|
expectedRequestFailurePathPrefixes: string[]
|
||||||
|
/** Next.js RSC prefetch console noise while the browser context is offline. */
|
||||||
|
allowOfflineRscPrefetchErrors: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadFailurePrefix = 'Failed to load resource'
|
const loadFailurePrefix = 'Failed to load resource'
|
||||||
|
|
@ -49,6 +53,8 @@ const isAllowedConsoleError = (
|
||||||
message: ConsoleMessage,
|
message: ConsoleMessage,
|
||||||
origin: string | null,
|
origin: string | null,
|
||||||
expectedRequestFailurePaths: string[],
|
expectedRequestFailurePaths: string[],
|
||||||
|
expectedRequestFailurePathPrefixes: string[],
|
||||||
|
allowOfflineRscPrefetchErrors: boolean,
|
||||||
): boolean => {
|
): boolean => {
|
||||||
const { url } = message.location()
|
const { url } = message.location()
|
||||||
if (!url || origin === null) return false
|
if (!url || origin === null) return false
|
||||||
|
|
@ -59,23 +65,50 @@ const isAllowedConsoleError = (
|
||||||
// The app intentionally has no /favicon.ico asset yet.
|
// The app intentionally has no /favicon.ico asset yet.
|
||||||
if (message.text() === missingFaviconConsoleError) return location.pathname === '/favicon.ico'
|
if (message.text() === missingFaviconConsoleError) return location.pathname === '/favicon.ico'
|
||||||
|
|
||||||
return (
|
if (
|
||||||
message.text().startsWith(loadFailurePrefix) &&
|
allowOfflineRscPrefetchErrors &&
|
||||||
expectedRequestFailurePaths.includes(location.pathname)
|
message.text().includes('Failed to fetch RSC payload') &&
|
||||||
)
|
message.text().includes('/campanha')
|
||||||
|
) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
const pathAllowed =
|
||||||
|
expectedRequestFailurePaths.includes(location.pathname) ||
|
||||||
|
expectedRequestFailurePathPrefixes.some((prefix) => location.pathname.startsWith(prefix))
|
||||||
|
|
||||||
|
return message.text().startsWith(loadFailurePrefix) && pathAllowed
|
||||||
}
|
}
|
||||||
|
|
||||||
export const test = base.extend<E2EFailureGuardFixtures>({
|
export const test = base.extend<E2EFailureGuardFixtures>({
|
||||||
expectedRequestFailurePaths: [[], { option: true }],
|
expectedRequestFailurePaths: [[], { option: true }],
|
||||||
|
expectedRequestFailurePathPrefixes: [[], { option: true }],
|
||||||
|
allowOfflineRscPrefetchErrors: [false, { option: true }],
|
||||||
e2eFailureGuard: [
|
e2eFailureGuard: [
|
||||||
async ({ baseURL, context, expectedRequestFailurePaths, page }, use) => {
|
async (
|
||||||
|
{
|
||||||
|
baseURL,
|
||||||
|
context,
|
||||||
|
expectedRequestFailurePaths,
|
||||||
|
expectedRequestFailurePathPrefixes,
|
||||||
|
allowOfflineRscPrefetchErrors,
|
||||||
|
page,
|
||||||
|
},
|
||||||
|
use,
|
||||||
|
) => {
|
||||||
const failures: BrowserFailure[] = []
|
const failures: BrowserFailure[] = []
|
||||||
const origin = baseURL ? new URL(baseURL).origin : null
|
const origin = baseURL ? new URL(baseURL).origin : null
|
||||||
|
|
||||||
const onConsole = (message: ConsoleMessage) => {
|
const onConsole = (message: ConsoleMessage) => {
|
||||||
if (
|
if (
|
||||||
message.type() !== 'error' ||
|
message.type() !== 'error' ||
|
||||||
isAllowedConsoleError(message, origin, expectedRequestFailurePaths)
|
isAllowedConsoleError(
|
||||||
|
message,
|
||||||
|
origin,
|
||||||
|
expectedRequestFailurePaths,
|
||||||
|
expectedRequestFailurePathPrefixes,
|
||||||
|
allowOfflineRscPrefetchErrors,
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue