general.mjs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect } from 'chai'
  3. import { By, until, Condition } from 'selenium-webdriver'
  4. //import * as waitOn from 'wait-on'
  5. import {
  6. getRootAndWait,
  7. getActionButtons,
  8. takeScreenshotOnFailure,
  9. } from '../lib/elements.js'
  10. describe('config: general', function () {
  11. before(async function () {
  12. await runner.start('general')
  13. })
  14. after(async () => {
  15. await runner.stop()
  16. })
  17. afterEach(function () {
  18. takeScreenshotOnFailure(this.currentTest, webdriver);
  19. });
  20. it('Page title', async function () {
  21. await webdriver.get(runner.baseUrl())
  22. const title = await webdriver.getTitle()
  23. expect(title).to.be.equal("OliveTin")
  24. })
  25. it('Page title2', async function () {
  26. /*
  27. await webdriver.get(runner.baseUrl())
  28. const title = await webdriver.getTitle()
  29. expect(title).to.be.equal("OliveTin")
  30. */
  31. })
  32. it('Footer contains promo', async function () {
  33. const ftr = await webdriver.findElement(By.tagName('footer')).getText()
  34. expect(ftr).to.contain('Documentation')
  35. })
  36. it('Default buttons are rendered', async function() {
  37. await getRootAndWait()
  38. const buttons = await getActionButtons(webdriver)
  39. expect(buttons).to.have.length(8)
  40. })
  41. it('Start dir action (popup)', async function () {
  42. await getRootAndWait()
  43. const buttons = await webdriver.findElements(By.css('[title="dir-popup"]'))
  44. expect(buttons).to.have.length(1)
  45. const buttonCMD = buttons[0]
  46. expect(buttonCMD).to.not.be.null
  47. buttonCMD.click()
  48. const dialog = await webdriver.findElement(By.id('execution-results-popup'))
  49. expect(await dialog.isDisplayed()).to.be.true
  50. const title = await webdriver.findElement(By.id('execution-dialog-title'))
  51. expect(await webdriver.wait(until.elementTextIs(title, 'dir-popup'), 2000))
  52. const dialogErr = await webdriver.findElement(By.id('big-error'))
  53. expect(dialogErr).to.not.be.null
  54. expect(await dialogErr.isDisplayed()).to.be.false
  55. })
  56. it('Start cd action (passive)', async function () {
  57. await getRootAndWait()
  58. const buttons = await webdriver.findElements(By.css('[title="cd-passive"]'))
  59. expect(buttons).to.have.length(1)
  60. const buttonCMD = buttons[0]
  61. expect(buttonCMD).to.not.be.null
  62. buttonCMD.click()
  63. const dialog = await webdriver.findElement(By.id('execution-results-popup'))
  64. expect(await dialog.isDisplayed()).to.be.false
  65. const title = await webdriver.findElement(By.id('execution-dialog-title'))
  66. expect(await title.getAttribute('innerText')).to.be.equal('?')
  67. const dialogErr = await webdriver.findElement(By.id('big-error'))
  68. console.log("big error is: " + dialogErr.innerHTML)
  69. expect(dialogErr).to.not.be.null
  70. expect(await dialogErr.isDisplayed()).to.be.false
  71. })
  72. })