chore: add e2e test that shows db cleanup problem

This commit is contained in:
Faris Nabiev 2023-10-13 00:02:46 +03:00
parent df068dbde8
commit 18ea27ac58
3 changed files with 62 additions and 3 deletions

View File

@ -10,7 +10,7 @@ interface CypressConfig {
type CypressMermaidConfig = MermaidConfig & CypressConfig;
interface CodeObject {
code: string;
code: string | string[];
mermaid: CypressMermaidConfig;
}
@ -25,7 +25,7 @@ const batchId: string =
: Cypress.env('CYPRESS_COMMIT') || Date.now().toString());
export const mermaidUrl = (
graphStr: string,
graphStr: string | string[],
options: CypressMermaidConfig,
api: boolean
): string => {
@ -82,7 +82,7 @@ export const urlSnapshotTest = (
};
export const renderGraph = (
graphStr: string,
graphStr: string | string[],
options: CypressMermaidConfig = {},
api = false
): void => {

View File

@ -930,4 +930,32 @@ context('Sequence diagram', () => {
});
});
});
context('db clear', () => {
it('should render diagram after fixing destroy participant error', () => {
renderGraph([
`sequenceDiagram
Alice->>Bob: Hello Bob, how are you ?
Bob->>Alice: Fine, thank you. And you?
create participant Carl
Alice->>Carl: Hi Carl!
create actor D as Donald
Carl->>D: Hi!
destroy Carl
Alice-xCarl: We are too many
destroy Bo
Bob->>Alice: I agree`,
`sequenceDiagram
Alice->>Bob: Hello Bob, how are you ?
Bob->>Alice: Fine, thank you. And you?
create participant Carl
Alice->>Carl: Hi Carl!
create actor D as Donald
Carl->>D: Hi!
destroy Carl
Alice-xCarl: We are too many
destroy Bob
Bob->>Alice: I agree`,
]);
});
});
});

View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Mermaid Quick Test Page</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
</head>
<body>
<div id="graph"></div>
<script type="module">
import mermaid from './mermaid.esm.mjs';
await mermaid.initialize({ startOnLoad: false });
await mermaid.run();
const searchParams = new URLSearchParams(location.search);
const graphStr = searchParams.get('graphStr ');
const errorGraphStr = searchParams.get('errorGraphStr ');
await mermaid.mermaidAPI.initialize({ securityLevel: 'strict' });
try {
console.log('rendering');
await mermaid.mermaidAPI.render('graphDiv', errorGraphStr);
} catch (e) {}
const { svg } = await mermaid.mermaidAPI.render('graphDiv', graphStr);
document.getElementById('graph').innerHTML = svg;
</script>
</body>
</html>