Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add VR tests for mobile search header #1968

Merged
merged 1 commit into from
Nov 18, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions test/playwright/utils/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions test/playwright/utils/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
90 changes: 47 additions & 43 deletions test/playwright/visual-regression/components/header.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,64 +17,66 @@ 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 }) => {
await enableNewHeader(page)
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
})
})
}
Expand Down
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.