4
0

general.mjs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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('navbar contains default policy links', async function () {
  33. await getRootAndWait()
  34. const logListLink = await webdriver.findElements(By.css('[href="/logs"]'))
  35. expect(logListLink).to.not.be.empty
  36. const diagnosticsLink = await webdriver.findElements(By.css('[href="/diagnostics"]'))
  37. expect(diagnosticsLink).to.not.be.empty
  38. })
  39. it('Footer contains promo', async function () {
  40. const ftr = await webdriver.findElement(By.tagName('footer')).getText()
  41. expect(ftr).to.contain('Documentation')
  42. })
  43. it('Default buttons are rendered', async function() {
  44. await getRootAndWait()
  45. const buttons = await getActionButtons()
  46. expect(buttons).to.have.length(8)
  47. })
  48. it('Start dir action (popup)', async function () {
  49. await getRootAndWait()
  50. const buttons = await webdriver.findElements(By.css('[title="dir-popup"]'))
  51. expect(buttons).to.have.length(1)
  52. const buttonCMD = buttons[0]
  53. expect(buttonCMD).to.not.be.null
  54. buttonCMD.click()
  55. const dialog = await webdriver.findElement(By.id('execution-results-popup'))
  56. expect(await dialog.isDisplayed()).to.be.true
  57. const title = await webdriver.findElement(By.id('execution-dialog-title'))
  58. expect(await webdriver.wait(until.elementTextIs(title, 'dir-popup'), 2000))
  59. const dialogErr = await webdriver.findElement(By.id('big-error'))
  60. expect(dialogErr).to.not.be.null
  61. expect(await dialogErr.isDisplayed()).to.be.false
  62. })
  63. it('Start cd action (passive)', async function () {
  64. await getRootAndWait()
  65. const buttons = await webdriver.findElements(By.css('[title="cd-passive"]'))
  66. expect(buttons).to.have.length(1)
  67. const buttonCMD = buttons[0]
  68. expect(buttonCMD).to.not.be.null
  69. buttonCMD.click()
  70. const dialog = await webdriver.findElement(By.id('execution-results-popup'))
  71. expect(await dialog.isDisplayed()).to.be.false
  72. const title = await webdriver.findElement(By.id('execution-dialog-title'))
  73. expect(await title.getAttribute('innerText')).to.be.equal('?')
  74. const dialogErr = await webdriver.findElement(By.id('big-error'))
  75. console.log("big error is: " + dialogErr.innerHTML)
  76. expect(dialogErr).to.not.be.null
  77. expect(await dialogErr.isDisplayed()).to.be.false
  78. })
  79. })