onlyDashboards.mjs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { describe, it, before, after } from 'mocha'
  2. import { assert, expect } 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. expect(navLinks).to.not.be.empty
  27. for (const link of navLinks) {
  28. console.log(await link.getAttribute('title'))
  29. }
  30. const firstLink = await navLinks[0];
  31. assert.isNotNull(firstLink, 'Actions link should not be null')
  32. assert.equal(await firstLink.getAttribute('title'), 'My Dashboard', 'First link should have the title "My Dashboard"')
  33. const firstDashboardLink = await webdriver.findElement(By.css('li[title="My Dashboard"]'), 'The first dashboard link should be present')
  34. assert.isNotNull(firstDashboardLink, 'First dashboard link should not be null')
  35. assert.isTrue(await firstDashboardLink.isDisplayed(), '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. })