diff --git a/tests/e2e/campaignAiLinks.e2e.spec.ts b/tests/e2e/campaignAiLinks.e2e.spec.ts index 8e96b7d7..2f28b718 100644 --- a/tests/e2e/campaignAiLinks.e2e.spec.ts +++ b/tests/e2e/campaignAiLinks.e2e.spec.ts @@ -20,6 +20,13 @@ const ASSISTANT_LINKS = 'Confira [o portal da saúde](https://www.saude.ba.gov.br/) e [o município de Ilhéus](/campanha/municipios/ilheus).' const openChatAndSend = async (page: Page) => { + // B203 — fresh desktop sessions start closed (this spec is desktop-only); + // open explicitly via the header button. + await waitForRouterSettled(page) + await page + .getByRole('button', { name: 'Sollinha — Assistente virtual' }) + .filter({ visible: true }) + .click() await expect(page.getByText('Olá! Eu sou o Sollinha')).toBeVisible({ timeout: 20_000 }) // OPS42 — dev-only settle before interacting (see `waitForRouterSettled`). await waitForRouterSettled(page) diff --git a/tests/e2e/campaignSollinhaContext.e2e.spec.ts b/tests/e2e/campaignSollinhaContext.e2e.spec.ts index 61b075db..bc36687e 100644 --- a/tests/e2e/campaignSollinhaContext.e2e.spec.ts +++ b/tests/e2e/campaignSollinhaContext.e2e.spec.ts @@ -51,18 +51,10 @@ const gatedMockAiChat = (page: Page) => { const MESSAGE = 'Mensagem que sobrevive ao reload' const SECOND_MESSAGE = 'Segunda pergunta' -const openDesktopChat = async (page: Page) => { - // B203 — fresh desktop sessions start closed; open explicitly via the header button. - await waitForRouterSettled(page) - await page - .getByRole('button', { name: 'Sollinha — Assistente virtual' }) - .filter({ visible: true }) - .click() - await expect(page.getByText('Olá! Eu sou o Sollinha')).toBeVisible({ timeout: 20_000 }) -} - const openChatAndSend = async (page: Page) => { - await openDesktopChat(page) + // The chat must already be open (desktop: via the header button — B203; + // mobile: via the drawer) — this helper only sends. + await expect(page.getByText('Olá! Eu sou o Sollinha')).toBeVisible({ timeout: 20_000 }) // OPS42 — dev-only settle before interacting (see `waitForRouterSettled`). await waitForRouterSettled(page) const input = page.getByRole('textbox', { name: 'Pergunte para o Sollinha...' }) @@ -71,6 +63,16 @@ const openChatAndSend = async (page: Page) => { await expect(page.getByText(MESSAGE)).toBeVisible({ timeout: 20_000 }) } +/** B203 — desktop-only: fresh sessions start closed; open via the header button. */ +const openDesktopChat = async (page: Page) => { + await waitForRouterSettled(page) + await page + .getByRole('button', { name: 'Sollinha — Assistente virtual' }) + .filter({ visible: true }) + .click() + await expect(page.getByText('Olá! Eu sou o Sollinha')).toBeVisible({ timeout: 20_000 }) +} + /** The chat has settled once the mic button re-enables (busy → ready). */ const waitForChatSettled = async (page: Page) => { await expect( @@ -111,6 +113,7 @@ test.describe('B188 — contexto da conversa persiste na sessão da janela/tab', await page.setViewportSize({ width: 1280, height: 800 }) await page.goto('/campanha') + await openDesktopChat(page) await openChatAndSend(page) await waitForChatSettled(page) // Deterministic gate: the persist effect must have landed before reload. @@ -130,6 +133,7 @@ test.describe('B188 — contexto da conversa persiste na sessão da janela/tab', await page.setViewportSize({ width: 1280, height: 800 }) await page.goto('/campanha') + await openDesktopChat(page) await openChatAndSend(page) await waitForChatSettled(page)