This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch fix-assets-e2e-tests in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit b7e4198ae32f523627e34614c59d4447e30fade2 Author: Philipp Zehnder <[email protected]> AuthorDate: Thu Apr 4 18:26:38 2024 +0200 fix: Fix and refactor create asset e2e test --- ui/.lintstagedrc.json | 2 +- ui/cypress/support/utils/asset/AssetUtils.ts | 23 +++++++++++++++ .../utils/configuration/ConfigutationUtils.ts | 23 +++++++++++++++ .../tests/assetManagement/createAsset.spec.ts | 34 ++++++++++++---------- .../asset-overview/asset-overview.component.html | 2 +- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/ui/.lintstagedrc.json b/ui/.lintstagedrc.json index d67c35505b..059fea6ac0 100644 --- a/ui/.lintstagedrc.json +++ b/ui/.lintstagedrc.json @@ -1,4 +1,4 @@ { - "*.*": "prettier --write", + "src/**/*.ts": "prettier --write", "src/**/*.ts": ["ng-lint-staged lint --fix"] } diff --git a/ui/cypress/support/utils/asset/AssetUtils.ts b/ui/cypress/support/utils/asset/AssetUtils.ts new file mode 100644 index 0000000000..1df1f6907e --- /dev/null +++ b/ui/cypress/support/utils/asset/AssetUtils.ts @@ -0,0 +1,23 @@ +/* + * 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 AssetUtils { + public static goToAssets() { + cy.visit('#/assets/overview'); + } +} diff --git a/ui/cypress/support/utils/configuration/ConfigutationUtils.ts b/ui/cypress/support/utils/configuration/ConfigutationUtils.ts new file mode 100644 index 0000000000..44731e6e4f --- /dev/null +++ b/ui/cypress/support/utils/configuration/ConfigutationUtils.ts @@ -0,0 +1,23 @@ +/* + * 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 ConfigurationUtils { + public static goToConfigurationExport() { + cy.visit('#/configuration/export'); + } +} diff --git a/ui/cypress/tests/assetManagement/createAsset.spec.ts b/ui/cypress/tests/assetManagement/createAsset.spec.ts index fb5c529013..ad131c2631 100644 --- a/ui/cypress/tests/assetManagement/createAsset.spec.ts +++ b/ui/cypress/tests/assetManagement/createAsset.spec.ts @@ -18,6 +18,9 @@ import { AdapterBuilder } from '../../support/builder/AdapterBuilder'; import { ConnectUtils } from '../../support/utils/connect/ConnectUtils'; +import { AssetUtils } from '../../support/utils/asset/AssetUtils'; +import { DashboardUtils } from '../../support/utils/DashboardUtils'; +import { ConfigurationUtils } from '../../support/utils/configuration/ConfigutationUtils'; describe('Creates a new adapter, add to assets and export assets', () => { beforeEach('Setup Test', () => { @@ -33,8 +36,8 @@ describe('Creates a new adapter, add to assets and export assets', () => { it('Perform Test', () => { // Create new asset from adapters - cy.visit('#/assets'); - cy.dataCy('connect-create-new-adapter-button').click(); + AssetUtils.goToAssets(); + cy.dataCy('create-new-asset-button').click(); cy.dataCy('asset-name').clear(); cy.dataCy('asset-name').type('Test asset'); cy.dataCy('save-data-view').click(); @@ -60,26 +63,26 @@ describe('Creates a new adapter, add to assets and export assets', () => { cy.dataCy('save-data-explorer-go-back-to-overview').click(); // Leave and navigate back to Assets - cy.visit('#/dashboard'); - cy.visit('#/assets'); + DashboardUtils.goToDashboard(); + AssetUtils.goToAssets(); cy.dataCy('assets-table').should('have.length', 1); // Export Asset - cy.visit('#/configuration/export'); + ConfigurationUtils.goToConfigurationExport(); cy.get('[type="checkbox"]').check(); cy.dataCy('export-asset-button').click(); cy.dataCy('download-export-button').click(); // Delete Adapter and Asset - cy.visit('#/connect'); + ConnectUtils.goToConnect(); cy.dataCy('delete-adapter').click(); cy.dataCy('delete-adapter-confirmation').click(); - cy.visit('#/assets'); + AssetUtils.goToAssets(); cy.dataCy('delete').click(); // Import downloaded Asset - cy.visit('#/configuration/export'); + ConfigurationUtils.goToConfigurationExport(); cy.dataCy('import-application-data-button').click(); cy.get('input[type="file"]').selectFile( 'cypress/downloads/data_export.zip', @@ -89,24 +92,24 @@ describe('Creates a new adapter, add to assets and export assets', () => { cy.dataCy('import-button').click(); // Check if import was successful - cy.visit('#/connect'); + ConnectUtils.goToConnect(); cy.dataCy('adapters-table').children().should('have.length', 1); - cy.visit('#/assets'); + AssetUtils.goToAssets(); cy.dataCy('assets-table').should('have.length', 1); // Export Asset via Assets page cy.dataCy('download').click(); // Delete Adapter and Asset - cy.visit('#/connect'); + ConnectUtils.goToConnect(); cy.dataCy('delete-adapter').click(); cy.dataCy('delete-adapter-confirmation').click(); - cy.visit('#/assets'); + AssetUtils.goToAssets(); cy.dataCy('delete').click(); // Import downloaded Asset - cy.visit('#/configuration/export'); + ConfigurationUtils.goToConfigurationExport(); cy.dataCy('import-application-data-button').click(); cy.get('input[type="file"]').selectFile( 'cypress/downloads/assetExport.zip', @@ -116,9 +119,10 @@ describe('Creates a new adapter, add to assets and export assets', () => { cy.dataCy('import-button').click(); // Check if import was successful - cy.visit('#/connect'); + ConnectUtils.goToConnect(); cy.dataCy('adapters-table').children().should('have.length', 1); - cy.visit('#/assets'); + + AssetUtils.goToAssets(); cy.dataCy('assets-table').should('have.length', 1); }); }); diff --git a/ui/src/app/assets/components/asset-overview/asset-overview.component.html b/ui/src/app/assets/components/asset-overview/asset-overview.component.html index d08ce9d0e8..a31367fe3e 100644 --- a/ui/src/app/assets/components/asset-overview/asset-overview.component.html +++ b/ui/src/app/assets/components/asset-overview/asset-overview.component.html @@ -27,7 +27,7 @@ mat-button mat-raised-button color="accent" - data-cy="connect-create-new-adapter-button" + data-cy="create-new-asset-button" (click)="createNewAsset()" > <i class="material-icons">add</i> New asset
