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

Update va-select events #351

Closed
wants to merge 6 commits into from
Closed

Update va-select events #351

wants to merge 6 commits into from

Conversation

andresriveratoro
Copy link
Contributor

@andresriveratoro andresriveratoro commented Apr 7, 2022

Chromatic

https://671-va-select-event--60f9b557105290003b387cd5.chromatic.com

Description

Closes department-of-veterans-affairs/vets-design-system-documentation#671

Testing done

E2E, Storybook

Screenshots

Screen Shot 2022-04-07 at 14 03 23

Acceptance criteria

  • Replace vaKeyDown with keydown native event
  • Update vaSelect event propagation

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@andresriveratoro andresriveratoro requested a review from a team as a code owner April 7, 2022 18:08
@andresriveratoro andresriveratoro added the patch Patch change in semantic versioning label Apr 7, 2022
Copy link
Contributor

@bkjohnson bkjohnson left a comment

Choose a reason for hiding this comment

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

Do we know if the team is having an issue with the keydown event or the change one?

@andresriveratoro
Copy link
Contributor Author

Do we know if the team is having an issue with the keydown event or the change one?

I believe it's the change event. I don't see any teams using the keydown event.

@andresriveratoro andresriveratoro self-assigned this Apr 8, 2022
Comment on lines +54 to +58
@Event({
bubbles: true,
composed: true,
})
vaSelect: EventEmitter;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this is what should make that test easier for the app team, right? I was too focused on the keydown changes to notice this the first time 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests are still failing locally when using userEvent.click(await screen.findByText(/use your current location/i));. 😞

@@ -79,6 +91,7 @@ const Template = ({
error={error}
aria-live-region-text={ariaLiveRegionText}
use-add-button={useAddButton}
onKeyDown={() => console.log('KEYDOWN FIRED')}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also in favor of this native event + handler replacing the custom one 👍

@andresriveratoro
Copy link
Contributor Author

I have been unable to observe the vaChange event fire in vets-website tests.

This code allows you to select a new value using userEvent and the test passes, but vaChange isn't fired.

const select = await screen.findByTestId('providersSelect');
userEvent.selectOptions(select, 'Two');
expect(screen.getByRole('option', { name: 'Two' }).selected).to.equal(true);

This throws a Error: The given element does not have a value setter

fireEvent.change(select, { target: { value: 'Two' } });

Related Issues

testing-library/dom-testing-library#413
testing-library/dom-testing-library#742

@pdavies88
Copy link
Contributor

@andresriveratoro can we notate your last comment on the ticket: department-of-veterans-affairs/vets-design-system-documentation#671 and tag Paul so he's aware

@pdavies88 pdavies88 self-requested a review April 14, 2022 14:51
@andresriveratoro andresriveratoro added the backlog To be addressed in a future sprint label Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog To be addressed in a future sprint patch Patch change in semantic versioning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Select] React Testing Library does not find select event on VaSelect component
3 participants