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

Commit

Permalink
Use cookies code from the Playwright PR
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Dec 13, 2022
1 parent 5a14396 commit dbf1398
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 15 additions & 1 deletion test/playwright/utils/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, Page } from '@playwright/test'
import { BrowserContext, expect, Page } from '@playwright/test'

import rtlMessages from '~~/test/locales/ar.json'

Expand Down Expand Up @@ -458,3 +458,17 @@ export const enableNewHeader = async (page: Page) => {
},
])
}

export const setCookies = async (
context: BrowserContext,
cookies: Record<string, string | boolean | string[]>
) => {
await context.addCookies(
Object.entries(cookies).map(([name, value]) => ({
name,
value: JSON.stringify(value),
domain: 'localhost',
path: '/',
}))
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
dismissTranslationBanner,
pathWithDir,
languageDirections,
setCookies,
} from '~~/test/playwright/utils/navigation'

test.describe.configure({ mode: 'parallel' })
Expand All @@ -15,15 +16,12 @@ for (const contentPage of contentPages) {
for (const dir of languageDirections) {
test.describe(`${contentPage} ${dir} page snapshots`, () => {
breakpoints.describeEvery(({ breakpoint, expectSnapshot }) => {
test('full page', async ({ page }) => {
await page.context().addCookies([
{
name: 'uiBreakpoint',
value: JSON.stringify(breakpoint),
domain: 'localhost',
path: '/',
},
])
test('full page', async ({ context, page }) => {
await setCookies(context, {
uiBreakpoint: breakpoint,
uiDismissedBanners: ['translation-ar'],
})

await page.goto(pathWithDir(contentPage, dir))
await dismissTranslationBanner(page)

Expand Down

0 comments on commit dbf1398

Please sign in to comment.