Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pog, Toast, Tooltip, Upsell, Video: add visual diff testing and screenshot to description in VSCode (Flow extension) #2057

Merged
merged 1 commit into from Apr 8, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Pog-dark_spec.js
@@ -0,0 +1,15 @@
describe('Pog visual dark mode regression check', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these files be Flow typed? Have we been add Flow annotations to the other visual test files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we been add Flow annotations to the other visual test files?
NO

beforeEach(() => {
cy.visit('/visual-test/Pog-dark');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Pog-dark',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Pog_spec.js
@@ -0,0 +1,15 @@
describe('Pog visual regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Pog');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Pog',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Toast-dark_spec.js
@@ -0,0 +1,15 @@
describe('Toast visual dark mode regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Toast-dark');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Toast-dark',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Toast_spec.js
@@ -0,0 +1,15 @@
describe('Toast visual regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Toast');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Toast',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
17 changes: 17 additions & 0 deletions cypress/integration/visual-test/Tooltip-dark_spec.js
@@ -0,0 +1,17 @@
describe('Tooltip visual dark mode regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Tooltip-dark');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').find('button').first().focus();

cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Tooltip-dark',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
17 changes: 17 additions & 0 deletions cypress/integration/visual-test/Tooltip_spec.js
@@ -0,0 +1,17 @@
describe('Tooltip visual regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Tooltip');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').find('button').first().focus();

cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Tooltip',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Upsell-dark_spec.js
@@ -0,0 +1,15 @@
describe('Upsell dark mode visual regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Upsell-dark');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Upsell-dark',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Upsell_spec.js
@@ -0,0 +1,15 @@
describe('Upsell visual regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Upsell');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Upsell',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/visual-test/Video_spec.js
@@ -0,0 +1,15 @@
describe('Video visual regression check', () => {
beforeEach(() => {
cy.visit('/visual-test/Video');
});

it('Compares snapshots', () => {
cy.get('[data-test-id="visual-test"]').toMatchImageSnapshot({
name: 'Video',
imageConfig: {
threshold: 0.001,
thresholdType: 'percent',
},
});
});
});
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.
36 changes: 36 additions & 0 deletions docs/pages/visual-test/Pog-dark.js
@@ -0,0 +1,36 @@
// @flow strict
import { type Node } from 'react';
import { Text, Flex, Pog, Box, ColorSchemeProvider } from 'gestalt';

export default function Screenshot(): Node {
return (
<ColorSchemeProvider colorScheme="dark">
<Box color="white" display="inlineBlock" padding={1}>
<Flex direction="column" gap={4}>
<Flex gap={4}>
<Flex direction="column" gap={1}>
<Text>Default</Text>
<Pog icon="heart" iconColor="red" />
</Flex>
<Flex direction="column" gap={1}>
<Text>Hovered</Text>
<Pog icon="heart" iconColor="red" hovered />
</Flex>
<Flex direction="column" gap={1}>
<Text>Focused</Text>
<Pog icon="heart" iconColor="red" focused />
</Flex>
<Flex direction="column" gap={1}>
<Text>Active</Text>
<Pog icon="heart" iconColor="red" active />
</Flex>
<Flex direction="column" gap={1}>
<Text>Selected</Text>
<Pog icon="heart" iconColor="red" selected />
</Flex>
</Flex>
</Flex>
</Box>
</ColorSchemeProvider>
);
}
34 changes: 34 additions & 0 deletions docs/pages/visual-test/Pog.js
@@ -0,0 +1,34 @@
// @flow strict
import { type Node } from 'react';
import { Pog, Text, Flex, Box } from 'gestalt';

export default function Screenshot(): Node {
return (
<Box color="white" display="inlineBlock" padding={1}>
<Flex direction="column" gap={4}>
<Flex gap={4}>
<Flex direction="column" gap={1}>
<Text>Default</Text>
<Pog icon="heart" iconColor="red" />
</Flex>
<Flex direction="column" gap={1}>
<Text>Hovered</Text>
<Pog icon="heart" iconColor="red" hovered />
</Flex>
<Flex direction="column" gap={1}>
<Text>Focused</Text>
<Pog icon="heart" iconColor="red" focused />
</Flex>
<Flex direction="column" gap={1}>
<Text>Active</Text>
<Pog icon="heart" iconColor="red" active />
</Flex>
<Flex direction="column" gap={1}>
<Text>Selected</Text>
<Pog icon="heart" iconColor="red" selected />
</Flex>
</Flex>
</Flex>
</Box>
);
}
34 changes: 16 additions & 18 deletions docs/pages/visual-test/Tag.js
@@ -1,25 +1,23 @@
// @flow strict
import { type Node } from 'react';
import { ColorSchemeProvider, Flex, Tag } from 'gestalt';
import { Flex, Tag } from 'gestalt';

export default function Snapshot(): Node {
return (
<ColorSchemeProvider colorScheme="light">
<Flex direction="column" gap={2}>
<Tag onRemove={() => {}} removeIconAccessibilityLabel="Remove" text="New" />
<Tag disabled text="Disabled" />
<Tag
onRemove={() => {}}
errorMessage="NOPE"
removeIconAccessibilityLabel="Remove"
text="Error"
/>
<Tag
onRemove={() => {}}
removeIconAccessibilityLabel="Remove"
text="Some really long text that just keeps going on and on and on and on and on and on"
/>
</Flex>
</ColorSchemeProvider>
<Flex direction="column" gap={2}>
<Tag onRemove={() => {}} removeIconAccessibilityLabel="Remove" text="New" />
<Tag disabled text="Disabled" />
<Tag
onRemove={() => {}}
errorMessage="NOPE"
removeIconAccessibilityLabel="Remove"
text="Error"
/>
<Tag
onRemove={() => {}}
removeIconAccessibilityLabel="Remove"
text="Some really long text that just keeps going on and on and on and on and on and on"
/>
</Flex>
);
}
24 changes: 24 additions & 0 deletions docs/pages/visual-test/Toast-dark.js
@@ -0,0 +1,24 @@
// @flow strict
import { type Node } from 'react';
import { ColorSchemeProvider, Toast, Button, Image, Box } from 'gestalt';

export default function Snapshot(): Node {
return (
<ColorSchemeProvider colorScheme="dark">
<Box color="white">
<Toast
button={<Button key="button-key" text="Undo" size="lg" />}
text="Home decor"
thumbnail={
<Image
alt="Modern ceramic vase pin."
naturalHeight={564}
naturalWidth={564}
src="https://i.ibb.co/Lx54BCT/stock1.jpg"
/>
}
/>
</Box>
</ColorSchemeProvider>
);
}
20 changes: 20 additions & 0 deletions docs/pages/visual-test/Toast.js
@@ -0,0 +1,20 @@
// @flow strict
import { type Node } from 'react';
import { Toast, Button, Image } from 'gestalt';

export default function Snapshot(): Node {
return (
<Toast
button={<Button key="button-key" text="Undo" size="lg" />}
text="Home decor"
thumbnail={
<Image
alt="Modern ceramic vase pin."
naturalHeight={564}
naturalWidth={564}
src="https://i.ibb.co/Lx54BCT/stock1.jpg"
/>
}
/>
);
}
21 changes: 21 additions & 0 deletions docs/pages/visual-test/Tooltip-dark.js
@@ -0,0 +1,21 @@
// @flow strict
import { type Node } from 'react';
import { ColorSchemeProvider, Tooltip, IconButton, Box } from 'gestalt';

export default function Snapshot(): Node {
return (
<ColorSchemeProvider colorScheme="dark">
<Box color="white" padding={4} width={150}>
<Tooltip idealDirection="right" inline text="Share" accessibilityLabel="">
<IconButton
accessibilityLabel="Share this Pin"
bgColor="white"
icon="share"
iconColor="darkGray"
size="lg"
/>
</Tooltip>
</Box>
</ColorSchemeProvider>
);
}
19 changes: 19 additions & 0 deletions docs/pages/visual-test/Tooltip.js
@@ -0,0 +1,19 @@
// @flow strict
import { type Node } from 'react';
import { Tooltip, IconButton, Box } from 'gestalt';

export default function Snapshot(): Node {
return (
<Box color="white" padding={4} width={150}>
<Tooltip idealDirection="right" inline text="Share" accessibilityLabel="">
<IconButton
accessibilityLabel="Share this Pin"
bgColor="white"
icon="share"
iconColor="darkGray"
size="lg"
/>
</Tooltip>
</Box>
);
}
29 changes: 29 additions & 0 deletions docs/pages/visual-test/Upsell-dark.js
@@ -0,0 +1,29 @@
// @flow strict
import { type Node } from 'react';
import { Upsell, Box, ColorSchemeProvider, Icon } from 'gestalt';

export default function Snapshot(): Node {
return (
<ColorSchemeProvider colorScheme="dark">
<Box color="white" padding={5}>
<Upsell
dismissButton={{
accessibilityLabel: 'Dismiss banner',
onDismiss: () => {},
}}
imageData={{
component: <Icon icon="pinterest" accessibilityLabel="" color="darkGray" size={32} />,
}}
message="Earn $60 of ads credit, and give $30 of ads credit to a friend"
primaryAction={{
href: 'https://pinterest.com',
label: 'Send invite',
accessibilityLabel: 'Invite friend to use ads',
target: 'blank',
}}
title="Give $30, get $60 in ads credit"
/>
</Box>
</ColorSchemeProvider>
);
}