mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 15:30:03 +02:00
Merge branch 'develop' into fix-sandbox-utf16
This commit is contained in:
2
.github/workflows/e2e.yml
vendored
2
.github/workflows/e2e.yml
vendored
@@ -131,7 +131,7 @@ jobs:
|
|||||||
VITEST_COVERAGE: true
|
VITEST_COVERAGE: true
|
||||||
CYPRESS_COMMIT: ${{ github.sha }}
|
CYPRESS_COMMIT: ${{ github.sha }}
|
||||||
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
|
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
|
||||||
ARGOS_PARALLEL: ${{ env.CYPRESS_RECORD_KEY != '' }}
|
ARGOS_PARALLEL: ${{ secrets.CYPRESS_RECORD_KEY != '' }}
|
||||||
ARGOS_PARALLEL_TOTAL: 4
|
ARGOS_PARALLEL_TOTAL: 4
|
||||||
ARGOS_PARALLEL_INDEX: ${{ matrix.containers }}
|
ARGOS_PARALLEL_INDEX: ${{ matrix.containers }}
|
||||||
|
|
||||||
|
@@ -19,16 +19,19 @@ export default eyesPlugin(
|
|||||||
}
|
}
|
||||||
return launchOptions;
|
return launchOptions;
|
||||||
});
|
});
|
||||||
addMatchImageSnapshotPlugin(on, config);
|
|
||||||
// copy any needed variables from process.env to config.env
|
// copy any needed variables from process.env to config.env
|
||||||
config.env.useAppli = process.env.USE_APPLI ? true : false;
|
config.env.useAppli = process.env.USE_APPLI ? true : false;
|
||||||
|
config.env.useArgos = !!process.env.ARGOS_TOKEN;
|
||||||
|
|
||||||
// Argos
|
if (config.env.useArgos) {
|
||||||
registerArgosTask(on, config, {
|
// Argos
|
||||||
uploadToArgos: !!process.env.CI,
|
registerArgosTask(on, config, {
|
||||||
token: process.env.ARGOS_TOKEN,
|
uploadToArgos: !!process.env.CI,
|
||||||
});
|
token: process.env.ARGOS_TOKEN,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addMatchImageSnapshotPlugin(on, config);
|
||||||
|
}
|
||||||
// do not forget to return the changed config object!
|
// do not forget to return the changed config object!
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
|
@@ -95,19 +95,8 @@ export const openURLAndVerifyRendering = (
|
|||||||
options: CypressMermaidConfig,
|
options: CypressMermaidConfig,
|
||||||
validation?: any
|
validation?: any
|
||||||
): void => {
|
): void => {
|
||||||
const useAppli: boolean = Cypress.env('useAppli');
|
|
||||||
const name: string = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
const name: string = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
|
|
||||||
if (useAppli) {
|
|
||||||
cy.log(`Opening eyes ${Cypress.spec.name} --- ${name}`);
|
|
||||||
cy.eyesOpen({
|
|
||||||
appName: 'Mermaid',
|
|
||||||
testName: name,
|
|
||||||
batchName: Cypress.spec.name,
|
|
||||||
batchId: batchId + Cypress.spec.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cy.visit(url);
|
cy.visit(url);
|
||||||
cy.window().should('have.property', 'rendered', true);
|
cy.window().should('have.property', 'rendered', true);
|
||||||
cy.get('svg').should('be.visible');
|
cy.get('svg').should('be.visible');
|
||||||
@@ -116,15 +105,28 @@ export const openURLAndVerifyRendering = (
|
|||||||
cy.get('svg').should(validation);
|
cy.get('svg').should(validation);
|
||||||
}
|
}
|
||||||
|
|
||||||
cy.argosScreenshot(name);
|
verifyScreenshot(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const verifyScreenshot = (name: string): void => {
|
||||||
|
const useAppli: boolean = Cypress.env('useAppli');
|
||||||
|
const useArgos: boolean = Cypress.env('useArgos');
|
||||||
|
|
||||||
if (useAppli) {
|
if (useAppli) {
|
||||||
|
cy.log(`Opening eyes ${Cypress.spec.name} --- ${name}`);
|
||||||
|
cy.eyesOpen({
|
||||||
|
appName: 'Mermaid',
|
||||||
|
testName: name,
|
||||||
|
batchName: Cypress.spec.name,
|
||||||
|
batchId: batchId + Cypress.spec.name,
|
||||||
|
});
|
||||||
cy.log(`Check eyes ${Cypress.spec.name}`);
|
cy.log(`Check eyes ${Cypress.spec.name}`);
|
||||||
cy.eyesCheckWindow('Click!');
|
cy.eyesCheckWindow('Click!');
|
||||||
cy.log(`Closing eyes ${Cypress.spec.name}`);
|
cy.log(`Closing eyes ${Cypress.spec.name}`);
|
||||||
cy.eyesClose();
|
cy.eyesClose();
|
||||||
|
} else if (useArgos) {
|
||||||
|
cy.argosScreenshot(name);
|
||||||
} else {
|
} else {
|
||||||
// Argos will take care of this
|
cy.matchImageSnapshot(name);
|
||||||
// cy.matchImageSnapshot(name);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { renderGraph } from '../../helpers/util.ts';
|
import { renderGraph, verifyScreenshot } from '../../helpers/util.ts';
|
||||||
describe('Configuration', () => {
|
describe('Configuration', () => {
|
||||||
describe('arrowMarkerAbsolute', () => {
|
describe('arrowMarkerAbsolute', () => {
|
||||||
it('should handle default value false of arrowMarkerAbsolute', () => {
|
it('should handle default value false of arrowMarkerAbsolute', () => {
|
||||||
@@ -120,7 +120,7 @@ describe('Configuration', () => {
|
|||||||
cy.visit(url);
|
cy.visit(url);
|
||||||
cy.window().should('have.property', 'rendered', true);
|
cy.window().should('have.property', 'rendered', true);
|
||||||
cy.get('svg').should('be.visible');
|
cy.get('svg').should('be.visible');
|
||||||
cy.matchImageSnapshot(
|
verifyScreenshot(
|
||||||
'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
|
'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -145,7 +145,7 @@ describe('Configuration', () => {
|
|||||||
// none of the diagrams should be error diagrams
|
// none of the diagrams should be error diagrams
|
||||||
expect($svg).to.not.contain('Syntax error');
|
expect($svg).to.not.contain('Syntax error');
|
||||||
});
|
});
|
||||||
cy.matchImageSnapshot(
|
verifyScreenshot(
|
||||||
'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set'
|
'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -162,7 +162,7 @@ describe('Configuration', () => {
|
|||||||
// some of the diagrams should be error diagrams
|
// some of the diagrams should be error diagrams
|
||||||
expect($svg).to.contain('Syntax error');
|
expect($svg).to.contain('Syntax error');
|
||||||
});
|
});
|
||||||
cy.matchImageSnapshot(
|
verifyScreenshot(
|
||||||
'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set'
|
'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -39,6 +39,26 @@ describe('flowchart-elk detector', () => {
|
|||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// The error from the issue was reproduced with mindmap, so this is just an example
|
||||||
|
// what matters is the keyword somewhere inside graph definition
|
||||||
|
it('should check only the beginning of the line in search of keywords', () => {
|
||||||
|
expect(
|
||||||
|
detector('mindmap ["Descendant node in flowchart"]', {
|
||||||
|
flowchart: {
|
||||||
|
defaultRenderer: 'elk',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).toBe(false);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
detector('mindmap ["Descendant node in graph"]', {
|
||||||
|
flowchart: {
|
||||||
|
defaultRenderer: 'elk',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('should detect flowchart-elk', () => {
|
it('should detect flowchart-elk', () => {
|
||||||
expect(detector('flowchart-elk')).toBe(true);
|
expect(detector('flowchart-elk')).toBe(true);
|
||||||
});
|
});
|
||||||
|
@@ -11,7 +11,7 @@ const detector: DiagramDetector = (txt, config): boolean => {
|
|||||||
// If diagram explicitly states flowchart-elk
|
// If diagram explicitly states flowchart-elk
|
||||||
/^\s*flowchart-elk/.test(txt) ||
|
/^\s*flowchart-elk/.test(txt) ||
|
||||||
// If a flowchart/graph diagram has their default renderer set to elk
|
// If a flowchart/graph diagram has their default renderer set to elk
|
||||||
(/^\s*flowchart|graph/.test(txt) && config?.flowchart?.defaultRenderer === 'elk')
|
(/^\s*(flowchart|graph)/.test(txt) && config?.flowchart?.defaultRenderer === 'elk')
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user