fix(test): retry municipality allocation until word-start queries are distinct

This commit is contained in:
Cursor Agent 2026-08-01 04:48:26 +00:00
parent 9ab0dbd153
commit 2cd1e7cfd7
No known key found for this signature in database

View file

@ -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)