From 10e0c17078ae52d294d42f2ec051b312b36337cf Mon Sep 17 00:00:00 2001 From: Francisco Solla Date: Mon, 24 Aug 2026 07:17:03 -0300 Subject: [PATCH] =?UTF-8?q?fix(e2e):=20OPS83=20=E2=80=94=20polish=20after?= =?UTF-8?q?=20review:=20rename=20expectSectionCount,=20toBeOK,=20settle=20?= =?UTF-8?q?helper=20reuse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/e2e/campaignMunicipalities.e2e.spec.ts | 7 ++++--- tests/e2e/frontend.e2e.spec.ts | 18 +++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/e2e/campaignMunicipalities.e2e.spec.ts b/tests/e2e/campaignMunicipalities.e2e.spec.ts index decb9668..d120bdc5 100644 --- a/tests/e2e/campaignMunicipalities.e2e.spec.ts +++ b/tests/e2e/campaignMunicipalities.e2e.spec.ts @@ -719,9 +719,10 @@ test.describe('Municípios — jornadas por papel', () => { // leadership-list chunk can land after `goto` settles, so let the stream // commit before asserting the leadership link (same class as the `:115` // editar checkbox and the C142 FAB). The generic `S:` gate alone is not - // enough (observed in the OPS83 verify run #15): poll the DOM for the - // specific link instead of `.first()` on the nondeterministic stream. - await page.waitForFunction(() => document.querySelectorAll('div[id^="S:"]').length === 0) + // enough (observed in the OPS83 verify run #15): poll until the specific + // link lands in the DOM, then assert visibility (`.first()` only disambiguates + // if a duplicate ever appears — the count poll is the real gate). + await settleMunicipalityStream(page) const leadershipLink = page.getByRole('link', { name: contact.name }) await expect.poll(() => leadershipLink.count(), { timeout: 15_000 }).toBeGreaterThan(0) await expect(leadershipLink.first()).toBeVisible() diff --git a/tests/e2e/frontend.e2e.spec.ts b/tests/e2e/frontend.e2e.spec.ts index faf911a0..35cf09a1 100644 --- a/tests/e2e/frontend.e2e.spec.ts +++ b/tests/e2e/frontend.e2e.spec.ts @@ -699,7 +699,7 @@ test.describe('Campaign home content section', () => { * link). This is the source that observes the actual payload — pair it with * `gotoHomeFresh` so the navigation itself misses the cache. */ - const expectSectionCardCount = (locator: Locator, expected: number, timeout = 15_000) => + const expectSectionCount = (locator: Locator, expected: number, timeout = 15_000) => expect .poll(async () => locator.count(), { timeout, message: 'contents section card count' }) .toBe(expected) @@ -803,13 +803,13 @@ test.describe('Campaign home content section', () => { const revalidate = await request.post(`${baseURL}/api/revalidate?tag=posts`, { headers: { 'x-revalidate-secret': revalidateSecret }, }) - expect(revalidate.ok()).toBeTruthy() + expect(revalidate).toBeOK() await waitForHomeSectionState(request, 'absent', 30) // Plain URL on purpose: the test also pins the canonical home URL. await page.goto('/') await expect(page).toHaveURL(/\/$/) - await expectSectionCardCount(page.locator('[data-home-section="contents"]'), 0) + await expectSectionCount(page.locator('[data-home-section="contents"]'), 0) await expect(page.getByText('A caminhada, em tempo real')).toHaveCount(0) const proof = await page.locator('[data-home-section="proof"]').boundingBox() @@ -1350,8 +1350,8 @@ test.describe('Campaign home content section', () => { await expect(section.getByRole('link', { name: /E2e Artigo fallback IG/ })).toBeVisible() // Same rendered-DOM class as the kill-switch test (OPS83 run #15): the // server poll converged but the page served a stale body — poll the DOM. - await expectSectionCardCount(section.getByText('E2e Post do muro'), 0) - await expectSectionCardCount(section.getByRole('link', { name: /Seguir no Instagram/ }), 0) + await expectSectionCount(section.getByText('E2e Post do muro'), 0) + await expectSectionCount(section.getByRole('link', { name: /Seguir no Instagram/ }), 0) await page.goto('about:blank') await expect(page).toHaveURL(/about:blank/) @@ -1482,10 +1482,10 @@ test.describe('Campaign home content section', () => { const section = page.locator('[data-home-section="contents"]') await expect(section).toBeVisible() await expect(section.getByRole('link', { name: /E2e Artigo kill switch/ })).toBeVisible() - await expectSectionCardCount(section.getByText('E2e Vídeo em destaque'), 0) - await expectSectionCardCount(section.getByRole('link', { name: /YouTube →/ }), 0) - await expectSectionCardCount(section.getByText('E2e Post do muro'), 0) - await expectSectionCardCount(section.getByRole('link', { name: /Seguir no Instagram/ }), 0) + await expectSectionCount(section.getByText('E2e Vídeo em destaque'), 0) + await expectSectionCount(section.getByRole('link', { name: /YouTube →/ }), 0) + await expectSectionCount(section.getByText('E2e Post do muro'), 0) + await expectSectionCount(section.getByRole('link', { name: /Seguir no Instagram/ }), 0) await page.goto('about:blank') await expect(page).toHaveURL(/about:blank/)