From b60e93994b5fc3609996d611a94835adbe879e41 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 4 Apr 2022 16:10:49 +0200 Subject: [PATCH] catalog-graph: work around test race and missing mocks Signed-off-by: Patrik Oldsberg Co-authored-by: Johan Haals --- .../CatalogGraphPage/CatalogGraphPage.test.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx index 700053bcd7..fc5676e7c9 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.test.tsx @@ -45,6 +45,14 @@ describe('', () => { value: () => ({ width: 100, height: 100 }), configurable: true, }); + Object.defineProperty(window.SVGElement.prototype, 'viewBox', { + value: { baseVal: { x: 0, y: 0, width: 100, height: 100 } }, + configurable: true, + }); + Object.defineProperty(window.MouseEvent.prototype, 'view', { + value: window, + configurable: true, + }); }); beforeEach(() => { @@ -194,6 +202,9 @@ describe('', () => { expect(await 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 userEvent.click(getByText('b:d/e')); expect(analyticsSpy.getEvents()[0]).toMatchObject({