35 lines
761 B
JavaScript
Raw Normal View History

/* eslint-env jest */
2019-09-18 18:25:06 +02:00
import { Base64 } from 'js-base64';
export const mermaidUrl = (graphStr, options, api) => {
const obj = {
code: graphStr,
mermaid: options
2019-09-18 18:25:06 +02:00
};
const objStr = JSON.stringify(obj);
let url = 'http://localhost:9000/e2e.html?graph=' + Base64.encodeURI(objStr);
if (api) {
2019-09-18 18:25:06 +02:00
url = 'http://localhost:9000/xss.html?graph=' + graphStr;
}
if (options.listUrl) {
2019-09-18 18:25:06 +02:00
cy.log(options.listId, ' ', url);
}
2019-09-18 18:25:06 +02:00
return url;
};
2019-09-18 18:25:06 +02:00
export const imgSnapshotTest = (graphStr, options, api) => {
const url = mermaidUrl(graphStr, options, api);
cy.visit(url);
2019-09-18 18:25:06 +02:00
cy.get('svg');
cy.percySnapshot();
};
export const renderGraph = (graphStr, options, api) => {
const url = mermaidUrl(graphStr, options, api);
cy.visit(url);
};