dashboardsWithBasicFieldsets.mjs 2.2 KB

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