test: deflake indexed e2e (#11911)
### What? This PR aims to deflake the indexed fields e2e test in `test/fields/collections/Indexed/e2e.spec.ts`. The issue is that this test is setup in a way where sometimes two toasts will present themselves in the ui. The second toast assertion will fail with a strict mode violation as the toast locator will resolve to two elements. ### Why? To prevent this test from flaking in ci. ### How? Adding a new `dismissAfterAssertion` flag to the `assertToastErrors` helper function which dismisses the toasts. This way, the toasts will not raise the aforementioned error as they will be dismissed from the ui. The logic is handled in a separate loop through such that the assertions occur first. This is done so that dismissing a toast does not surface errors due to the order of toasts being shown changing.
This commit is contained in:
@@ -100,6 +100,7 @@ describe('Radio', () => {
|
|||||||
await assertToastErrors({
|
await assertToastErrors({
|
||||||
page,
|
page,
|
||||||
errors: ['uniqueText'],
|
errors: ['uniqueText'],
|
||||||
|
dismissAfterAssertion: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('create')
|
await expect.poll(() => page.url(), { timeout: POLL_TOPASS_TIMEOUT }).toContain('create')
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import { expect } from '@playwright/test'
|
|||||||
export async function assertToastErrors({
|
export async function assertToastErrors({
|
||||||
page,
|
page,
|
||||||
errors,
|
errors,
|
||||||
|
dismissAfterAssertion,
|
||||||
}: {
|
}: {
|
||||||
|
dismissAfterAssertion?: boolean
|
||||||
errors: string[]
|
errors: string[]
|
||||||
page: Page
|
page: Page
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
@@ -24,4 +26,13 @@ export async function assertToastErrors({
|
|||||||
).toHaveText(error)
|
).toHaveText(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dismissAfterAssertion) {
|
||||||
|
const closeButtons = page.locator('.payload-toast-container button.payload-toast-close-button')
|
||||||
|
const count = await closeButtons.count()
|
||||||
|
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
await closeButtons.nth(i).click()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user