Skip to content

Commit

Permalink
test(Popover): add visual screenshots
Browse files Browse the repository at this point in the history
test(Popover): add linux screenshots
  • Loading branch information
mainframev committed Nov 21, 2023
1 parent 3d59d4d commit 5a6eaa9
Show file tree
Hide file tree
Showing 43 changed files with 152 additions and 6 deletions.
82 changes: 82 additions & 0 deletions packages/orbit-components/src/Popover/Popover.ct-story.tsx
@@ -0,0 +1,82 @@
import React from "react";
import type { Placement } from "@popperjs/core/lib/enums";

import Text from "../Text";
import Button from "../Button";
import Stepper from "../Stepper";
import Stack from "../Stack";

import Popover from ".";

const content = <Text>Popover content</Text>;

const selects = (
<Stack direction="column">
<Stack flex shrink align="center" justify="between">
<Stack flex direction="column" spacing="none">
<Text>Adult</Text>
<Text type="secondary">11+</Text>
</Stack>
<Stepper minValue={0} />
</Stack>
<Stack flex shrink align="center" justify="between">
<Stack flex direction="column" spacing="none">
<Text>Child</Text>
<Text type="secondary">2-11</Text>
</Stack>
<Stepper minValue={0} />
</Stack>
</Stack>
);

export function DefaultPopover() {
return (
<div className="flex h-screen items-center justify-center">
<Popover opened content={content}>
<Button>open popover</Button>
</Popover>
</div>
);
}

export function PopoverWithCustomWidth() {
return (
<div className="flex h-screen items-center justify-center">
<Popover opened content={content} width="400px">
<Button>open popover</Button>
</Popover>
</div>
);
}

export const PopoverPlacements = ({ placement }: { placement: Placement }) => (
<div className="flex h-screen items-center justify-center">
<Popover opened content={content} placement={placement}>
<Button>open popover</Button>
</Popover>
</div>
);

export const PopoverWithFixedPosition = () => (
<div className="flex h-screen items-center justify-center">
<Popover opened content={content} fixed>
<Button>open popover</Button>
</Popover>
</div>
);

export const PopoverOverlapped = () => (
<div className="flex h-screen items-center justify-center">
<Popover opened content={content} overlapped>
<Button>open popover</Button>
</Popover>
</div>
);

export const PopoverLongContent = () => (
<div className="flex h-screen items-center justify-center">
<Popover opened content={<Stack>{Array.from({ length: 8 }).map(() => selects)}</Stack>}>
<Button>open popover</Button>
</Popover>
</div>
);
64 changes: 64 additions & 0 deletions packages/orbit-components/src/Popover/Popover.ct.tsx
@@ -0,0 +1,64 @@
import * as React from "react";
import { test, expect } from "@playwright/experimental-ct-react";

import {
DefaultPopover,
PopoverWithCustomWidth,
PopoverWithFixedPosition,
PopoverPlacements,
PopoverOverlapped,
PopoverLongContent,
} from "./Popover.ct-story";
import { PLACEMENTS } from "../common/consts";

test.describe("visual Popover", () => {
test(`screenshot for default`, async ({ mount }, { project }) => {
if (project.name === "Desktop") {
const component = await mount(<DefaultPopover />);

await expect(component).toHaveScreenshot();
}
});

Object.values(PLACEMENTS).forEach(placement => {
test(`screenshot for placement ${placement}`, async ({ mount }, { project }) => {
if (project.name === "Desktop") {
const component = await mount(<PopoverPlacements placement={placement} />);

await expect(component).toHaveScreenshot();
}
});
});

test(`screenshot for custom width`, async ({ mount }, { project }) => {
if (project.name === "Desktop") {
const component = await mount(<PopoverWithCustomWidth />);

await expect(component).toHaveScreenshot();
}
});

test(`screenshot for fixed position`, async ({ mount }, { project }) => {
if (project.name === "Desktop") {
const component = await mount(<PopoverWithFixedPosition />);

await expect(component).toHaveScreenshot();
}
});

test(`screenshot for overlapped`, async ({ mount }, { project }) => {
if (project.name === "Desktop") {
const component = await mount(<PopoverOverlapped />);

await expect(component).toHaveScreenshot();
}
});

test(`screenshot for long content`, async ({ mount }, { project }) => {
if (project.name === "Desktop") {
const component = await mount(<PopoverLongContent />);

await expect(component).toHaveScreenshot();
}
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions packages/orbit-components/src/Popover/Popover.stories.tsx
Expand Up @@ -34,22 +34,22 @@ const ScrollWrapper = styled.div`
`;

const selects = (
<>
<Stack align="center">
<Stack spacing="none">
<Stack direction="column">
<Stack flex shrink align="center" justify="between">
<Stack inline direction="column" spacing="none">
<Text>Adult</Text>
<Text type="secondary">11+</Text>
</Stack>
<Stepper minValue={0} />
</Stack>
<Stack align="center">
<Stack spacing="none">
<Stack flex shrink align="center" justify="between">
<Stack inline direction="column" spacing="none">
<Text>Child</Text>
<Text type="secondary">2-11</Text>
</Stack>
<Stepper minValue={0} />
</Stack>
</>
</Stack>
);

const content = <Stack>{selects}</Stack>;
Expand Down

0 comments on commit 5a6eaa9

Please sign in to comment.