Skip to content

Commit 9adca64

Browse files
committed
test: [PROD-13346] test disabled Launch button
1 parent f8a5baa commit 9adca64

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) Cosmo Tech.
2+
// Licensed under the MIT license.
3+
import { DatasetManager, Login, ScenarioParameters, Scenarios, ScenarioSelector } from '../../commons/actions';
4+
import { stub } from '../../commons/services/stubbing';
5+
import {
6+
WORKSPACE,
7+
DATASETS_TO_REFRESH,
8+
ORGANIZATION_WITH_DEFAULT_ROLE_USER,
9+
} from '../../fixtures/stubbing/DatasetManager';
10+
import { SCENARIOS_WITH_DATASET_ERROR } from '../../fixtures/stubbing/DisableLaunchButton/scenarios';
11+
12+
describe('DisableLaunchButton', () => {
13+
stub.start();
14+
stub.setOrganizations([ORGANIZATION_WITH_DEFAULT_ROLE_USER]);
15+
stub.setWorkspaces([WORKSPACE]);
16+
stub.setDatasets([...DATASETS_TO_REFRESH]);
17+
stub.setScenarios(SCENARIOS_WITH_DATASET_ERROR);
18+
19+
const scenarioWithBrokenDataset = SCENARIOS_WITH_DATASET_ERROR[1];
20+
const scenarioReadyToLaunch = SCENARIOS_WITH_DATASET_ERROR[2];
21+
const scenarioWithoutDataset = SCENARIOS_WITH_DATASET_ERROR[3];
22+
23+
const refreshSuccessOptions = {
24+
expectedPollsCount: 2,
25+
finalIngestionStatus: 'SUCCESS',
26+
};
27+
28+
const refreshFailedOptions = {
29+
expectedPollsCount: 2,
30+
finalIngestionStatus: 'ERROR',
31+
};
32+
33+
beforeEach(() => Login.login({ url: '/W-stbbdbrwryWithDM', workspaceId: 'W-stbbdbrwryWithDM' }));
34+
after(stub.stop);
35+
it('can disable and enable Launch button when dataset status changes', () => {
36+
ScenarioParameters.getLaunchButton().should('be.disabled');
37+
ScenarioSelector.selectScenario(scenarioWithBrokenDataset.name, scenarioWithBrokenDataset.id);
38+
ScenarioParameters.getLaunchButton().should('not.be.disabled');
39+
ScenarioSelector.selectScenario(scenarioReadyToLaunch.name, scenarioReadyToLaunch.id);
40+
ScenarioParameters.getLaunchButton().should('not.be.disabled');
41+
ScenarioSelector.selectScenario(scenarioWithoutDataset.name, scenarioWithoutDataset.id);
42+
ScenarioParameters.getLaunchButton().should('not.be.disabled');
43+
DatasetManager.ignoreDatasetTwingraphQueries();
44+
DatasetManager.switchToDatasetManagerView();
45+
DatasetManager.selectDatasetById(DATASETS_TO_REFRESH[1].id);
46+
DatasetManager.refreshDataset(DATASETS_TO_REFRESH[1].id, refreshFailedOptions);
47+
DatasetManager.getDatasetOverviewPlaceholderTitle().contains('An error', { timeout: 30000 });
48+
Scenarios.switchToScenarioView();
49+
ScenarioSelector.selectScenario(scenarioWithBrokenDataset.name, scenarioWithBrokenDataset.id);
50+
ScenarioParameters.getLaunchButton().should('be.disabled');
51+
DatasetManager.switchToDatasetManagerView();
52+
DatasetManager.selectDatasetById(DATASETS_TO_REFRESH[1].id);
53+
DatasetManager.refreshDataset(DATASETS_TO_REFRESH[1].id, refreshSuccessOptions);
54+
DatasetManager.getRefreshDatasetSpinner(DATASETS_TO_REFRESH[1].id, 30000).should('not.exist');
55+
Scenarios.switchToScenarioView();
56+
ScenarioParameters.getLaunchButton().should('not.be.disabled');
57+
});
58+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Cosmo Tech.
2+
// Licensed under the MIT license.
3+
import { SCENARIO_EXAMPLE } from '../default';
4+
5+
export const SCENARIOS_WITH_DATASET_ERROR = [
6+
{
7+
...SCENARIO_EXAMPLE,
8+
name: 'Test Cypress - 1 - dataset not found',
9+
id: 's-stubbedscnr02',
10+
datasetList: ['D-stbdatasetnfd'],
11+
},
12+
{
13+
...SCENARIO_EXAMPLE,
14+
name: 'Test Cypress - 2 - broken dataset',
15+
id: 's-stubbedscnr01',
16+
datasetList: ['D-stbdataset9'],
17+
},
18+
{
19+
...SCENARIO_EXAMPLE,
20+
name: 'Test Cypress - 3',
21+
id: 's-stubbedscnr03',
22+
datasetList: ['D-stbdataset8'],
23+
},
24+
{
25+
...SCENARIO_EXAMPLE,
26+
name: 'Test Cypress - 4 - empty datasetList',
27+
id: 's-stubbedscnr04',
28+
datasetList: [],
29+
},
30+
];

src/components/ScenarioParameters/components/ScenarioActions/ScenarioActions.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jest.mock('@cosmotech/ui', () => ({
2222
PermissionsGate: ({ children }) => {
2323
return <div data-testid="PermissionsGate">{children}</div>;
2424
},
25+
FadingTooltip: ({ children }) => {
26+
return <div data-testid="FadingTooltip">{children}</div>;
27+
},
2528
}));
2629

2730
const mockUseLaunchScenario = jest.fn();

tests/samples/datasets.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,12 @@ export const DEFAULT_DATASETS_LIST_DATA = [
3535
ingestionStatus: 'SUCCESS',
3636
twincacheStatus: 'FULL',
3737
},
38+
{
39+
...DEFAULT_DATASET,
40+
id: 'D-4jwyQnmv7jx',
41+
name: 'DataSet Sample 001',
42+
main: true,
43+
ingestionStatus: 'SUCCESS',
44+
twincacheStatus: 'FULL',
45+
},
3846
];

0 commit comments

Comments
 (0)