Skip to content

Commit

Permalink
fix(#3388): Extend asset link test to test deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Dec 23, 2024
1 parent eb2ef73 commit 4777236
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
8 changes: 8 additions & 0 deletions ui/cypress/support/utils/asset/AssetBtns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export class AssetBtns {
return cy.dataCy('save-asset', { timeout: 10000 });
}

public static editAssetBtn(assetName: string) {
return cy.dataCy('edit-asset-' + assetName, { timeout: 10000 });
}

public static deleteAssetBtn(assetName: string) {
return cy.dataCy('delete-asset-' + assetName, { timeout: 10000 });
}

public static basicTab() {
return cy.dataCy('basic-tab', { timeout: 10000 });
}
Expand Down
31 changes: 31 additions & 0 deletions ui/cypress/support/utils/asset/AssetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import { AssetBtns } from './AssetBtns';
import { ConnectUtils } from '../connect/ConnectUtils';

export class AssetUtils {
public static goToAssets() {
Expand Down Expand Up @@ -56,4 +57,34 @@ export class AssetUtils {
.children()
.should('have.length', amount);
}

public static editAsset(assetName: string) {
AssetBtns.editAssetBtn(assetName).click();
}

public static addAssetWithOneAdapter(assetName: string) {
const adapterName = 'Machine_Data_Simulator';
ConnectUtils.addMachineDataSimulator(adapterName);

// Create new asset from adapters
AssetUtils.goToAssets();

AssetUtils.addNewAsset(assetName);

AssetBtns.assetLinksTab().click();
AssetUtils.openManageAssetLinks();

AssetUtils.selectAdapterAssetLink(adapterName);
AssetUtils.selectDataStreamAssetLink(adapterName);
AssetBtns.updateAssetLinksBtn().click();

AssetUtils.checkAmountOfLinkedResources(2);
AssetBtns.saveAssetBtn().click();
AssetUtils.goBackToOverview();
}

public static deleteAsset(assetName: string) {
AssetBtns.deleteAssetBtn(assetName).click();
cy.dataCy('confirm-delete').click();
}
}
29 changes: 12 additions & 17 deletions ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,34 @@
*
*/

import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
import { AssetUtils } from '../../support/utils/asset/AssetUtils';
import { DashboardUtils } from '../../support/utils/DashboardUtils';
import { AssetBtns } from '../../support/utils/asset/AssetBtns';

describe('Creates a new adapter, add to assets', () => {
const adapterName = 'Machine_Data_Simulator';

beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
ConnectUtils.addMachineDataSimulator(adapterName);
});

it('Perform Test', () => {
// Create new asset from adapters
AssetUtils.goToAssets();

AssetUtils.addNewAsset('Test Asset');
const assetName = 'TestAsset';

AssetBtns.assetLinksTab().click();
AssetUtils.openManageAssetLinks();
AssetUtils.addAssetWithOneAdapter(assetName);

AssetUtils.selectAdapterAssetLink(adapterName);
AssetUtils.selectDataStreamAssetLink(adapterName);
AssetBtns.updateAssetLinksBtn().click();
// // Leave and navigate back to Assets
DashboardUtils.goToDashboard();
AssetUtils.goToAssets();
AssetUtils.checkAmountOfAssets(1);

// Check that everything was stored correctly
AssetUtils.editAsset(assetName);
AssetBtns.assetLinksTab().click();
AssetUtils.checkAmountOfLinkedResources(2);
AssetBtns.saveAssetBtn().click();
AssetUtils.goBackToOverview();

// // Leave and navigate back to Assets
DashboardUtils.goToDashboard();
// Check that deletion of asset works
AssetUtils.goToAssets();
AssetUtils.checkAmountOfAssets(1);
AssetUtils.deleteAsset(assetName);
AssetUtils.checkAmountOfAssets(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
matTooltip="Edit asset"
matTooltipPosition="above"
data-cy="edit-asset-button"
[attr.data-cy]="
'edit-asset-' + asset.assetName
"
(click)="goToDetailsView(asset, true)"
>
<i class="material-icons">edit</i>
Expand All @@ -119,6 +122,9 @@
matTooltip="Delete asset"
data-cy="delete"
matTooltipPosition="above"
[attr.data-cy]="
'delete-asset-' + asset.assetName
"
(click)="deleteAsset(asset)"
>
<i class="material-icons">delete</i>
Expand Down

0 comments on commit 4777236

Please sign in to comment.