multi-dashboard-includes.mjs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { describe, it, before, after } from 'mocha'
  2. import { expect, assert } from 'chai'
  3. import { By } from 'selenium-webdriver'
  4. import {
  5. getRootAndWait,
  6. getActionButtons,
  7. getNavigationLinks,
  8. openSidebar,
  9. takeScreenshotOnFailure,
  10. } from '../../lib/elements.js'
  11. describe('config: multi-dashboard-includes', function () {
  12. this.timeout(30000)
  13. before(async function () {
  14. await runner.start('multi-dashboard-includes')
  15. })
  16. after(async () => {
  17. await runner.stop()
  18. })
  19. afterEach(function () {
  20. takeScreenshotOnFailure(this.currentTest, webdriver);
  21. });
  22. async function clickNavigationLinkByTitle (title) {
  23. await openSidebar()
  24. const navigationLinks = await getNavigationLinks()
  25. assert.isAbove(navigationLinks.length, 0, 'Expected at least one navigation link')
  26. const matching = []
  27. for (const li of navigationLinks) {
  28. const liTitle = await li.getAttribute('title')
  29. if (liTitle === title) {
  30. matching.push(li)
  31. }
  32. }
  33. assert.strictEqual(matching.length, 1, `Expected exactly one navigation link with title "${title}"`)
  34. await matching[0].click()
  35. }
  36. async function getActionTitlesOnDashboard (dashboardTitle = null) {
  37. const buttons = await getActionButtons(dashboardTitle)
  38. const titles = []
  39. for (const button of buttons) {
  40. titles.push(await button.getAttribute('title'))
  41. }
  42. return titles
  43. }
  44. it('Should expose both dashboards from included files in navigation', async function () {
  45. await getRootAndWait()
  46. await openSidebar()
  47. const navigationLinks = await getNavigationLinks()
  48. assert.isAbove(navigationLinks.length, 0, 'Expected navigation to have at least one link')
  49. const titles = []
  50. for (const li of navigationLinks) {
  51. titles.push(await li.getAttribute('title'))
  52. }
  53. expect(titles).to.include('First Dashboard')
  54. expect(titles).to.include('Second Dashboard')
  55. })
  56. it('First Dashboard shows First and Second inline actions from include', async function () {
  57. await getRootAndWait()
  58. // Navigate to "First Dashboard"
  59. await clickNavigationLinkByTitle('First Dashboard')
  60. // Buttons on this dashboard only
  61. const titles = await getActionTitlesOnDashboard('First Dashboard')
  62. expect(titles).to.include('First Action')
  63. expect(titles).to.include('Second Action')
  64. // Ensure actions from the second dashboard are not rendered here
  65. expect(titles).to.not.include('Third Action')
  66. expect(titles).to.not.include('Fourth Action')
  67. })
  68. it('Second Dashboard shows Third and Fourth inline actions from include', async function () {
  69. await getRootAndWait()
  70. // Navigate to "Second Dashboard"
  71. await clickNavigationLinkByTitle('Second Dashboard')
  72. const titles = await getActionTitlesOnDashboard('Second Dashboard')
  73. expect(titles).to.include('Third Action')
  74. expect(titles).to.include('Fourth Action')
  75. // Ensure actions from the first dashboard are not rendered here
  76. expect(titles).to.not.include('First Action')
  77. expect(titles).to.not.include('Second Action')
  78. })
  79. })