Playwright fix (#12883)

* Improved API error handling

* Robustify playwright test

* Adjust playwright test

* Remove comment
This commit is contained in:
Oliver authored and GitHub committed 2026-09-19 11:53:28 +10:00
1 parent 793725def6
commit 668731598c
4 files changed
+22 -10

No files matched your search

+12
View File
@@ -26,6 +26,15 @@ export function extractErrorMessage({
error_data['non_field_errors'];
}
// Fallback to 'errors' array
if (
!message &&
Array.isArray(error_data?.errors) &&
error_data.errors.length > 0
) {
message = error_data.errors[0].message ?? '';
}
// No message? Look at the response status codes
if (!message) {
const status = error.status ?? error.response?.status ?? null;
@@ -47,6 +56,9 @@ export function extractErrorMessage({
case 405:
message = t`Method not allowed`;
break;
case 409:
message = t`Conflict`;
break;
case 500:
message = t`Internal server error`;
break;
@@ -34,6 +34,7 @@ import { useNavigate } from 'react-router-dom';
import { useShallow } from 'zustand/react/shallow';
import { api, queryClient } from '../../../../App';
import { authApi, doLogout } from '../../../../functions/auth';
import { showApiErrorMessage } from '../../../../functions/notifications';
import { useServerApiState } from '../../../../states/ServerApiState';
import { useGlobalSettingsState } from '../../../../states/SettingsStates';
import { QrRegistrationForm } from './QrRegistrationForm';
@@ -476,12 +477,11 @@ function RegisterTOTPModal({
setSecret(error.response?.data?.meta?.secret ?? '');
break;
default:
// Any other error is unexpected
showNotification({
title: t`Error Fetching TOTP Registration`,
message: t`An unexpected error occurred while fetching TOTP registration data.`,
color: 'red'
showApiErrorMessage({
error: error,
title: t`Error Fetching TOTP Registration`
});
throw error;
}
+4 -1
View File
@@ -493,7 +493,10 @@ test('Login - MFA - TOTP', async ({ page }) => {
// Remove TOTP token
await page.getByRole('button', { name: 'remove-totp' }).click();
await page.getByRole('button', { name: 'Remove', exact: true }).click();
await page
.getByLabel('Remove TOTP Token')
.getByRole('button', { name: 'Remove' })
.click();
await page.getByText('TOTP token removed successfully').waitFor();
+1 -4
View File
@@ -608,17 +608,14 @@ test('Settings - Auth - Email', async ({ browser }) => {
await loadTab(page, 'Security');
await page.getByText('Currently no email addresses are registered').waitFor();
await page.getByLabel('email-address-input').fill('test-email@domain.org');
await page.getByLabel('email-address-submit').click();
await page.getByText('Unverified', { exact: true }).waitFor();
await page.getByText('Unverified', { exact: true }).first().waitFor();
await page.getByLabel('test-email@domain.').click();
await page.getByRole('button', { name: 'Make Primary' }).click();
await page.getByText('Primary', { exact: true }).waitFor();
await page.getByRole('button', { name: 'Remove' }).click();
await page.getByText('Currently no email addresses are registered').waitFor();
});
async function testColorPicker(page: Page, ref: string) {