fix some tests
This commit is contained in:
@@ -23,26 +23,3 @@
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||
/* globals Cypress */
|
||||
// remove the style attributes that is causing differences in snapshots
|
||||
const ngAttributes = ['style']
|
||||
|
||||
Cypress.Commands.add(
|
||||
'cleanSnapshot',
|
||||
{
|
||||
prevSubject: true
|
||||
},
|
||||
(subject, _snapshotOptions) => {
|
||||
let html = subject[0].outerHTML
|
||||
|
||||
for (const attribute of ngAttributes) {
|
||||
const expression = new RegExp(`${attribute}[^= ]*="[^"]*"`, 'g')
|
||||
html = html.replace(expression, '')
|
||||
}
|
||||
html = html.replace(/<!--[\s\S]*?-->/g, '')
|
||||
|
||||
const sanitisedBody = new DOMParser().parseFromString(html, 'text/html').querySelector('body')
|
||||
|
||||
return cy.wrap(sanitisedBody.firstChild).toMatchSnapshot()
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export const approveStorage = () => {
|
||||
// JFH will need to be chnaged when dialog is changed...
|
||||
cy.get('#storage_ok').click()
|
||||
}
|
||||
|
||||
@@ -22,3 +21,10 @@ export const selectEnglish = () => {
|
||||
cy.get('#lang_select').select('en')
|
||||
cy.get('#tool_prefs_save').click()
|
||||
}
|
||||
|
||||
export const testSnapshot = () => {
|
||||
cy.window().then((win) => { // access to the remote Window so we can get the svgEditor variable
|
||||
const svgContent = win.svgEditor.svgCanvas.getSvgString()
|
||||
cy.wrap(unescape(svgContent)).toMatchSnapshot()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user