From 7de40fe4a7bb9add31dbee8e01dd4347ff6920b5 Mon Sep 17 00:00:00 2001 From: Bingbing Date: Mon, 28 Sep 2026 15:16:13 +0800 Subject: [PATCH] fix: de-flake import deep-link cURL auto-scan smoke test (#10555) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Background The `value-bearing curl param` smoke test failed intermittently on CI (run 35832135624, shard 3/6, both retries) while passing on isolated reruns and in dev mode. Repro: `npm run test:smoke:build -- --project=Smoke --grep "value-bearing curl param" --repeat-each=20 --workers=4` → ~25% first-attempt failure rate. ## Root cause A value-bearing deep link auto-scans, and the scan result replaces the pre-scan form within milliseconds of the modal opening. The assertion `getByText('http://insomnia.rest/')` could only match the transient pre-scan state — the raw cURL in the textarea's initial text content — so the test raced against scan completion and lost whenever the scan landed before the first assertion poll (fast in build mode on CI). The stable post-scan state never contained the URL text at all: the scan-results table renders `{importerSign} resources to be imported from {oriFileName}:`, and the cURL scan source sets no `oriFileName`, producing the dangling-colon label "cURL resources to be imported from :". ## Changes - `import-modal/shared.tsx` — omit the `from {oriFileName}` clause when a scan result has no source name (cURL deep-link scan). Sources with a real name (uri, file, clipboard, mcp) keep the existing wording. - `import-deep-link.test.ts` — assert the stable post-scan state ("cURL resources to be imported:" and "1 Request") instead of the transient pre-scan form; renamed the test accordingly. ## Verification - Fixed test: 20/20 passed under the same build-mode + parallel-load conditions that produced 5/20 flaky before the fix. - `import deep links` suite: 3/3 passed in build mode. --- .../tests/smoke/import-deep-link.test.ts | 10 +++++++--- .../src/ui/components/modals/import-modal/shared.tsx | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/insomnia-smoke-test/tests/smoke/import-deep-link.test.ts b/packages/insomnia-smoke-test/tests/smoke/import-deep-link.test.ts index dd56a6c4f9..cd5812cf73 100644 --- a/packages/insomnia-smoke-test/tests/smoke/import-deep-link.test.ts +++ b/packages/insomnia-smoke-test/tests/smoke/import-deep-link.test.ts @@ -49,13 +49,17 @@ test.describe('import deep links', () => { await expect.soft(insomnia.page.getByText('Invalid cURL request')).toHaveCount(0); }); - test('value-bearing curl param pre-populates the cURL tab', async ({ app, insomnia }) => { + test('value-bearing curl param auto-scans and shows the detected request', async ({ app, insomnia }) => { const curlCommand = 'curl --request GET --url http://insomnia.rest/'; await sendDeepLink(app, `insomnia://app/import?curl=${encodeURIComponent(curlCommand)}`); await expect.soft(insomnia.page.getByRole('dialog')).toBeVisible(); // A value-bearing param auto-scans: the modal skips the source picker and - // shows the detected resources ready to import. - await expect.soft(insomnia.page.getByText('http://insomnia.rest/')).toBeVisible(); + // shows the detected resources ready to import. The scan completes within + // milliseconds of the modal opening, so assert on the stable post-scan + // state — the pre-scan form (whose textarea value contains the URL) is + // replaced as soon as the scan result lands. + await expect.soft(insomnia.page.getByText('cURL resources to be imported:')).toBeVisible(); + await expect.soft(insomnia.page.getByText('1 Request')).toBeVisible(); }); }); diff --git a/packages/insomnia/src/ui/components/modals/import-modal/shared.tsx b/packages/insomnia/src/ui/components/modals/import-modal/shared.tsx index ab51edc228..4feb87c38b 100644 --- a/packages/insomnia/src/ui/components/modals/import-modal/shared.tsx +++ b/packages/insomnia/src/ui/components/modals/import-modal/shared.tsx @@ -230,7 +230,7 @@ export const ScanResultsTable = ({ scanResults }: { scanResults: ScanResult[] }) ) : ( - {getImporterSign(scanResult)} resources to be imported from {scanResult.oriFileName}: + {getImporterSign(scanResult)} resources to be imported{scanResult.oriFileName ? ` from ${scanResult.oriFileName}` : ''}: )}