diff --git a/cypress/commons/constants/generic/IdConstants.js b/cypress/commons/constants/generic/IdConstants.js index e044b30a0..8a667c911 100644 --- a/cypress/commons/constants/generic/IdConstants.js +++ b/cypress/commons/constants/generic/IdConstants.js @@ -54,6 +54,9 @@ export const GENERIC_SELECTORS = { cytovizElementAttributeName: '[data-cy="cytoviz-element-attribute-name"]', cytovizElementAttributeValue: '[data-cy="cytoviz-element-attribute-value"]', }, + dashboards: { + tabName: '[data-cy="tabs.dashboards.key"]', + }, scenario: { view: '[data-cy=scenario-view]', tabName: '[data-cy="tabs.scenario.key"]', diff --git a/cypress/commons/utils/apiUtils.js b/cypress/commons/utils/apiUtils.js index 30bdcfeed..0243b8a98 100644 --- a/cypress/commons/utils/apiUtils.js +++ b/cypress/commons/utils/apiUtils.js @@ -742,8 +742,10 @@ const interceptWorkspaceSelectorQueries = () => { ]; }; -const interceptSelectWorkspaceQueries = () => { - return [interceptPowerBIAzureFunction(), interceptGetSolution(), interceptGetScenarios()]; +const interceptSelectWorkspaceQueries = (isPowerBiEnabled = true) => { + const workspaceQueries = [interceptGetSolution(), interceptGetScenarios()]; + if (isPowerBiEnabled) workspaceQueries.push(interceptPowerBIAzureFunction()); + return workspaceQueries; }; export const apiUtils = { diff --git a/cypress/commons/utils/routeUtils.js b/cypress/commons/utils/routeUtils.js index 811de8cdb..1f18dc981 100644 --- a/cypress/commons/utils/routeUtils.js +++ b/cypress/commons/utils/routeUtils.js @@ -16,9 +16,9 @@ const _navigateTo = (url) => { }); }; -const getBrowseQueries = (workspaceId, scenarioId) => { +const getBrowseQueries = (workspaceId, scenarioId, isPowerBiEnabled = true) => { const queries = api.interceptWorkspaceSelectorQueries(); - if (workspaceId) queries.push(...api.interceptSelectWorkspaceQueries()); + if (workspaceId) queries.push(...api.interceptSelectWorkspaceQueries(isPowerBiEnabled)); if (scenarioId) queries.push(api.interceptGetScenario(scenarioId)); return queries; }; @@ -55,7 +55,7 @@ const browse = (options) => { : options.url?.match(WEBAPP_URL_REGEX.SCENARIO_ID_PATTERN)?.[1]; // Intercept scenario only when explicitly specified in options (part 2 of WorkingInTwoWorkspaces) - const queries = getBrowseQueries(workspaceId, options.scenarioId); + const queries = getBrowseQueries(workspaceId, options.scenarioId, options.isPowerBiEnabled); _navigateTo(options.url); if (options.onBrowseCallback) options.onBrowseCallback(); waitBrowseQueries(queries); diff --git a/cypress/e2e/brewery/ResultsDashboards-DisplayDisabled.cy.js b/cypress/e2e/brewery/ResultsDashboards-DisplayDisabled.cy.js new file mode 100644 index 000000000..7fe05fe92 --- /dev/null +++ b/cypress/e2e/brewery/ResultsDashboards-DisplayDisabled.cy.js @@ -0,0 +1,60 @@ +// Copyright (c) Cosmo Tech. +// Licensed under the MIT license. +import { Login, ScenarioParameters, Scenarios } from '../../commons/actions'; +import { GENERIC_SELECTORS } from '../../commons/constants/generic/IdConstants'; +import { stub } from '../../commons/services/stubbing'; +import { routeUtils as route } from '../../commons/utils'; +import { + WORKSPACE_LIST_WITHOUT_DASHBOARDS, + WORKSPACE_WITHOUT_DASHBOARDS, +} from '../../fixtures/stubbing/ScenarioViewDashboard/workspace'; +import { DEFAULT_SCENARIOS_LIST } from '../../fixtures/stubbing/default'; + +const { id: scenarioId } = DEFAULT_SCENARIOS_LIST[0]; +const runOptions = { + runDuration: 1000, + dataIngestionDuration: 1000, + finalStatus: 'Successful', + expectedPollsCount: 2, +}; + +describe('results display is disabled', () => { + before(() => { + stub.start(); + stub.setWorkspaces(WORKSPACE_LIST_WITHOUT_DASHBOARDS); + }); + + beforeEach(() => { + Login.login({ + url: `/${WORKSPACE_WITHOUT_DASHBOARDS.id}`, + workspaceId: WORKSPACE_WITHOUT_DASHBOARDS.id, + isPowerBiEnabled: false, + }); + }); + + after(() => { + stub.stop(); + }); + + it('can launch a scenario and show Display of results is disabled dashboard', () => { + cy.get(GENERIC_SELECTORS.dashboards.tabName).should('not.exist'); + ScenarioParameters.launch({ scenarioId, runOptions, saveAndLaunch: true }); + ScenarioParameters.waitForScenarioRunEnd(); + Scenarios.getDashboardAccordionLogsDownloadButton().should('be.visible'); + Scenarios.getDashboardAccordion().click(); + Scenarios.getDashboardPlaceholder().should('be.visible'); + Scenarios.getDashboardPlaceholder().should( + 'have.text', + 'Scenario run was successful but the display of results is disabled' + ); + }); + it('can redirect from dashboards to workspace view when results display is disabled', () => { + route.browse({ + url: `${WORKSPACE_WITHOUT_DASHBOARDS.id}/dashboards`, + workspaceId: WORKSPACE_WITHOUT_DASHBOARDS.id, + expectedURL: `${WORKSPACE_WITHOUT_DASHBOARDS.id}/scenario/s-stubbedscnr01`, + isPowerBiEnabled: false, + }); + cy.get(GENERIC_SELECTORS.dashboards.tabName).should('not.exist'); + }); +}); diff --git a/cypress/fixtures/stubbing/ScenarioViewDashboard/workspace.js b/cypress/fixtures/stubbing/ScenarioViewDashboard/workspace.js new file mode 100644 index 000000000..948372097 --- /dev/null +++ b/cypress/fixtures/stubbing/ScenarioViewDashboard/workspace.js @@ -0,0 +1,16 @@ +// Copyright (c) Cosmo Tech. +// Licensed under the MIT license. +import { WORKSPACE_EXAMPLE } from '../default'; + +export const WORKSPACE_WITHOUT_DASHBOARDS = { + ...WORKSPACE_EXAMPLE, + id: 'w-stbwrknodsh', + key: 'breweryNoDashboards', + webApp: { + url: null, + iframes: null, + options: null, + }, +}; + +export const WORKSPACE_LIST_WITHOUT_DASHBOARDS = [WORKSPACE_EXAMPLE, WORKSPACE_WITHOUT_DASHBOARDS];