origin-add.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. var t = require('assert')
  2. var defaults = require('./utils/defaults')
  3. module.exports = ({popup, advanced, content}) => {
  4. before(async () => {
  5. await defaults({popup, advanced, content})
  6. })
  7. describe('defaults', () => {
  8. it('localhost:3000', async () => {
  9. await advanced.bringToFront()
  10. await advanced.waitFor(300)
  11. t.equal(
  12. await advanced.evaluate(() =>
  13. document.querySelectorAll('.m-origins .m-list li').length
  14. ),
  15. 2,
  16. 'allowed origins count should be 2'
  17. )
  18. t.equal(
  19. await advanced.evaluate(() =>
  20. document.querySelector('.m-origins .m-list li:nth-of-type(1) .m-title').innerText
  21. ),
  22. 'http://localhost:3000',
  23. 'origin name should be http://localhost:3000'
  24. )
  25. t.strictEqual(
  26. await advanced.evaluate(() =>
  27. document.querySelector('.m-origins .m-list li:nth-of-type(1) .m-switch').classList.contains('is-checked')
  28. ),
  29. false,
  30. 'csp checkbox should be disabled'
  31. )
  32. t.equal(
  33. await advanced.evaluate(() =>
  34. document.querySelector('.m-origins .m-list li:nth-of-type(1) .m-encoding select').value
  35. ),
  36. '',
  37. 'encoding should be set to auto'
  38. )
  39. t.strictEqual(
  40. await advanced.evaluate(() =>
  41. document.querySelectorAll('.m-origins .m-list li:nth-of-type(1) .m-footer .m-button').length
  42. ),
  43. 1,
  44. 'only one button should be visible in the origin footer'
  45. )
  46. t.equal(
  47. await advanced.evaluate(() =>
  48. document.querySelector('.m-origins .m-list li:nth-of-type(1) .m-footer .m-button').innerText.toLowerCase()
  49. ),
  50. 'remove',
  51. 'remove origin button should be rendered'
  52. )
  53. })
  54. })
  55. }