general.mjs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. openSidebar,
  10. } from '../../lib/elements.js'
  11. describe('config: general', function () {
  12. before(async function () {
  13. await runner.start('general')
  14. })
  15. after(async () => {
  16. await runner.stop()
  17. })
  18. afterEach(function () {
  19. takeScreenshotOnFailure(this.currentTest, webdriver);
  20. });
  21. it('Page title', async function () {
  22. await webdriver.get(runner.baseUrl())
  23. const title = await webdriver.getTitle()
  24. expect(title).to.be.equal("Actions - OliveTin")
  25. })
  26. it('navbar contains default policy links', async function () {
  27. await getRootAndWait()
  28. await openSidebar()
  29. const logsLink = await webdriver.findElements(By.css('a[href="/logs"]'))
  30. const diagnosticsLink = await webdriver.findElements(By.css('a[href="/diagnostics"]'))
  31. expect(logsLink).to.not.be.empty
  32. expect(diagnosticsLink).to.not.be.empty
  33. })
  34. it('Footer contains promo', async function () {
  35. const ftr = await webdriver.findElement(By.tagName('footer')).getText()
  36. expect(ftr).to.contain('Documentation')
  37. })
  38. it('Default buttons are rendered', async function() {
  39. await getRootAndWait()
  40. await webdriver.wait(new Condition('wait for action buttons', async () => {
  41. const btns = await webdriver.findElements(By.css('[title="dir-popup"], [title="cd-passive"], .action-button button'))
  42. return btns.length >= 1
  43. }), 10000)
  44. const buttons = await getActionButtons()
  45. expect(buttons.length).to.be.greaterThanOrEqual(4)
  46. })
  47. it('Start dir action (popup)', async function () {
  48. await getRootAndWait()
  49. await webdriver.wait(new Condition('wait for dir-popup button', async () => {
  50. const btns = await webdriver.findElements(By.css('[title="dir-popup"]'))
  51. return btns.length === 1
  52. }), 10000)
  53. const buttons = await webdriver.findElements(By.css('[title="dir-popup"]'))
  54. expect(buttons).to.have.length(1)
  55. const buttonCMD = buttons[0]
  56. expect(buttonCMD).to.not.be.null
  57. buttonCMD.click()
  58. // New UI navigates to /logs/<id> instead of showing old dialog
  59. await webdriver.wait(new Condition('wait navigate to logs', async () => {
  60. const url = await webdriver.getCurrentUrl()
  61. return url.includes('/logs/')
  62. }), 8000)
  63. })
  64. it('Start cd action (passive)', async function () {
  65. await getRootAndWait()
  66. await webdriver.wait(new Condition('wait for cd-passive button', async () => {
  67. const btns = await webdriver.findElements(By.css('[title="cd-passive"]'))
  68. return btns.length === 1
  69. }), 10000)
  70. const buttons = await webdriver.findElements(By.css('[title="cd-passive"]'))
  71. expect(buttons).to.have.length(1)
  72. const buttonCMD = buttons[0]
  73. expect(buttonCMD).to.not.be.null
  74. buttonCMD.click()
  75. // Should not navigate to logs for passive action
  76. await webdriver.sleep(500)
  77. const url = await webdriver.getCurrentUrl()
  78. expect(url.includes('/logs/')).to.be.false
  79. })
  80. })