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

[jest/globalSearchBar] Switch to jest-environment-jsdom #95200

Closed
spalger opened this issue Mar 23, 2021 · 3 comments · Fixed by #95640
Closed

[jest/globalSearchBar] Switch to jest-environment-jsdom #95200

spalger opened this issue Mar 23, 2021 · 3 comments · Fixed by #95640
Assignees
Labels
chore Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@spalger
Copy link
Contributor

spalger commented Mar 23, 2021

Part of #95198

As we upgraded to jest-environment-jsdom the "Kibana Pipeline / jest / Jest Tests.x-pack/plugins/global_search_bar/public/components.SearchBar supports keyboard shortcuts" test started failing with the following error:

https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/114474/testReport/junit/Jest%20Tests/x-pack_plugins_global_search_bar_public_components/Kibana_Pipeline___jest___SearchBar_supports_keyboard_shortcuts/

Error: expect(received).toMatchSnapshot()

Snapshot name: `SearchBar supports keyboard shortcuts 1`

- Snapshot  -  10
+ Received  + 104

- <input
-   aria-activedescendant=""
-   aria-haspopup="listbox"
-   aria-label="Search Elastic"
-   autocomplete="off"
-   class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch--compressed euiSelectableSearch euiSelectableTemplateSitewide__search kbnSearchBar"
-   data-test-subj="nav-search-input"
-   placeholder="Search Elastic"
-   type="search"
-   value=""
+ <body>
+   <div>
+     <div
+       data-eui="EuiFocusTrap"
+     >
+       <div
+         aria-live="assertive"
+         aria-modal="true"
+         class="euiPanel euiPanel--borderRadiusMedium euiPanel--plain euiPopover__panel euiPopover__panel--bottom euiPopover__panel-isOpen navSearch__panel"
+         role="dialog"
+         style="top: 16px; left: -22px; z-index: 2000;"
+       >
+         <div
+           class="euiPopover__panelArrow euiPopover__panelArrow--bottom"
+           style="left: 10px; top: 0px;"
+         />
+         <div>
+           <div
+             style="width: 600px; max-width: 100%;"
+           >
+             <div
+               class="euiSelectableList euiSelectableTemplateSitewide__list"
+             >
+               <div
+                 style="overflow: visible; width: 0px;"
+               />
+               <div
+                 class="resize-triggers"
+               >
+                 <div
+                   class="expand-trigger"
+                 >
+                   <div
+                     style="width: 1px; height: 1px;"
                    />
+                 </div>
+                 <div
+                   class="contract-trigger"
+                 />
+               </div>
+             </div>
+             <div
+               class="euiPopoverFooter euiPopoverFooter--paddingSmall"
+             >
+               <div
+                 class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--justifyContentSpaceBetween euiFlexGroup--directionRow euiFlexGroup--wrap"
+               >
+                 <div
+                   class="euiFlexItem"
+                 >
+                   <div
+                     class="euiText euiText--extraSmall"
+                   >
+                     <div
+                       class="euiTextColor euiTextColor--subdued"
+                     >
+                       <p>
+                         Filter by
+                          
+                         <span>
+                           <code>
+                             type:
+                           </code>
+                         </span>
+                          
+                         or
+                          
+                         <span>
+                           <code>
+                             tag:
+                           </code>
+                         </span>
+                       </p>
+                     </div>
+                   </div>
+                 </div>
+                 <div
+                   class="euiFlexItem euiFlexItem--flexGrowZero"
+                 >
+                   <div
+                     class="euiText euiText--extraSmall"
+                   >
+                     <div
+                       class="euiTextColor euiTextColor--subdued"
+                     >
+                       <p>
+                         Shortcut
+                          
+                         <span>
+                           <code>
+                             Control + /
+                           </code>
+                         </span>
+                       </p>
+                     </div>
+                   </div>
+                 </div>
+               </div>
+             </div>
+           </div>
+         </div>
+       </div>
+     </div>
+   </div>
+ </body>
    at Object.<anonymous> (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/global_search_bar/public/components/search_bar.test.tsx:133:36)
    at Promise.then.completed (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:276:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/utils.js:216:10)
    at _callCircusTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:212:40)
    at _runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:149:3)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:63:9)
    at _runTestsForDescribeBlock (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:57:9)
    at run (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:176:21)
    at jestAdapter (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:109:19)
    at runTestInternal (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:380:16)
    at runTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/runTest.js:472:34)
    at Object.worker (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-runner/build/testWorker.js:133:12)

To unblock the upgrade this Jest project was pinned to jest-environment-jsdom-thirteen which is outdated and should be removed.

@spalger spalger added chore Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Mar 23, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@spalger
Copy link
Contributor Author

spalger commented Mar 23, 2021

@joshdover Looks like the issue might be enzymejs/enzyme#2337 (comment)

I bet if we tell mount() to { attachTo: document.body } this event will properly set document.activeElement.

@spalger
Copy link
Contributor Author

spalger commented Mar 24, 2021

See #95327 for some ideas about how Lens fixed this in their tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants