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

feat(Dropdown): add E2E tests #1962

Merged
merged 15 commits into from
Feb 7, 2024
Merged

feat(Dropdown): add E2E tests #1962

merged 15 commits into from
Feb 7, 2024

Conversation

saurabhdaware
Copy link
Member

@saurabhdaware saurabhdaware commented Jan 12, 2024

  • Add basic E2E tests for Dropdown
  • Remove unit tests which were e2e tests in disguise and move them to real e2e
  • Fixes a bug that was found while writing these e2e tests 🙈 . The dropdown was getting closed even when the state change on consumer end was not called inside onOpenChange
  • Fixes onClick getting called twice on Dropdown triggers

Copy link

changeset-bot bot commented Jan 12, 2024

🦋 Changeset detected

Latest commit: be7c691

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/blade Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Jan 12, 2024

✅ PR title follows Conventional Commits specification.

Comment on lines 102 to 104
useDidUpdate(() => {
onOpenChange?.(isOpen);
if (!isOpen) {
Copy link
Member Author

Choose a reason for hiding this comment

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

With this logic, we were calling onOpenChange as well as we were actually closing and opening dropdown.

Ideally we should only call onOpenChange wherever state needs to change and then consumers add

<Dropdown isOpen={isDropdownOpen} onOpenChange={(isOpen) => { setIsDropdownOpen(isOpen) }} />

if someone doesn't call state change in onOpenChange, then it shouldn't close the dropdown.

Copy link

codesandbox-ci bot commented Jan 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.

Comment on lines 101 to 103
const setIsOpenControlled = (isControlledStateOpen: boolean): void => {
onOpenChange?.(isControlledStateOpen);
if (!isControlledStateOpen) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the useControllableState hook to manage the controlled/uncontrolled behaviour of isOpen?

Copy link
Member Author

Choose a reason for hiding this comment

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

ouu didn't know about this hook. let me see.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

anuraghazra
anuraghazra previously approved these changes Jan 12, 2024
Copy link
Member

@anuraghazra anuraghazra left a comment

Choose a reason for hiding this comment

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

LGTM.

  • Check the tests on Safari/Firefox

@saurabhdaware saurabhdaware marked this pull request as ready for review February 5, 2024 03:56
@saurabhdaware
Copy link
Member Author

LGTM.

Check the tests on Safari/Firefox

done

anuraghazra
anuraghazra previously approved these changes Feb 5, 2024
Copy link
Member

@anuraghazra anuraghazra left a comment

Choose a reason for hiding this comment

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

lint failing. else lgtm

@saurabhdaware saurabhdaware merged commit 9801ff8 into master Feb 7, 2024
16 checks passed
@saurabhdaware saurabhdaware deleted the tests/dropdown-e2e branch February 7, 2024 07:39
anuraghazra pushed a commit that referenced this pull request Apr 9, 2024
* feat: add initial dropdown test

* feat: move major interaction tests to e2e

* feat: add controleld dropdown e2e tests

* Create lovely-chairs-sneeze.md

* fix: console log

* Update lovely-chairs-sneeze.md

* Update lovely-chairs-sneeze.md

* fix: BaseInput 2 clicks on dropdown

* fix: test for safari

* fix: handle double clicks with stopPropogation

* fix: eslint error

* fix: lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants