Skip to content

fix: prevent race condition in environment-editor smoke test#9944

Merged
jackkav merged 4 commits into
developfrom
fix/environment-editor-flaky-test
May 26, 2026
Merged

fix: prevent race condition in environment-editor smoke test#9944
jackkav merged 4 commits into
developfrom
fix/environment-editor-flaky-test

Conversation

@jackkav
Copy link
Copy Markdown
Contributor

@jackkav jackkav commented May 21, 2026

Summary

  • Replaces all click({ delay: 200 }) timing workarounds with deterministic Playwright waits:
    • After Add Row: wait for the new row to be visible instead of a blind delay
    • After Modal Submit (JSON value editor): wait for role="dialog" name="Modal" to be hidden
    • After Close (environment editor): wait for the Manage Environments heading to be hidden
    • Clicking a different cell to move focus already triggers the OneLineEditor's 100ms debounce flush — no delay needed there
  • Adds a second test case: disabled environment variable falls back to base environment — verifies that disabling a KV pair in a sub-environment causes the request to use the base environment's value instead

The original failure was TimeoutError: waiting for getByText('kvstring') at line 127 (now line 130). The root cause was click({ delay: 200 }) on the Close button after Modal Submit — delay adds time between mousedown and mouseup, not after the click, so it coincidentally works but is fragile. Waiting for the dialog to disappear is unambiguous and CI-safe.

Test plan

  • npm run test:smoke:dev -- environment-editor-interactions passes locally

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 21, 2026 13:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Stabilizes the environment-editor-interactions Playwright smoke test by adding an extra synchronization point after JSON modal submission, reducing flakiness when the environment editor is closed before UI state has settled.

Changes:

  • Adds a { delay: 200 } to the “Close” button click after submitting the JSON modal.
  • Adds an explicit expect(...).toBeVisible() for kvstring before attempting to click it, improving failure clarity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

ghost commented May 21, 2026

✅ Circular References Report

Generated at: 2026-05-26T05:45:51.651Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 19 19 0 (0.00%)
Click to view all circular references in PR (19)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts -> insomnia/src/scripting/require-interceptor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/concurrency.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/network/network.ts -> insomnia/src/main/network/get-auth-header.ts -> insomnia/src/main/network/o-auth-2/get-token.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/base-extension-worker.ts -> insomnia/src/templating/worker.ts
insomnia/src/templating/index.ts -> insomnia/src/templating/base-extension.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/templating/types.ts -> insomnia/src/templating/utils.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (19)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts -> insomnia/src/scripting/require-interceptor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/concurrency.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/network/network.ts -> insomnia/src/main/network/get-auth-header.ts -> insomnia/src/main/network/o-auth-2/get-token.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/base-extension-worker.ts -> insomnia/src/templating/worker.ts
insomnia/src/templating/index.ts -> insomnia/src/templating/base-extension.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/templating/types.ts -> insomnia/src/templating/utils.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

@jackkav jackkav requested a review from a team May 21, 2026 17:19
@jackkav jackkav enabled auto-merge (squash) May 26, 2026 05:41
jackkav and others added 4 commits May 26, 2026 06:41
After the JSON modal submit, the KV table state update is async.
Add delay: 200 to the subsequent Close click (matching every other
post-edit action in the test) so the debounce has time to settle
before the dialog closes.

Also add an explicit toBeVisible() assertion before clicking 'kvstring'
in the console, which gives a clearer failure message if it recurs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nt rule

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…variable test

Replace all `click({ delay: 200 })` workarounds with observable Playwright
waits: wait for new rows to be visible after Add Row, wait for the JSON
modal to be hidden after Modal Submit, and wait for the Manage Environments
heading to be hidden after Close. Clicking different cells to move focus
already triggers the OneLineEditor debounce without needing an artificial
delay.

Add a new test case that verifies a disabled KV pair falls back to the base
environment value in the sent request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ce loss

OneLineEditor now calls onChange immediately on blur so KV row values
are not lost when focus moves away before the 100ms debounce fires.

CodePromptModal now reads the current CodeEditor value and calls
onChange explicitly when Submit is clicked, so the JSON value is always
saved regardless of debounce state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jackkav jackkav force-pushed the fix/environment-editor-flaky-test branch from e428668 to 7c1ea01 Compare May 26, 2026 05:41
@jackkav jackkav merged commit 15a0d50 into develop May 26, 2026
21 checks passed
@jackkav jackkav deleted the fix/environment-editor-flaky-test branch May 26, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants