catalog-graph: work around test race and missing mocks

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-04-04 16:10:49 +02:00
committed by Johan Haals
parent d02c070f8f
commit b60e93994b
@@ -45,6 +45,14 @@ describe('<CatalogGraphPage/>', () => {
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('<CatalogGraphPage/>', () => {
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({