mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-16 20:49:45 +02:00
Added option to skip screenshot for cypress tests
This commit is contained in:
@@ -6,6 +6,7 @@ interface CypressConfig {
|
|||||||
listUrl?: boolean;
|
listUrl?: boolean;
|
||||||
listId?: string;
|
listId?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
screenshot?: boolean;
|
||||||
}
|
}
|
||||||
type CypressMermaidConfig = MermaidConfig & CypressConfig;
|
type CypressMermaidConfig = MermaidConfig & CypressConfig;
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ export const renderGraph = (
|
|||||||
|
|
||||||
export const openURLAndVerifyRendering = (
|
export const openURLAndVerifyRendering = (
|
||||||
url: string,
|
url: string,
|
||||||
options: CypressMermaidConfig,
|
{ screenshot = true, ...options }: CypressMermaidConfig,
|
||||||
validation?: any
|
validation?: any
|
||||||
): void => {
|
): void => {
|
||||||
const name: string = (options.name ?? cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
const name: string = (options.name ?? cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
@@ -105,7 +106,9 @@ export const openURLAndVerifyRendering = (
|
|||||||
cy.get('svg').should(validation);
|
cy.get('svg').should(validation);
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyScreenshot(name);
|
if (screenshot) {
|
||||||
|
verifyScreenshot(name);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const verifyScreenshot = (name: string): void => {
|
export const verifyScreenshot = (name: string): void => {
|
||||||
|
@@ -1039,7 +1039,7 @@ graph TD
|
|||||||
style C stroke-width:4px,stroke-dasharray: 5
|
style C stroke-width:4px,stroke-dasharray: 5
|
||||||
L_A_B_0@{ animation: slow }
|
L_A_B_0@{ animation: slow }
|
||||||
L_B_D_0@{ animation: fast }`,
|
L_B_D_0@{ animation: fast }`,
|
||||||
{ look: 'handDrawn' }
|
{ look: 'handDrawn', screenshot: false }
|
||||||
);
|
);
|
||||||
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
|
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
|
||||||
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
|
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
|
||||||
|
@@ -775,13 +775,16 @@ describe('Graph', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('40: should add edge animation', () => {
|
it('40: should add edge animation', () => {
|
||||||
renderGraph(`
|
renderGraph(
|
||||||
|
`
|
||||||
flowchart TD
|
flowchart TD
|
||||||
A(["Start"]) L_A_B_0@--> B{"Decision"}
|
A(["Start"]) L_A_B_0@--> B{"Decision"}
|
||||||
B --> C["Option A"] & D["Option B"]
|
B --> C["Option A"] & D["Option B"]
|
||||||
style C stroke-width:4px,stroke-dasharray: 5
|
style C stroke-width:4px,stroke-dasharray: 5
|
||||||
L_A_B_0@{ animation: slow }
|
L_A_B_0@{ animation: slow }
|
||||||
L_B_D_0@{ animation: fast }`);
|
L_B_D_0@{ animation: fast }`,
|
||||||
|
{ screenshot: false }
|
||||||
|
);
|
||||||
// Verify animation classes are applied to both edges
|
// Verify animation classes are applied to both edges
|
||||||
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
|
cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow');
|
||||||
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
|
cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');
|
||||||
|
Reference in New Issue
Block a user