forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash.spec.ts
43 lines (39 loc) · 1.35 KB
/
flash.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { test, expect, type Page } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
test.beforeEach(async ({ page }) => {
await page.goto('/settings');
});
const checkFlashMessageVisibility = async (page: Page, translation: string) => {
const flashMessage = page.getByText(translation);
await expect(flashMessage).toBeVisible();
const closeButton = page.getByRole('button', { name: 'close' });
await closeButton.click();
await expect(flashMessage).not.toBeVisible();
};
test.describe('Flash Message component E2E test', () => {
test('Flash Message Visibility for Night Mode Toggle', async ({ page }) => {
await page
.getByRole('button', { name: translations.buttons.menu, exact: true })
.click();
await page
.getByRole('button', {
name: translations.settings.labels['night-mode'],
exact: true
})
.click();
await checkFlashMessageVisibility(
page,
translations.flash['updated-themes']
);
});
test('Flash Message Visibility for Sound Mode Toggle', async ({ page }) => {
await page
.getByLabel(translations.settings.labels['sound-mode'])
.getByRole('button', { name: translations.buttons.on })
.click();
await checkFlashMessageVisibility(
page,
translations.flash['updated-sound']
);
});
});