From 9c99469c369f635256931917175168b33c94e57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Thu, 6 Aug 2026 19:00:13 -0300 Subject: [PATCH] test(e2e): stabilize municipality campaign journeys --- tests/e2e/campaignHomeActions.e2e.spec.ts | 4 +++- tests/e2e/campaignMunicipalities.e2e.spec.ts | 6 +++++- tests/e2e/fixtures/campaignE2EFixtures.ts | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/e2e/campaignHomeActions.e2e.spec.ts b/tests/e2e/campaignHomeActions.e2e.spec.ts index c2605f80..0a4fa896 100644 --- a/tests/e2e/campaignHomeActions.e2e.spec.ts +++ b/tests/e2e/campaignHomeActions.e2e.spec.ts @@ -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() diff --git a/tests/e2e/campaignMunicipalities.e2e.spec.ts b/tests/e2e/campaignMunicipalities.e2e.spec.ts index 5caa9d38..f59ea26c 100644 --- a/tests/e2e/campaignMunicipalities.e2e.spec.ts +++ b/tests/e2e/campaignMunicipalities.e2e.spec.ts @@ -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 diff --git a/tests/e2e/fixtures/campaignE2EFixtures.ts b/tests/e2e/fixtures/campaignE2EFixtures.ts index 5ca937a3..372e8616 100644 --- a/tests/e2e/fixtures/campaignE2EFixtures.ts +++ b/tests/e2e/fixtures/campaignE2EFixtures.ts @@ -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: {