Skip to content

Commit

Permalink
Merge pull request #1312 from eclipse-tractusx/chore/xxx-execution-e2…
Browse files Browse the repository at this point in the history
…e-test-frontend

Chore/xxx execution e2e test frontend
  • Loading branch information
ds-lcapellino authored Jul 26, 2024
2 parents 664b9ec + 366bf74 commit 1f77f37
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 185 deletions.
179 changes: 40 additions & 139 deletions .github/workflows/e2e-tests-xray_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@
# SPDX-License-Identifier: Apache-2.0

# Require to set secrets:
# - ORG_IRS_JIRA_USERNAME
# - ORG_IRS_JIRA_PASSWORD
# - ASSOCIATION_SUPERVISOR_CLIENT_ID
# - ASSOCIATION_SUPERVISOR_PASSWORD
name: "[FE][TEST][E2E]- Cypress"

on:
# triggered manually by Test Manager
workflow_dispatch:
inputs:
jira_filter_id:
description: 'Jira filter ID to fetch test scenarios'
required: false
# by default, we use this filter: https://jira.catena-x.net/issues/?filter=11645
default: 11645
# or automatically by merge to main
#push:
branches: main
push:
branches:
- main
paths:
- 'frontend/**'

Expand All @@ -56,14 +51,29 @@ jobs:
with:
cmd: install # will run `yarn install` command

# Fetch feature files
# Fetch feature files
- name: Fetch .feature files from Jira Xray
env:
JIRA_USERNAME: ${{ secrets.ORG_IRS_JIRA_USERNAME }}
JIRA_PASSWORD: ${{ secrets.ORG_IRS_JIRA_PASSWORD }}
JIRA_FILTER_ID: ${{ github.event.inputs.jira_filter_id }}
JIRA_USERNAME: ${{ secrets.ASSOCIATION_TX_JIRA_USERNAME }}
JIRA_PASSWORD: ${{ secrets.ASSOCIATION_TX_JIRA_PASSWORD }}
working-directory: frontend
run: ./scripts/xray-download-feature-files.sh
run: |
token=$(curl -H "Content-Type: application/json" -X POST \
--data "{ \"client_id\": \"$JIRA_USERNAME\",\"client_secret\": \"$JIRA_PASSWORD\" }" \
https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
export HTTP_RESULT=$(curl -s --show-error -w "%{http_code}" --header "Authorization: Bearer $token" \
"https://xray.cloud.getxray.app/api/v2/export/cucumber?filter=10007&fz=true" -o features.zip)
[[ $HTTP_RESULT == 200 || $HTTP_RESULT == 400 ]]
echo "::set-output name=http_response::$HTTP_RESULT"
- name: Unzip feature files
if: ${{ steps.download.outputs.http_response == '200' }}
working-directory: frontend
run: |
unzip -o features.zip -d cypress/e2e
rm -f features.zip
- name: Save cypress/e2e folder
uses: actions/upload-artifact@v4
Expand All @@ -76,6 +86,7 @@ jobs:
cypress-run-chrome:
timeout-minutes: 15
runs-on: ubuntu-latest
if: ${{ steps.download.outputs.http_response == '200' }}
defaults:
run:
working-directory: frontend
Expand Down Expand Up @@ -125,22 +136,30 @@ jobs:
working-directory: frontend
# using wait-on parameter causes "Error: connect ECONNREFUSED 127.0.0.1:4200"
env:
CYPRESS_SUPERVISOR_LOGIN: ${{ secrets.TRACE_X_SUPERVISOR_LOGIN }}
CYPRESS_SUPERVISOR_PW: ${{ secrets.TRACE_X_SUPERVISOR_PW }}
CYPRESS_SUPERVISOR_LOGIN: ${{ secrets.ASSOCIATION_SUPERVISOR_CLIENT_ID }}
CYPRESS_SUPERVISOR_PW: ${{ secrets.ASSOCIATION_SUPERVISOR_PASSWORD }}
CYPRESS_ADMIN_LOGIN: ${{ secrets.TRACE_X_ADMIN_LOGIN }}
CYPRESS_ADMIN_PW: ${{ secrets.TRACE_X_ADMIN_PW }}
CYPRESS_USER_LOGIN: ${{ secrets.TRACE_X_USER_LOGIN }}
CYPRESS_USER_PW: ${{ secrets.TRACE_X_USER_PW }}
CYPRESS_REDIRECT_URI: https://traceability-portal-e2e-a.dev.demo.catena-x.net/dashboard
CYPRESS_REDIRECT_URI: https://traceability-portal-int-a.int.catena-x.net/dashboard

- name: Submit results to Xray
# we don't want to submit results to xray when it was run by PR
if: github.event_name != 'pull_request' && (success() || failure())
env:
JIRA_USERNAME: ${{ secrets.ORG_IRS_JIRA_USERNAME }}
JIRA_PASSWORD: ${{ secrets.ORG_IRS_JIRA_PASSWORD }}
JIRA_USERNAME: ${{ secrets.ASSOCIATION_TX_JIRA_USERNAME }}
JIRA_PASSWORD: ${{ secrets.ASSOCIATION_TX_JIRA_PASSWORD }}
run: |
./scripts/xray-push-test-results.sh
token=$(curl -H "Content-Type: application/json" -X POST \
--data "{ \"client_id\": \"$JIRA_USERNAME\",\"client_secret\": \"$JIRA_PASSWORD\" }" \
https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
curl --request POST \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $token" \
--data-binary '@cypress/reports/cucumber-report.json' \
"https://xray.cloud.getxray.app/api/v2/import/execution/cucumber"
- name: Archive cypress artifacts
if: success() || failure()
Expand All @@ -150,121 +169,3 @@ jobs:
path: |
frontend/cypress/videos/
frontend/cypress/screenshots/
# cypress-run-firefox:
# timeout-minutes: 15
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: frontend
# container:
# # if you need to change image please make sure use the same version in all places
# # (here and in cypress/Dockerfile)
# image: cypress/browsers:node16.16.0-chrome107-ff107-edge
# options: --user 1001
# needs: install
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Download the cypress/e2e folder
# uses: actions/download-artifact@v4
# with:
# name: cypress - e2e
# path: frontend/cypress/e2e
#
# - name: Use Node.js 18.x
# uses: actions/setup-node@v4
# with:
# node-version: 18.x
#
# - name: Cypress run all tests
# uses: cypress-io/github-action@v6.7.1 # use the explicit version number
# with:
# start: npm start
# wait-on: "http://localhost:4200"
# wait-on-timeout: 120
# browser: firefox
# working-directory: frontend
#
# - name: Submit results to Xray
# # we don't want to submit results to xray when it was run by PR
# if: github.event_name != 'pull_request' && (success() || failure())
# env:
# JIRA_USERNAME: ${{ secrets.ORG_IRS_JIRA_USERNAME }}
# JIRA_PASSWORD: ${{ secrets.ORG_IRS_JIRA_PASSWORD }}
# run: |
# ./scripts/xray-push-test-results.sh
#
# - name: Archive cypress artifacts
# if: success() || failure()
# uses: actions/upload-artifact@v4
# with:
# name: cypress generated files - firefox
# path: |
# frontend/cypress/videos/
# frontend/cypress/screenshots/
#
# cypress-run-webkit:
# timeout-minutes: 15
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: frontend
# needs: install
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Download the cypress/e2e folder
# uses: actions/download-artifact@v4
# with:
# name: cypress - e2e
# path: frontend/cypress/e2e

# commented because if we use it here, we face with that problem:
# "http://localhost:4200 timed out on retry 151 of 5, elapsed 150449ms, limit 150000ms
# Error: connect ECONNREFUSED 127.0.0.1:4200"

# - name: Use Node.js 18.x
# uses: actions/setup-node@v4
# with:
# node-version: 18.x

# - name: Use Node.js 16.x
# uses: actions/setup-node@v4
# with:
# node-version: 16.x
#
# # https://docs.cypress.io/guides/guides/launching-browsers#Linux-Dependencies
# - name: Install additional dependencies
# run: npx playwright install --with-deps webkit
#
# - name: Cypress run all tests
# uses: cypress-io/github-action@v6.7.1 # use the explicit version number
# with:
# start: npm start:auth:e2ea
# wait-on: "http://localhost:4200"
# wait-on-timeout: 120
# browser: webkit
# working-directory: frontend
#
# - name: Submit results to Xray
# # we don't want to submit results to xray when it was run by PR
# if: github.event_name != 'pull_request' && (success() || failure())
# env:
# JIRA_USERNAME: ${{ secrets.ORG_IRS_JIRA_USERNAME }}
# JIRA_PASSWORD: ${{ secrets.ORG_IRS_JIRA_PASSWORD }}
# run: |
# ./scripts/xray-push-test-results.sh
#
# - name: Archive cypress artifacts
# if: success() || failure()
# uses: actions/upload-artifact@v4
# with:
# name: cypress generated files - webkit
# path: |
# frontend/cypress/videos/
# frontend/cypress/screenshots/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #XXX update springboot to 3.2.8 from 3.2.5
- #XXX define uid and gid of backend Dockerfile directly in user, instead of variables
- #1244 upgraded registry from 0.4.1 to 0.5.0
- #XXX update e2e-tests-xray_frontend.yml to support association int environment

## [13.0.0 - 19.07.2024]

Expand Down
2 changes: 2 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ yarn-error.log

scripts/download/*
/cypress.local.config.ts
/cypress.local.config-original.ts
/cypress/downloads/Exported_Contracts.csv
6 changes: 3 additions & 3 deletions frontend/cypress/support/step_definitions/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Given('user logged in as {string}', function(userType) {

let redirectUri = encodeURIComponent(Cypress.env('REDIRECT_URI'));

cy.visit('https://centralidp.dev.demo.catena-x.net/auth/realms/CX-Central/protocol/openid-connect/auth?client_id=Cl17-CX-Part&redirect_uri=' + redirectUri + '&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.visit('https://centralidp.int.catena-x.net/auth/realms/CX-Central/protocol/openid-connect/auth?client_id=app12&redirect_uri=' + redirectUri);
cy.get('.search').click();
cy.get('.search').type('CX-Test-Access');
cy.get('.CX_Test_Access').click();
cy.get('.search').type('BMW Trace-X');
cy.get('.idp-card').contains('BMW Trace-X').click();
cy.get('input[name="username"]').type(loginMail);
cy.get('input[name="password"]').click().focus().type(loginPW, {log:false});
cy.get('input[type="submit"]').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Then('select part with id {string}', function(id: string) {
Then('start notification creation with description {string}', function(notificationType: string, description: string) {
const date = new Date().getTime();
notificationDescription = description + '_' + date;
cy.get('[data-testid="create-notification-button"]').click();
cy.get('[data-testid="create-notification-button"]').click({force: true});
cy.get('mat-label').contains(/^Description$/i).click().type(notificationDescription);
});

Expand All @@ -65,7 +65,7 @@ When('{string} deadline', function(deadline: string) {


When('request the {string}', function(notificationType: string) {
cy.get('[data-testid="save-button"]').click();
cy.get('[data-testid="save-button"]').click({force: true});
});


Expand Down
20 changes: 0 additions & 20 deletions frontend/scripts/xray-download-feature-files.sh

This file was deleted.

21 changes: 0 additions & 21 deletions frontend/scripts/xray-push-test-results.sh

This file was deleted.

0 comments on commit 1f77f37

Please sign in to comment.