| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import { describe, it, before, after } from 'mocha'
- import { expect, assert } from 'chai'
- import { By } from 'selenium-webdriver'
- import {
- DEFAULT_UI_WAIT_MS,
- getRootAndWait,
- getActionButtons,
- getNavigationLinks,
- openSidebar,
- takeScreenshotOnFailure,
- waitForDashboardLoaded,
- } from '../../lib/elements.js'
- describe('config: multi-dashboard-includes', function () {
- this.timeout(30000)
- before(async function () {
- await runner.start('multi-dashboard-includes')
- })
- after(async () => {
- await runner.stop()
- })
- afterEach(function () {
- takeScreenshotOnFailure(this.currentTest, webdriver);
- });
- async function clickNavigationLinkByTitle (title) {
- await openSidebar()
- const navigationLinks = await getNavigationLinks()
- assert.isAbove(navigationLinks.length, 0, 'Expected at least one navigation link')
- const matching = []
- for (const li of navigationLinks) {
- const liTitle = await li.getAttribute('title')
- if (liTitle === title) {
- matching.push(li)
- }
- }
- assert.strictEqual(matching.length, 1, `Expected exactly one navigation link with title "${title}"`)
- await matching[0].click()
- await waitForDashboardLoaded(DEFAULT_UI_WAIT_MS, title)
- }
- async function getActionTitlesOnDashboard (dashboardTitle = null) {
- const buttons = await getActionButtons(dashboardTitle)
- const titles = []
- for (const button of buttons) {
- titles.push(await button.getAttribute('title'))
- }
- return titles
- }
- it('Should expose both dashboards from included files in navigation', async function () {
- await getRootAndWait()
- await openSidebar()
- const navigationLinks = await getNavigationLinks()
- assert.isAbove(navigationLinks.length, 0, 'Expected navigation to have at least one link')
- const titles = []
- for (const li of navigationLinks) {
- titles.push(await li.getAttribute('title'))
- }
- expect(titles).to.include('First Dashboard')
- expect(titles).to.include('Second Dashboard')
- })
- it('First Dashboard shows First and Second inline actions from include', async function () {
- await getRootAndWait()
- // Navigate to "First Dashboard"
- await clickNavigationLinkByTitle('First Dashboard')
- // Buttons on this dashboard only
- const titles = await getActionTitlesOnDashboard('First Dashboard')
- expect(titles).to.include('First Action')
- expect(titles).to.include('Second Action')
- // Ensure actions from the second dashboard are not rendered here
- expect(titles).to.not.include('Third Action')
- expect(titles).to.not.include('Fourth Action')
- })
- it('Second Dashboard shows Third and Fourth inline actions from include', async function () {
- await getRootAndWait()
- // Navigate to "Second Dashboard"
- await clickNavigationLinkByTitle('Second Dashboard')
- const titles = await getActionTitlesOnDashboard('Second Dashboard')
- expect(titles).to.include('Third Action')
- expect(titles).to.include('Fourth Action')
- // Ensure actions from the first dashboard are not rendered here
- expect(titles).to.not.include('First Action')
- expect(titles).to.not.include('Second Action')
- })
- })
|