mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-15 18:53:06 +00:00
Emends B47 so focusing the input clears strip/summary before typing; hardens hit rows against blur-before-click.
224 lines
8.6 KiB
TypeScript
224 lines
8.6 KiB
TypeScript
import { WIZARD_MUNICIPALITY_STEP_TITLE } from '../../src/lib/campaignWizardCopy.js'
|
|
import { expect, test } from './fixtures/campaignE2EFixtures.js'
|
|
|
|
const staffActionLabels = [
|
|
'Ajustar votos',
|
|
'Registrar sinal',
|
|
'Mudar tendência',
|
|
'Atualizar liderança',
|
|
'Registrar pedido',
|
|
'Ver esquecidos',
|
|
] as const
|
|
|
|
test.describe('Início — busca global (B47)', () => {
|
|
test('staff sees campaign search on home', async ({ campaign, page }) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
await expect(page.getByLabel('Buscar na campanha')).toBeVisible()
|
|
})
|
|
|
|
test('leader does not see campaign search on home', async ({ campaign, page }) => {
|
|
const { fixtures } = campaign
|
|
const leader = await fixtures.createCampaignUser('leader', {
|
|
name: fixtures.value('Liderança'),
|
|
})
|
|
|
|
await campaign.login(page, leader.email!, leader.password)
|
|
await expect(page.getByLabel('Buscar na campanha')).toHaveCount(0)
|
|
})
|
|
|
|
test('staff focused search hides action strip on input focus (B66)', async ({
|
|
campaign,
|
|
page,
|
|
}) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
const actionsSlot = page.locator('[data-slot="home-actions"]')
|
|
await expect(actionsSlot).toBeVisible()
|
|
await expect(page.getByLabel('Ações rápidas')).toBeVisible()
|
|
|
|
await page.getByLabel('Buscar na campanha').focus()
|
|
await expect(actionsSlot).toBeHidden({ timeout: 5000 })
|
|
|
|
await page.getByLabel('Buscar na campanha').blur()
|
|
await expect(actionsSlot).toBeVisible({ timeout: 5000 })
|
|
})
|
|
|
|
test('staff typing in search keeps action strip hidden after debounce', async ({
|
|
campaign,
|
|
page,
|
|
}) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
const actionsSlot = page.locator('[data-slot="home-actions"]')
|
|
await expect(actionsSlot).toBeVisible()
|
|
|
|
await page.getByLabel('Buscar na campanha').fill('ca')
|
|
await expect(actionsSlot).toBeHidden({ timeout: 5000 })
|
|
|
|
await page.getByLabel('Buscar na campanha').fill('')
|
|
await expect(actionsSlot).toBeVisible({ timeout: 5000 })
|
|
})
|
|
|
|
test('staff search shows municipality hits and opens detail (B48)', async ({
|
|
campaign,
|
|
page,
|
|
}) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
const search = page.getByLabel('Buscar na campanha')
|
|
await search.fill('Cairu')
|
|
|
|
const group = page.getByRole('region', { name: 'Resultados da busca' })
|
|
await expect(group.getByRole('heading', { name: 'Municípios' })).toBeVisible({
|
|
timeout: 15000,
|
|
})
|
|
await group.getByRole('link', { name: /Cairu/i }).click()
|
|
await page.waitForURL(/\/campanha\/municipios\/cairu/)
|
|
})
|
|
})
|
|
|
|
test.describe('Início — catálogo de ações (B45)', () => {
|
|
test('staff sees six home actions and can open municipalities without coverage', async ({
|
|
campaign,
|
|
page,
|
|
}) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
await expect(page.getByLabel('Ações rápidas')).toBeVisible()
|
|
|
|
for (const label of staffActionLabels) {
|
|
const link = page.getByRole('link', { name: label, exact: true })
|
|
const button = page.getByRole('button', { name: label, exact: true })
|
|
await expect(link.or(button)).toBeVisible()
|
|
}
|
|
|
|
await page.getByRole('link', { name: 'Ajustar votos', exact: true }).click()
|
|
await page.waitForURL(/\/campanha\/acoes\/atualizar-votos/)
|
|
await expect(page.getByRole('heading', { name: WIZARD_MUNICIPALITY_STEP_TITLE })).toBeVisible()
|
|
|
|
await page.goto('/campanha')
|
|
await page.getByRole('link', { name: 'Ver esquecidos', exact: true }).click()
|
|
await page.waitForURL(/\/campanha\/municipios/)
|
|
const url = new URL(page.url())
|
|
expect(url.searchParams.get('coverage')).toBe('sem_assessor')
|
|
expect(url.searchParams.get('sort')).toBe('votos')
|
|
})
|
|
|
|
test('leader sees two home actions and can open contacts', async ({ campaign, page }) => {
|
|
const { fixtures } = campaign
|
|
const leader = await fixtures.createCampaignUser('leader', {
|
|
name: fixtures.value('Liderança'),
|
|
})
|
|
|
|
await campaign.login(page, leader.email!, leader.password)
|
|
await expect(page.getByLabel('Ações rápidas')).toBeVisible()
|
|
|
|
await expect(
|
|
page.getByRole('button', { name: 'Cadastrar apoiador', exact: true }),
|
|
).toBeVisible()
|
|
await expect(page.getByRole('link', { name: 'Ver meus contatos', exact: true })).toBeVisible()
|
|
|
|
await page.getByRole('link', { name: 'Ver meus contatos', exact: true }).click()
|
|
await page.waitForURL(/\/campanha\/contatos/)
|
|
await expect(page.getByRole('heading', { name: /Meus contatos/ })).toBeVisible()
|
|
})
|
|
})
|
|
|
|
test.describe('Wizard — busca município (B60)', () => {
|
|
test('selecting a municipality advances with ?municipio= and sticky caption', async ({
|
|
campaign,
|
|
page,
|
|
}) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
await page.goto('/campanha/acoes/atualizar-votos')
|
|
await expect(page.getByRole('heading', { name: WIZARD_MUNICIPALITY_STEP_TITLE })).toBeVisible()
|
|
|
|
const search = page.getByLabel('Buscar município')
|
|
await search.fill('Cairu')
|
|
|
|
const results = page.getByRole('region', { name: 'Resultados da busca' })
|
|
await expect(results.getByRole('button', { name: /Cairu/i })).toBeVisible({ timeout: 15000 })
|
|
await results.getByRole('button', { name: /Cairu/i }).click()
|
|
|
|
await page.waitForURL(/\/campanha\/acoes\/atualizar-votos\?municipio=cairu/)
|
|
await expect(page.getByLabel(/Município em atualização: Cairu/i)).toBeVisible()
|
|
await expect(page.getByRole('heading', { name: /Qual a nova estimativa média/i })).toBeVisible()
|
|
})
|
|
})
|
|
|
|
test.describe('Wizard — ajuste de votos (B61)', () => {
|
|
test('confirming média advances to pessimista step', async ({ campaign, page }) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
await page.goto('/campanha/acoes/atualizar-votos?municipio=cairu')
|
|
|
|
await expect(page.getByRole('heading', { name: /Qual a nova estimativa média/i })).toBeVisible({
|
|
timeout: 15000,
|
|
})
|
|
|
|
const input = page.getByLabel(/Média em Cairu/i)
|
|
await input.fill('500')
|
|
await page.getByRole('button', { name: 'Ajustar estimativa média →' }).click()
|
|
|
|
await page.waitForURL(/cenario=pessimistic/)
|
|
await expect(
|
|
page.getByRole('heading', { name: /Qual a nova estimativa pessimista/i }),
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('incoherent pessimista shows warning and return link', async ({ campaign, page }) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Geral'),
|
|
})
|
|
|
|
await campaign.login(page, coordinator.email!, coordinator.password)
|
|
await page.goto('/campanha/acoes/atualizar-votos?municipio=cairu')
|
|
|
|
await expect(page.getByRole('heading', { name: /Qual a nova estimativa média/i })).toBeVisible({
|
|
timeout: 15000,
|
|
})
|
|
|
|
await page.getByLabel(/Média em Cairu/i).fill('200')
|
|
await page.getByRole('button', { name: 'Ajustar estimativa média →' }).click()
|
|
await page.waitForURL(/cenario=pessimistic/)
|
|
|
|
await page.getByLabel(/Pessimista em Cairu/i).fill('900')
|
|
await page.getByRole('button', { name: 'Ajustar estimativa pessimista →' }).click()
|
|
|
|
await page.waitForURL(/cenario=central/)
|
|
const step = page.getByRole('main', { name: /Qual a nova estimativa média/i })
|
|
await expect(step.getByRole('alert')).toContainText(/Pessimista/i)
|
|
await expect(step.getByRole('button', { name: /Voltar para pessimista/i })).toBeVisible()
|
|
})
|
|
})
|