onlyDashboards.mjs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { describe, it, before, after } from 'mocha'
  2. import { assert, expect } from 'chai'
  3. import { By, until } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. getActionButtons,
  7. getNavigationLinks,
  8. openSidebar,
  9. takeScreenshotOnFailure,
  10. } from '../../lib/elements.js'
  11. describe('config: onlyDashboards', function () {
  12. before(async function () {
  13. await runner.start('onlyDashboards')
  14. })
  15. after(async () => {
  16. await runner.stop()
  17. })
  18. afterEach(function () {
  19. takeScreenshotOnFailure(this.currentTest, webdriver);
  20. });
  21. it('When there are only dashboards, actions are hidden', async function () {
  22. await getRootAndWait()
  23. await openSidebar()
  24. const navLinks = await getNavigationLinks()
  25. expect(navLinks).to.not.be.empty
  26. for (const link of navLinks) {
  27. console.log(await link.getAttribute('title'))
  28. }
  29. const firstLink = await navLinks[0];
  30. assert.isNotNull(firstLink, 'Actions link should not be null')
  31. assert.equal(await firstLink.getAttribute('title'), 'My Dashboard', 'First link should have the title "My Dashboard"')
  32. const firstDashboardLink = await webdriver.findElement(By.css('li[title="My Dashboard"]'), 'The first dashboard link should be present')
  33. assert.isNotNull(firstDashboardLink, 'First dashboard link should not be null')
  34. // The sidebar is marked as shown when it starts opening, so wait for the link to become visible.
  35. await webdriver.wait(until.elementIsVisible(firstDashboardLink), 5000, 'First dashboard link should be displayed')
  36. const actionButtonsOnDashboard = await getActionButtons()
  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. })