From df042e70994a8541eda4341c035d99b267202433 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Fri, 17 Dec 2021 13:57:32 +0100 Subject: [PATCH 1/4] [Snapshot & Restore] Add component tests for snapshot list search --- .../client_integration/helpers/index.ts | 2 + .../helpers/snapshot_list.helpers.ts | 62 ++++ .../__jest__/client_integration/home.test.ts | 10 - .../client_integration/snapshot_list.test.tsx | 304 ++++++++++++++++++ .../components/snapshot_search_bar.tsx | 2 +- 5 files changed, 369 insertions(+), 11 deletions(-) create mode 100644 x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts create mode 100644 x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts index e28409871fb4d..fdf8ea8d83868 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts @@ -12,6 +12,7 @@ import { setup as repositoryEditSetup } from './repository_edit.helpers'; import { setup as policyAddSetup } from './policy_add.helpers'; import { setup as policyEditSetup } from './policy_edit.helpers'; import { setup as restoreSnapshotSetup } from './restore_snapshot.helpers'; +import { setup as snapshotListSetup } from './snapshot_list.helpers'; export type { TestBed } from '@kbn/test/jest'; export { nextTick, getRandomString, findTestSubject, delay } from '@kbn/test/jest'; @@ -25,4 +26,5 @@ export const pageHelpers = { policyAdd: { setup: policyAddSetup }, policyEdit: { setup: policyEditSetup }, restoreSnapshot: { setup: restoreSnapshotSetup }, + snapshotList: { setup: snapshotListSetup }, }; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts new file mode 100644 index 0000000000000..9452bcd6f54f3 --- /dev/null +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { act } from 'react-dom/test-utils'; +import { AsyncTestBedConfig, registerTestBed, TestBed } from '@kbn/test/jest'; + +import { BASE_PATH } from '../../../public/application/constants'; +import { SnapshotList } from '../../../public/application/sections/home/snapshot_list'; +import { WithAppDependencies } from './setup_environment'; + +const getTestBedConfig = (query?: string): AsyncTestBedConfig => ({ + memoryRouter: { + initialEntries: [`${BASE_PATH}/snapshots${query ?? ''}`], + componentRoutePath: `${BASE_PATH}/snapshots/:repositoryName?/:snapshotId*`, + }, + doMountAsync: true, +}); + +const initTestBed = (query?: string) => + registerTestBed(WithAppDependencies(SnapshotList), getTestBedConfig(query))(); + +export interface SnapshotListTestBed extends TestBed { + actions: { + clickReloadButton: () => void; + setSearchText: (value: string, advanceTime?: boolean) => void; + }; +} + +const searchBarSelector = 'snapshotListSearch'; +export const setup = async (query?: string): Promise => { + const testBed = await initTestBed(query); + const { find, form, component } = testBed; + + /** + * User Actions + */ + const clickReloadButton = () => { + find('reloadButton').simulate('click'); + }; + + const setSearchText = async (value: string, advanceTime = true) => { + await act(async () => { + form.setInputValue(searchBarSelector, value); + if (advanceTime) { + jest.advanceTimersByTime(500); + } + }); + component.update(); + }; + + return { + ...testBed, + actions: { + clickReloadButton, + setSearchText, + }, + }; +}; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts index e738cea578ca2..60fe9d2bd7128 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts @@ -32,16 +32,6 @@ jest.mock('@kbn/i18n-react', () => { }; }); -jest.mock('../../common/constants', () => { - const original = jest.requireActual('../../common/constants'); - - return { - ...original, - // Mocking this value to a lower number in order to more easily trigger the max snapshots warning in the tests - SNAPSHOT_LIST_MAX_SIZE: 2, - }; -}); - const removeWhiteSpaceOnArrayValues = (array: any[]) => array.map((value) => { if (!value.trim) { diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx new file mode 100644 index 0000000000000..84aa9f81e943d --- /dev/null +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx @@ -0,0 +1,304 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { act } from 'react-dom/test-utils'; +import { EuiSearchBoxProps } from '@elastic/eui/src/components/search_bar/search_box'; + +import { useLoadSnapshots } from '../../public/application/services/http'; +import { DEFAULT_SNAPSHOT_LIST_PARAMS } from '../../public/application/lib'; + +import * as fixtures from '../../test/fixtures'; +import { SnapshotListTestBed } from './helpers/snapshot_list.helpers'; +import { REPOSITORY_NAME } from './helpers/constant'; +import { pageHelpers, getRandomString } from './helpers'; + +/* + * We are mocking useLoadSnapshots instead of sinon fake server because it's not + * spying on url parameters used in requests, for example /api/snapshot_restore/snapshots + * ?sortField=startTimeInMillis&sortDirection=desc&pageIndex=0&pageSize=20 + * &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', () => ({ + useLoadSnapshots: jest.fn(), + setUiMetricServiceSnapshot: () => {}, + setUiMetricService: () => {}, +})); + +/* + * Mocking EuiSearchBar because its onChange is not firing during tests + */ +jest.mock('@elastic/eui/lib/components/search_bar/search_box', () => { + return { + EuiSearchBox: (props: EuiSearchBoxProps) => ( + ) => { + props.onSearch(event.target.value); + }} + /> + ), + }; +}); + +const { setup } = pageHelpers.snapshotList; + +describe('', () => { + let testBed: SnapshotListTestBed; + let setSearchText: SnapshotListTestBed['actions']['setSearchText']; + + beforeAll(() => { + jest.useFakeTimers(); + const snapshot = fixtures.getSnapshot({ + repository: REPOSITORY_NAME, + snapshot: `a${getRandomString()}`, + }); + const snapshots = [snapshot]; + (useLoadSnapshots as jest.Mock).mockReturnValue({ + error: null, + isInitialRequest: false, + isLoading: false, + data: { + snapshots, + repositories: [REPOSITORY_NAME], + policies: [], + errors: {}, + total: snapshots.length, + }, + resendRequest: () => {}, + }); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + + beforeEach(async () => { + testBed = await setup(); + ({ + actions: { setSearchText }, + } = testBed); + }); + + describe('search', () => { + describe('url parameters', () => { + test('query is updated with repository name from the url', async () => { + testBed = await setup('?repository=test_repo'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'repository', + searchValue: 'test_repo', + searchMatch: 'must', + searchOperator: 'exact', + }); + }); + + test('query is updated with snapshot policy name from the url', async () => { + testBed = await setup('?policy=test_policy'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'policyName', + searchValue: 'test_policy', + searchMatch: 'must', + searchOperator: 'exact', + }); + }); + + test('query is not updated with unknown params from the url', async () => { + testBed = await setup('?some_param=test_param'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + }); + }); + }); + + describe('debounce', () => { + test('waits after input to update list params for search', async () => { + await setSearchText('snapshot=test_snapshot', false); + // the last request was without any search params + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + }); + // advance the timers until after the debounce timeout + // we use act because the component is updated when the timers advance + act(() => { + jest.advanceTimersByTime(500); + }); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must', + searchOperator: 'exact', + }); + }); + }); + + describe('query parsing', () => { + describe('snapshot', () => { + test('term search is converted to partial snapshot search', async () => { + await setSearchText('test_snapshot'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must', + searchOperator: 'eq', + }); + }); + + test('excluding term search is converted to partial excluding snapshot search', async () => { + await setSearchText('-test_snapshot'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must_not', + searchOperator: 'eq', + }); + }); + + test('partial snapshot search is parsed', async () => { + await setSearchText('snapshot:test_snapshot'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must', + searchOperator: 'eq', + }); + }); + + test('excluding partial snapshot search is parsed', async () => { + await setSearchText('-snapshot:test_snapshot'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must_not', + searchOperator: 'eq', + }); + }); + + test('exact snapshot search is parsed', async () => { + await setSearchText('snapshot=test_snapshot'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must', + searchOperator: 'exact', + }); + }); + + test('excluding exact snapshot search is parsed', async () => { + await setSearchText('-snapshot=test_snapshot'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'snapshot', + searchValue: 'test_snapshot', + searchMatch: 'must_not', + searchOperator: 'exact', + }); + }); + }); + + describe('repository', () => { + test('partial repository search is parsed', async () => { + await setSearchText('repository:test_repository'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'repository', + searchValue: 'test_repository', + searchMatch: 'must', + searchOperator: 'eq', + }); + }); + + test('excluding partial repository search is parsed', async () => { + await setSearchText('-repository:test_repository'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'repository', + searchValue: 'test_repository', + searchMatch: 'must_not', + searchOperator: 'eq', + }); + }); + + test('exact repository search is parsed', async () => { + await setSearchText('repository=test_repository'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'repository', + searchValue: 'test_repository', + searchMatch: 'must', + searchOperator: 'exact', + }); + }); + + test('excluding exact repository search is parsed', async () => { + await setSearchText('-repository=test_repository'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'repository', + searchValue: 'test_repository', + searchMatch: 'must_not', + searchOperator: 'exact', + }); + }); + }); + + describe('policy', () => { + test('partial policy search is parsed', async () => { + await setSearchText('policyName:test_policy'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'policyName', + searchValue: 'test_policy', + searchMatch: 'must', + searchOperator: 'eq', + }); + }); + + test('excluding partial policy search is parsed', async () => { + await setSearchText('-policyName:test_policy'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'policyName', + searchValue: 'test_policy', + searchMatch: 'must_not', + searchOperator: 'eq', + }); + }); + + test('exact policy search is parsed', async () => { + await setSearchText('policyName=test_policy'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'policyName', + searchValue: 'test_policy', + searchMatch: 'must', + searchOperator: 'exact', + }); + }); + + test('excluding exact policy search is parsed', async () => { + await setSearchText('-policyName=test_policy'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + searchField: 'policyName', + searchValue: 'test_policy', + searchMatch: 'must_not', + searchOperator: 'exact', + }); + }); + }); + }); + }); +}); diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx index a577bdf59563c..047000574de15 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx @@ -152,7 +152,7 @@ export const SnapshotSearchBar: React.FunctionComponent = ({ onChange={onSearchBarChange} toolsLeft={deleteButton} toolsRight={reloadButton} - box={{ schema: searchSchema, incremental: true }} + box={{ schema: searchSchema, incremental: true, 'data-test-subj': 'snapshotListSearch' }} /> {error ? ( From 4fbf2b426156e4f92da001b6999efb0eeccf7f02 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Fri, 17 Dec 2021 15:10:14 +0100 Subject: [PATCH 2/4] [Snapshot & Restore] Fix term search --- .../helpers/snapshot_list.helpers.ts | 25 +++++++------------ .../client_integration/snapshot_list.test.tsx | 4 +-- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts index 9452bcd6f54f3..ab04f6835d467 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts @@ -6,18 +6,17 @@ */ import { act } from 'react-dom/test-utils'; -import { AsyncTestBedConfig, registerTestBed, TestBed } from '@kbn/test/jest'; +import { TestBedConfig, registerTestBed, TestBed } from '@kbn/test/jest'; import { BASE_PATH } from '../../../public/application/constants'; import { SnapshotList } from '../../../public/application/sections/home/snapshot_list'; import { WithAppDependencies } from './setup_environment'; -const getTestBedConfig = (query?: string): AsyncTestBedConfig => ({ +const getTestBedConfig = (query?: string): TestBedConfig => ({ memoryRouter: { initialEntries: [`${BASE_PATH}/snapshots${query ?? ''}`], componentRoutePath: `${BASE_PATH}/snapshots/:repositoryName?/:snapshotId*`, }, - doMountAsync: true, }); const initTestBed = (query?: string) => @@ -25,7 +24,6 @@ const initTestBed = (query?: string) => export interface SnapshotListTestBed extends TestBed { actions: { - clickReloadButton: () => void; setSearchText: (value: string, advanceTime?: boolean) => void; }; } @@ -33,29 +31,24 @@ export interface SnapshotListTestBed extends TestBed { const searchBarSelector = 'snapshotListSearch'; export const setup = async (query?: string): Promise => { const testBed = await initTestBed(query); - const { find, form, component } = testBed; - - /** - * User Actions - */ - const clickReloadButton = () => { - find('reloadButton').simulate('click'); - }; + const { form, component } = testBed; const setSearchText = async (value: string, advanceTime = true) => { await act(async () => { form.setInputValue(searchBarSelector, value); - if (advanceTime) { - jest.advanceTimersByTime(500); - } }); component.update(); + if (advanceTime) { + await act(async () => { + jest.advanceTimersByTime(500); + }); + component.update(); + } }; return { ...testBed, actions: { - clickReloadButton, setSearchText, }, }; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx index 84aa9f81e943d..04fe7222f20dd 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx @@ -142,11 +142,11 @@ describe('', () => { describe('query parsing', () => { describe('snapshot', () => { test('term search is converted to partial snapshot search', async () => { - await setSearchText('test_snapshot'); + await setSearchText('term_snapshot_search'); expect(useLoadSnapshots).lastCalledWith({ ...DEFAULT_SNAPSHOT_LIST_PARAMS, searchField: 'snapshot', - searchValue: 'test_snapshot', + searchValue: 'term_snapshot_search', searchMatch: 'must', searchOperator: 'eq', }); From 5784f384e625f43a0693ea5c6397a1ab8d30eae3 Mon Sep 17 00:00:00 2001 From: Yulia Cech Date: Fri, 17 Dec 2021 15:55:04 +0100 Subject: [PATCH 3/4] [Snapshot & Restore] Add error handling tests --- .../helpers/snapshot_list.helpers.ts | 16 +++++++- .../client_integration/snapshot_list.test.tsx | 37 ++++++++++++++++++- .../components/snapshot_search_bar.tsx | 1 + 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts index ab04f6835d467..176e5714f1308 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts @@ -25,13 +25,17 @@ const initTestBed = (query?: string) => export interface SnapshotListTestBed extends TestBed { actions: { setSearchText: (value: string, advanceTime?: boolean) => void; + searchErrorExists: () => boolean; + getSearchErrorText: () => string; }; } const searchBarSelector = 'snapshotListSearch'; +const searchErrorSelector = 'snapshotListSearchError'; + export const setup = async (query?: string): Promise => { const testBed = await initTestBed(query); - const { form, component } = testBed; + const { form, component, find, exists } = testBed; const setSearchText = async (value: string, advanceTime = true) => { await act(async () => { @@ -46,10 +50,20 @@ export const setup = async (query?: string): Promise => { } }; + const searchErrorExists = (): boolean => { + return exists(searchErrorSelector); + }; + + const getSearchErrorText = (): string => { + return find(searchErrorSelector).text(); + }; + return { ...testBed, actions: { setSearchText, + searchErrorExists, + getSearchErrorText, }, }; }; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx index 04fe7222f20dd..6d7fba100a4df 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx @@ -51,6 +51,8 @@ const { setup } = pageHelpers.snapshotList; describe('', () => { let testBed: SnapshotListTestBed; let setSearchText: SnapshotListTestBed['actions']['setSearchText']; + let searchErrorExists: SnapshotListTestBed['actions']['searchErrorExists']; + let getSearchErrorText: SnapshotListTestBed['actions']['getSearchErrorText']; beforeAll(() => { jest.useFakeTimers(); @@ -81,7 +83,7 @@ describe('', () => { beforeEach(async () => { testBed = await setup(); ({ - actions: { setSearchText }, + actions: { setSearchText, searchErrorExists, getSearchErrorText }, } = testBed); }); @@ -300,5 +302,38 @@ describe('', () => { }); }); }); + + describe('error handling', () => { + test(`doesn't allow more than 1 terms in the query`, async () => { + await setSearchText('term1 term2'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + }); + expect(searchErrorExists()).toBeTruthy(); + expect(getSearchErrorText()).toEqual( + 'Invalid search: You can only use one clause in the search bar' + ); + }); + + test(`doesn't allow more than 1 clauses in the query`, async () => { + await setSearchText('snapshot=test_snapshot policyName:test_policy'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + }); + expect(searchErrorExists()).toBeTruthy(); + expect(getSearchErrorText()).toEqual( + 'Invalid search: You can only use one clause in the search bar' + ); + }); + + test(`doesn't allow unknown properties in the query`, async () => { + await setSearchText('unknown_field=test'); + expect(useLoadSnapshots).lastCalledWith({ + ...DEFAULT_SNAPSHOT_LIST_PARAMS, + }); + expect(searchErrorExists()).toBeTruthy(); + expect(getSearchErrorText()).toEqual('Invalid search: Unknown field `unknown_field`'); + }); + }); }); }); diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx index 047000574de15..6f873eacceb51 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/components/snapshot_search_bar.tsx @@ -158,6 +158,7 @@ export const SnapshotSearchBar: React.FunctionComponent = ({ {error ? ( <> Date: Mon, 20 Dec 2021 12:06:29 +0100 Subject: [PATCH 4/4] [Snapshot & Restore] Add code review suggestions --- .../__jest__/client_integration/snapshot_list.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx index 6d7fba100a4df..fc00953724428 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/snapshot_list.test.tsx @@ -58,7 +58,7 @@ describe('', () => { jest.useFakeTimers(); const snapshot = fixtures.getSnapshot({ repository: REPOSITORY_NAME, - snapshot: `a${getRandomString()}`, + snapshot: getRandomString(), }); const snapshots = [snapshot]; (useLoadSnapshots as jest.Mock).mockReturnValue({ @@ -121,7 +121,8 @@ describe('', () => { describe('debounce', () => { test('waits after input to update list params for search', async () => { - await setSearchText('snapshot=test_snapshot', false); + const ADVANCE_TIME = false; + await setSearchText('snapshot=test_snapshot', ADVANCE_TIME); // the last request was without any search params expect(useLoadSnapshots).lastCalledWith({ ...DEFAULT_SNAPSHOT_LIST_PARAMS,