fix some tests

This commit is contained in:
JFH
2021-12-30 05:29:49 -03:00
parent fdcfc8a253
commit 2ae3ba770e
38 changed files with 819 additions and 4494 deletions

View File

@@ -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()
}
)

View File

@@ -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()
})
}