Skip to content

fix: prevent flake in environment-editor JSON input#9956

Open
jackkav wants to merge 2 commits into
developfrom
fix/environment-editor-kv-json-flake
Open

fix: prevent flake in environment-editor JSON input#9956
jackkav wants to merge 2 commits into
developfrom
fix/environment-editor-kv-json-flake

Conversation

@jackkav
Copy link
Copy Markdown
Contributor

@jackkav jackkav commented May 26, 2026

Summary

  • Fixes a pre-existing flaky test in environment-editor-interactions.test.ts — "manage environment"
  • The original flake was partly caused by bodyEditor.fill() bypassing CodeMirror's key event handlers; replacing it with ControlOrMeta+a + page.keyboard.type() makes the JSON edit path behave like a real user edit
  • The remaining flake was a broader persistence race: environment edits are debounced and saved asynchronously, so the test could close the modal before those updates had finished settling
  • This change adds an explicit save-complete signal to the manage-environments modal and updates the smoke test to wait for that signal before closing

Rationale

  • We considered splitting or removing the test, but that would either increase CI time materially or reduce coverage on a valuable end-to-end environment-editing flow
  • We also wanted to avoid layering on more timing-based waits, because they can reduce the flake rate without eliminating the race
  • Exposing a real save-state signal gives the app and the test a deterministic synchronization point tied to the actual async work, which is a safer long-term fix than relying on editor timing or modal transition timing alone
  • Disabling close while a save is pending also improves product behavior, not just the test, because users can no longer dismiss the modal while environment mutations are still in flight

Test plan

  • Confirm the "manage environment" smoke test passes consistently in CI (shard 2/6)
  • No other environment editor tests affected

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 26, 2026 08:03
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

This PR stabilizes the “manage environment” Playwright smoke test by changing how JSON is entered into the Environment Editor’s CodeMirror-based JSON modal, avoiding fill() (which can bypass CodeMirror’s key handling and lead to incorrect saved content).

Changes:

  • Replace cursor movement + locator.fill() with “select all” + page.keyboard.type() to ensure CodeMirror processes the input via key events.
  • Ensure the full JSON object (including braces) is typed into the JSON editor modal.

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

✅ Circular References Report

Generated at: 2026-05-28T04:31:32.737Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 18 18 0 (0.00%)
Click to view all circular references in PR (18)
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/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 (18)
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/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 enabled auto-merge (squash) May 26, 2026 09:03
@jackkav jackkav requested a review from a team May 26, 2026 09:03
@jackkav jackkav force-pushed the fix/environment-editor-kv-json-flake branch from 1452e1b to 0b833e8 Compare May 26, 2026 11:35
Copy link
Copy Markdown
Contributor

@fiosman fiosman left a comment

Choose a reason for hiding this comment

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

https://github.com/Kong/insomnia/actions/runs/26440164941/job/77887439182 on the latest CI run it appears that this e2e test is still failing

@jackkav jackkav disabled auto-merge May 26, 2026 16:14
@jackkav
Copy link
Copy Markdown
Contributor Author

jackkav commented May 27, 2026

@fiosman I ran it 20 times before this change and it failed 5 times, I ran it 40 times after this change and it failed once.

jackkav and others added 2 commits May 28, 2026 06:26
….type instead of fill

.fill() bypasses CodeMirror's key event handlers, causing the JSON to be
saved incorrectly when cursor position isn't exactly right. Select-all +
keyboard.type() writes the complete valid JSON via key events that
CodeMirror processes correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jackkav jackkav force-pushed the fix/environment-editor-kv-json-flake branch from 0b833e8 to d315067 Compare May 28, 2026 04:26
@jackkav jackkav requested a review from cwangsmv May 28, 2026 04:28
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