onlyDashboards.mjs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { describe, it, before, after } from 'mocha'
  2. import { assert } from 'chai'
  3. import { By } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. getActionButtons,
  7. getNavigationLinks,
  8. openSidebar,
  9. closeSidebar,
  10. takeScreenshotOnFailure,
  11. } from '../lib/elements.js'
  12. describe('config: onlyDashboards', function () {
  13. before(async function () {
  14. await runner.start('onlyDashboards')
  15. })
  16. after(async () => {
  17. await runner.stop()
  18. })
  19. afterEach(function () {
  20. takeScreenshotOnFailure(this.currentTest, webdriver);
  21. });
  22. it('When there are only dashboards, actions are hidden', async function () {
  23. await getRootAndWait()
  24. await openSidebar()
  25. const navLinks = await getNavigationLinks()
  26. const actionsLink = navLinks[0];
  27. assert.isNotNull(actionsLink, 'Actions link should not be null')
  28. assert.equal(await actionsLink.getAttribute('title'), 'Actions', 'Actions link should have the title "Actions"')
  29. assert.isFalse(await actionsLink.isDisplayed(), 'Actions link should not be displayed when there are only dashboards')
  30. const firstDashboardLink = await webdriver.findElement(By.css('li[title="My Dashboard"]'), 'The first dashboard link should be present')
  31. assert.isNotNull(firstDashboardLink, 'First dashboard link should not be null')
  32. assert.isTrue(await firstDashboardLink.isDisplayed(), 'First dashboard link should be displayed')
  33. const actionButtons = await getActionButtons()
  34. assert.isArray(actionButtons, 'Action buttons should be an array')
  35. assert.lengthOf(actionButtons, 0, 'Action buttons should be empty when everything is added to the dashboard')
  36. const actionButtonsOnDashboard = await getActionButtons('MyDashboard')
  37. assert.isArray(actionButtonsOnDashboard, 'Action buttons on dashboard should be an array')
  38. assert.lengthOf(actionButtonsOnDashboard, 3, 'Action buttons on dashboard should have 3 buttons')
  39. })
  40. })