test(e2e): assert entity identity in shell chrome (B145)

This commit is contained in:
Cursor Agent 2026-08-02 23:26:11 +00:00
parent 33d2e5ba01
commit c62fe67809
No known key found for this signature in database
4 changed files with 9 additions and 9 deletions

View file

@ -1,4 +1,4 @@
import { expect, test } from './fixtures/campaignE2EFixtures.js'
import { campaignPageChrome, expect, test } from './fixtures/campaignE2EFixtures.js'
test.describe('Atividades — registro-fundação', () => {
test.setTimeout(90_000)
@ -34,7 +34,7 @@ test.describe('Atividades — registro-fundação', () => {
await page.getByRole('button', { name: 'Criar atividade' }).click()
await expect(page).toHaveURL(/\/campanha\/atividades\/[^/?]+$/)
await expect(page.getByRole('heading', { name: activityTitle })).toBeVisible({
await expect(campaignPageChrome(page, activityTitle)).toBeVisible({
timeout: 15_000,
})
await expect(page.getByText('Obrigação política', { exact: true })).toBeVisible()

View file

@ -52,7 +52,7 @@ test.describe('Municípios — jornadas por papel', () => {
).toBeVisible()
await page.goto(`${campaign.baseURL}/campanha/municipios/${municipality.slug}`)
await expect(page.getByRole('heading', { name: municipality.name })).toBeVisible()
await expect(campaignPageChrome(page, municipality.name)).toBeVisible()
await page.goto(`${campaign.baseURL}/campanha/municipios/${municipality.slug}/editar`)
await page.getByLabel(`${advisor.name} `, { exact: false }).check()
@ -360,7 +360,7 @@ test.describe('Municípios — jornadas por papel', () => {
await page.getByLabel('Município').selectOption({ label: municipality.name })
await page.getByLabel('Detalhe a necessidade').fill('Precisamos para a caminhada de sábado.')
await page.getByRole('button', { name: 'Abrir demanda' }).click()
await expect(page.getByRole('heading', { name: demandTitle })).toBeVisible()
await expect(campaignPageChrome(page, demandTitle)).toBeVisible()
await expect(page.getByRole('button', { name: 'Aprovar' })).toBeVisible()
await page.goto(`${campaign.baseURL}/campanha/demandas`)
@ -422,7 +422,7 @@ test.describe('Municípios — cards no celular (B42)', () => {
// overlay receives it (as a user's finger would), and the card navigates.
await card.getByText('Tendência', { exact: true }).click({ force: true })
await expect(page).toHaveURL(`${campaign.baseURL}/campanha/municipios/${municipality.slug}`)
await expect(page.getByRole('heading', { name: municipality.name })).toBeVisible()
await expect(campaignPageChrome(page, municipality.name)).toBeVisible()
})
})

View file

@ -1,4 +1,4 @@
import { expect, test } from './fixtures/campaignE2EFixtures.js'
import { campaignPageChrome, expect, test } from './fixtures/campaignE2EFixtures.js'
/**
* B8 F2 — Salvador used to be one polygon carrying the whole city's votes, so
@ -51,5 +51,5 @@ test('the dashboard map paints Salvador zone by zone and opens one', async ({ ca
await readout.getByRole('link', { name: 'Abrir município' }).click()
// B145: entity identity lives in the shell header, not a body h1.
await expect(page).toHaveURL(/\/campanha\/municipios\/salvador-ze-\d+$/)
await expect(page.locator('[data-slot="campaign-page-chrome-title"]')).toBeVisible()
await expect(campaignPageChrome(page, /Salvador — ZE \d+/)).toBeVisible()
})

View file

@ -561,11 +561,11 @@ export const test = base.extend<CampaignE2ETestFixtures>({
},
})
export const campaignPageChrome = (page: Page, title: string) =>
export const campaignPageChrome = (page: Page, title: string | RegExp) =>
page
.locator('[data-slot="campaign-page-chrome"]')
.filter({ visible: true })
.locator('[data-slot="campaign-page-chrome-title"]')
.getByText(title, { exact: true })
.getByText(title, typeof title === 'string' ? { exact: true } : undefined)
export { expect }