From 2cd1e7cfd785d70670d7f87f75f478f2273a3ba4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 1 Aug 2026 04:48:26 +0000 Subject: [PATCH] fix(test): retry municipality allocation until word-start queries are distinct --- tests/int/homeSearchMunicipalities.int.spec.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/int/homeSearchMunicipalities.int.spec.ts b/tests/int/homeSearchMunicipalities.int.spec.ts index cbbbb447..898318de 100644 --- a/tests/int/homeSearchMunicipalities.int.spec.ts +++ b/tests/int/homeSearchMunicipalities.int.spec.ts @@ -48,8 +48,20 @@ describe('searchHomeMunicipalities (B48)', () => { const advisor = await fixtures.createCampaignUser('advisor') const coordinator = await fixtures.createCampaignUser('coordinator') - const administered = await fixtures.getMunicipality() - const other = await fixtures.getMunicipality() + let administered = await fixtures.getMunicipality() + let other = await fixtures.getMunicipality() + for (let attempt = 0; attempt < 30; attempt++) { + try { + distinctWordStartQuery(other.name, administered.name) + distinctWordStartQuery(administered.name, other.name) + break + } catch { + other = await fixtures.getMunicipality() + } + if (attempt === 29) { + throw new Error('could not allocate two municipalities with distinct word-start queries') + } + } await fixtures.assignMunicipalityAdvisors(administered.id, [advisor.id]) const otherQuery = distinctWordStartQuery(other.name, administered.name)