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

chore(Pagination): Add e2e snapshot tests for pagination #5297

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
62 changes: 62 additions & 0 deletions e2e/components/Pagination.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'

const stories = [
{
title: 'Default',
id: 'components-pagination--default',
},
{
title: 'Dev Default',
id: 'components-pagination-dev--dev-default',
},
{
title: 'Hide Page Numbers',
id: 'components-pagination-features--hide-page-numbers',
},
{
title: 'Hide Page Numbers By Viewport',
id: 'components-pagination-features--hide-page-numbers-by-viewport&globals=viewport:small',
},
{
title: 'Higher Surrounding Page Count',
id: 'components-pagination-features--higher-surrounding-page-count&globals=viewport:small',
},
{
title: 'Larger Page Count Margin',
id: 'components-pagination-features--larger-page-count-margin&globals=viewport:small',
},
] as const

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

// Default state
expect(await page.screenshot()).toMatchSnapshot(`Pagehead.${story.title}.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: story.id,
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})
}
})
13 changes: 13 additions & 0 deletions packages/react/src/Pagination/Pagination.dev.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import type {Meta} from '@storybook/react'
import type {ComponentProps} from '../utils/types'
import Pagination from './Pagination'

export default {
title: 'Components/Pagination/Dev',
component: Pagination,
} as Meta<ComponentProps<typeof Pagination>>

export const DevDefault = () => (
<Pagination pageCount={15} currentPage={2} onPageChange={e => e.preventDefault()} showPages={{narrow: false}} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current Pagination component doesn't seem to support any custom styling around sx for style. Is this something we want to add as part of the CSS module migration work?

Copy link
Member

Choose a reason for hiding this comment

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

Na, if it's not supported we want to avoid adding it

)
Loading