Skip to content

Commit

Permalink
Hotfix remove unused classes (#3389)
Browse files Browse the repository at this point in the history
* fix(#3388): Refactor asset link test

* fix(#3388): Extend asset link test to test deletion

* refactor: Remove unused classes AssetsUtil and LocalesUtil
  • Loading branch information
tenthe authored Jan 20, 2025
1 parent 9561fb5 commit eccff93
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 132 deletions.

This file was deleted.

This file was deleted.

73 changes: 73 additions & 0 deletions ui/cypress/support/utils/asset/AssetBtns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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.
*
*/

export class AssetBtns {
public static createAssetBtn() {
return cy.dataCy('create-new-asset-button', { timeout: 10000 });
}

public static assetNameInput() {
return cy.dataCy('asset-name', { timeout: 10000 });
}

public static saveAssetBtn() {
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 });
}

public static assetLinksTab() {
return cy.dataCy('asset-links-tab', { timeout: 10000 });
}

public static manageLinksBtn() {
return cy.dataCy('assets-manage-links-button', { timeout: 10000 });
}

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

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

public static updateAssetLinksBtn() {
return cy.dataCy('assets-update-links-button', { timeout: 10000 });
}

public static goBackToOverviewBtn() {
return cy.dataCy('save-data-explorer-go-back-to-overview', {
timeout: 10000,
});
}
}
67 changes: 67 additions & 0 deletions ui/cypress/support/utils/asset/AssetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,75 @@
*
*/

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

export class AssetUtils {
public static goToAssets() {
cy.visit('#/assets/overview');
}

public static goBackToOverview() {
AssetBtns.goBackToOverviewBtn().click();
}

public static addNewAsset(assetName: string) {
AssetBtns.createAssetBtn().click();
AssetBtns.assetNameInput().clear();
AssetBtns.assetNameInput().type(assetName);
AssetBtns.saveAssetBtn().click();
}

public static openManageAssetLinks() {
AssetBtns.manageLinksBtn().should('be.enabled');
AssetBtns.manageLinksBtn().click();
}

public static selectAdapterAssetLink(adapterName: string) {
AssetBtns.adapterCheckbox(adapterName).click();
}

public static selectDataStreamAssetLink(adapterName: string) {
AssetBtns.dataStreamCheckbox(adapterName).click();
}

public static checkAmountOfAssets(amount: number) {
cy.dataCy('assets-table').should('have.length', amount);
}

public static checkAmountOfLinkedResources(amount: number) {
cy.dataCy('linked-resources-list')
.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();
}
}
62 changes: 0 additions & 62 deletions ui/cypress/tests/assetManagement/createAsset.spec.ts

This file was deleted.

49 changes: 49 additions & 0 deletions ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 { DashboardUtils } from '../../support/utils/DashboardUtils';
import { AssetBtns } from '../../support/utils/asset/AssetBtns';

describe('Creates a new adapter, add to assets', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
});

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

AssetUtils.addAssetWithOneAdapter(assetName);

// // 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);

// 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 @@ -40,7 +40,7 @@
<button
mat-button
mat-raised-button
data-cy="save-asset-button"
data-cy="save-asset"
color="accent"
(click)="saveAsset()"
>
Expand All @@ -56,12 +56,14 @@
<nav mat-tab-nav-bar color="accent">
<a
mat-tab-link
data-cy="basic-tab"
[active]="activeTab === 'basic'"
(click)="activeTab = 'basic'"
>Basics</a
>
<a
mat-tab-link
data-cy="asset-links-tab"
[active]="activeTab === 'asset-links'"
(click)="activeTab = 'asset-links'"
>Asset Links</a
Expand Down
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
Loading

0 comments on commit eccff93

Please sign in to comment.