Skip to content

Commit

Permalink
Merge pull request #798 from catenax-ng/feature/TRACEFOSS-2838-implem…
Browse files Browse the repository at this point in the history
…ent-first-cucumber-tests

testing:TRACEFOSS-2838 implemented first q-investigation cucumber tests
  • Loading branch information
ds-mwesener authored Nov 28, 2023
2 parents 40e983c + 25511e8 commit 9547135
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- new filtering capabilities ( receivedQualityAlertIdsInStatusActive, sentQualityAlertIdsInStatusActive, receivedQualityInvestigationIdsInStatusActive, sentQualityInvestigationIdsInStatusActive )
- Validation check if table-settings correct and reset on invalid state
- Added Api-Input in Argo Workflow to fix bugs
- Added implementation for cucumber tests for quality investigations
### Changed
- Filter configuration for tables to be resuable and easy to adapt
- Realigned some mappings e.g. (manufacturer / manufacturerName) to be more clear
Expand Down
24 changes: 24 additions & 0 deletions frontend/cypress/integration/pages/QualityInvestigationsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/********************************************************************************
* Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2022, 2023 ZF Friedrichshafen AG
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

export class QualityInvestigationsPage {
//TBD if necessary
}
3 changes: 2 additions & 1 deletion frontend/cypress/support/step_definitions/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
import { DashboardPage } from '../../integration/pages/DashboardPage';


Expand Down Expand Up @@ -47,6 +47,7 @@ Then(/^should be visible "Dashboard" header$/, () => {
Then(/^should be visible "TOTAL OF PARTS" section$/, () => {
cy.get('section').contains('Total of parts').should('be.visible');
});

Then(/^should be visible "TOTAL OF OTHER PARTS" section$/, () => {
cy.get('section').contains('Total of other parts').should('be.visible');
});
Expand Down
7 changes: 1 addition & 6 deletions frontend/cypress/support/step_definitions/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ Given('user logged in as {string}', function(userType) {
cy.visit('https://centralidp.dev.demo.catena-x.net/auth/realms/CX-Central/protocol/openid-connect/auth?client_id=Cl17-CX-Part&redirect_uri=https%3A%2F%2Ftraceability-portal-e2e-a.dev.demo.catena-x.net%2Fdashboard&state=0aaee615-388e-400c-8b0c-81ac443a2cf3&response_mode=fragment&response_type=code&scope=openid&nonce=4104d5ab-b2bd-43a1-b6c2-7adf30543579&code_challenge=uXHR3gDRnSyjPEu8yWNdzm6Izsd7cKzEryfvRAtJTjU&code_challenge_method=S256');
cy.get('.search').click();
cy.get('.search').type('CX-Test-Access');
cy.wait(5000);
cy.get('.CX_Test_Access').click();
cy.wait(5000);
cy.get('input[name="username"]').type(loginMail,{log:false});
cy.wait(5000);
cy.get('input[name="username"]').type(loginMail);
cy.get('input[name="password"]').click().focus().type(loginPW, {log:false});
cy.wait(5000);
cy.get('input[type="submit"]').click();
});


Given('user is directed to the {string}', function(value) {
cy.wait(5000);
cy.get('div.layout-content').should('exist');
});
63 changes: 63 additions & 0 deletions frontend/cypress/support/step_definitions/menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/********************************************************************************
* Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2022, 2023 ZF Friedrichshafen AG
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';


When("user navigate to {string}", function(desiredMenu) {
matched = false;
switch (desiredMenu) {
case 'Other parts': {
matched = true;
cy.get('[href="/otherParts"]').click();
break;
}
case 'Parts': {
matched = true;
cy.get('[href="/parts"]').click();
break;
}
case 'Dashboard': {
matched = true;
cy.get('[href="/dashboard"]').click();
break;
}
case 'Quality investigations': {
matched = true;
cy.get('[href="/investigations"]').click();
break;
}
case 'Quality alerts': {
matched = true;
cy.get('[href="/alerts"]').click();
break;
}
case 'About': {
matched = true;
cy.get('[href="/about"]').click();
break;
}
default: {
throw new Error("Set header menu '" + desiredMenu + "' is not one of valid status [Dashboard, Parts, Other parts, Quality investigations, Quality alerts, About].");
break;
}
}
});
257 changes: 257 additions & 0 deletions frontend/cypress/support/step_definitions/quality-investigations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
/********************************************************************************
* Copyright (c) 2022, 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2022, 2023 ZF Friedrichshafen AG
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
import { When, Then, Given } from '@badeball/cypress-cucumber-preprocessor';
import { QualityInvestigationsPage } from '../../integration/pages/QualityInvestigationsPage';

let notificationDescription = null;

Then("select {string} other part", (partAmount) => {
//since IDs of desired asset are not shown in FE the selection has to be done by other number.
cy.get('span').contains('As Planned').click(); // This has to be done to avoid asPlanned selection
cy.get('#mat-mdc-checkbox-38*').click(); //---TBD--- this is only a method to make it run, has to be changed to selected part.

});


Then("start investigation creation with description {string}", function (description) {
const date = new Date().getTime();
notificationDescription = description + "_" + date;
cy.get('div').contains('Start investigation').click();
cy.get('mat-label').contains('Description').click().type(notificationDescription);
});


When("severity {string}", function (severity) {
cy.get('#mat-select-56').click(); // First the dropdown has to be opened.
cy.get('p').contains(severity).click();
});


When("{string} deadline", function (deadline) {
if (deadline == 'no') {
// do nothing
} else {
// ---TBD--- implement timepicker once it´s necessary.
}
});


When("request the investigation", () => {
cy.get('span').contains('ADD TO QUEUE').click();
});


Then("selected parts are marked as investigated", () => {
//cy.get('class').contains('highlighted');
//---TBD--- to check the desired assets, have to be adjusted with desired asset selection
});


When("popup with information about queued investigation is shown", () => {
cy.contains(/You queued an investigation for 1 part/i).should('be.visible');
});


When("user navigate to {string} with button in popup", (popupClick) => {
cy.get('a').contains('Go to Queue').click();
});


When("open details of created investigation", () => {
cy.get('[data-testid="table-menu-button"]').first().click(); //the first investigation will be opened
cy.get('[data-testid="table-menu-button--actions.viewDetails"]').first().click();
});


// --- TBD --- check id, description, status, created, createdby, text
// --- TBD --- #check: popup on the right sight is shown
When("user confirm cancelation of selected investigation with entering {string} id", (input) => {
let investigationId = '';
switch (input) {
case 'no': {
cy.get('span').contains('Confirm cancellation').click();
break;
}
case 'wrong': {
cy.get('#mat-mdc-form-field-label-4').click().focus().type('000');
cy.get('span').contains('Confirm cancellation').click();
break;
}
case 'correct': {
cy.get('mat-label').invoke('text').as('cancelId');
cy.get('@cancelId').then((cancelId) => {
cy.get('#mat-input-0').click().type(cancelId);
});
cy.get('span').contains('Confirm cancellation').click();
break;
}
default: {
throw new Error("Set cancelation id '" + input + "' is not one of valid actions [no, wrong, correct].");
break;
}
}
});


Then("cancelation is not possible due to {string} id", (id) => {
switch (id) {
case 'no': {
cy.contains(/This field is required!/i).should('be.visible');
break;
}
case 'wrong': {
cy.contains(/Please enter data that matches this pattern:/i).should('be.visible');
break;
}
default: {
throw new Error("Set cancelation action '" + id + "' is not one of valid actions [no, wrong].");
break;
}
}
});


When("user {string} selected investigation", (action) => {
//within opened detail view of quality investigation
switch (action) {
case 'approve': {
cy.get('div').contains('Approve').click();
break;
}
case 'cancel': {
cy.get('div').contains('Cancel').click();
break;
}
case 'close': {
cy.get('div').contains('Close').click();
break;
}
case 'acknowledge': {
cy.get('div').contains('Acknowledge').click();
break;
}
case 'accept': {
cy.get('div').contains('Accept').click();
break;
}
case 'decline': {
cy.get('div').contains('Decline').click();
break;
}
default: {
throw new Error("Set action '" + action + "' is not one of valid actions [approve, cancel, close, acknowledge, accept, decline].");
break;
}
}
});


When("user confirm approval of selected investigation", (action) => {
cy.get('app-confirm').find('span').contains('Approve').click();
});


Then("informations for selected investigation are displayed as expected", () => {
// --- TBD --- include: overview, supplier parts, STATUS
});


Then("selected {string} has been {string} as expected", (notificationType, expectedStatus) => {
matched = false;
switch (expectedStatus) {
case 'canceled': {
matched = true;
cy.get('[title="Cancelled"]').should('be.visible');
break;
}
case 'approved': {
// same as "requested"
matched = true;
cy.get('[title="Requested"]', { timeout: 10000 }).should('be.visible');
break;
}
case 'accepted': {
matched = true;
cy.get('[title="Accepted"]', { timeout: 10000 }).should('be.visible');
break;
}
case 'declined': {
matched = true;
cy.get('[title="Declined"]', { timeout: 10000 }).should('be.visible');
break;
}
case 'acknowledged': {
matched = true;
cy.get('[title="Acknowledged"]', { timeout: 10000 }).should('be.visible');
break;
}
case 'closed': {
matched = true;
cy.get('[title="Closed"]', { timeout: 10000 }).should('be.visible');
break;
}
default: {
throw new Error("Set expected status '" + expectedStatus + "' is not one of valid status [canceled, approved, accepted, declined, acknowledged, closed].");
break;
}
}
});


When("selected {string} is not allowed to be {string}", (notificationType, status) => {
matched = false;
switch (status) {
case 'canceled': {
matched = true;
cy.get('div').contains('/^Cancel$/', {matchCase: true}).should('not.exist');
break;
}
case 'approved': {
matched = true;
cy.get('div').contains('/^Approve$/', {matchCase: true}).should('not.exist');
break;
}
case 'accepted': {
matched = true;
cy.get('div').contains('/^Accept$/', {matchCase: true}).should('not.exist');
break;
}
case 'declined': {
matched = true;
cy.get('div').contains('/^Decline$/', {matchCase: true}).should('not.exist');
break;
}
case 'acknowledged': {
matched = true;
cy.get('div').contains('/^Acknowledge$/', {matchCase: true}).should('not.exist');
break;
}
case 'closed': {
matched = true;
cy.get('div').contains('/^Close$/', {matchCase: true}).should('not.exist');
break;
}
default: {
throw new Error("Set status '" + status + "' is not one of valid status [canceled, approved, accepted, declined, acknowledged, closed].");
break;
}
}
});

0 comments on commit 9547135

Please sign in to comment.