|
| 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 | +}); |
0 commit comments