Skip to content

Commit

Permalink
refactor(#3398): Add failing test for file assets
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Jan 5, 2025
1 parent 9b13132 commit 206d9ba
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 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 fileCheckbox(fileName: string) {
return cy.dataCy(`select-file-checkbox-${fileName.replace('.', '_')}`, {
timeout: 10000,
});
}

public static pipelineCheckbox(pipelineName: string) {
return cy.dataCy('select-pipeline-checkbox-' + pipelineName, {
timeout: 10000,
Expand Down
4 changes: 4 additions & 0 deletions ui/cypress/support/utils/asset/AssetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export class AssetUtils {
AssetBtns.dataStreamCheckbox(adapterName).click();
}

public static selectFileAssetLink(fileName: string) {
AssetBtns.fileCheckbox(fileName).click();
}

public static selectPipelineAssetLink(pipelineName: string) {
AssetBtns.pipelineCheckbox(pipelineName).click();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 { AssetBtns } from '../../../support/utils/asset/AssetBtns';
import { AssetUtils } from '../../../support/utils/asset/AssetUtils';
import { FileManagementUtils } from '../../../support/utils/FileManagementUtils';

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

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

// delete resources that should remove also asset links
FileManagementUtils.deleteFile();

// Check that asset link is removed
AssetUtils.goToAssets();
AssetUtils.checkAmountOfAssets(1);
AssetUtils.editAsset(assetName);
AssetBtns.assetLinksTab().click();
AssetUtils.checkAmountOfLinkedResources(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@
<mat-checkbox
color="accent"
[checked]="linkSelected(element.fileId)"
[attr.data-cy]="
'select-file-checkbox-' +
element.filename.replaceAll('.', '_')
"
(change)="
selectLink(
$event.checked,
Expand Down

0 comments on commit 206d9ba

Please sign in to comment.