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:
@@ -5,7 +5,9 @@ import { expect } from '@playwright/test'
|
||||
export async function assertToastErrors({
|
||||
page,
|
||||
errors,
|
||||
dismissAfterAssertion,
|
||||
}: {
|
||||
dismissAfterAssertion?: boolean
|
||||
errors: string[]
|
||||
page: Page
|
||||
}): Promise<void> {
|
||||
@@ -24,4 +26,13 @@ export async function assertToastErrors({
|
||||
).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