origin-add.js 2.3 KB

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