Fix broken unit tests in time-planning-pn components #339
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
name: .NET Master | |
on: | |
pull_request: | |
branches: [ master, stable, angular19 ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: eform-angular-timeplanning-plugin | |
- name: 'Preparing Frontend checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: microting/eform-angular-frontend | |
ref: stable | |
path: eform-angular-frontend | |
- name: Copy dependencies | |
run: | | |
cp -av eform-angular-timeplanning-plugin/eform-client/src/app/plugins/modules/time-planning-pn eform-angular-frontend/eform-client/src/app/plugins/modules/time-planning-pn | |
cp -av eform-angular-timeplanning-plugin/eform-client/e2e/Tests/time-planning-settings eform-angular-frontend/eform-client/e2e/Tests/time-planning-settings | |
cp -av eform-angular-timeplanning-plugin/eform-client/e2e/Tests/time-planning-general eform-angular-frontend/eform-client/e2e/Tests/time-planning-general | |
cp -av eform-angular-timeplanning-plugin/eform-client/e2e/Page\ objects/TimePlanning eform-angular-frontend/eform-client/e2e/Page\ objects/TimePlanning | |
cp -av eform-angular-timeplanning-plugin/eform-client/wdio-headless-plugin-step2a.conf.ts eform-angular-frontend/eform-client/wdio-headless-plugin-step2a.conf.ts | |
cp -av eform-angular-timeplanning-plugin/eform-client/wdio-plugin-step2.conf.ts eform-angular-frontend/eform-client/wdio-plugin-step2.conf.ts | |
cd eform-angular-frontend/eform-client && ../../eform-angular-timeplanning-plugin/testinginstallpn.sh | |
- name: Copy Dockerfile | |
run: cp eform-angular-timeplanning-plugin/Dockerfile . | |
- name: Build the tagged Docker image | |
run: docker build . -t microtingas/time-planning-container:latest -t microtingas/time-planning-container:1.0.0 --build-arg GITVERSION=1.0.0 --build-arg PLUGINVERSION=1.0.0 | |
- name: Tag builds | |
run: |- | |
docker tag microtingas/time-planning-container:latest microtingas/time-planning-container:latest | |
- run: docker save microtingas/time-planning-container:latest -o time-planning-container.tar | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: time-planning-container | |
path: time-planning-container.tar | |
angular-unit-test: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: eform-angular-timeplanning-plugin | |
- name: 'Preparing Frontend checkout' | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: microting/eform-angular-frontend | |
ref: stable | |
path: eform-angular-frontend | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Copy dependencies | |
run: | | |
cp -av eform-angular-timeplanning-plugin/eform-client/src/app/plugins/modules/time-planning-pn eform-angular-frontend/eform-client/src/app/plugins/modules/time-planning-pn | |
cd eform-angular-frontend/eform-client && ../../eform-angular-timeplanning-plugin/testinginstallpn.sh | |
- name: yarn install | |
run: cd eform-angular-frontend/eform-client && yarn install | |
- name: Run Angular unit tests | |
run: | | |
cd eform-angular-frontend/eform-client | |
# Check if Jest is configured | |
if [ ! -f "jest.config.js" ] && [ ! -f "jest.config.ts" ]; then | |
echo "⚠️ Jest is not configured in the frontend repository." | |
echo "Unit tests require Jest to be configured. Skipping unit tests." | |
echo "" | |
echo "To enable unit tests, ensure Jest is configured in the frontend repository." | |
exit 0 | |
fi | |
# Run Jest tests for time-planning-pn plugin | |
echo "Running Jest tests for time-planning-pn plugin..." | |
npm run test:unit -- --testPathPatterns=time-planning-pn --coverage --collectCoverageFrom='src/app/plugins/modules/time-planning-pn/**/*.ts' --coveragePathIgnorePatterns='\.spec\.ts$' | |
pn-test: | |
needs: build | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
test: [a,b,c,d,e,f,g,h] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
path: eform-angular-timeplanning-plugin | |
- uses: actions/download-artifact@v4 | |
with: | |
name: time-planning-container | |
- run: docker load -i time-planning-container.tar | |
- name: Create docker network | |
run: docker network create --driver bridge --attachable data | |
- name: Start MariaDB | |
run: | | |
docker pull mariadb:10.8 | |
docker run --name mariadbtest --network data -e MYSQL_ROOT_PASSWORD=secretpassword -p 3306:3306 -d mariadb:10.8 | |
- name: Start rabbitmq | |
run: | | |
docker pull rabbitmq:latest | |
docker run -d --hostname my-rabbit --name some-rabbit --network data -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=password rabbitmq:latest | |
- name: Sleep 15 | |
run: sleep 15 | |
- name: Start the newly build Docker container | |
id: docker-run | |
run: docker run --name my-container -p 4200:5000 --network data microtingas/time-planning-container:latest "/ConnectionString=host=mariadbtest;Database=420_Angular;user=root;password=secretpassword;port=3306;Convert Zero Datetime = true;SslMode=none;" > docker_run_log 2>&1 & | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: 'Preparing Frontend checkout' | |
uses: actions/checkout@v3 | |
with: | |
repository: microting/eform-angular-frontend | |
ref: stable | |
path: eform-angular-frontend | |
- name: Copy dependencies | |
run: | | |
cp -av eform-angular-timeplanning-plugin/eform-client/src/app/plugins/modules/time-planning-pn eform-angular-frontend/eform-client/src/app/plugins/modules/time-planning-pn | |
cp -av eform-angular-timeplanning-plugin/eform-client/e2e/Tests/time-planning-settings eform-angular-frontend/eform-client/e2e/Tests/time-planning-settings | |
cp -av eform-angular-timeplanning-plugin/eform-client/e2e/Tests/time-planning-general eform-angular-frontend/eform-client/e2e/Tests/time-planning-general | |
cp -av eform-angular-timeplanning-plugin/eform-client/e2e/Page\ objects/TimePlanning eform-angular-frontend/eform-client/e2e/Page\ objects/TimePlanning | |
cp -av eform-angular-timeplanning-plugin/eform-client/wdio-headless-plugin-step2a.conf.ts eform-angular-frontend/eform-client/wdio-headless-plugin-step2a.conf.ts | |
cp -av eform-angular-timeplanning-plugin/eform-client/wdio-plugin-step2.conf.ts eform-angular-frontend/eform-client/wdio-plugin-step2.conf.ts | |
mkdir -p eform-angular-frontend/eFormAPI/eFormAPI.Web/Plugins | |
mkdir -p eform-angular-frontend/eform-client/cypress/e2e/plugins/ | |
mkdir -p eform-angular-frontend/eform-client/cypress/fixtures/ | |
cp -av eform-angular-timeplanning-plugin/eform-client/cypress/fixtures eform-angular-frontend/eform-client/cypress | |
cp -av eform-angular-timeplanning-plugin/eform-client/cypress/e2e/plugins/time-planning-pn eform-angular-frontend/eform-client/cypress/e2e/plugins/time-planning-pn | |
cd eform-angular-frontend/eform-client && ../../eform-angular-timeplanning-plugin/testinginstallpn.sh | |
- name: yarn install | |
run: cd eform-angular-frontend/eform-client && yarn install | |
- name: Create errorShots directory | |
run: mkdir eform-angular-frontend/eform-client/errorShots | |
- name: Pretest changes to work with Docker container | |
run: sed -i 's/localhost/mariadbtest/g' eform-angular-frontend/eform-client/e2e/Constants/DatabaseConfigurationConstants.ts | |
- name: Get standard output | |
run: | | |
cat docker_run_log | |
- name: DB Configuration | |
uses: cypress-io/github-action@v4 | |
with: | |
start: echo 'hi' | |
wait-on: "http://localhost:4200" | |
wait-on-timeout: 120 | |
browser: chrome | |
record: false | |
spec: cypress/e2e/db/* | |
config-file: cypress.config.ts | |
working-directory: eform-angular-frontend/eform-client | |
command-prefix: "--" | |
- name: Change rabbitmq hostname | |
run: docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"' | |
- name: Create database | |
if: matrix.test == 'd' | |
run: | | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword -e 'update 420_Angular.EformPlugins set Status = 1' | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword -e 'create database `420_eform-angular-time-planning-plugin`' | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword 420_SDK < eform-angular-frontend/eform-client/cypress/e2e/plugins/time-planning-pn/d/420_SDK.sql | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword 420_eform-angular-time-planning-plugin < eform-angular-frontend/eform-client/cypress/e2e/plugins/time-planning-pn/d/420_eform-angular-time-planning-plugin.sql | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"' | |
- name: Create database | |
if: matrix.test != 'd' | |
run: | | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword -e 'update 420_Angular.EformPlugins set Status = 1' | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword -e 'create database `420_eform-angular-time-planning-plugin`' | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword 420_SDK < eform-angular-frontend/eform-client/cypress/e2e/plugins/time-planning-pn/a/420_SDK.sql | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword 420_eform-angular-time-planning-plugin < eform-angular-frontend/eform-client/cypress/e2e/plugins/time-planning-pn/a/420_eform-angular-time-planning-plugin.sql | |
docker exec -i mariadbtest mariadb -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"' | |
- name: ${{matrix.test}} test | |
uses: cypress-io/github-action@v4 | |
with: | |
start: echo 'hi' | |
wait-on: "http://localhost:4200" | |
wait-on-timeout: 120 | |
browser: chrome | |
record: false | |
spec: cypress/e2e/plugins/time-planning-pn/${{matrix.test}}/* | |
config-file: cypress.config.ts | |
working-directory: eform-angular-frontend/eform-client | |
command-prefix: "--" | |
- name: Stop the newly build Docker container | |
run: docker stop my-container | |
- name: Get standard output | |
run: | | |
cat docker_run_log | |
result=`cat docker_run_log | grep "Now listening on: http://0.0.0.0:5000" -m 1 | wc -l` | |
if [ $result -ne 1 ];then exit 1; fi | |
- name: The job has failed | |
if: always() | |
run: | | |
cat docker_run_log | |
- name: Archive screenshot artifacts | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: error Screenshots | |
path: | | |
eform-angular-frontend/eform-client/errorShots/chrome*.png | |
retention-days: 2 | |
test-dotnet: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Create docker network | |
run: docker network create --driver bridge --attachable data | |
- name: Start MariaDB | |
run: | | |
docker pull mariadb:10.8 | |
docker run --name mariadbtest --network data -e MYSQL_ROOT_PASSWORD=secretpassword -p 3306:3306 -d mariadb:10.8 | |
- name: Start rabbitmq | |
run: | | |
docker pull rabbitmq:latest | |
docker run -d --hostname my-rabbit --name some-rabbit --network data -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=password -p 5672:5672 rabbitmq:latest | |
- name: Sleep 15 | |
run: sleep 15 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 9.0.x | |
- name: Build | |
run: dotnet build eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn.sln | |
- name: Unit Tests | |
run: dotnet test --no-restore -c Release -v n eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn.Test/TimePlanning.Pn.Test.csproj |