Files
Gitea/web_src/js/utils/testhelper.ts
T
silverwind 2b10f77e42 enhance: update mermaid to v12 (#39331)
Update to [mermaid
v12](https://github.com/mermaid-js/mermaid/releases#release-mermaid@12.0.0),
ELK is now the default layout so the plugin and all supporting code is
gone.

Layout switching to previous `dagre` layout via frontmatter works as
expected. Diagrams use the new `neo` default look which renders them
slightly different (smaller boxes) then the `classic` look that was
default in v11.

The `neo` look got some tweaks to remove shadows and gradient to look
better. Also did some related refactors and mermaid dragging now works
on touch devices too.
2026-09-17 23:28:51 +00:00

22 lines
778 B
TypeScript

import {onTestFinished} from 'vitest';
/** Record and block navigations, as a real browser forbids stubbing "window.location" */
export function captureNavigations() {
const navigations: Array<{url: string, type: NavigationType}> = [];
const onNavigate = (e: NavigateEvent) => {
navigations.push({url: e.destination.url, type: e.navigationType});
e.preventDefault();
};
window.navigation.addEventListener('navigate', onNavigate);
onTestFinished(() => window.navigation.removeEventListener('navigate', onNavigate));
return navigations;
}
export function normalizeTestHtml(s: string) {
const lines = s.replace(/>\s+</g, '>\n<').trim().split('\n');
for (let i = 0; i < lines.length; i++) {
lines[i] = lines[i].trim();
}
return lines.join('\n');
}