test(e2e): stabilize municipality campaign journeys

This commit is contained in:
Francisco Ignácio Fontoura Solla 2026-08-06 19:00:13 -03:00
parent 48623b0d06
commit 9c99469c36
3 changed files with 19 additions and 2 deletions

View file

@ -191,7 +191,9 @@ test.describe('Wizard — busca município (B60)', () => {
await search.fill(municipality.name)
const results = page.getByRole('region', { name: WIZARD_MUNICIPALITY_STEP_TITLE })
const hit = results.locator(`a[href*="municipio=${municipality.slug}"]`)
const hit = results.locator(
`a[href="/campanha/acoes/atualizar-votos?municipio=${municipality.slug}"]`,
)
await expect(hit).toBeVisible({ timeout: 15000 })
await hit.click()

View file

@ -29,8 +29,12 @@ const showAllMunicipalityColumns = (page: Page, url: string) =>
const municipalityContainer = (page: Page) =>
page.locator('[data-container="municipality-list"]').last()
const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const visibleMunicipalityButton = (page: Page, name: string) =>
municipalityContainer(page).getByRole('button', { name }).filter({ visible: true })
municipalityContainer(page)
.getByRole('button', { name: new RegExp(`^${escapeRegExp(name)}(?: —|$)`) })
.filter({ visible: true })
const ensureWideMunicipalityList = async (page: Page) => {
// The resizable panel hydrates independently from the RSC list and can

View file

@ -19,6 +19,7 @@ type OwnedCollection =
| 'campaignUser'
| 'organization'
| 'contact'
| 'stateDeputy'
| 'leadership'
| 'votePledge'
| 'campaignDemand'
@ -39,6 +40,7 @@ const deletionOrder: OwnedCollection[] = [
'leadership',
'supporter',
'organization',
'stateDeputy',
'contact',
'campaignUser',
'consent',
@ -276,6 +278,15 @@ class CampaignE2EOwnership {
const userIDs = this.ids('campaignUser')
const contactIDs = this.ids('contact')
const stateDeputies = contactIDs.length
? await this.rootPayload.find({
collection: 'stateDeputy',
where: { contact: { in: contactIDs } },
depth: 0,
pagination: false,
})
: { docs: [] }
for (const stateDeputy of stateDeputies.docs) this.own('stateDeputy', stateDeputy.id)
const leaderships = await this.rootPayload.find({
collection: 'leadership',
where: {