From 1efe57a719cc54699bb2475b0df03f17dcf84cf9 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Sat, 29 Jun 2024 19:10:29 +0200 Subject: [PATCH] chore(website): mock ResizeObserver, neccesary for headlessui v2 see https://github.com/tailwindlabs/headlessui/issues/3268 --- website/package-lock.json | 8 ++++++++ website/package.json | 1 + website/vitest.setup.ts | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/website/package-lock.json b/website/package-lock.json index ef587dc95..21422e787 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -78,6 +78,7 @@ "msw": "^2.3.1", "prettier": "3.3.2", "prettier-plugin-astro": "^0.14.0", + "resize-observer-polyfill": "^1.5.1", "sass": "^1.77.6", "tailwindcss": "^3.4.4", "typescript": "^5.5.2", @@ -12668,6 +12669,13 @@ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", "dev": true }, + "node_modules/resize-observer-polyfill": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", + "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==", + "dev": true, + "license": "MIT" + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", diff --git a/website/package.json b/website/package.json index 9f6cb0442..d3d0cbc9a 100644 --- a/website/package.json +++ b/website/package.json @@ -90,6 +90,7 @@ "msw": "^2.3.1", "prettier": "3.3.2", "prettier-plugin-astro": "^0.14.0", + "resize-observer-polyfill": "^1.5.1", "sass": "^1.77.6", "tailwindcss": "^3.4.4", "typescript": "^5.5.2", diff --git a/website/vitest.setup.ts b/website/vitest.setup.ts index dcf83fa66..50748b02c 100755 --- a/website/vitest.setup.ts +++ b/website/vitest.setup.ts @@ -4,7 +4,8 @@ import '@testing-library/jest-dom'; import { HttpStatusCode } from 'axios'; import { http } from 'msw'; import { setupServer } from 'msw/node'; -import { afterAll, afterEach, beforeAll, beforeEach } from 'vitest'; +import ResizeObserver from 'resize-observer-polyfill'; +import { afterAll, afterEach, beforeAll, beforeEach, vi } from 'vitest'; import type { GetSequencesResponse, Group, SequenceEntryToEdit, SubmissionIdMapping } from './src/types/backend.ts'; import type { DetailsResponse, InsertionsResponse, LapisError, MutationsResponse } from './src/types/lapis.ts'; @@ -33,6 +34,10 @@ export const testConfig = { backendKeycloakClientSecret: 'dummy', } as RuntimeConfig; +// Stubbing necessary since headlessui v2 +// See https://github.com/tailwindlabs/headlessui/issues/3268 +vi.stubGlobal('ResizeObserver', ResizeObserver); + export const metadataKey = 'originalMetaDataField'; export const editableEntry = 'originalMetaDataValue'; export const defaultReviewData: SequenceEntryToEdit = {