From e5bb28cf34daebf7e3e7010f85001de9c5bcf63b Mon Sep 17 00:00:00 2001 From: istarkov Date: Tue, 31 Dec 2024 09:59:09 +0000 Subject: [PATCH] Fix test --- .../webstudio-component/get-browser-style.ts | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/builder/app/canvas/features/webstudio-component/get-browser-style.ts b/apps/builder/app/canvas/features/webstudio-component/get-browser-style.ts index 4cee48c067fb..3d4694960ef4 100644 --- a/apps/builder/app/canvas/features/webstudio-component/get-browser-style.ts +++ b/apps/builder/app/canvas/features/webstudio-component/get-browser-style.ts @@ -66,6 +66,10 @@ export const getBrowserStyle = ( ): Style => { const browserStyle: Style = {}; + if (process.env.NODE_ENV === "test") { + return browserStyle; + } + if (instanceSelector === undefined) { return browserStyle; } @@ -107,6 +111,10 @@ const defaultUnitSizes: UnitSizes = { export const calculateUnitSizes = ( instanceSelector: InstanceSelector | undefined ): UnitSizes => { + if (process.env.NODE_ENV === "test") { + return defaultUnitSizes; + } + if (instanceSelector === undefined) { return defaultUnitSizes; } @@ -159,21 +167,26 @@ export const calculateUnitSizes = ( export const getElementAndAncestorInstanceTags = ( instanceSelector: Readonly | undefined ) => { + const instanceToTag = new Map([ + [ROOT_INSTANCE_ID, "html"], + ]); + + if (process.env.NODE_ENV === "test") { + return instanceToTag; + } + if (instanceSelector === undefined) { - return; + return instanceToTag; } const elements = getAllElementsByInstanceSelector(instanceSelector); if (elements.length === 0) { - return; + return instanceToTag; } const [element] = elements; - const instanceToTag = new Map([ - [ROOT_INSTANCE_ID, "html"], - ]); for ( let ancestorOrSelf: HTMLElement | null = element; ancestorOrSelf !== null;