Skip to content

test(webview): wait for the new default where it is read - #151

Merged
BartvHelvert merged 1 commit into
masterfrom
test/custom-editor-default-applied
Nov 11, 2026
Merged

BartvHelvert merged 1 commit into
masterfrom
test/custom-editor-default-applied

Conversation

@BartvHelvert

@BartvHelvert BartvHelvert commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Closes #141, which #142 narrowed but did not close — see the
reopening comment
for the full timelines.

SplitModeCustomEditorTest > the editor switcher … sets the default waits for the association to
reach the user's settings file, then closes and reopens the file:

awaitProbeValue("the default editor association saved", { userSettings.readText() }) { … }
awaitProbeValue("the custom editor still shown", { pageShowing() }) { it }
driver.invokeAction("CloseContent", …)
open(name)

CustomEditorDefaults.setDefault writes that file first and calls apply() afterwards, so the
wait returns at the earliest moment in the whole operation — before anything has been applied
anywhere. In both recorded failures the backend's own File types changed arrived after the
reopen (402 ms after in
42692783765, 672 ms after
in 42520388173), so
setDefaultEditor had not returned either time and the client was still holding the old
association when it decided which editor to show.

The test now waits for the client to hold the new association, which is what the reopen actually
depends on: CodeBridgeCustomEditors.defaultTypeOf reads setup.associations, and that is what
decides whether a newly opened file is swapped into the custom editor. 306e178 made the client
take the association as soon as the backend has, so this is the first moment at which the reopen
can be relied on at all.

defaultForTest is a test-only accessor, in keeping with the …ForTest members elsewhere in the
runtime; the client's associations are not worth exposing more widely. The UI test reaches it the
way the other tests reach internal services, with a @Remote on the module that owns it.

Nothing about the product's behaviour changes.

Why not wait on the file type instead

CustomEditorFileTypeOverrider only overrides a file whose own type is INativeFileType.
example.probetext is a text file, so it never gets a CodeBridge.CustomEditor.* type — the
custom editor is put in front of it by the client, not by the backend's typing. Reading the file
type would therefore have observed nothing for this scenario.

How it was tested

  • :webview.frontend:compileKotlin and :ui-test:compileTestKotlin pass.
  • The scenario was not run locally: this machine cannot execute the downloaded JBR
    (exit value 127 under NixOS), and the failure has only been seen on Windows CI. It has
    reproduced twice there, most recently on ci-flake/escape-04.

Checklist

  • Nothing is special-cased for one extension.
  • A new feature has a UI test. A fix to an existing UI test, plus the accessor it reads.
  • No internal, override-only, obsolete or deprecated platform API.
  • docs/ is updated where behaviour changed, docs/status.md especially. No behaviour change.
  • Third-party material keeps its notice and is listed in NOTICE.md. None added.

The switcher test waited for the association to reach the user's
settings file before closing and reopening the file. *Set Default*
writes that file first and applies it afterwards, so the wait returns
at the earliest possible moment: in both recorded failures the
backend's own file-type change landed 402ms and 672ms after the test
had already reopened the file, and the client, which decides from its
own copy of the setup, was still holding the old association.

Wait for the client to be holding the new one instead, which is what
the reopen depends on. 306e178 gave it that as soon as the backend
takes the change, so this is the first moment the reopen can be relied
on. The accessor is test-only: the client's associations are not worth
exposing otherwise.

Refs #141
@BartvHelvert
BartvHelvert merged commit 673486b into master Nov 11, 2026
8 checks passed
@BartvHelvert
BartvHelvert deleted the test/custom-editor-default-applied branch November 11, 2026 21:33
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.

Set Default is not applied to files opened right after it, until the backend's setup arrives

1 participant