|
| 1 | +// Copyright (c) Cosmo Tech. |
| 2 | +// Licensed under the MIT license. |
| 3 | +import { Login, DatasetManager } from '../../commons/actions'; |
| 4 | +import { GENERIC_SELECTORS } from '../../commons/constants/generic/IdConstants'; |
| 5 | +import { stub } from '../../commons/services/stubbing'; |
| 6 | +import { ORGANIZATION_WITH_DEFAULT_ROLE_USER } from '../../fixtures/stubbing/DatasetManager'; |
| 7 | +import { DATASETS, RUNNERS, SOLUTION, WORKSPACE } from '../../fixtures/stubbing/DatasetManagerParametersEdition'; |
| 8 | + |
| 9 | +const NINE_CUSTOMERS_DATASET_ZIP_FILE_PATH = 'customers2.csv'; |
| 10 | + |
| 11 | +describe('Dataset Manager - Parameters Edition', () => { |
| 12 | + const ingestionOptions = { |
| 13 | + expectedPollsCount: 2, |
| 14 | + finalIngestionStatus: 'SUCCESS', |
| 15 | + }; |
| 16 | + before(() => { |
| 17 | + stub.start(); |
| 18 | + stub.setOrganizations([ORGANIZATION_WITH_DEFAULT_ROLE_USER]); |
| 19 | + stub.setSolutions([SOLUTION]); |
| 20 | + stub.setWorkspaces([WORKSPACE]); |
| 21 | + stub.setDatasets([...DATASETS]); |
| 22 | + stub.setRunners([...RUNNERS]); |
| 23 | + }); |
| 24 | + |
| 25 | + beforeEach(() => |
| 26 | + Login.login({ url: `/${WORKSPACE.id}/datasetmanager`, workspaceId: WORKSPACE.id, isPowerBiEnabled: false }) |
| 27 | + ); |
| 28 | + after(stub.stop); |
| 29 | + |
| 30 | + it('should edit ETL parameters of a dataset', () => { |
| 31 | + const datasetFile = DATASETS[2]; |
| 32 | + const datasetETLDynamicValues = DATASETS[3]; |
| 33 | + const datasetETLLocalFile = DATASETS[4]; |
| 34 | + const secondDatasetETLLocalFile = DATASETS[6]; |
| 35 | + const enumParameterSelector = '[data-cy=enum-input-select-etl_dynamic_values_enum_parameter]'; |
| 36 | + const enumValue1Selector = '[data-cy=First]'; |
| 37 | + const fileParameterSelector = '[data-cy="file-upload-etl_file_parameter"]'; |
| 38 | + const stockParameterSelector = '[data-cy=text-input-etl_stock]'; |
| 39 | + const getStockParameterInput = () => { |
| 40 | + return cy.get(stockParameterSelector).find('input'); |
| 41 | + }; |
| 42 | + const clearStockParameterInput = () => { |
| 43 | + getStockParameterInput().click().type('{selectAll}{backspace}'); |
| 44 | + }; |
| 45 | + const editStockParameter = (value) => { |
| 46 | + clearStockParameterInput(); |
| 47 | + getStockParameterInput().type(value); |
| 48 | + }; |
| 49 | + |
| 50 | + const validateRequest = (req) => |
| 51 | + expect(req.body).to.deep.equal({ query: 'MATCH(n:Customer) RETURN n.id as customer_id' }); |
| 52 | + const queryResponse = [{ customer_id: 'First' }, { customer_id: 'Second' }, { customer_id: 'Third' }]; |
| 53 | + |
| 54 | + DatasetManager.ignoreDatasetTwingraphQueries(); |
| 55 | + DatasetManager.switchToDatasetManagerView(); |
| 56 | + DatasetManager.selectDatasetById(datasetFile.id); |
| 57 | + DatasetManager.getUpdateDatasetParametersButton().should('not.exist'); |
| 58 | + DatasetManager.selectDatasetById(datasetETLDynamicValues.id); |
| 59 | + DatasetManager.getUpdateDatasetParametersButton().should('be.visible'); |
| 60 | + const waitForTwingraphQuery = DatasetManager.expectDatasetTwingraphQuery(queryResponse, validateRequest); |
| 61 | + DatasetManager.openUpdateDatasetParametersDialog(); |
| 62 | + DatasetManager.getUpdateDatasetParametersDialog().should('be.visible'); |
| 63 | + DatasetManager.getRunnerRunTemplate().should('exist').contains('ETL with dynamic values'); |
| 64 | + waitForTwingraphQuery(); |
| 65 | + cy.get(enumParameterSelector).should('be.visible'); |
| 66 | + cy.get(enumParameterSelector).find('input').should('have.value', 'Second'); |
| 67 | + cy.get(enumParameterSelector).click(); |
| 68 | + cy.get(enumValue1Selector).click(); |
| 69 | + cy.get(enumParameterSelector).find('input').should('have.value', 'First'); |
| 70 | + DatasetManager.updateDatasetParameters(datasetETLDynamicValues.id, { |
| 71 | + importJobOptions: ingestionOptions, |
| 72 | + }); |
| 73 | + DatasetManager.getRefreshDatasetSpinner(datasetETLDynamicValues.id, 20).should('not.exist'); |
| 74 | + DatasetManager.selectDatasetById(secondDatasetETLLocalFile.id); |
| 75 | + DatasetManager.getUpdateDatasetParametersButton().should('be.visible'); |
| 76 | + DatasetManager.openUpdateDatasetParametersDialog(); |
| 77 | + DatasetManager.getRunnerRunTemplate().should('exist').contains('ETL with local file'); |
| 78 | + cy.get(fileParameterSelector) |
| 79 | + .find(GENERIC_SELECTORS.genericComponents.uploadFile.fileName) |
| 80 | + .should('have.text', 'reference_two.zip'); |
| 81 | + getStockParameterInput().should('have.value', '56'); |
| 82 | + DatasetManager.closeUpdateDatasetParametersDialog(); |
| 83 | + DatasetManager.selectDatasetById(datasetETLLocalFile.id); |
| 84 | + DatasetManager.getUpdateDatasetParametersButton().should('be.visible'); |
| 85 | + DatasetManager.openUpdateDatasetParametersDialog(); |
| 86 | + DatasetManager.getRunnerRunTemplate().should('exist').contains('ETL with local file'); |
| 87 | + cy.get(fileParameterSelector) |
| 88 | + .find(GENERIC_SELECTORS.genericComponents.uploadFile.fileName) |
| 89 | + .should('have.text', 'reference.zip'); |
| 90 | + getStockParameterInput().should('have.value', '150'); |
| 91 | + DatasetManager.getUpdateParametersButton().should('be.disabled'); |
| 92 | + clearStockParameterInput(); |
| 93 | + DatasetManager.getUpdateParametersButton().should('be.disabled'); |
| 94 | + editStockParameter('150'); |
| 95 | + DatasetManager.getUpdateParametersButton().should('be.disabled'); |
| 96 | + cy.get(stockParameterSelector).find('input').click(); |
| 97 | + editStockParameter('98'); |
| 98 | + DatasetManager.getUpdateParametersButton().should('not.be.disabled'); |
| 99 | + DatasetManager.uploadFileInParametersEditionDialog(NINE_CUSTOMERS_DATASET_ZIP_FILE_PATH); |
| 100 | + |
| 101 | + DatasetManager.updateDatasetParameters(datasetETLLocalFile.id, { |
| 102 | + datasetsEvents: [{ id: 'd-stbddtspr1' }], |
| 103 | + importJobOptions: ingestionOptions, |
| 104 | + }); |
| 105 | + DatasetManager.getRefreshDatasetSpinner(datasetETLLocalFile.id, 20).should('not.exist'); |
| 106 | + DatasetManager.selectDatasetById(datasetETLDynamicValues.id); |
| 107 | + DatasetManager.openUpdateDatasetParametersDialog(); |
| 108 | + cy.get(enumParameterSelector).find('input').should('have.value', 'First'); |
| 109 | + DatasetManager.closeUpdateDatasetParametersDialog(); |
| 110 | + DatasetManager.selectDatasetById(datasetETLLocalFile.id); |
| 111 | + DatasetManager.openUpdateDatasetParametersDialog(); |
| 112 | + getStockParameterInput().should('have.value', '98'); |
| 113 | + cy.get(fileParameterSelector) |
| 114 | + .find(GENERIC_SELECTORS.genericComponents.uploadFile.fileName) |
| 115 | + .should('have.text', 'customers2.csv'); |
| 116 | + DatasetManager.closeUpdateDatasetParametersDialog(); |
| 117 | + }); |
| 118 | +}); |
0 commit comments