Skip to content

Commit

Permalink
test(dialog): fix broken playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Parsium committed Sep 26, 2024
1 parent bf6e5f6 commit a6cbfdf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 36 deletions.
13 changes: 1 addition & 12 deletions playwright/components/alert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,4 @@ const alertDialog = (page: Page) => {
return page.locator(ALERT_DIALOG);
};

const alertChildren = (page: Page) => {
return page.locator('[data-component="alert"] div:nth-of-type(2) div');
};

export {
alert,
alertCrossIcon,
alertTitle,
alertSubtitle,
alertDialog,
alertChildren,
};
export { alert, alertCrossIcon, alertTitle, alertSubtitle, alertDialog };
5 changes: 1 addition & 4 deletions src/components/alert/alert.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
alertCrossIcon,
alertTitle,
alertSubtitle,
alertChildren,
alertDialog,
} from "../../../playwright/components/alert";
import {
Expand Down Expand Up @@ -50,9 +49,7 @@ test.describe("should render Alert component", () => {
test(`with ${text} as children`, async ({ mount, page }) => {
await mount(<AlertComponent title="title">{text}</AlertComponent>);

const children = alertChildren(page);
const alertChildrenText = await children.textContent();
expect(alertChildrenText).toEqual(text);
await expect(page.getByText(text)).toBeVisible();
});
});

Expand Down
65 changes: 45 additions & 20 deletions src/components/date/date.pw.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { expect, test } from "@playwright/experimental-ct-react17";
import dayjs from "dayjs";
import Confirm from "../confirm";
import {
DateInputCustom,
DateInputValidationNewDesign,
Expand Down Expand Up @@ -784,26 +783,52 @@ test.describe("Functionality tests", () => {
await expect(wrapper).toBeVisible();
});

[true, false].forEach((state) => {
test(`should render with disablePortal prop ${state}`, async ({
mount,
page,
}) => {
await mount(
<Confirm open height="60px" onConfirm={() => {}}>
<DateInputCustom disablePortal={state} />
</Confirm>
);
test("date picker does not float above the rest of the page, when disablePortal prop is true", async ({
mount,
page,
}) => {
await mount(
<div
id="clipping-container"
style={{
position: "relative",
overflow: "hidden",
border: "1px solid black",
}}
>
<DateInputCustom disablePortal />
</div>
);

const input = getDataElementByValue(page, "input");
await input.click();
const wrapper = dayPickerWrapper(page);
if (state) {
await expect(wrapper).not.toBeInViewport();
} else {
await expect(wrapper).toBeInViewport();
}
});
const input = page.getByLabel("Date");
await input.click();

const datePicker = dayPickerWrapper(page);
await expect(datePicker).not.toBeInViewport();
});

test("date picker floats above the rest of the page, when disablePortal prop is false", async ({
mount,
page,
}) => {
await mount(
<div
id="clipping-container"
style={{
position: "relative",
overflow: "hidden",
border: "1px solid black",
}}
>
<DateInputCustom disablePortal={false} />
</div>
);

const input = page.getByLabel("Date");
await input.click();

const datePicker = dayPickerWrapper(page);
await expect(datePicker).toBeInViewport();
});

test(`should have the expected border radius styling`, async ({
Expand Down

0 comments on commit a6cbfdf

Please sign in to comment.