Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/visualBuilder/__test__/hover/fields/boolean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import visualBuilderPostMessage from "../../../utils/visualBuilderPostMessage";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -64,7 +65,7 @@ describe("When an element is hovered in visual builder mode", () => {
let booleanField: HTMLParagraphElement;
let visualBuilder: VisualBuilder;

beforeEach( async () => {
beforeEach(async () => {
booleanField = document.createElement("p");
booleanField.setAttribute(
"data-cslp",
Expand All @@ -86,7 +87,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
booleanField.dispatchEvent(mousemoveEvent);
await act(async () => {
booleanField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
expect(booleanField).toHaveAttribute("data-cslp", "all_fields.bltapikey.en-us.boolean");
expect(booleanField).not.toHaveAttribute("contenteditable");
Expand Down
5 changes: 4 additions & 1 deletion src/visualBuilder/__test__/hover/fields/date.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Config from "../../../../configManager/configManager";
import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -84,7 +85,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
dataField.dispatchEvent(mousemoveEvent);
await act(async () => {
dataField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
expect(dataField).toHaveAttribute("data-cslp", "all_fields.bltapikey.en-us.date");
expect(dataField).not.toHaveAttribute("contenteditable");
Expand Down
23 changes: 16 additions & 7 deletions src/visualBuilder/__test__/hover/fields/file.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen, waitFor } from "@testing-library/preact";
import { screen, waitFor, act } from "@testing-library/preact";
import { getFieldSchemaMap } from "../../../../__test__/data/fieldSchemaMap";
import { waitForHoverOutline } from "../../../../__test__/utils";
import Config from "../../../../configManager/configManager";
Expand Down Expand Up @@ -56,7 +56,6 @@ describe("When an element is hovered in visual builder mode", () => {
observe: vi.fn(),
disconnect: vi.fn(),
}));

});

beforeEach(() => {
Expand Down Expand Up @@ -111,7 +110,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
fileField.dispatchEvent(mousemoveEvent);
await act(async () => {
fileField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -126,7 +127,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have a outline and custom cursor on the url as well", async () => {
imageField.dispatchEvent(mousemoveEvent);
await act(async () => {
imageField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();

const hoverOutline = document.querySelector(
Expand Down Expand Up @@ -214,7 +217,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -229,7 +234,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor on individual instances", async () => {
firstFileField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstFileField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -247,7 +254,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor on the url", async () => {
firstImageField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstImageField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down
17 changes: 13 additions & 4 deletions src/visualBuilder/__test__/hover/fields/group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { VisualBuilder } from "../../../index";
import { screen } from "@testing-library/preact";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -96,7 +97,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
groupField.dispatchEvent(mousemoveEvent);
await act(async () => {
groupField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down Expand Up @@ -124,7 +127,9 @@ describe("When an element is hovered in visual builder mode", () => {

groupField.appendChild(singleLine);

singleLine.dispatchEvent(mousemoveEvent);
await act(async () => {
singleLine.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down Expand Up @@ -203,7 +208,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -217,7 +224,9 @@ describe("When an element is hovered in visual builder mode", () => {
expect(customCursor).toHaveAttribute('data-icon', 'group');
expect(customCursor?.classList.contains("visible")).toBeTruthy();

firstNestedMultiLine.dispatchEvent(mousemoveEvent);
await act(async () => {
firstNestedMultiLine.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();

const newCustomCursor = document.querySelector(
Expand Down
13 changes: 10 additions & 3 deletions src/visualBuilder/__test__/hover/fields/html-rte.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Config from "../../../../configManager/configManager";
import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -84,7 +85,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
htmlRteField.dispatchEvent(mousemoveEvent);
await act(async () => {
htmlRteField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down Expand Up @@ -149,7 +152,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -165,7 +170,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and cursor on individual instances", async () => {
firstHtmlRteField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstHtmlRteField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down
13 changes: 10 additions & 3 deletions src/visualBuilder/__test__/hover/fields/json-rte.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Config from "../../../../configManager/configManager";
import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -84,7 +85,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
jsonRteField.dispatchEvent(mousemoveEvent);
await act(async () => {
jsonRteField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down Expand Up @@ -149,7 +152,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -165,7 +170,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor on individual instances", async () => {
firstJsonRteField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstJsonRteField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down
13 changes: 10 additions & 3 deletions src/visualBuilder/__test__/hover/fields/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Config from "../../../../configManager/configManager";
import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -84,7 +85,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
linkField.dispatchEvent(mousemoveEvent);
await act(async () => {
linkField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down Expand Up @@ -146,7 +149,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -162,7 +167,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor on individual instances", async () => {
firstLinkField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstLinkField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down
13 changes: 10 additions & 3 deletions src/visualBuilder/__test__/hover/fields/markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Config from "../../../../configManager/configManager";
import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -85,7 +86,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
markdownField.dispatchEvent(mousemoveEvent);
await act(async () => {
markdownField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down Expand Up @@ -150,7 +153,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -166,7 +171,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor on individual instances", async () => {
firstMarkdownField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstMarkdownField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down
13 changes: 10 additions & 3 deletions src/visualBuilder/__test__/hover/fields/multi-line.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Config from "../../../../configManager/configManager";
import { VisualBuilder } from "../../../index";
import { FieldSchemaMap } from "../../../utils/fieldSchemaMap";
import { mockDomRect } from "./mockDomRect";
import { act } from "@testing-library/preact";

vi.mock("../../../utils/visualBuilderPostMessage", async () => {
const { getAllContentTypes } = await vi.importActual<
Expand Down Expand Up @@ -84,7 +85,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
multiLineField.dispatchEvent(mousemoveEvent);
await act(async () => {
multiLineField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = screen.getByTestId(
"visual-builder__hover-outline"
Expand Down Expand Up @@ -148,7 +151,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor", async () => {
container.dispatchEvent(mousemoveEvent);
await act(async () => {
container.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand All @@ -164,7 +169,9 @@ describe("When an element is hovered in visual builder mode", () => {
});

test("should have outline and custom cursor on individual instances", async () => {
firstMultiLineField.dispatchEvent(mousemoveEvent);
await act(async () => {
firstMultiLineField.dispatchEvent(mousemoveEvent);
});
await waitForHoverOutline();
const hoverOutline = document.querySelector(
"[data-testid='visual-builder__hover-outline']"
Expand Down
Loading
Loading