Skip to content

Commit

Permalink
fix: disallow overriding styles by frameworks (#2629)
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed May 31, 2023
1 parent f715a9d commit b078f5b
Show file tree
Hide file tree
Showing 2 changed files with 574 additions and 534 deletions.
40 changes: 40 additions & 0 deletions cypress/e2e/styling.cy.js
Expand Up @@ -108,4 +108,44 @@ describe('Styling', () => {
},
})
})

it('should not allow frameworks like bulma to ovrrride default styles', (done) => {
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.4/css/bulma.min.css'
document.head.appendChild(link)
Swal.fire({
title: 'title',
icon: 'success',
imageUrl: '/assets/swal2-logo.png',
input: 'text',
inputLabel: 'inputLabel',
showDenyButton: true,
showCancelButton: true,
footer: 'footer',
timer: 1000,
timerProgressBar: true,
didOpen: () => {
expect(window.getComputedStyle(Swal.getContainer()).zIndex).to.equal('1060')
expect(window.getComputedStyle(Swal.getPopup()).width).to.equal('512px')
expect(window.getComputedStyle(Swal.getTitle()).fontSize).to.equal('30px')
expect(window.getComputedStyle(Swal.getCloseButton()).fontSize).to.equal('40px')
expect(window.getComputedStyle(Swal.getIcon()).width).to.equal('80px')
expect(window.getComputedStyle(Swal.getImage()).maxWidth).to.equal('100%')
expect(window.getComputedStyle(Swal.getInput()).fontSize).to.equal('18px')
expect(window.getComputedStyle(Swal.getInputLabel()).margin).to.equal('16px 0px 0px')
Swal.showValidationMessage('validationMessage')
expect(window.getComputedStyle(Swal.getValidationMessage()).padding).to.equal('10px')
expect(window.getComputedStyle(Swal.getActions()).padding).to.equal('0px')
expect(window.getComputedStyle(Swal.getConfirmButton()).paddingTop).to.equal('10px')
expect(window.getComputedStyle(Swal.getDenyButton()).paddingLeft).to.equal('17.6px')
expect(window.getComputedStyle(Swal.getCancelButton()).paddingBottom).to.equal('10px')
Swal.showLoading()
expect(window.getComputedStyle(Swal.getLoader()).borderWidth).to.equal('4px')
expect(window.getComputedStyle(Swal.getFooter()).paddingTop).to.equal('16px')
expect(window.getComputedStyle(Swal.getTimerProgressBar()).height).to.equal('4px')
done()
},
})
})
})

0 comments on commit b078f5b

Please sign in to comment.