From 2bb8eb020014fd0dfb843925e61417a32585d093 Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Tue, 11 Jun 2024 15:10:41 -0700 Subject: [PATCH] Flakey unit tests fix (#339) * fixed flakey tests Signed-off-by: sumukhswamy * fixed linter issues Signed-off-by: sumukhswamy * added pr in release notes Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- .../Main/__snapshots__/main.test.tsx.snap | 12 +++++++ public/components/Main/main.test.tsx | 35 ++++++++++--------- ...-query-workbench.release-notes-2.15.0.0.md | 2 +- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/public/components/Main/__snapshots__/main.test.tsx.snap b/public/components/Main/__snapshots__/main.test.tsx.snap index ec09cff..a0635e7 100644 --- a/public/components/Main/__snapshots__/main.test.tsx.snap +++ b/public/components/Main/__snapshots__/main.test.tsx.snap @@ -971,6 +971,8 @@ exports[`
spec click run button, and response is not ok 1`] = ` > spec click run button, and response is not ok 1`] = ` > spec click run button, and response is ok 1`] = ` > spec click run button, and response is ok 1`] = ` > spec click run button, response fills null and missing values > spec click run button, response fills null and missing values > spec', () => { }); expect(document.body.children[0]).toMatchSnapshot(); }); - - + it('renders the component and checks if side tree is loaded', async () => { const client = httpClientMock; client.post = jest.fn().mockResolvedValue(mockHttpQuery); @@ -115,13 +114,14 @@ describe('
spec', () => { client.get = jest.fn().mockResolvedValue(mockDatasourcesQuery); client.post = jest.fn().mockResolvedValue(mockQueryResultJDBCResponse); - const { getByText, getByTestId } = await render( + const { getByText } = await render(
); const onRunButton = getByText('Run'); - const pplbutton =getByTestId('PPL'); + const sqlbutton = getByText('SQL'); waitFor(() => { - expect(pplbutton).toBeInTheDocument(); + expect(sqlbutton).toBeInTheDocument(); + fireEvent.click(sqlbutton); }); const asyncTest = () => { fireEvent.click(onRunButton); @@ -135,12 +135,13 @@ describe('
spec', () => { client.post = jest.fn().mockResolvedValue(mockResultWithNull); client.get = jest.fn().mockResolvedValue(mockDatasourcesQuery); - const { getByText ,getByTestId } = await render( + const { getByText } = await render(
); - const pplbutton = getByTestId('PPL'); + const sqlbutton = getByText('SQL'); waitFor(() => { - expect(pplbutton).toBeInTheDocument(); + expect(sqlbutton).toBeInTheDocument(); + fireEvent.click(sqlbutton); }); const onRunButton = getByText('Run'); const asyncTest = () => { @@ -179,12 +180,13 @@ describe('
spec', () => { }); client.get = jest.fn().mockResolvedValue(mockDatasourcesQuery); - const { getByText, getByTestId } = await render( + const { getByText } = await render(
); - const pplbutton = getByTestId("PPL"); + const sqlbutton = getByText('SQL'); waitFor(() => { - expect(pplbutton).toBeInTheDocument(); + expect(sqlbutton).toBeInTheDocument(); + fireEvent.click(sqlbutton); }); const onRunButton = getByText('Run'); const asyncTest = () => { @@ -206,12 +208,13 @@ describe('
spec', () => { } }); - const { getByText,getByTestId } = await render( + const { getByText } = await render(
); - const pplbutton = getByTestId("PPL"); + const sqlbutton = getByText('SQL'); waitFor(() => { - expect(pplbutton).toBeInTheDocument(); + expect(sqlbutton).toBeInTheDocument(); + fireEvent.click(sqlbutton); }); const onTranslateButton = getByText('Explain'); const asyncTest = () => { @@ -238,4 +241,4 @@ describe('
spec', () => { await asyncTest(); expect(document.body.children[0]).toMatchSnapshot(); }); -}); \ No newline at end of file +}); diff --git a/release-notes/opensearch-query-workbench.release-notes-2.15.0.0.md b/release-notes/opensearch-query-workbench.release-notes-2.15.0.0.md index c728de3..13adbe8 100644 --- a/release-notes/opensearch-query-workbench.release-notes-2.15.0.0.md +++ b/release-notes/opensearch-query-workbench.release-notes-2.15.0.0.md @@ -5,7 +5,7 @@ Compatible with OpenSearch and OpenSearch Dashboards 2.15.0 ### Bug Fixes - added fix for runAsync query without mds id ([#323](https://github.com/opensearch-project/dashboards-query-workbench/pull/323)) - +- Flakey unit tests fix ([#339](https://github.com/opensearch-project/dashboards-query-workbench/pull/339)) ### Maintenance