Skip to content

chore(dom): merge test suites#14763

Open
jcfranco wants to merge 5 commits into
devfrom
jcfranco/merge-dom-browser-tests
Open

chore(dom): merge test suites#14763
jcfranco wants to merge 5 commits into
devfrom
jcfranco/merge-dom-browser-tests

Conversation

@jcfranco

@jcfranco jcfranco commented Jul 7, 2026

Copy link
Copy Markdown
Member

Related Issue: N/A

Summary

Merges dom.ts tests now that browser mode allows them to share the same environment.

Noteworthy changes

@jcfranco
jcfranco requested a review from Copilot July 7, 2026 00:42
@github-actions github-actions Bot added the chore Issues with changes that don't modify src or test files. label Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 consolidates browser test coverage by removing the separate dom2 browser spec and merging its test cases into the existing dom browser spec, while also relocating a custom Vitest Browser locator extension into the shared browser test setup.

Changes:

  • Removed dom2.browser.spec.tsx and merged its queryElementRoots-related tests into dom.browser.spec.tsx.
  • Refactored parts of dom.browser.spec.tsx to use @arcgis/lumina-compiler/testing’s mount + Vitest Browser page locators.
  • Moved the getBySelector locator extension from a shared test util into the global browser setup.ts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/components/src/utils/dom2.browser.spec.tsx Deleted as part of merging test suites.
packages/components/src/utils/dom.browser.spec.tsx Absorbs dom2 tests and refactors multiple tests to use mount/Vitest Browser locators.
packages/components/src/tests/commonTests/browser/utils.ts Removes locator extension code and keeps only shared browser-test utilities.
packages/components/src/tests/browser/setup.ts Adds global getBySelector locator extension for browser tests.
Comments suppressed due to low confidence (7)

packages/components/src/utils/dom.browser.spec.tsx:48

  • suggestion: queryElementRoots is being tested twice in this file (the new describe("queries") block and the existing describe(queryElementRoots) block). This increases runtime and also defines two different LitElement classes with the same static tagName = "test-component", which can lead to custom element registration conflicts depending on how mount(..., { dynamicComponents }) registers elements. Consider consolidating into a single suite and reusing one TestComponent definition/tag name.
    packages/components/src/utils/dom.browser.spec.tsx:364
  • blocking: This test uses a global locator (page.getBySelector("slot")) inside a suite that does not clear the DOM between tests, so it can accidentally bind to a <slot> from a previous test run and become order-dependent/flaky. Prefer scoping the query to the element returned by mount (e.g. el.shadowRoot!.querySelector(...)).
    packages/components/src/utils/dom.browser.spec.tsx:405
  • blocking: Similar to the previous case, using page.getBySelector("slot") here can match slots from earlier mounts since this suite doesn't reset the DOM. Scoping to el.shadowRoot makes the test deterministic and avoids cross-test coupling.
    packages/components/src/utils/dom.browser.spec.tsx:480
  • blocking: This test also uses a global page.getBySelector("slot") which can bind to a slot from a previous test since the DOM isn't cleared in this suite. Query the slot from the mounted element's shadowRoot instead to keep the test isolated.
    packages/components/src/utils/dom.browser.spec.tsx:524
  • blocking: Using page.getBySelector("slot") here can select slots from previous tests/mounts because this suite doesn't reset DOM state. Scoping to el.shadowRoot!.querySelectorAll("slot") avoids flakiness.
    packages/components/src/utils/dom.browser.spec.tsx:1189
  • blocking: This test uses page.getBySelector("span") (global) even though each test mounts new markup. If prior tests leave spans in the DOM, the locator may resolve to an earlier instance and make the test order-dependent. Scope the query to the container returned from mount.
    packages/components/src/utils/dom.browser.spec.tsx:1205
  • blocking: Same issue as the previous test: page.getBySelector("span") is global and can match a stale element from earlier mounts. Use the container returned from mount to scope the query.

@jcfranco jcfranco added the skip visual snapshots Pull requests that do not need visual regression testing. label Jul 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

packages/components/src/utils/dom.browser.spec.tsx:939

  • expect(button).toBeDefined() is a no-op here (the Locator object is always defined) and doesn’t actually assert that the button element was found before calling getShadowRootNode. Capture the underlying element and assert on that instead.

@jcfranco
jcfranco marked this pull request as ready for review July 14, 2026 23:25
@jcfranco
jcfranco requested a review from a team July 14, 2026 23:25

@driskull driskull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Issues with changes that don't modify src or test files. skip visual snapshots Pull requests that do not need visual regression testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants