Skip to content

Commit

Permalink
refactor(#3398): Add e2e test to validate data view is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Jan 7, 2025
1 parent e77de80 commit b1d5e16
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 21 deletions.
6 changes: 6 additions & 0 deletions ui/cypress/support/utils/asset/AssetBtns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class AssetBtns {
});
}

public static dataViewCheckbox(adapterName: string) {
return cy.dataCy('select-data-view-checkbox-' + adapterName, {
timeout: 10000,
});
}

public static fileCheckbox(fileName: string) {
return cy.dataCy(`select-file-checkbox-${fileName.replace('.', '_')}`, {
timeout: 10000,
Expand Down
18 changes: 18 additions & 0 deletions ui/cypress/support/utils/asset/AssetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ export class AssetUtils {
AssetBtns.manageLinksBtn().click();
}

public static addNewAssetWithLink(
assetName: string,
selectLinkFunction: () => void,
) {
AssetUtils.goToAssets();
AssetUtils.addNewAsset(assetName);
AssetBtns.assetLinksTab().click();
AssetUtils.openManageAssetLinks();
selectLinkFunction();
AssetBtns.updateAssetLinksBtn().click();
AssetBtns.saveAssetBtn().click();
cy.wait(1000);
}

public static selectAdapterAssetLink(adapterName: string) {
AssetBtns.adapterCheckbox(adapterName).click();
}
Expand All @@ -51,6 +65,10 @@ export class AssetUtils {
AssetBtns.dataStreamCheckbox(adapterName).click();
}

public static selectDataViewAssetLink(adapterName: string) {
AssetBtns.dataViewCheckbox(adapterName).click();
}

public static selectFileAssetLink(fileName: string) {
AssetBtns.fileCheckbox(fileName).click();
}
Expand Down
4 changes: 3 additions & 1 deletion ui/cypress/support/utils/datalake/DataLakeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,16 @@ export class DataLakeUtils {
PrepareTestDataUtils.loadDataIntoDataLake('fileTest/random.csv');
}

public static createAndEditDashboard(name: string) {
public static createDashboard(name: string) {
// Create new data view
cy.dataCy('open-new-dashboard-dialog').click();

// Configure data view
cy.dataCy('data-view-name').type(name);
cy.dataCy('save-data-view').click();
}

public static createAndEditDashboard(name: string) {
this.editDashboard(name);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import { AssetUtils } from '../../../support/utils/asset/AssetUtils';
import { DataLakeUtils } from '../../../support/utils/datalake/DataLakeUtils';

describe('Delete data view and auto remove asset links of data view', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
});

it('Perform Test', () => {
const dashboardName = 'TestDashboard';
const assetName = 'TestAsset';

DataLakeUtils.goToDatalake();
DataLakeUtils.createDashboard(dashboardName);

AssetUtils.addNewAssetWithLink(assetName, () => {
AssetUtils.selectDataViewAssetLink(dashboardName);
});

DataLakeUtils.goToDatalake();
DataLakeUtils.deleteDashboard(dashboardName);

AssetUtils.validateOneAssetWithNoAssetLinks(assetName);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
*/

import { AssetBtns } from '../../../support/utils/asset/AssetBtns';
import { AssetUtils } from '../../../support/utils/asset/AssetUtils';
import { FileManagementUtils } from '../../../support/utils/FileManagementUtils';

Expand All @@ -28,16 +27,11 @@ describe('Delete file and auto remove asset links of file', () => {
it('Perform Test', () => {
FileManagementUtils.addFile('fileTest/random.csv');

// Add asset with pipeline
const assetName = 'TestAsset';
AssetUtils.goToAssets();
AssetUtils.addNewAsset(assetName);
AssetBtns.assetLinksTab().click();
AssetUtils.openManageAssetLinks();
AssetUtils.selectFileAssetLink('random.csv');
AssetBtns.updateAssetLinksBtn().click();
AssetBtns.saveAssetBtn().click();
cy.wait(1000);

AssetUtils.addNewAssetWithLink(assetName, () => {
AssetUtils.selectFileAssetLink('random.csv');
});

// delete resources that should remove also asset links
FileManagementUtils.deleteFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
*/

import { AssetBtns } from '../../../support/utils/asset/AssetBtns';
import { AssetUtils } from '../../../support/utils/asset/AssetUtils';
import { ConnectUtils } from '../../../support/utils/connect/ConnectUtils';
import { PipelineUtils } from '../../../support/utils/pipeline/PipelineUtils';
Expand All @@ -31,15 +30,10 @@ describe('Delete pipeline and measurements and auto remove asset links', () => {
const assetName = 'TestAsset';
ConnectUtils.addMachineDataSimulator('sample', true);

// Add asset with pipeline
AssetUtils.goToAssets();
AssetUtils.addNewAsset(assetName);
AssetBtns.assetLinksTab().click();
AssetUtils.openManageAssetLinks();
AssetUtils.selectPipelineAssetLink('persist_sample');
AssetUtils.selectMeasurementAssetLink('sample');
AssetBtns.updateAssetLinksBtn().click();
AssetBtns.saveAssetBtn().click();
AssetUtils.addNewAssetWithLink(assetName, () => {
AssetUtils.selectPipelineAssetLink('persist_sample');
AssetUtils.selectMeasurementAssetLink('sample');
});

// delete resources that should remove also asset links
cy.wait(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@
<mat-checkbox
color="accent"
[checked]="linkSelected(element.elementId)"
[attr.data-cy]="
'select-data-view-checkbox-' + element.name
"
(change)="
selectLink(
$event.checked,
Expand Down

0 comments on commit b1d5e16

Please sign in to comment.