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

[EuiSelectableTemplateSitewide] fix: The keydown popup display shall be Enter key. #5886

Merged
merged 7 commits into from
May 17, 2022

Conversation

ki504178
Copy link
Contributor

@ki504178 ki504178 commented May 7, 2022

Summary

Address the following issues.
#5726

Checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@ki504178 ki504178 changed the title fix: The keydown popup display shall be Enter key. [EuiSelectableTemplateSitewide] fix: The keydown popup display shall be Enter key. May 7, 2022
@ki504178 ki504178 marked this pull request as ready for review May 8, 2022 01:37
Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

I QA'd this locally and it's looking great, thank you @ki504178!

This is potentially out of scope, so I'm ok with skipping it for now - but just curious, would you be interested in writing E2E Cypress tests for this file to ensure we don't see regressions in the future?

No worries if you'd rather not, we can skip it if so (since this file doesn't have existing E2E tests written for it) - but if you're at all interested in learning Cypress, let me know and I can provide more details on what I'm looking for in terms of a regression test for this behavior.

@ki504178
Copy link
Contributor Author

Thanks for the review! @constancecchen
I am interested in writing an E2E test with Cypress and would love to try it.

ki504178 and others added 3 commits May 12, 2022 09:12
- To apply the appropriate modification description.

Co-authored-by: Constance <constancecchen@users.noreply.github.com>
- No need for quick returns based on whether or not the pop-up bar is displayed
- Use predefined constants for Enter key comparisons instead of literals
@cee-chen
Copy link
Member

jenkins test this

Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

Changes look fantastic, thank you @ki504178! I'd be good with this merging in as-is, although also very excited to see what you come up with for Cypress tests.

You will want to create a new file called selectable_template_sitewide.spec.tsx. You can take a look at the following docs for how to run Cypress tests (you will likely want to use yarn test-cypress-dev) and an example to get a quick peek at setup:

You should be able to mount a minimal EuiSelectableTemplateSitewide component using something like this:

const options = [
  {
    label: 'Hello',
    meta: [{ text: 'Test', highlightSearchString: true }],
  },
  {
    label: 'World',
    meta: [{ text: 'Test', highlightSearchString: true }],
  },
];

cy.mount(
  <EuiSelectableTemplateSitewide
    options={options}
    searchProps={{ 'data-test-subj': 'searchInput' }}
    popoverProps={{ 'data-test-subj': 'searchPopover' }}
  />
);

With the above component, I'd like to see the following 2-3 separate E2E tests:

  1. One that asserts that clicking into the searchInput and then pressing Enter makes the searchPopover appear
  2. One that asserts that pressing the Escape key makes the popover disappear
  3. (Optional additional test) One that asserts that typing the character H into the searchInput makes the 'Hello' option appear, but not the World option

Hope that helps! You'll likely want to make use of Cypress APIs such as cy.realPress for the keypresses, cy.get('...').should('not.exist') for checking that DOM nodes are not present, and cy.contains for checking whether 'hello' vs 'world' exists.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5886/

@ki504178
Copy link
Contributor Author

@constancecchen
Thanks for the re-review and the detailed description of Cypress!
Please let me hold off on the merge because I would like to try to create a test case for Cypress using the pattern you taught me.

@ki504178
Copy link
Contributor Author

Sorry @constancecchen
We ran into the following problem, which may take some time to resolve, so we will leave the addition of test cases by Cypress for another time.
cypress-io/cypress-docker-images#431

@cee-chen
Copy link
Member

Gotcha, no worries at all! Hopefully some other time in the future!

Going to go ahead and merge, thanks so much for your time with this fix!!

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.

3 participants