fix(insomnia-test): ignore a deleted resource's own not-found toast in delete spec

While a delete action settles, the deleted request/folder/collection's own
route loader can re-run before the tab close navigates away, briefly showing
"<Kind> not found: <id>". Users don't notice it, but the spec's one-shot
toast snapshot failed on slow CI runners. Skip toasts naming the resources
the test deleted; any other resource-not-found toast still fails the spec.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Bob QiuandClaude Sonnet 5.5 committed 2026-11-03 18:04:27 +08:00
1 parent c54fcb15cc
commit 419b294f3c
2 files changed
+22 -3

No files matched your search

@@ -1324,9 +1324,14 @@ export class WorkspacePage extends BasePage {
/**
* Reads the titles of any visible "resource not found" toasts, so a failing
* assertion names the route that raised it.
*
* `ignoreResourceIds` skips the `<Kind> not found: <id>` toast for
* resources the test itself just deleted: while the delete action settles,
* the deleted resource's own route loader can briefly re-run before the tab
* close navigates away, which users do not notice.
*/
async getResourceNotFoundToastTexts(): Promise<string[]> {
return this.page
async getResourceNotFoundToastTexts(ignoreResourceIds: string[] = []): Promise<string[]> {
const texts = await this.page
.getByTestId("toast-body")
.filter({
has: this.page
@@ -1337,6 +1342,7 @@ export class WorkspacePage extends BasePage {
}),
})
.allInnerTexts();
return texts.filter((text) => !ignoreResourceIds.some((id) => text.includes(`not found: ${id}`)));
}
/**
@@ -90,5 +90,18 @@ test("Verify Deleting a Request, Folder and Collection With Open Tabs via the De
{ timeout: DEFAULT_TIMEOUT },
)
.toEqual([false, false, false, false]);
expect(await workspacePage.getResourceNotFoundToastTexts()).toEqual([]);
// A deleted resource's own "<Kind> not found: <id>" toast is a benign, timing
// dependent blip; any other resource-not-found toast is a real regression.
const deletedResourceIds = [
shortcutRequest,
menuRequest,
shortcutCollectionRequest,
menuCollectionRequest,
shortcutFolder,
menuFolder,
shortcutCollection,
menuCollection,
].flatMap((resource) => (resource.id ? [resource.id] : []));
expect(deletedResourceIds).toHaveLength(8);
expect(await workspacePage.getResourceNotFoundToastTexts(deletedResourceIds)).toEqual([]);
});