Skip to content

test(e2e): add toast interaction tests #2012

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

Merged
merged 9 commits into from
Feb 15, 2024
Merged

test(e2e): add toast interaction tests #2012

merged 9 commits into from
Feb 15, 2024

Conversation

anuraghazra
Copy link
Member

Description

Changes

Additional Information

Component Checklist

  • Update Component Status Page
  • Perform Manual Testing in Other Browsers
  • Add KitchenSink Story
  • Add Interaction Tests (if applicable)
  • Add changeset

Copy link

changeset-bot bot commented Feb 12, 2024

⚠️ No Changeset found

Latest commit: 890da22

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@anuraghazra anuraghazra changed the base branch from anu/toast to master February 12, 2024 05:54
@anuraghazra anuraghazra changed the base branch from master to anu/toast February 12, 2024 05:54
Copy link
Contributor

github-actions bot commented Feb 12, 2024

✅ PR title follows Conventional Commits specification.

@anuraghazra anuraghazra added the Review - L1 First level of review label Feb 12, 2024
Copy link

codesandbox-ci bot commented Feb 12, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 890da22:

Sandbox Source
razorpay/blade: basic Configuration

Comment on lines 1 to 2
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable import/no-extraneous-dependencies */
Copy link
Contributor

Choose a reason for hiding this comment

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

How do I run these tests locally? Do we have a guide?

Copy link
Member Author

Choose a reason for hiding this comment

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

yarn test:react:interaction

Copy link
Contributor

@snitin315 snitin315 Feb 13, 2024

Choose a reason for hiding this comment

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

I see toast tests are failing. Also, can you point me to the docs with more info like how to write these tests?

Screenshot 2024-02-13 at 1 27 44 PM Screenshot 2024-02-13 at 1 29 49 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@snitin315 more info on here: https://storybook.js.org/docs/writing-tests/interaction-testing

You can also check example code for Popover, Carousel etc interaction tests.

await expect(queryByText(toastContent)).not.toBeInTheDocument();
const button = getByRole('button', { name: 'Show Toast' });
await userEvent.click(button);
await sleep(400);
Copy link
Member

Choose a reason for hiding this comment

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

await waitFor(() => ) instead of sleep

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried it before, doesn't work. We need to discreetly wait for the animations to finish before asserting.

Copy link
Member

Choose a reason for hiding this comment

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

The exit would depend on absolute duration no? but I am guessing the toast opens immediately on button click. So can we not use waitFor on those parts? and keep sleep where we want to actually wait for some duration for toast to disappear etc?

Copy link
Member Author

Choose a reason for hiding this comment

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

So can we not use waitFor on those parts

Maybe somethings wrong with storybook testing lib, it doesn't work with waitFor. You need to wait for a discreet amount of time.

@anuraghazra anuraghazra merged commit 62e45aa into anu/toast Feb 15, 2024
@anuraghazra anuraghazra deleted the anu/toast-e2e branch February 15, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review - L1 First level of review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants