Skip to content

Conversation

gethinwebster
Copy link
Member

@gethinwebster gethinwebster commented Sep 16, 2025

Description

Re-run of #3816 with adjusted implementation for better cross-version compatibility

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

How has this been tested?

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.

Copy link

codecov bot commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.15%. Comparing base (e5e2ffc) to head (0188b2c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3868      +/-   ##
==========================================
- Coverage   97.15%   97.15%   -0.01%     
==========================================
  Files         854      854              
  Lines       24960    24959       -1     
  Branches     8792     8794       +2     
==========================================
- Hits        24251    24250       -1     
  Misses        660      660              
  Partials       49       49              

☔ 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.

@gethinwebster gethinwebster marked this pull request as ready for review September 16, 2025 09:46
@gethinwebster gethinwebster requested a review from a team as a code owner September 16, 2025 09:46
@gethinwebster gethinwebster requested review from georgylobko and removed request for a team September 16, 2025 09:46
georgylobko
georgylobko previously approved these changes Sep 16, 2025
export default class ButtonWrapper extends ComponentWrapper<HTMLButtonElement> {
static rootSelector: string = styles.button;
static rootSelector: string = buttonTestUtilsStyles.root;
static legacyRootSelector: string = 'awsui_button_vjswe';
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest writing a unit test for this scenario - just copy the HTML markup for the legacy selector and verify it still works correctly. Yes, this scenario is technically covered in this repository: https://github.com/cloudscape-design/test-utils/blob/c7200f200913812a551c8286bb4d1dccd5087565/src/core/test/selectors.test.ts#L116

The difference is that this selector skips the last hash part, which is why I still recommend doing it this way

Copy link
Member Author

Choose a reason for hiding this comment

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

good call, turns out what I had didn't actually work! updated

export default class ToggleButtonWrapper extends ButtonWrapper {
static rootSelector: string = buttonStyles.button;
static rootSelector: string = testStyles.root;
static legacyRootSelector: string = '';
Copy link
Member

Choose a reason for hiding this comment

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

Is this empty selector needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, because extends ButtonWrapper

Copy link
Member

Choose a reason for hiding this comment

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

Understood. Great that you handle it, but also important learning to check all descendants when using this property on other wrappers

No more questions from me on this PR, removing myself


describe('legacy selectors', () => {
test(
'finds legacy and new buttons',
Copy link
Member

Choose a reason for hiding this comment

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

[non-blocking] I'd suggest to turn this test and its page to a unit test since it's faster and less resource-intensive than running it in the browser

Copy link
Member Author

Choose a reason for hiding this comment

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

see below, unit and integ tests handle selectors a bit differently, so this is deliberate

export default class ButtonWrapper extends ComponentWrapper<HTMLButtonElement> {
static rootSelector: string = styles.button;
static rootSelector: string = buttonTestUtilsStyles.root;
static legacyRootSelector: string = 'awsui_button_vjswe_t8nlg_157';
Copy link
Member

Choose a reason for hiding this comment

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

[non-blocking just curious] doesn't the hash at the end get regenerated with every build? I checked both the cloudWatch and lambda consoles though, and it looks like they both use this selector for their buttons

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes the last hash segment changes regularly. That's why I added the test as an integ test: the selectors utils trim these "full" class selectors and turn them into [class*=...] instead, so that they are insensitive to the 2nd part of the hash. dom utils use the class as-is, as typically the dom test utils aren't used in multi-version environments.

georgylobko
georgylobko previously approved these changes Oct 15, 2025
@gethinwebster gethinwebster added this pull request to the merge queue Oct 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 15, 2025
@gethinwebster gethinwebster added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit ee7ac59 Oct 15, 2025
49 checks passed
@gethinwebster gethinwebster deleted the dev-v3-gethinw-toggle-test-utils branch October 15, 2025 12:52
gethinwebster added a commit that referenced this pull request Oct 15, 2025
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