Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(popup): Add tests for Popup #600

Merged
merged 11 commits into from
May 4, 2020
Merged

test(popup): Add tests for Popup #600

merged 11 commits into from
May 4, 2020

Conversation

mannycarrera4
Copy link
Contributor

@mannycarrera4 mannycarrera4 commented Apr 27, 2020

Summary

Adds visual and cypress test for Popup and change enzyme test to react testing library

@@ -152,7 +152,6 @@ export default class Popup extends React.Component<PopupProps> {
size={closeIconSize}
onClick={handleClose}
icon={xIcon}
title={closeLabel}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have an aria label which is why removed the title, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think it was added so that a mouse user could see what the Icon would do? I agree we don't want both title and aria-label. Perhaps this should be a label Tooltip? The new Tooltip API only exists on the v4 branch, but would be what we want.

It would look something like:

<Tooltip title={closeLabel}>
  <IconButton
    /* ... */
  />

The label is actually required on the tooltip as well as the `IconButton` because of Typescript. The Tooltip uses `React.cloneElement` and adds an `aria-label` to the child it wraps.
</Tooltip>

@@ -41,8 +41,8 @@ describe('Toast', () => {
{toastMessage}
</Toast>
);
const closeIcon = container.querySelector('[data-close="close"]'); /*? */
fireEvent.click(closeIcon); /*? */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was some comments that where left, seemed minor enough to remove

Copy link
Member

Choose a reason for hiding this comment

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

I think these are also removed in v4

@cypress
Copy link

cypress bot commented Apr 27, 2020



Test summary

317 0 0 0


Run details

Project canvas-kit
Status Passed
Commit 51a17e6 ℹ️
Started May 4, 2020 8:48 PM
Ended May 4, 2020 8:51 PM
Duration 03:08 💡
OS Linux Ubuntu Linux - 18.04
Browser Electron 80

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@lychyi lychyi linked an issue Apr 28, 2020 that may be closed by this pull request

function getCloseButton() {
return getPopup().find('[data-close]');
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this function and the one above are similar to the modal helper functions, should I use those instead?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. If I were to share some helpers I might do the opposite since Popup is what's common between Popup and Modal. But that's an implementation detail of the Modal. Modal uses shared helpers - those helper functions are meant to be usable eventually outside of this repository. Non-sharable helper functions should remain inside the spec file IMO.

These helper functions are different than the modal ones. They don't map as closely to the Cypress command log - these are more like "macro helpers" than just call to other commands and don't have their own logging. This isn't a huge problem on simpler tests, but can really aid in debugging larger tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah gotcha, thanks for explaining that!

@@ -35,6 +35,9 @@
"workday",
"popup"
],
"devDependencies": {
"@workday/canvas-kit-labs-react-core": "^3.6.0"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

used for stories using static states component

@mannycarrera4
Copy link
Contributor Author

Some things to note about our Popup. Our popup is more of a styled container, our Modal component has more accessibility and functionality than our popup. After talking to Nicholas for a bit, this component seems more like a dialog container. I wrote some minimal cypress tests and wanted to get some clarification if they make sense @NicholasBoll

@mannycarrera4 mannycarrera4 marked this pull request as ready for review April 30, 2020 22:51
@mannycarrera4 mannycarrera4 added ready for review Code is ready for review testing labels May 1, 2020
@@ -26,7 +26,7 @@ export interface PopupProps extends React.HTMLAttributes<HTMLDivElement> {
* The origin from which the Popup will animate.
* @default {horizontal: 'center', vertical: 'top'}
*/
transformOrigin: TransformOrigin;
transformOrigin: TransformOrigin | null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this allows to pass null in the visual stories and doesn't add the animation allowing for the snap shots to be captured

@NicholasBoll NicholasBoll added the approved Code has been reviewed and approved (ship it) label May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Code has been reviewed and approved (ship it)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Testing for Popup
3 participants