|
1 | 1 | import { expect, test } from '@playwright/test'; |
2 | 2 | import TestData from '../fixtures/testData'; |
3 | 3 | import { setupPageWithoutQuickEscape } from '../fixtures/testHelpers'; |
| 4 | +import { BreathingExercisePage } from '../page-objects'; |
| 5 | +import { expectUiLanguage } from '../fixtures/assertionsHelper'; |
4 | 6 |
|
5 | 7 | test.describe('Navigation', () => { |
6 | 8 | test.beforeEach(async ({ page }) => { |
7 | 9 | await setupPageWithoutQuickEscape(page, TestData.urls.homepage); |
8 | 10 | }); |
9 | 11 |
|
10 | 12 | test.describe('Language Switching', () => { |
11 | | - test('should switch to Spanish when language toggle is clicked', async ({ page }) => { |
12 | | - const languageToggle = page.locator('button').filter({ hasText: 'En' }); |
13 | | - await expect(languageToggle).toBeVisible(); |
14 | | - await expect(page.locator('text="Donate"')).toBeVisible(); |
15 | | - |
16 | | - await languageToggle.click(); |
17 | | - |
18 | | - const spanishToggle = page.locator('button').filter({ hasText: 'Es' }); |
19 | | - await expect(spanishToggle).toBeVisible(); |
20 | | - await expect(page.locator('text="Donar"')).toBeVisible(); |
21 | | - }); |
| 13 | + test('should switch to Spanish when language toggle is clicked', async ({ page }) => { |
| 14 | + const exercise = new BreathingExercisePage(page); |
| 15 | + // Initial state, En |
| 16 | + await expectUiLanguage(page, 'EN'); |
| 17 | + // Change to Es |
| 18 | + await exercise.switchLanguage('ES'); |
| 19 | + // Es language state |
| 20 | + await expectUiLanguage(page, 'ES'); |
| 21 | + }); |
22 | 22 |
|
23 | | - test('should switch back to English when language toggle is clicked again', async ({ page }) => { |
24 | | - const languageToggle = page.locator('button').filter({ hasText: 'En' }); |
25 | | - await languageToggle.click(); |
26 | | - |
27 | | - const spanishToggle = page.locator('button').filter({ hasText: 'Es' }); |
28 | | - await expect(spanishToggle).toBeVisible(); |
29 | | - await expect(page.locator('text="Donar"')).toBeVisible(); |
30 | | - |
31 | | - await spanishToggle.click(); |
32 | | - |
33 | | - const englishToggle = page.locator('button').filter({ hasText: 'En' }); |
34 | | - await expect(englishToggle).toBeVisible(); |
35 | | - await expect(page.locator('text="Donate"')).toBeVisible(); |
36 | | - }); |
| 23 | + test('should switch back to English when language toggle is clicked again', async ({ page }) => { |
| 24 | + const exercise = new BreathingExercisePage(page); |
| 25 | + |
| 26 | + // Go to Es and check |
| 27 | + await exercise.switchLanguage('ES'); |
| 28 | + await expectUiLanguage(page, 'ES'); |
| 29 | + |
| 30 | + // Go back to En and Check |
| 31 | + await exercise.switchLanguage('EN'); |
| 32 | + await expectUiLanguage(page, 'EN'); |
37 | 33 | }); |
| 34 | +}); |
38 | 35 |
|
39 | 36 | test.describe('Quick Escape Feature', () => { |
40 | 37 | test('should display quick escape modal by default', async ({ page }) => { |
|
0 commit comments