Skip to content

Commit c3be530

Browse files
committed
removing unwanted changes
1 parent 5e8dc83 commit c3be530

4 files changed

Lines changed: 49 additions & 59 deletions

File tree

src/__test__/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const waitForHoverOutline = async () => {
4343
);
4444
expect(hoverOutline).not.toBeNull();
4545
});
46-
};
46+
}
4747
export const waitForBuilderSDKToBeInitialized = async (visualBuilderPostMessage: EventManager | undefined) => {
4848
await waitFor(() => {
4949
expect(visualBuilderPostMessage?.send).toBeCalledWith(
@@ -62,7 +62,7 @@ export const triggerAndWaitForClickAction = async (visualBuilderPostMessage: Eve
6262
})
6363
if(!skipWaitForFieldType) {
6464
await waitFor(() => {
65-
expect(element).toHaveAttribute("data-cslp-field-type");
65+
expect(element).toHaveAttribute("data-cslp-field-type")
6666
})
6767
}
6868
}
@@ -72,7 +72,7 @@ export const waitForToolbaxToBeVisible = async () => {
7272
".visual-builder__focused-toolbar__field-label-container"
7373
);
7474
expect(toolbar).not.toBeNull();
75-
})
75+
});
7676
}
7777
const defaultRect = {
7878
left: 10,
@@ -94,4 +94,4 @@ export const asyncRender: (componentChild: ComponentChild) => ReturnType<typeof
9494
returnValue = render(...args);
9595
});
9696
return returnValue;
97-
}
97+
}

src/livePreview/__test__/live-preview.test.ts

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getDefaultConfig } from "../../configManager/config.default";
99
import Config from "../../configManager/configManager";
1010
import { PublicLogger } from "../../logger/logger";
1111
import { ILivePreviewWindowType } from "../../types/types";
12-
import { addLivePreviewQueryTags } from "../../utils/addLivePreviewQueryTags";
12+
import { addLivePreviewQueryTags } from '../../utils/addLivePreviewQueryTags';
1313
import livePreviewPostMessage from "../eventManager/livePreviewEventManager";
1414
import { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from "../eventManager/livePreviewEventManager.constant";
1515
import {
@@ -42,6 +42,7 @@ vi.mock("../../visualBuilder/utils/visualBuilderPostMessage", async () => {
4242
};
4343
});
4444

45+
4546
Object.defineProperty(globalThis, "crypto", {
4647
value: {
4748
getRandomValues: (arr: Array<any>) => crypto.randomBytes(arr.length),
@@ -442,42 +443,31 @@ describe("incoming postMessage", () => {
442443
vi.spyOn(window.history, "go").mockImplementation(() => {});
443444

444445
// for forward
445-
await livePreviewPostMessage?.send(
446-
LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,
447-
{
448-
type: "forward",
449-
} as HistoryLivePreviewPostMessageEventData
450-
);
446+
await livePreviewPostMessage?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY, {
447+
type: "forward",
448+
} as HistoryLivePreviewPostMessageEventData);
451449

452450
expect(window.history.forward).toHaveBeenCalled();
453451

454452
// for back
455-
await livePreviewPostMessage?.send(
456-
LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,
457-
{
458-
type: "backward",
459-
} as HistoryLivePreviewPostMessageEventData
460-
);
453+
await livePreviewPostMessage?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY, {
454+
type: "backward",
455+
} as HistoryLivePreviewPostMessageEventData);
461456

462457
expect(window.history.back).toHaveBeenCalled();
463458

464459
// for reload
465-
await livePreviewPostMessage?.send(
466-
LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,
467-
{
468-
type: "reload",
469-
} as HistoryLivePreviewPostMessageEventData
470-
);
460+
await livePreviewPostMessage?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY, {
461+
type: "reload",
462+
} as HistoryLivePreviewPostMessageEventData);
471463

472464
expect(window.history.go).toHaveBeenCalled();
473465
});
474466
});
475467

476468
describe("testing window event listeners", () => {
477469
let addEventListenerMock: any;
478-
const sendInitEvent = vi
479-
.fn()
480-
.mockImplementation(mockLivePreviewInitEventListener);
470+
const sendInitEvent = vi.fn().mockImplementation(mockLivePreviewInitEventListener);
481471
let livePreviewInstance: LivePreview;
482472

483473
beforeEach(() => {
@@ -518,9 +508,7 @@ describe("testing window event listeners", () => {
518508
});
519509

520510
test("should attach a load event to call requestDataSync if document is not yet loaded", () => {
521-
const readyState = vi
522-
.spyOn(document, "readyState", "get")
523-
.mockReturnValue("loading");
511+
const readyState = vi.spyOn(document, "readyState", "get").mockReturnValue("loading");
524512

525513
Config.replace({
526514
enable: true,
@@ -535,6 +523,7 @@ describe("testing window event listeners", () => {
535523
readyState.mockRestore();
536524
});
537525
test("should handle link click event if ssr is set to true", async () => {
526+
538527
Config.replace({
539528
enable: true,
540529
ssr: true,
@@ -546,15 +535,13 @@ describe("testing window event listeners", () => {
546535

547536
document.body.appendChild(targetElement);
548537
await act(async () => {
549-
livePreviewInstance = new LivePreview();
538+
livePreviewInstance = new LivePreview();
550539
});
551540
await waitFor(() => {
552541
expect(sendInitEvent).toBeCalled();
553-
});
542+
})
554543
await waitFor(() => {
555-
expect(Config.get().stackDetails.contentTypeUid).toBe(
556-
"contentTypeUid"
557-
);
544+
expect(Config.get().stackDetails.contentTypeUid).toBe("contentTypeUid");
558545
});
559546
await act(async () => {
560547
fireEvent.click(targetElement);

src/visualBuilder/__test__/click/fields/number.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,7 @@ describe("When an element is clicked in visual builder mode", () => {
228228
},
229229
},
230230
});
231-
} else if (
232-
eventName ===
233-
VisualBuilderPostMessageEvents.GET_RESOLVED_VARIANT_PERMISSIONS
234-
) {
231+
} else if (eventName === VisualBuilderPostMessageEvents.GET_RESOLVED_VARIANT_PERMISSIONS) {
235232
return Promise.resolve({
236233
update: true,
237234
});

src/visualBuilder/__test__/index.test.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,27 @@ Object.defineProperty(globalThis, "crypto", {
9494
},
9595
});
9696
// Increase the timeout for the test
97-
describe("Visual builder", () => {
98-
beforeAll(() => {
99-
FieldSchemaMap.setFieldSchema(
100-
"all_fields",
101-
getFieldSchemaMap().all_fields
102-
);
103-
Config.set("mode", 2);
104-
vi.spyOn(
105-
document.documentElement,
106-
"clientWidth",
107-
"get"
108-
).mockReturnValue(100);
109-
vi.spyOn(
110-
document.documentElement,
111-
"clientHeight",
112-
"get"
113-
).mockReturnValue(100);
114-
vi.spyOn(document.body, "scrollHeight", "get").mockReturnValue(100);
115-
});
97+
describe(
98+
"Visual builder",
99+
() => {
100+
beforeAll(() => {
101+
FieldSchemaMap.setFieldSchema(
102+
"all_fields",
103+
getFieldSchemaMap().all_fields
104+
);
105+
Config.set("mode", 2);
106+
vi.spyOn(
107+
document.documentElement,
108+
"clientWidth",
109+
"get"
110+
).mockReturnValue(100);
111+
vi.spyOn(
112+
document.documentElement,
113+
"clientHeight",
114+
"get"
115+
).mockReturnValue(100);
116+
vi.spyOn(document.body, "scrollHeight", "get").mockReturnValue(100);
117+
});
116118

117119
beforeEach(() => {
118120
vi.clearAllMocks();
@@ -139,7 +141,9 @@ describe("Visual builder", () => {
139141
);
140142

141143
expect(
142-
document.querySelector('[data-testid="visual-builder__cursor"]')
144+
document.querySelector(
145+
'[data-testid="visual-builder__cursor"]'
146+
)
143147
).toBeInTheDocument();
144148
expect(
145149
document.querySelector(
@@ -159,7 +163,9 @@ describe("Visual builder", () => {
159163
x.destroy();
160164
});
161165

162-
test("should add overlay to DOM when clicked", async () => {
166+
test(
167+
"should add overlay to DOM when clicked",
168+
async () => {
163169
const h1Tag = document.createElement("h1");
164170
h1Tag.textContent = INLINE_EDITABLE_FIELD_VALUE;
165171
h1Tag.setAttribute(

0 commit comments

Comments
 (0)