-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/ 12 Setup E2E tests #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0ec1375
feat(frontend): Add e2e test setup and write a example test #12
f061aed
test(e2e): Add page model with abstraction for more reuseability in t…
ce56110
docs(frontend): Add troubleshooting steps for e2e tests #12
08bdbb2
ci(frontend): Use newest node setup version and rename file to have .…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| name: "On push" | ||
|
|
||
| on: | ||
| push: | ||
|
|
||
| jobs: | ||
| format: | ||
| uses: ./.github/workflows/reusable__format.yaml | ||
| with: | ||
| COMMIT_HASH: ${{ github.sha }} | ||
|
|
||
| tests: | ||
| uses: ./.github/workflows/reusable__tests.yaml | ||
| with: | ||
| COMMIT_HASH: ${{ github.sha }} | ||
|
|
||
| e2e-tests: | ||
| needs: | ||
| - format | ||
| - tests | ||
| uses: ./.github/workflows/reusable__e2e-testing.yaml | ||
| with: | ||
| COMMIT_HASH: ${{ github.sha }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| name: 'Reusable - Run E2E Tests (Matrix)' | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| DOCKER_IMAGE_TAG: | ||
| type: string | ||
| description: 'The full Docker image tag being tested' | ||
| required: false | ||
| COMMIT_HASH: | ||
| type: string | ||
| description: 'The commit hash from which to check out the repository' | ||
| required: false | ||
|
|
||
| jobs: | ||
| get-e2e-files: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| file_list: ${{ steps.generate-file-list.outputs.file_list }} | ||
| steps: | ||
| - name: Checkout Target Repo Code (to find test files) | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ inputs.COMMIT_HASH }} | ||
|
|
||
| - name: Install jq (JSON processor) | ||
| run: sudo apt-get update && sudo apt-get install -y jq | ||
|
|
||
| - name: Generate list of E2E test files | ||
| id: generate-file-list | ||
| env: | ||
| E2E_DIR: frontend/cypress/e2e | ||
| run: | | ||
| if [ -d "$E2E_DIR" ] && [ "$(ls -A $E2E_DIR)" ]; then | ||
| FILES=$(ls $E2E_DIR | jq -R . | jq -s . | jq -c) | ||
| echo "Found test files: $FILES" | ||
| else | ||
| echo "No test files found in $E2E_DIR or directory does not exist." | ||
| FILES="[]" | ||
| fi | ||
| echo "file_list=$FILES" >> $GITHUB_OUTPUT | ||
|
|
||
| e2e: | ||
| needs: get-e2e-files | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }} | ||
| env: | ||
| BRANCH_NAME: ${{ github.ref_name || github.base_ref }} | ||
| COMMIT_REF: ${{ inputs.COMMIT_HASH || github.ref_name }} | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ env.COMMIT_REF }} | ||
|
|
||
| - name: Start application stack with Docker Compose | ||
| run: cd docker && docker compose -f docker-compose.yml -f docker-compose.e2e.yml up -d | ||
|
|
||
| - name: Set up node for Cypress | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: ${{ vars.NODE_VERSION }} | ||
|
|
||
| - name: Cypress run e2e tests | ||
| uses: cypress-io/github-action@v6 | ||
| with: | ||
| working-directory: frontend | ||
| install: true | ||
| wait-on: 'http://localhost:4200/' | ||
| wait-on-timeout: 300 | ||
| browser: chrome | ||
| headed: false | ||
| config: baseUrl=http://localhost:4200/ | ||
| spec: cypress/e2e/${{ matrix.file }} | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: cypress-screenshots for ${{ matrix.file }} | ||
| path: frontend/cypress/screenshots |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
backend/src/main/resources/application-e2e-test.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| spring.application.name=PCTS | ||
|
|
||
| spring.datasource.url=jdbc:postgresql://pcts-db:5432/pcts | ||
| spring.datasource.username=user | ||
| spring.datasource.password=pwd | ||
| spring.datasource.driver-class-name=org.postgresql.Driver | ||
|
|
||
| #Flyway | ||
| spring.flyway.locations=classpath:db/migration,classpath:db/e2e-data-migration | ||
| spring.flyway.schemas=public | ||
|
|
||
| springdoc.api-docs.enabled=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| services: | ||
| pcts-backend: | ||
| container_name: pcts-e2e-backend | ||
| environment: | ||
| SPRING_PROFILE: e2e-test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
| git_base_path=$(git rev-parse --show-toplevel) | ||
|
|
||
| echo "**Changing into the docker directory**" | ||
| cd "$git_base_path"/docker | ||
|
|
||
| echo "**Merging and running the docker-compose file**" | ||
| echo "----------------------------------------------------------------" | ||
| docker compose -f docker-compose.yml -f docker-compose.e2e.yml up | ||
|
|
||
| echo "**Stopping the docker containers**" | ||
| trap 'docker compose down' EXIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { defineConfig } from 'cypress'; | ||
|
|
||
| export default defineConfig({ | ||
| e2e: { | ||
| baseUrl: 'http://localhost:4200', | ||
| experimentalMemoryManagement: true, | ||
| testIsolation: true, | ||
| viewportWidth: 1920, | ||
| viewportHeight: 1080 | ||
| }, | ||
| retries: { | ||
| // Configure retry attempts for `cypress run` | ||
| runMode: 2, | ||
| // Configure retry attempts for `cypress open` | ||
| openMode: 0, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import HomePage from '../pages/homePage'; | ||
|
|
||
| describe('example page', () => { | ||
| beforeEach(() => { | ||
| HomePage.visitDefaultPage(); | ||
| }); | ||
|
|
||
| it('should show html', () => { | ||
| cy.get('html') | ||
| .should('be.visible'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "Using fixtures to represent data", | ||
| "email": "hello@cypress.io", | ||
| "body": "Fixtures are a great way to mock data for responses to routes" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.