Skip to content

Commit

Permalink
test(e2e): wait for theme-directives.html
Browse files Browse the repository at this point in the history
The `theme-directives.html` test currently sometimes takes a screenshot
before all of the Mermaid diagrams have completed rendering.

We can use the `urlSnapshopTest()` helper function, which waits until
a `.rendered` property exists on the page.

Co-authored-by: Sidharth Vinod <sidharthv96@gmail.com>
  • Loading branch information
aloisklink and sidharthv96 committed Sep 17, 2023
1 parent 518e277 commit 17f5052
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cypress/integration/rendering/conf-and-directives.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { imgSnapshotTest } from '../../helpers/util.ts';
import { imgSnapshotTest, urlSnapshotTest } from '../../helpers/util.ts';

describe('Configuration and directives - nodes should be light blue', () => {
it('No config - use default', () => {
Expand Down Expand Up @@ -206,8 +206,7 @@ graph TD
describe('when rendering several diagrams', () => {
it('diagrams should not taint later diagrams', () => {
const url = 'http://localhost:9000/theme-directives.html';
cy.visit(url);
cy.matchImageSnapshot('conf-and-directives.spec-when-rendering-several-diagrams-diagram-1');
urlSnapshotTest(url, {});
});
});
});
7 changes: 7 additions & 0 deletions cypress/platform/theme-directives.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ <h1>Nothing set, should be Default</h1>
fontFamily: '"arial", sans-serif',
curve: 'cardinal',
securityLevel: 'strict',
startOnLoad: false,
});

await mermaid.run();

if (window.Cypress) {
window.rendered = true;
}
</script>
</body>
</html>

0 comments on commit 17f5052

Please sign in to comment.