[Snapshot & Restore] Add component tests for snapshot list search#121537
[Snapshot & Restore] Add component tests for snapshot list search#121537yuliacech merged 5 commits intoelastic:mainfrom
Conversation
| SNAPSHOT_LIST_MAX_SIZE: 2, | ||
| }; | ||
| }); | ||
|
|
There was a problem hiding this comment.
This old mock was used for testing a warning callout about only showing a limited number of snapshots. The warning was removed in #110266
|
Pinging @elastic/kibana-stack-management (Team:Stack Management) |
sabarasaba
left a comment
There was a problem hiding this comment.
Nice work adding all these tests @yuliacech! Only left two small comments 🚀
|
|
||
| describe('debounce', () => { | ||
| test('waits after input to update list params for search', async () => { | ||
| await setSearchText('snapshot=test_snapshot', false); |
There was a problem hiding this comment.
To improve readability, wdyt of creating a variable for this?
const ADVANCE_TIME = false;
await setSearchText('snapshot=test_snapshot', ADVANCE_TIME);
| jest.useFakeTimers(); | ||
| const snapshot = fixtures.getSnapshot({ | ||
| repository: REPOSITORY_NAME, | ||
| snapshot: `a${getRandomString()}`, |
There was a problem hiding this comment.
Good catch! I copy-pasted this from a different test, not needed here.
|
@elasticmachine merge upstream |
|
Thank you for the review, @sabarasaba! I addressed your comments, could you please have another look? |
| * &searchField=repository&searchValue=test&searchMatch=must&searchOperator=exact | ||
| * would be shown as url=/api/snapshot_restore/snapshots is sinon server | ||
| */ | ||
| jest.mock('../../public/application/services/http', () => ({ |
There was a problem hiding this comment.
Just a note. I haven't made an "official" recommendation for it but personally I like that pattern to declare in a single place all the jest mocks for the component integration tests. It has 2 benefits: 1. reduce the size of the test file and 2. avoid declaring multiple times the same jest.mock(...) declaration.
In my last PR you can see
- the single jest.mocks.ts file
- I import it in a single place in
setup_environment.tswhich all the test file import - Done. 😊
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…astic#121537) * [Snapshot & Restore] Add component tests for snapshot list search * [Snapshot & Restore] Fix term search * [Snapshot & Restore] Add error handling tests * [Snapshot & Restore] Add code review suggestions Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…astic#121537) * [Snapshot & Restore] Add component tests for snapshot list search * [Snapshot & Restore] Fix term search * [Snapshot & Restore] Add error handling tests * [Snapshot & Restore] Add code review suggestions Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit c4585b3)
…astic#121537) * [Snapshot & Restore] Add component tests for snapshot list search * [Snapshot & Restore] Fix term search * [Snapshot & Restore] Add error handling tests * [Snapshot & Restore] Add code review suggestions Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit c4585b3)
|
Backporting this PR to 8.0 and 7.17 to avoid merge conflicts for backports of #125234 and any further bug fixes. |
…21537) (#125617) * [Snapshot & Restore] Add component tests for snapshot list search * [Snapshot & Restore] Fix term search * [Snapshot & Restore] Add error handling tests * [Snapshot & Restore] Add code review suggestions Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit c4585b3)
…21537) (#125618) * [Snapshot & Restore] Add component tests for snapshot list search * [Snapshot & Restore] Fix term search * [Snapshot & Restore] Add error handling tests * [Snapshot & Restore] Add code review suggestions Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit c4585b3) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Related to Snapshot & Restore tests issue
Follow up work for Snapshots pagination PR.
Summary
This PR adds component integration tests for search functionality in snapshots list.
Note: Instead of asserting on sinon fake server requests, I had to mock
useLoadSnapshotsbecause the sinon server doesn't keep track of query params used in the requests (sinon issue I opened for that).