Skip to content

test: Convert some tests to Typescript - #10423

Open
gonfunko wants to merge 8 commits into
mainfrom
ts-tests
Open

test: Convert some tests to Typescript#10423
gonfunko wants to merge 8 commits into
mainfrom
ts-tests

Conversation

@gonfunko

Copy link
Copy Markdown
Contributor

The basics

The details

Proposed Changes

This PR converts several core test files and helpers to Typescript. Generally, this entails:

  • Renaming the files
  • Declaring locally scoped variables for workspaces or other objects created in setup() and updating tests to reference those rather than accessing them on this
  • Explicitly passing workspaces created in setup() to the teardown methods
  • Adding types to helper functions

A few tests were modified or dropped:

  • The "check character -> constant" test from field_checkbox_test was removed because it was mutating a readonly property, which has been unsupported for some time
  • The serializeKeyEvent suite from shortcut_registry_test was dropped, because that method is private
  • The oldxml test from trashcan_test was removed, because the oldXml field was removed from events in v13
  • Two tests that exercised passing null for an argument that is typed as undefined were removed from variable_model_test and variable_map_test; there were already tests for the undefined case, which were left in place.
  • The domToWorkspace suite in xml_test was largely passing by accident; all the assert.throws() were throwing (and thus passing) because this.workspace was undefined, as the function passed to the assert was not an arrow function. Switching to locally-scoped variables fixed that, but made the "Variables at top missing type" test start failing, because the exception it was expecting had been removed from core long ago; I updated that test to assert that it does not throw.

There are also two small core changes:

  • A TEST_ONLY export was removed from toolbox.ts because the sole use of it in a test was rewritten to use supported public APIs
  • The argument type for initializeGlobalAriaLiveRegion() was broaded from HTMLDivElement to HTMLElement; nothing about the implementation actually cares that the element is a <div> specifically.

Test Coverage

All tests pass, now with fewer bugs.

@gonfunko
gonfunko requested a review from a team as a code owner September 10, 2026 21:14
@gonfunko
gonfunko requested a review from mikeharv September 10, 2026 21:14
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.

2 participants