Skip to content

refactor: move theme validation after render setup in tests#4253

Open
srungta08 wants to merge 1 commit intomainfrom
test/classic-theme-drawer-filtering
Open

refactor: move theme validation after render setup in tests#4253
srungta08 wants to merge 1 commit intomainfrom
test/classic-theme-drawer-filtering

Conversation

@srungta08
Copy link
Member

Description

Improved test organization by moving validateThemeCompatibility calls to after component render and variable destructuring in 17 tests.

Benefits:

  • Better code organization: setup → render → validate → test
  • Allows test setup code (registerDrawer, delay) to run for all themes
  • Validates component state after setup completes
  • More consistent test structure

Pattern change:
Before:
registerDrawer(...) await delay() if (await validateThemeCompatibility(...)) return; const { wrapper } = await renderComponent(...)

After:
registerDrawer(...) await delay() const { wrapper } = await renderComponent(...) if (await validateThemeCompatibility(...)) return;

This ensures drawer registration and delays execute for all themes, then validates the rendered state before proceeding with assertions.

Tests affected: 17 tests in toolbar mode suite
Net change: +142/-129 lines (formatting improvements)

Related links, issue #, if available: n/a

How has this been tested?

Ran unit tests with:

npm run test

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Improved test organization by moving validateThemeCompatibility calls to
after component render and variable destructuring in 17 tests.

Benefits:
- Better code organization: setup → render → validate → test
- Allows test setup code (registerDrawer, delay) to run for all themes
- Validates component state after setup completes
- More consistent test structure

Pattern change:
Before:
  registerDrawer(...)
  await delay()
  if (await validateThemeCompatibility(...)) return;
  const { wrapper } = await renderComponent(...)

After:
  registerDrawer(...)
  await delay()
  const { wrapper } = await renderComponent(...)
  if (await validateThemeCompatibility(...)) return;

This ensures drawer registration and delays execute for all themes,
then validates the rendered state before proceeding with assertions.

Tests affected: 17 tests in toolbar mode suite
Net change: +142/-129 lines (formatting improvements)
@srungta08 srungta08 requested a review from a team as a code owner February 13, 2026 15:19
@srungta08 srungta08 requested review from gethinwebster and removed request for a team February 13, 2026 15:19
@srungta08 srungta08 changed the title refactor(app-layout): move theme validation after render setup in tests refactor: move theme validation after render setup in tests Feb 13, 2026
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (38a9eb8) to head (906bade).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4253   +/-   ##
=======================================
  Coverage   97.19%   97.19%           
=======================================
  Files         886      886           
  Lines       26029    26029           
  Branches     9438     9437    -1     
=======================================
  Hits        25299    25299           
- Misses        683      724   +41     
+ Partials       47        6   -41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mountContent: container => (container.textContent = 'global drawer content 1'),
});

const renderProps = await renderComponent(<AppLayout drawers={[testDrawer]} />);
Copy link
Member

Choose a reason for hiding this comment

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

Given that validateThemeCompatibility tests whether renderComponent throws an error I would suggest keeping it before any non-wrapped calls to renderComponent. That way the resulting error messages if something goes wrong will be more descriptive.

});

test('should render trigger buttons for global drawers even if local drawers are not present', async () => {
if (await validateThemeCompatibility(theme, <AppLayout toolsHide={true} />)) {
Copy link
Member

Choose a reason for hiding this comment

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

however this is a (partially) valid change: for validateThemeCompatibility to be useful it needs to run after registerDrawer, otherwise there's not really anything for it to test

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