From 419b294f3cc10ea9b2ce1714109d66ea2a256136 Mon Sep 17 00:00:00 2001 From: Bob Qiu Date: Tue, 3 Nov 2026 18:04:27 +0800 Subject: [PATCH] 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 " not found: ". 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 --- packages/insomnia-test/pages/workspace.page.ts | 10 ++++++++-- .../delete-via-shortcut-and-context-menu.spec.ts | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/insomnia-test/pages/workspace.page.ts b/packages/insomnia-test/pages/workspace.page.ts index e81c6ca299..40b7242c86 100644 --- a/packages/insomnia-test/pages/workspace.page.ts +++ b/packages/insomnia-test/pages/workspace.page.ts @@ -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 ` not found: ` 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 { - return this.page + async getResourceNotFoundToastTexts(ignoreResourceIds: string[] = []): Promise { + 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}`))); } /** diff --git a/packages/insomnia-test/tests/workspace/delete-via-shortcut-and-context-menu.spec.ts b/packages/insomnia-test/tests/workspace/delete-via-shortcut-and-context-menu.spec.ts index 21ed8f68cc..4418073008 100644 --- a/packages/insomnia-test/tests/workspace/delete-via-shortcut-and-context-menu.spec.ts +++ b/packages/insomnia-test/tests/workspace/delete-via-shortcut-and-context-menu.spec.ts @@ -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 " not found: " 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([]); });