diff --git a/test/playwright/utils/breakpoints.ts b/test/playwright/utils/breakpoints.ts index 315b282d85..e7835d9e82 100644 --- a/test/playwright/utils/breakpoints.ts +++ b/test/playwright/utils/breakpoints.ts @@ -21,8 +21,13 @@ type BreakpointBlock = (options: { expectSnapshot: ExpectSnapshot }) => void -const desktopBreakpoints = ['2xl', 'xl', 'lg'] as const -const mobileBreakpoints = ['md', 'sm', 'xs'] as const +export const desktopBreakpoints = ['2xl', 'xl', 'lg'] as const +export const mobileBreakpoints = ['md', 'sm', 'xs'] as const + +export const isMobileBreakpoint = ( + bp: Breakpoint +): bp is typeof mobileBreakpoints[number] => + (mobileBreakpoints as unknown as string[]).includes(bp) // For desktop UA use the default const desktopUa = undefined diff --git a/test/playwright/utils/navigation.ts b/test/playwright/utils/navigation.ts index 727e4f3fd1..c4cf5582fb 100644 --- a/test/playwright/utils/navigation.ts +++ b/test/playwright/utils/navigation.ts @@ -459,10 +459,4 @@ export const enableNewHeader = async (page: Page) => { path: '/', }, ]) - await page.goto('/preferences') - const newHeaderCheckboxLocator = 'input#new_header' - - if (!(await page.locator(newHeaderCheckboxLocator).isChecked())) { - await page.click(newHeaderCheckboxLocator) - } } diff --git a/test/playwright/visual-regression/components/header.spec.ts b/test/playwright/visual-regression/components/header.spec.ts index c9d21450e0..f063bc3b6b 100644 --- a/test/playwright/visual-regression/components/header.spec.ts +++ b/test/playwright/visual-regression/components/header.spec.ts @@ -1,6 +1,8 @@ import { test } from '@playwright/test' -import breakpoints from '~~/test/playwright/utils/breakpoints' +import breakpoints, { + isMobileBreakpoint, +} from '~~/test/playwright/utils/breakpoints' import { hideInputCursors } from '~~/test/playwright/utils/page' import { closeFilters, @@ -15,7 +17,7 @@ test.describe.configure({ mode: 'parallel' }) const headerSelector = '.main-header' -test.describe('header snapshots', () => { +test.describe('header', () => { for (const dir of languageDirections) { test.describe(dir, () => { test.beforeEach(async ({ page }) => { @@ -23,56 +25,58 @@ test.describe('header snapshots', () => { await goToSearchTerm(page, 'birds', { dir }) }) - test.describe('header', () => { - breakpoints.describeEachDesktop(({ expectSnapshot }) => { - test('filters open', async ({ page }) => { - await page.mouse.move(0, 150) - await expectSnapshot( - `filters-open-${dir}`, - page.locator(headerSelector) - ) - }) + breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => { + test('filters open', async ({ page }) => { + await page.mouse.move(0, 150) + await expectSnapshot( + `filters-open-${dir}`, + page.locator(headerSelector) + ) + }) - test('resting', async ({ page }) => { - // By default, filters are open. We need to close them. + test('resting', async ({ page }) => { + // By default, filters are open on desktop. We need to close them. + if (!isMobileBreakpoint(breakpoint)) { await closeFilters(page) - // Make sure the header is not hovered on - await page.mouse.move(0, 150) - await expectSnapshot(`resting-${dir}`, page.locator(headerSelector)) - }) + } + // Make sure the header is not hovered on + await page.mouse.move(0, 150) + await expectSnapshot(`resting-${dir}`, page.locator(headerSelector)) + }) - test('scrolled', async ({ page }) => { + test('scrolled', async ({ page }) => { + if (!isMobileBreakpoint(breakpoint)) { await closeFilters(page) - await scrollToBottom(page) - await page.mouse.move(0, 150) - await sleep(200) - await expectSnapshot( - `scrolled-${dir}`, - page.locator(headerSelector) - ) - }) + } + await scrollToBottom(page) + await page.mouse.move(0, 150) + await sleep(200) + await expectSnapshot(`scrolled-${dir}`, page.locator(headerSelector)) + }) - test('searchbar hovered', async ({ page }) => { + test('searchbar hovered', async ({ page }) => { + if (!isMobileBreakpoint(breakpoint)) { await closeFilters(page) - await page.hover('input') - await hideInputCursors(page) - await expectSnapshot( - `searchbar-hovered-${dir}`, - page.locator(headerSelector) - ) - }) + } + await page.hover('input') + await hideInputCursors(page) + await expectSnapshot( + `searchbar-hovered-${dir}`, + page.locator(headerSelector) + ) + }) - test('searchbar active', async ({ page }) => { + test('searchbar active', async ({ page }) => { + if (!isMobileBreakpoint(breakpoint)) { await closeFilters(page) - await hideInputCursors(page) - await page.click('input') - await expectSnapshot( - `searchbar-active-${dir}`, - page.locator(headerSelector) - ) - }) + } + await hideInputCursors(page) + await page.click('input') + const locator = isMobileBreakpoint(breakpoint) + ? page + : page.locator(headerSelector) + await expectSnapshot(`searchbar-active-${dir}`, locator) }) - // TODO: add mobile tests }) }) } diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-md-linux.png new file mode 100644 index 0000000000..2f04c8b748 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-sm-linux.png new file mode 100644 index 0000000000..a6b0c425b8 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-xs-linux.png new file mode 100644 index 0000000000..bc40c803ac Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-ltr-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-md-linux.png new file mode 100644 index 0000000000..61aa862b9a Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-sm-linux.png new file mode 100644 index 0000000000..7d5defd90e Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-xs-linux.png new file mode 100644 index 0000000000..69c0f73f75 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/filters-open-rtl-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-md-linux.png new file mode 100644 index 0000000000..2f04c8b748 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-sm-linux.png new file mode 100644 index 0000000000..a6b0c425b8 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-xs-linux.png new file mode 100644 index 0000000000..bc40c803ac Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-ltr-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-md-linux.png new file mode 100644 index 0000000000..61aa862b9a Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-sm-linux.png new file mode 100644 index 0000000000..7d5defd90e Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-xs-linux.png new file mode 100644 index 0000000000..69c0f73f75 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/resting-rtl-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-md-linux.png new file mode 100644 index 0000000000..f72fd18c79 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-sm-linux.png new file mode 100644 index 0000000000..dcf6aebc66 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-xs-linux.png new file mode 100644 index 0000000000..d32d99944e Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-ltr-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-md-linux.png new file mode 100644 index 0000000000..0cdad717a4 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-sm-linux.png new file mode 100644 index 0000000000..336a21e0ed Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-xs-linux.png new file mode 100644 index 0000000000..c55cd485ee Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/scrolled-rtl-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-md-linux.png new file mode 100644 index 0000000000..236f8935fc Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-sm-linux.png new file mode 100644 index 0000000000..76fc80e0d3 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-xs-linux.png new file mode 100644 index 0000000000..b56fe6c72d Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-ltr-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-md-linux.png new file mode 100644 index 0000000000..73180d2617 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-sm-linux.png new file mode 100644 index 0000000000..f0ad5b8132 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-xs-linux.png new file mode 100644 index 0000000000..72947ed0b7 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-active-rtl-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-md-linux.png new file mode 100644 index 0000000000..9557737d3a Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-sm-linux.png new file mode 100644 index 0000000000..97587cf3ef Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-xs-linux.png new file mode 100644 index 0000000000..44d29df59f Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-ltr-xs-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-md-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-md-linux.png new file mode 100644 index 0000000000..d73014345b Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-md-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-sm-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-sm-linux.png new file mode 100644 index 0000000000..83009f5d49 Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-sm-linux.png differ diff --git a/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-xs-linux.png b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-xs-linux.png new file mode 100644 index 0000000000..f04415c99d Binary files /dev/null and b/test/playwright/visual-regression/components/header.spec.ts-snapshots/searchbar-hovered-rtl-xs-linux.png differ