From a426ef77a5e126b43e055c9adf6d586f61178012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 4 Sep 2023 13:41:48 +0200 Subject: [PATCH 1/2] fix tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../components/CatalogGraphPage/CatalogGraphPage.test.tsx | 5 +---- plugins/gocd/src/components/Select/Select.test.tsx | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx index 17bec9a475..3d99c83966 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx @@ -194,10 +194,7 @@ describe('', () => { }, ); - expect(await screen.findAllByTestId('node')).toHaveLength(2); - - // We wait a bit here to reliably reproduce an issue where that requires the `baseVal` and `view` mocks - await new Promise(r => setTimeout(r, 100)); + await expect(screen.findAllByTestId('node')).resolves.toHaveLength(2); await userEvent.click(screen.getByText('b:d/e')); diff --git a/plugins/gocd/src/components/Select/Select.test.tsx b/plugins/gocd/src/components/Select/Select.test.tsx index 9d73194ed8..c93b5dd148 100644 --- a/plugins/gocd/src/components/Select/Select.test.tsx +++ b/plugins/gocd/src/components/Select/Select.test.tsx @@ -66,7 +66,7 @@ describe('Select', () => { />, ); user.tab(); - userEvent.keyboard('{enter}'); + await userEvent.keyboard('{enter}'); expect(rendered.getAllByText(testItems[0].label)).toHaveLength(2); expect(rendered.getByText(testItems[1].label)).toBeInTheDocument(); From 689457efd348cea3714c07aa3806873bf0cd1e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 5 Sep 2023 21:08:24 +0200 Subject: [PATCH 2/2] fix test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../CatalogGraphPage.test.tsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx index 3d99c83966..2e215e75f9 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx @@ -111,14 +111,14 @@ describe('', () => { await renderInTestApp(wrapper, { mountedRoutes: { - '/entity/{kind}/{namespace}/{name}': entityRouteRef, + '/entity/:kind/:namespace/:name': entityRouteRef, }, }); expect(screen.getByText('Catalog Graph')).toBeInTheDocument(); - expect(await screen.findByText('b:d/c')).toBeInTheDocument(); - expect(await screen.findByText('b:d/e')).toBeInTheDocument(); - expect(await screen.findAllByTestId('node')).toHaveLength(2); + await expect(screen.findByText('b:d/c')).resolves.toBeInTheDocument(); + await expect(screen.findByText('b:d/e')).resolves.toBeInTheDocument(); + await expect(screen.findAllByTestId('node')).resolves.toHaveLength(2); expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2); }); @@ -129,7 +129,7 @@ describe('', () => { await renderInTestApp(wrapper, { mountedRoutes: { - '/entity/{kind}/{namespace}/{name}': entityRouteRef, + '/entity/:kind/:namespace/:name': entityRouteRef, }, }); @@ -147,15 +147,15 @@ describe('', () => { await renderInTestApp(wrapper, { mountedRoutes: { - '/entity/{kind}/{namespace}/{name}': entityRouteRef, + '/entity/:kind/:namespace/:name': entityRouteRef, }, }); - expect(await screen.findAllByTestId('node')).toHaveLength(2); + await expect(screen.findAllByTestId('node')).resolves.toHaveLength(2); await userEvent.click(screen.getByText('b:d/e')); - expect(await screen.findByText('hasPart')).toBeInTheDocument(); + await expect(screen.findByText('hasPart')).resolves.toBeInTheDocument(); }); test('should navigate to entity', async () => { @@ -165,16 +165,16 @@ describe('', () => { await renderInTestApp(wrapper, { mountedRoutes: { - '/entity/{kind}/{namespace}/{name}': entityRouteRef, + '/entity/:kind/:namespace/:name': entityRouteRef, }, }); - expect(await screen.findAllByTestId('node')).toHaveLength(2); + await expect(screen.findAllByTestId('node')).resolves.toHaveLength(2); const user = userEvent.setup(); await user.keyboard('{Shift>}'); await user.click(screen.getByText('b:d/e')); - expect(navigate).toHaveBeenCalledWith('/entity/{kind}/{namespace}/{name}'); + expect(navigate).toHaveBeenCalledWith('/entity/b/d/e'); }); test('should capture analytics event when selecting other entity', async () => { @@ -189,7 +189,7 @@ describe('', () => { , { mountedRoutes: { - '/entity/{kind}/{namespace}/{name}': entityRouteRef, + '/entity/:kind/:namespace/:name': entityRouteRef, }, }, ); @@ -216,12 +216,12 @@ describe('', () => { , { mountedRoutes: { - '/entity/{kind}/{namespace}/{name}': entityRouteRef, + '/entity/:kind/:namespace/:name': entityRouteRef, }, }, ); - expect(await screen.findAllByTestId('node')).toHaveLength(2); + await expect(screen.findAllByTestId('node')).resolves.toHaveLength(2); const user = userEvent.setup(); await user.keyboard('{Shift>}'); @@ -231,7 +231,7 @@ describe('', () => { action: 'click', subject: 'b:d/e', attributes: { - to: '/entity/{kind}/{namespace}/{name}', + to: '/entity/b/d/e', }, }); });