dashboardsWithBasicFieldsets.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect, assert } from 'chai'
  3. import { By, until, Condition } from 'selenium-webdriver'
  4. //import * as waitOn from 'wait-on'
  5. import {
  6. getRootAndWait,
  7. getActionButtons,
  8. openSidebar,
  9. getNavigationLinks,
  10. takeScreenshotOnFailure,
  11. } from '../../lib/elements.js'
  12. describe('config: dashboards with basic fieldsets', function () {
  13. before(async function () {
  14. await runner.start('dashboardsWithBasicFieldsets')
  15. })
  16. after(async () => {
  17. await runner.stop()
  18. })
  19. afterEach(function () {
  20. takeScreenshotOnFailure(this.currentTest, webdriver);
  21. });
  22. it('Dashboards with basic fieldsets', async function () {
  23. await getRootAndWait()
  24. const title = await webdriver.getTitle()
  25. expect(title).to.be.equal("Test - OliveTin")
  26. await openSidebar()
  27. const navigationLinks = await getNavigationLinks()
  28. assert.equal(navigationLinks.length, 5, 'Expected the nav to only have 5 links') // test dashboard + logs + diagnostics + entities + separator
  29. const firstLink = await navigationLinks[0]
  30. expect(await firstLink.getAttribute('title')).to.be.equal('Test', 'Expected the first link to be the actions link')
  31. const actionButtons = await getActionButtons()
  32. expect(actionButtons).to.have.length(5, 'Expected 5 action buttons')
  33. // Check that we have the expected number of fieldsets
  34. const dashboardRows = await webdriver.findElements(By.css('.dashboard-row'))
  35. expect(dashboardRows).to.have.length(3, 'Expected 3 dashboard rows total')
  36. // Check that we have fieldsets with the expected titles
  37. const fieldsetTitles = []
  38. for (let i = 0; i < dashboardRows.length; i++) {
  39. const titleElements = await dashboardRows[i].findElements(By.css('h2'))
  40. if (titleElements.length > 0) {
  41. const title = await titleElements[0].getText()
  42. fieldsetTitles.push(title)
  43. }
  44. }
  45. // We should have fieldsets for: Fieldset 1, Fieldset 2, and Actions fieldsets
  46. expect(fieldsetTitles).to.include('Fieldset 1')
  47. expect(fieldsetTitles).to.include('Fieldset 2')
  48. })
  49. })