Skip to content

Commit

Permalink
test: [PROD-13567] cypress tests for disabled display of results
Browse files Browse the repository at this point in the history
  • Loading branch information
esasova committed Jul 16, 2024
1 parent 4b29784 commit 077e657
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cypress/commons/constants/generic/IdConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
Expand Down
6 changes: 4 additions & 2 deletions cypress/commons/utils/apiUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions cypress/commons/utils/routeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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);
Expand Down
60 changes: 60 additions & 0 deletions cypress/e2e/brewery/ResultsDashboards-DisplayDisabled.cy.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
16 changes: 16 additions & 0 deletions cypress/fixtures/stubbing/ScenarioViewDashboard/workspace.js
Original file line number Diff line number Diff line change
@@ -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];

0 comments on commit 077e657

Please sign in to comment.