mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(client): show more descriptive error message on fetchUserError (#64061)
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
+17
-4
@@ -1,10 +1,6 @@
|
||||
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();
|
||||
@@ -15,6 +11,8 @@ const checkFlashMessageVisibility = async (page: Page, translation: string) => {
|
||||
|
||||
test.describe('Flash Message component E2E test', () => {
|
||||
test('Flash Message Visibility for Night Mode Toggle', async ({ page }) => {
|
||||
await page.goto('/settings');
|
||||
|
||||
await page
|
||||
.getByRole('button', { name: translations.buttons.menu, exact: true })
|
||||
.click();
|
||||
@@ -31,6 +29,8 @@ test.describe('Flash Message component E2E test', () => {
|
||||
});
|
||||
|
||||
test('Flash Message Visibility for Sound Mode Toggle', async ({ page }) => {
|
||||
await page.goto('/settings');
|
||||
|
||||
await page
|
||||
.getByLabel(translations.settings.labels['sound-mode'])
|
||||
.getByRole('button', { name: translations.buttons.on })
|
||||
@@ -40,4 +40,17 @@ test.describe('Flash Message component E2E test', () => {
|
||||
translations.flash['updated-sound']
|
||||
);
|
||||
});
|
||||
|
||||
test('should be visible when a network error occurs', async ({ page }) => {
|
||||
await page.route(
|
||||
'*/**/user/get-session-user',
|
||||
async route => await route.fulfill({ status: 500 })
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await checkFlashMessageVisibility(
|
||||
page,
|
||||
translations.flash['user-fetch-error']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user