(e2e) check default lang attribut of html tag

Asserts that default lang attribute of html tag
matches with the language used by default in
browser for supported languages.
This commit is contained in:
daproclaima
2024-07-01 19:51:00 +02:00
committed by Sebastien Nobour
parent d3589dfca1
commit 2598f3649a

View File

@@ -1,13 +1,14 @@
import { expect, test } from '@playwright/test';
import { BrowserContext, Page, expect, test } from '@playwright/test';
import { LANGUAGES_ALLOWED } from 'app-desk/src/i18n/conf';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
});
test.describe('Language', () => {
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
});
test('checks the language picker', async ({ page }) => {
await expect(
page.getByRole('button', {
@@ -27,7 +28,6 @@ test.describe('Language', () => {
).toBeVisible();
});
// test('checks lang attribute of html tag has same default value as defined');
test('checks lang attribute of html tag updates when user changes language', async ({
page,
}) => {
@@ -43,3 +43,23 @@ test.describe('Language', () => {
await expect(html).toHaveAttribute('lang', 'fr');
});
});
test.describe('Default language', () => {
LANGUAGES_ALLOWED.forEach((language) => {
test(`checks lang attribute of html tag has right value by default for ${language} language`, async ({
browser,
browserName,
}) => {
const context: BrowserContext = await browser.newContext({
locale: language,
});
const page: Page = await context.newPage();
await page.goto('/');
await keyCloakSignIn(page, browserName);
await expect(page.locator('html')).toHaveAttribute('lang', language);
});
});
});