-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Uptime] Fix/details page tabs #86296
[Uptime] Fix/details page tabs #86296
Conversation
Pinging @elastic/uptime (Team:uptime) |
@elasticmachine merge upstream |
…nitor names and auto generated monitor ids
0e31d33
to
1792f21
Compare
@elasticmachine merge upstream |
@elasticmachine merge upstream |
history | ||
); | ||
expect(component.find('h1').text()).toBe(monitorName); | ||
expect(component.find('[data-test-subj="uptimeSettingsToOverviewLink"]').length).toBe(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we can just add a data-test-subj
to the whole tab group instead of looking for specific links? Seems like the wrong approach, and fragile if the links themselves change.
<EuiFlexItem> | ||
<PageTabs /> | ||
</EuiFlexItem> | ||
<EuiFlexItem>{isMonitorRoute ? <MonitorPageTitle /> : <PageTabs />}</EuiFlexItem> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit weird to me that the header should care about what page it's on. It would make more sense, IMHO, for the page to tell the header what should be in the header, that would, IMHO be less fragile. Each page could just say explicitly "I want this type of header".
Thinking ahead here, when we add a new page we want whoever works on it to make an explicit choice of header.
|
||
jest.mock('react-router-dom', () => ({ | ||
__esModule: true, | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this being ignored? Any type script ignore statements should come with a comment explaining the why here. As a reviewer (or someone coming along later) it answers a lot of questions.
const url = { | ||
full: 'https://www.elastic.co/', | ||
}; | ||
const monitorStatus = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like the complexity of these mocks at this point justifies a bit of refactoring here.
We do things like this elsewhere, but it's something we should avoid when we can. The reason is, if we add any additional mandatory fields to this type, this is one more file we must update. Also, it's hard to read etc.
I am wondering if we could make a new selector in redux that just pulls the fields we need, so we would only need to mock that minimal set of fields. In general, when passing a complex mocked object, that can point to a need to reduce the surface area of the function (or component) being tested. It may accept a more complex object than it needs to. I'm also open to other approaches that could simplify the tests here.
Good catch! I'm thinking to resolve this issue, while still keeping the PageHeader component prop based, to move the PageHeader component back to |
My original thought of how to resolve this was misguided, as it still causes the tabs component to be mounted, unmounted, and remounted, causing loss of focus. We could focus on the current tab on mount, but that would cause an odd experience when a user visits the page outside of using the tabs, for example visiting the direct url. @shahzad31's original implementation tracking the routes is likely the best approach given these challenges. |
@elasticmachine merge upstream |
jest.mock('react-redux', () => { | ||
const originalModule = jest.requireActual('react-redux'); | ||
|
||
return { | ||
...originalModule, | ||
useSelector: jest.fn(), | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if it make sense to use mocks we have in file
x-pack/plugins/uptime/public/lib/helper/test_helpers.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This works great. I tried to create one for react-router-dom
too, but it wouldn't let me use a spy without first running jest.mock in the test file, making a reusable function less helpful.
06f4d7a
to
59a59cc
Compare
59a59cc
to
8aae9e0
Compare
</EuiFlexGroup> | ||
{isMonRoute && <EuiHorizontalRule margin="m" />} | ||
{!isMonRoute && <EuiSpacer size="m" />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe this includeSpacer prop isn't needed, can we move this perhaps to top of those pages? where it's needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the includeSpacer stuff, otherwise it's looking good !!
ca076cb
to
f294605
Compare
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
* Remove tabs from details page * update * fix monitord id * var name * add Uptime PageHeader tests to test for the presences of tabs or header * add Uptime MonitorPageTitle test * Uptime adjust auto generated monitor id regex * Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids * remove history from MonitorPageTitle test * adjust uptime tabs tests * adjust MonitorPageTitle tests to mock useSelector * adjust uptime PageHeader tests * adjust import order in page_header.test * add props to Uptime PageHeader to determine render, rather than route context * alphabetize props in Uptime PageHeader * remove header from individual pages * add indepdent page header route that matches all paths * adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks * update tests * adjust header spacing Co-authored-by: Shahzad <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
* Remove tabs from details page * update * fix monitord id * var name * add Uptime PageHeader tests to test for the presences of tabs or header * add Uptime MonitorPageTitle test * Uptime adjust auto generated monitor id regex * Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids * remove history from MonitorPageTitle test * adjust uptime tabs tests * adjust MonitorPageTitle tests to mock useSelector * adjust uptime PageHeader tests * adjust import order in page_header.test * add props to Uptime PageHeader to determine render, rather than route context * alphabetize props in Uptime PageHeader * remove header from individual pages * add indepdent page header route that matches all paths * adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks * update tests * adjust header spacing Co-authored-by: Shahzad <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
* master: [APM] Define placement “Right” to offset tooltip (elastic#87729) Fix UI glitch on SOM delete confirmation modal (elastic#87623) Remove src/plugins/vis_default_editor -> src/plugins/visualizations cyclic dependencies (elastic#86988) [Timelion] Fix tests flakiness on suggestion click (elastic#87273) [Uptime] Fix/details page tabs (elastic#86296) [ML] Fix earliest and latest texts for date fields (elastic#87482) chore(NA): move grokdebugger plugin test fixtures out of __tests__ folder (elastic#87765) [Security Solution] Refactor Cypress scenarios to use internal contex… (elastic#86609) [Security Solution] Unskip cypress tests (elastic#86653)
* Remove tabs from details page * update * fix monitord id * var name * add Uptime PageHeader tests to test for the presences of tabs or header * add Uptime MonitorPageTitle test * Uptime adjust auto generated monitor id regex * Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids * remove history from MonitorPageTitle test * adjust uptime tabs tests * adjust MonitorPageTitle tests to mock useSelector * adjust uptime PageHeader tests * adjust import order in page_header.test * add props to Uptime PageHeader to determine render, rather than route context * alphabetize props in Uptime PageHeader * remove header from individual pages * add indepdent page header route that matches all paths * adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks * update tests * adjust header spacing Co-authored-by: Shahzad <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Shahzad <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
* Remove tabs from details page * update * fix monitord id * var name * add Uptime PageHeader tests to test for the presences of tabs or header * add Uptime MonitorPageTitle test * Uptime adjust auto generated monitor id regex * Uptime add tests for MonitorPageTitle to test behavior for missing monitor names and auto generated monitor ids * remove history from MonitorPageTitle test * adjust uptime tabs tests * adjust MonitorPageTitle tests to mock useSelector * adjust uptime PageHeader tests * adjust import order in page_header.test * add props to Uptime PageHeader to determine render, rather than route context * alphabetize props in Uptime PageHeader * remove header from individual pages * add indepdent page header route that matches all paths * adjust monitor tests to use mockReduxHooks helper, and add mockReactRouterDomHooks * update tests * adjust header spacing Co-authored-by: Shahzad <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Shahzad <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
Summary
Fixes: #85826
Fixes: #86743
Fixes: #86174
To test
Overview Page Heading
Monitor Page Heading
Certificates Page Header
Settings Page Header
Waterfall Page Heading