Skip to content

Commit 8e6a56d

Browse files
test: not sending field event in handleFieldInput
1 parent 15452fc commit 8e6a56d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/visualBuilder/utils/__test__/focusOverlayWrapper.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,32 @@ describe("hideFocusOverlay", () => {
270270
);
271271
});
272272

273+
test("should not send update field event when focusFieldReceivedInput is false", async () => {
274+
editedElement.setAttribute("contenteditable", "true");
275+
276+
// Set up global state
277+
VisualBuilder.VisualBuilderGlobalState.value.previousSelectedEditableDOM =
278+
editedElement;
279+
VisualBuilder.VisualBuilderGlobalState.value.focusFieldReceivedInput =
280+
false;
281+
282+
expect(focusOverlayWrapper.classList.contains("visible")).toBe(true);
283+
284+
hideFocusOverlay({
285+
visualBuilderContainer,
286+
visualBuilderOverlayWrapper: focusOverlayWrapper,
287+
focusedToolbar: document.querySelector(".visual-builder__toolbar"),
288+
resizeObserver: mockResizeObserver,
289+
noTrigger: false
290+
});
291+
292+
expect(focusOverlayWrapper.classList.contains("visible")).toBe(false);
293+
294+
await waitFor(() => {
295+
expect(visualBuilderPostMessage?.send).not.toHaveBeenCalled();
296+
});
297+
});
298+
273299
test("should run cleanup function", () => {
274300
// We"ll always click one of the overlays, so we can just grab the first one. Manually pointing the global state to the editedElement as we are not simulating mouse click on window here.
275301
VisualBuilder.VisualBuilderGlobalState.value.previousSelectedEditableDOM =

0 commit comments

Comments
 (0)