Skip to content

chore(Alert): updated tests to new standards#8114

Merged
tlabaj merged 5 commits intopatternfly:mainfrom
wise-king-sullyman:alert-test-revamp
Sep 29, 2022
Merged

chore(Alert): updated tests to new standards#8114
tlabaj merged 5 commits intopatternfly:mainfrom
wise-king-sullyman:alert-test-revamp

Conversation

@wise-king-sullyman
Copy link
Copy Markdown
Collaborator

What: Closes #7670

Additional issues:

I also resolved a few small bugs in 749bf18 which I discovered in AlertActionCloseButton and AlertToggleExpandButton while building out the test suites.

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Sep 28, 2022

Copy link
Copy Markdown
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

so, in the back of my mind I'm aware that right now, the a11y tests to flag a warning that we are putting an aria-label on a div without a valid role. And in the case of alert, the aria-label is the same text as the title of the alert (by default at least). So it'd be considered a breaking change at this point to remove the default aria-label, because of the unit tests in product, and now these unit tests.

I'm not sure what that means for this approach. When/if we implement a fix to avoid the warning, then we'll also need to update these unit tests and I guess that's okay. I just wanted to document the thought process i guess.

And yeah, outside of that, maybe we can make the timeouts shorter whenever possible - like instead of 3000 milliseconds, use 100 milliseconds or something like that?

await user.hover(alert);

act(() => {
jest.advanceTimersByTime(8000);
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.

It may be a little less pure, but could we possibly use a shorter timer than the default here? it'd be nice to keep as many timeouts as possible as short as possible in our unit tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I could be mistaken, but I believe that Jest's fake timer functionality here actually allows the timers to advance in non-real time, so the 8000ms here should actually be passing pretty much instantly.

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.

ooooo that's cool!

'Exclamation triangle icon mock'
);
jest.mock('@patternfly/react-icons/dist/esm/icons/info-circle-icon', () => () => 'Info circle icon mock');
jest.mock('@patternfly/react-icons/dist/esm/icons/bell-icon', () => () => 'Bell icon mock');
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.

🤯 good to know this is how it works!

Copy link
Copy Markdown
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

This looks great, awesome work on all of this! I had a couple of changes below (should be the first two comments), then a few comments asking the same question. Let me know what you think!

Copy link
Copy Markdown
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

🎉 💪🏼

@tlabaj tlabaj merged commit 1562f9b into patternfly:main Sep 29, 2022
@wise-king-sullyman wise-king-sullyman deleted the alert-test-revamp branch September 29, 2022 20:14
@patternfly-build
Copy link
Copy Markdown
Collaborator

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@4.92.18
  • @patternfly/react-code-editor@4.82.18
  • @patternfly/react-console@4.92.18
  • @patternfly/react-core@4.244.2
  • @patternfly/react-docs@5.102.21
  • @patternfly/react-inline-edit-extension@4.86.18
  • demo-app-ts@4.201.18
  • @patternfly/react-integration@4.203.7
  • @patternfly/react-log-viewer@4.87.13
  • @patternfly/react-table@4.110.18
  • @patternfly/react-topology@4.88.18
  • @patternfly/react-virtualized-extension@4.88.18

Thanks for your contribution! 🎉

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.

Alert test revamp

5 participants