mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-17 03:04:07 +01:00
e2e test for stricter security in mermaid
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
/* eslint-env jest */
|
||||
import { Base64 } from 'js-base64'
|
||||
|
||||
export const mermaidUrl = (graphStr, options) => {
|
||||
export const mermaidUrl = (graphStr, options, api) => {
|
||||
const obj = {
|
||||
code: graphStr,
|
||||
mermaid: options
|
||||
}
|
||||
const objStr = JSON.stringify(obj)
|
||||
// console.log(Base64)
|
||||
return 'http://localhost:9000/e2e.html?graph=' + Base64.encodeURI(objStr)
|
||||
let url = 'http://localhost:9000/e2e.html?graph=' + Base64.encodeURI(objStr)
|
||||
if (api) {
|
||||
url = 'http://localhost:9000/xss.html?graph=' + graphStr
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
export const imgSnapshotTest = async (page, graphStr, options) => {
|
||||
export const imgSnapshotTest = async (page, graphStr, options, api) => {
|
||||
return new Promise(async resolve => {
|
||||
const url = mermaidUrl(graphStr, options)
|
||||
const url = mermaidUrl(graphStr, options, api)
|
||||
|
||||
await page.goto(url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user