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

Test(Overlay): Add e2e testing #5315

Merged
merged 32 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4c843df
test(Overlay): add e2e testing
francinelucca Nov 19, 2024
8232bdf
fix(Overlay): add aria-label to dialog stories
francinelucca Nov 19, 2024
2c86ddd
chore(overlay): add dev story
francinelucca Nov 19, 2024
8148578
test(Overlay): skip story setup in e2e testing
francinelucca Nov 19, 2024
45dbb27
Merge branch 'main' of github.com:primer/react into francinelucca/ove…
francinelucca Nov 21, 2024
61ddc73
fix: wait only until storybook root is attached in storybook settings
francinelucca Nov 21, 2024
20bffa1
test(Overlay): uncomment e2e story setup
francinelucca Nov 21, 2024
e77fb7e
test(vrt): update snapshots
TylerJDev Nov 21, 2024
5d2e416
test
francinelucca Nov 21, 2024
be5e615
test
francinelucca Nov 22, 2024
0e3d4d8
chore(overlay): role correction
francinelucca Nov 22, 2024
3316a8e
test
francinelucca Nov 22, 2024
d17283a
test
francinelucca Nov 22, 2024
35fadb3
test(vrt): update snapshots
francinelucca Nov 22, 2024
b083f07
test
francinelucca Nov 22, 2024
32ba935
Merge branch 'francinelucca/overlay-e2e-testing' of github.com:primer…
francinelucca Nov 22, 2024
b7fdfec
test(vrt): update snapshots
francinelucca Nov 22, 2024
4ea3678
test
francinelucca Nov 25, 2024
7d20206
remove unusued import
francinelucca Nov 25, 2024
e4ce6d2
test(vrt): update snapshots
francinelucca Nov 25, 2024
f6a826b
test
francinelucca Nov 25, 2024
f6667d4
Merge branch 'francinelucca/overlay-e2e-testing' of github.com:primer…
francinelucca Nov 25, 2024
1065328
test
francinelucca Nov 25, 2024
6e1aae0
test
francinelucca Nov 25, 2024
9393541
test(vrt): update snapshots
francinelucca Nov 25, 2024
0ba0397
test
francinelucca Nov 25, 2024
81e20c4
Merge branch 'francinelucca/overlay-e2e-testing' of github.com:primer…
francinelucca Nov 25, 2024
e3099aa
test(vrt): update snapshots
francinelucca Nov 25, 2024
fa0dee4
test(Overlay): add open prop to dev story
francinelucca Nov 25, 2024
2604857
Merge branch 'francinelucca/overlay-e2e-testing' of github.com:primer…
francinelucca Nov 25, 2024
1a66294
Merge branch 'main' into francinelucca/overlay-e2e-testing
francinelucca Nov 25, 2024
9a918ab
test(vrt): update snapshots
francinelucca Nov 25, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions e2e/components/Overlay.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'

const stories = [
{
title: 'Default',
id: 'private-components-overlay--default',
},
{
title: 'Playground',
id: 'private-components-overlay--playground',
},
{
title: 'Dialog Overlay',
id: 'private-components-overlay-features--dialog-overlay',
},
{
title: 'Dropdown Overlay',
id: 'private-components-overlay-features--dropdown-overlay',
},
{
title: 'Memex Issue Overlay',
id: 'private-components-overlay-features--memex-issue-overlay',
},
{
title: 'Memex Nested Overlays',
id: 'private-components-overlay-features--memex-nested-overlays',
},
{
title: 'Nested Overlays',
id: 'private-components-overlay-features--nested-overlays',
},
{
title: 'Overlay On Top Of Overlay',
id: 'private-components-overlay-features--overlay-on-top-of-overlay',
},
{
title: 'Positioned Overlays',
id: 'private-components-overlay-features--positioned-overlays',
},
{
title: 'SX Props',
id: 'private-components-overlay-dev--sx-props',
},
] as const

test.describe('Overlay ', () => {
for (const story of stories) {
test.describe(story.title, () => {
for (const theme of themes) {
test.describe(theme, () => {
test('@vrt', async ({page}) => {
await visit(page, {
id: story.id,
globals: {
colorScheme: theme,
},
args: {
open: true,
},
})

await expect(page).toHaveScreenshot(`Overlay.${story.title}.${theme}.png`, {animations: 'disabled'})
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: story.id,
globals: {
colorScheme: theme,
},
args: {
open: true,
},
})

await expect(page).toHaveNoViolations()
})
})
}
})
}
})
2 changes: 1 addition & 1 deletion e2e/test-helpers/storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function visit(page: Page, options: Options) {

await page.goto(url.toString())
await page.waitForSelector('body.sb-show-main:not(.sb-show-preparing-story)')
await page.waitForSelector('#storybook-root > *')
await page.waitForSelector('#storybook-root > *', {state: 'attached'})

await waitForImages(page)
}
Expand Down
91 changes: 91 additions & 0 deletions packages/react/src/Overlay/Overlay.dev.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React, {useRef, useState} from 'react'
import type {Args, Meta} from '@storybook/react'
import Text from '../Text'
import {Button, IconButton} from '../Button'
import Overlay from './Overlay'
import {useFocusTrap} from '../hooks/useFocusTrap'
import Box from '../Box'
import {XIcon} from '@primer/octicons-react'

export default {
title: 'Private/Components/Overlay/Dev',
component: Overlay,
args: {
open: false,
},
argTypes: {
open: {
control: false,
visible: false,
},
},
} as Meta<typeof Overlay>

export const SxProps = (args: Args) => {
const [isOpen, setIsOpen] = useState(false)
const buttonRef = useRef<HTMLButtonElement>(null)
const confirmButtonRef = useRef<HTMLButtonElement>(null)
const anchorRef = useRef<HTMLDivElement>(null)
const closeOverlay = () => setIsOpen(false)
const containerRef = useRef<HTMLDivElement>(null)
useFocusTrap({
containerRef,
disabled: !isOpen,
})
return (
<Box ref={anchorRef}>
<Button
ref={buttonRef}
onClick={() => {
setIsOpen(!isOpen)
}}
>
Open overlay
</Button>
{isOpen || args.open ? (
<Overlay
initialFocusRef={confirmButtonRef}
returnFocusRef={buttonRef}
ignoreClickRefs={[buttonRef]}
onEscape={closeOverlay}
onClickOutside={closeOverlay}
width="large"
anchorSide="inside-right"
role="dialog"
aria-modal="true"
aria-label="Sample overlay"
ref={containerRef}
sx={{
left: '50%',
mt: 2,
color: 'var(--bgColor-danger-muted)',
}}
style={{padding: '16px'}}
>
<Box
sx={{
height: '100vh',
maxWidth: 'calc(-1rem + 100vw)',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<IconButton
aria-label="Close"
onClick={closeOverlay}
icon={XIcon}
variant="invisible"
sx={{
position: 'absolute',
left: '5px',
top: '5px',
}}
/>
<Text>Look! an overlay</Text>
</Box>
</Overlay>
) : null}
</Box>
)
}
Loading
Loading