Skip to content

[7.x] [Enterprise Search] Mocks/tests tech debt - avoid hungry mocking (#101107)#101788

Merged
cee-chen merged 1 commit intoelastic:7.xfrom
cee-chen:backport/7.x/pr-101107
Jun 9, 2021
Merged

[7.x] [Enterprise Search] Mocks/tests tech debt - avoid hungry mocking (#101107)#101788
cee-chen merged 1 commit intoelastic:7.xfrom
cee-chen:backport/7.x/pr-101107

Conversation

@cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Jun 9, 2021

Backports the following commits to 7.x:

…stic#101107)

* Move enzyme & misc test helpers out of __mocks__/ and into new test_helpers/

They're not technically mocks since nothing is being mocked, so we should move them into a test_helpers folder for specificity & organization

* Move React Router mocks into its own separate folder/import

This was part of the initial feedback, that it was unclear why importing something for Kea in __mocks__/index.ts was mocking react router along for the ride. Separating this out makes things clearer and imports more explicit

+ add some handy new mock useX jest.fn()s helpers, so we're not doing `useParams() as jest.Mock` errywhere

* Move Kea & logic mocks/helpers into kea_logic subfolder
- for organization

NOTE: It can't be a plain kea/ folder because then Jest automatically mocks the `kea` module itself kea 🤦

* Fix type failures

- Caused by switch from any to unknown (changed back to any + added a .test_helper suffix exclusion for any)

* Fix Enterprise Search tests/imports

- I checked all application folders but this one, whoops

* PR feedback: comment copy

* Update tests/files added since PR open with new import locations

* Fix misc react router typing

- null not being type-able as a boolean
- forgot to remove various useParam imports after adding mockUseParams
+ misc unused kea import, probably added while debugging kea mocks
# Conflicts:
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview.test.tsx
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts
@cee-chen cee-chen added the backport This PR is a backport of another PR label Jun 9, 2021
@cee-chen cee-chen enabled auto-merge (squash) June 9, 2021 15:36
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cee-chen cee-chen merged commit 996903c into elastic:7.x Jun 9, 2021
@cee-chen cee-chen deleted the backport/7.x/pr-101107 branch June 10, 2021 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants