Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs
Jacob Overgaard cd72dbe4ea V16: Retry requests after timeout (#19495)
* feat: fix a small-ish nitpick where extensions would reload after login

this could potentially try to re-register all private extensions after each auth signal, which is being prevented anyway because of duplicate aliases, but still nice to remove and not have to listen to

* feat: align login UI extension load with backoffice, i.e. wait for external load before registering core extensions

* build(deps): bump @hey-api to newest and re-generate client

* chore: adds extra error logging

* feat: adds retry logic to the api interceptor

* feat: warn about incomplete actions

* fix: the body was already plain text, but we need to ensure the headers say so as well

* feat: warns the user when actions could not be completed

* build(deps): update @hey-api/client-fetch

* chore: generate new api

* feat: simplify error handling to just UmbApiError and UmbCancelError

* feat: moves error notifications from interceptors into tryExecute, so you more easily can opt out of it and everything is gathered in one place

* feat: recreate responses with correct 'status' and 'statusText'

* build: stop dotnet processes after debug session

* feat: extrapolate common logic into helper method to create responses

* feat: returns a UmbProblemDetails like object on interceptors to be handled by tryExecute

* chore: deprecates duplicate, outdated UmbProblemDetails interface and type guard

* feat: uses the 'title' of the problem details object to convey the main message

* chore: 401 and 403 uses their own interceptors

* feat: show no notification if 401

* feat: uses the real request method and url (instead of the template placeholders) to tell the user what did not succeed

* feat: retry requests with no timeout/race

* feat: throttle and delay signals and disallow them from being updated from the outside

* chore: adds more logging to timeouts

* chore: optimise imports

* test: ignores any test files left in node_modules folder

* feat: uses auditTime to wait a bit before showing the timeout screen

* feat: adds 404 handling to error interceptor

* chore: cleans up after response modification

* feat: preserve only a few headers

this mimicks the v15 behavior

* feat: lets the UI handle 404 errors instead of notifying directly

* test: uses create action menu option instead to find the correct locator, and skips a seemingly unnecessary timeout
2025-06-12 12:24:11 +01:00

83 lines
2.6 KiB
JavaScript

import { esbuildPlugin } from '@web/dev-server-esbuild';
import { playwrightLauncher } from '@web/test-runner-playwright';
import { importMapsPlugin } from '@web/dev-server-import-maps';
import { createImportMap } from './devops/importmap/index.js';
const mode = process.env.MODE || 'dev';
if (!['dev', 'prod'].includes(mode)) {
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
}
const silencedLogs = [
'Lit is in dev mode.',
'Multiple versions of Lit loaded.',
'-- Extension of alias "',
'Error: Failed to create extension api from alias',
'Documentation: ',
'Found an issue? https://github.com/mswjs/msw/issues',
'Worker script URL:',
'Worker scope:',
];
/** @type {import('@web/dev-server').DevServerConfig} */
export default {
rootDir: '.',
files: ['./src/**/*.test.ts', '!**/node_modules/**'],
nodeResolve: { exportConditions: mode === 'dev' ? ['development'] : [], preferBuiltins: false, browser: false },
browsers: [playwrightLauncher({ product: 'chromium' })],
/* TODO: fix coverage report
coverageConfig: {
reporters: ['lcovonly', 'text-summary'],
},
*/
plugins: [
importMapsPlugin({
inject: {
importMap: createImportMap({
rootDir: './src',
additionalImports: {
'@umbraco-cms/internal/test-utils': './utils/test-utils.ts',
},
replaceModuleExtensions: true,
}),
},
}),
esbuildPlugin({ ts: true, tsconfig: './tsconfig.json', target: 'auto', json: true }),
],
filterBrowserLogs(log) {
for (const arg of log.args) {
if (typeof arg === 'string' && silencedLogs.some((l) => arg.includes(l))) {
return false;
}
}
return true;
},
testRunnerHtml: (testFramework, devMode) =>
`<html lang="en-us">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="src/assets/favicon.svg" />
<title>Umbraco</title>
<base href="/" />
<script>
window.__UMBRACO_TEST_RUN_A11Y_TEST = ${(!devMode).toString()};
</script>
<script src="/node_modules/msw/lib/iife/index.js"></script>
<script type="module" src="/web-test-runner.index.ts"></script>
<link rel="stylesheet" href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css">
<link rel="stylesheet" href="src/css/umb-css.css">
<script type="module">
import '@umbraco-cms/backoffice/components';
</script>
</head>
<body>
<script type="module" src="${testFramework}"></script>
<script type="module">
import 'element-internals-polyfill';
import '@umbraco-ui/uui';
</script>
</body>
</html>`,
};