fix: Race condition when running suppressError test.

Co-authored-by: Alois Klink <alois@aloisklink.com>
This commit is contained in:
Sidharth Vinod 2023-09-16 13:33:28 +05:30
parent bd1e7a7c13
commit 56d339b8f0
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 17 additions and 2 deletions

View File

@ -132,7 +132,17 @@ describe('Configuration', () => {
const url = 'http://localhost:9000/suppressError.html?suppressErrorRendering=true';
cy.viewport(1440, 1024);
cy.visit(url);
cy.get('#test');
cy.window().should('have.property', 'rendered', true);
cy.get('#test')
.find('svg')
.should(($svg) => {
expect($svg).to.have.length(2); // all failing diagrams should not appear!
$svg.each((_index, svg) => {
expect(cy.$$(svg)).to.be.visible();
// none of the diagrams should be error diagrams
expect($svg).to.not.contain('Syntax error');
});
});
cy.matchImageSnapshot(
'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set'
);
@ -142,6 +152,7 @@ describe('Configuration', () => {
const url = 'http://localhost:9000/suppressError.html';
cy.viewport(1440, 1024);
cy.visit(url);
cy.window().should('have.property', 'rendered', true);
cy.get('#test');
cy.matchImageSnapshot(
'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set'

View File

@ -46,7 +46,11 @@
import mermaid from './mermaid.esm.mjs';
const shouldSuppress =
new URLSearchParams(window.location.search).get('suppressErrorRendering') === 'true';
mermaid.initialize({ startOnLoad: true, suppressErrorRendering: shouldSuppress });
mermaid.initialize({ startOnLoad: false, suppressErrorRendering: shouldSuppress });
await mermaid.run();
if (window.Cypress) {
window.rendered = true;
}
</script>
</body>
</html>