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([]); });