mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-14 08:53:11 +00:00
Move page title/subtitle to CampaignMobileTopBar, CampaignDesktopHeader, and tab metadata (Solla - Campanha - %s). Strip section headers and scope chips from list/create routes; detail pages keep entity h1. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
70 lines
3.1 KiB
TypeScript
70 lines
3.1 KiB
TypeScript
import { campaignConceptHref } from '../../src/lib/campaignIntelligenceConcepts.js'
|
|
import { campaignPageChrome, expect, test } from './fixtures/campaignE2EFixtures.js'
|
|
|
|
/**
|
|
* E18 — `/campanha/conceitos` documents staff-only numbers (estimates, goals,
|
|
* field ceiling), so the route gate and the "Saiba mais" path out of the
|
|
* "Conta da cadeira" card are what these tests protect.
|
|
*/
|
|
test.describe('Conceitos de inteligência', () => {
|
|
test('staff reads the concepts page and reaches it from the goal-account card', async ({
|
|
campaign,
|
|
page,
|
|
}) => {
|
|
const { fixtures } = campaign
|
|
const coordinator = await fixtures.createCampaignUser('coordinator', {
|
|
name: fixtures.value('Coordenadora Conceitos'),
|
|
})
|
|
const password = coordinator.password
|
|
const email = coordinator.email!
|
|
const municipality = await fixtures.claimMunicipality()
|
|
|
|
await campaign.login(page, email, password)
|
|
|
|
// Always-visible way in, at the foot of the sidebar.
|
|
await page.getByRole('link', { name: 'Conceitos', exact: true }).click()
|
|
await expect(page).toHaveURL(/\/campanha\/conceitos$/)
|
|
|
|
await page.goto(`/campanha/municipios/${municipality.slug}`)
|
|
const goalAccount = page.getByRole('region', { name: 'Conta da cadeira' })
|
|
await expect(goalAccount).toBeVisible()
|
|
|
|
// Per-metric tooltips carry a deep link to the matching anchor.
|
|
await goalAccount.getByRole('button', { name: /Captura \(2022\): mais informações/ }).hover()
|
|
// Radix mirrors tooltip content for screen readers, so the link renders twice.
|
|
await expect(page.getByRole('link', { name: 'Saiba mais' }).first()).toHaveAttribute(
|
|
'href',
|
|
campaignConceptHref('captura'),
|
|
)
|
|
// The card-level Popover is the keyboard-reachable path (tooltip content is not tabbable).
|
|
await goalAccount.getByRole('button', { name: 'Sobre a conta da cadeira' }).click()
|
|
await page.getByRole('link', { name: 'Como cada número é calculado' }).click()
|
|
|
|
await expect(page).toHaveURL(/\/campanha\/conceitos$/)
|
|
await expect(campaignPageChrome(page, 'Conceitos de inteligência')).toBeVisible()
|
|
await expect(page.getByRole('heading', { name: 'Cobertura da meta' })).toBeVisible()
|
|
await expect(page.getByRole('heading', { name: 'Teto do campo (projetado)' })).toBeVisible()
|
|
|
|
// Deep link lands on the documented concept, not just on the page.
|
|
await page.goto(campaignConceptHref('captura'))
|
|
await expect(page.locator('article:target')).toHaveAttribute('id', 'captura')
|
|
})
|
|
|
|
test('leader cannot open the concepts page', async ({ campaign, page }) => {
|
|
const { fixtures } = campaign
|
|
const phone = fixtures.phone()
|
|
const leader = await fixtures.createCampaignUser('leader', {
|
|
name: fixtures.value('Liderança Conceitos'),
|
|
username: phone,
|
|
})
|
|
const password = leader.password
|
|
|
|
await campaign.login(page, phone, password)
|
|
await expect(page.getByRole('link', { name: 'Conceitos', exact: true })).toHaveCount(0)
|
|
|
|
await page.goto('/campanha/conceitos')
|
|
|
|
await expect(page).toHaveURL(/\/campanha\/contatos\/?$/)
|
|
await expect(campaignPageChrome(page, 'Conceitos de inteligência')).toHaveCount(0)
|
|
})
|
|
})
|