4
0

customJs.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { describe, it, before, after, afterEach } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. takeScreenshotOnFailure,
  7. } from '../../lib/elements.js'
  8. describe('config: customJs', function () {
  9. before(async function () {
  10. await runner.start('customJs')
  11. })
  12. after(async () => {
  13. await runner.stop()
  14. })
  15. afterEach(function () {
  16. takeScreenshotOnFailure(this.currentTest, webdriver)
  17. })
  18. it('loads custom.js when enableCustomJs is true (#803)', async function () {
  19. await getRootAndWait()
  20. await webdriver.wait(async () => {
  21. return await webdriver.executeScript('return window.olivetinCustomJsLoaded === true')
  22. }, 5000, 'custom.js should set window.olivetinCustomJsLoaded when enableCustomJs is enabled')
  23. const loaded = await webdriver.executeScript('return window.olivetinCustomJsLoaded === true')
  24. expect(loaded).to.equal(true)
  25. const scripts = await webdriver.findElements(By.css('#olivetin-custom-js'))
  26. expect(scripts).to.have.length(1, 'custom.js script tag should be injected into the page')
  27. })
  28. })