fix(test): retry municipality allocation until word-start queries are distinct
This commit is contained in:
parent
9ab0dbd153
commit
2cd1e7cfd7
1 changed files with 14 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue