mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-21 06:53:17 +08:00
Merge branch 'fix/1294_add-e2e-test' into fix/1294_exhaustive-clear-sequenceDb-variables
This commit is contained in:
commit
45552451fe
@ -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 => {
|
||||
|
@ -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`,
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
31
cypress/platform/render-diagram-after-error.html
Normal file
31
cypress/platform/render-diagram-after-error.html
Normal 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>
|
Loading…
x
Reference in New Issue
Block a user