Skip to content

Commit 5bc075e

Browse files
authored
Merge pull request #1347 from microting/feature/playwright-tests
Feature/playwright tests
2 parents 2930a48 + cb6e6b0 commit 5bc075e

File tree

9 files changed

+1019
-4
lines changed

9 files changed

+1019
-4
lines changed

.github/workflows/dotnet-core-master.yml

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
- name: Get standard output
131131
run: |
132132
cat docker_run_log
133-
result=`cat docker_run_log | grep "Now listening on: http://0.0.0.0:5000" -m 1 | wc -l`
133+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
134134
if [ $result -ne 1 ];then exit 1; fi
135135
- name: The job has failed
136136
if: ${{ failure() }}
@@ -161,4 +161,117 @@ jobs:
161161
- name: Build
162162
run: dotnet build eform-angular-workflow-plugin/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn.sln
163163
- name: Unit Tests
164-
run: dotnet test --no-restore -c Release -v n eform-angular-workflow-plugin/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn.Test/Workflow.Pn.Test.csproj
164+
run: dotnet test --no-restore -c Release -v n eform-angular-workflow-plugin/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn.Test/Workflow.Pn.Test.csproj
165+
workflow-playwright-test:
166+
needs: workflow-build
167+
runs-on: ubuntu-22.04
168+
strategy:
169+
fail-fast: false
170+
matrix:
171+
test: [a,b,c,d]
172+
steps:
173+
- uses: actions/checkout@v3
174+
with:
175+
path: eform-angular-workflow-plugin
176+
- name: Extract branch name
177+
id: extract_branch
178+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
179+
- name: Create docker network
180+
run: docker network create --driver bridge data
181+
- name: Start MariaDB
182+
run: |
183+
docker pull mariadb:10.8
184+
docker run --name mariadbtest --network data -e MYSQL_ROOT_PASSWORD=secretpassword -p 3306:3306 -d mariadb:10.8
185+
- name: Start rabbitmq
186+
run: |
187+
docker pull rabbitmq:latest
188+
docker run -d --hostname my-rabbit --name some-rabbit --network data -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=password rabbitmq:latest
189+
- uses: actions/download-artifact@v4
190+
with:
191+
name: workflow-container
192+
- run: docker load -i workflow-container.tar
193+
- name: Use Node.js
194+
uses: actions/setup-node@v3
195+
with:
196+
node-version: 22
197+
- name: 'Preparing Frontend checkout'
198+
uses: actions/checkout@v3
199+
with:
200+
repository: microting/eform-angular-frontend
201+
ref: ${{ steps.extract_branch.outputs.branch }}
202+
path: eform-angular-frontend
203+
- name: Sleep 15 seconds
204+
run: sleep 15
205+
- name: Load DB dump
206+
run: |
207+
mysql -u root -h 127.0.0.1 --password=secretpassword -e 'create database `420_eform-angular-workflow-plugin`'
208+
mysql -u root -h 127.0.0.1 --password=secretpassword 420_eform-angular-workflow-plugin < eform-angular-workflow-plugin/420_eform-angular-workflow-plugin.sql
209+
- name: Copy dependencies
210+
run: |
211+
cp -av eform-angular-workflow-plugin/eform-client/src/app/plugins/modules/workflow-pn eform-angular-frontend/eform-client/src/app/plugins/modules/workflow-pn
212+
mkdir -p eform-angular-frontend/eform-client/playwright/e2e/plugins/
213+
cp -av eform-angular-workflow-plugin/eform-client/playwright/e2e/plugins/workflow-pn eform-angular-frontend/eform-client/playwright/e2e/plugins/workflow-pn
214+
cp -av eform-angular-workflow-plugin/eform-client/playwright.config.ts eform-angular-frontend/eform-client/playwright.config.ts
215+
mkdir -p eform-angular-frontend/eFormAPI/eFormAPI.Web/Plugins
216+
cd eform-angular-frontend/eform-client && ../../eform-angular-workflow-plugin/testinginstallpn.sh
217+
- name: Start the newly build Docker container
218+
id: docker-run
219+
run: docker run --name my-container -p 4200:5000 --network data microtingas/workflow-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 &
220+
- name: Sleep 15 seconds
221+
run: sleep 15
222+
- name: Get standard output
223+
run: cat docker_run_log
224+
- name: Pretest changes to work with Docker container
225+
run: sed -i 's/localhost/mariadbtest/g' eform-angular-frontend/eform-client/e2e/Constants/DatabaseConfigurationConstants.ts
226+
- name: yarn install
227+
run: cd eform-angular-frontend/eform-client && yarn install
228+
- name: Install Playwright browsers
229+
run: cd eform-angular-frontend/eform-client && npx playwright install --with-deps chromium
230+
- name: DB Configuration
231+
uses: cypress-io/github-action@v4
232+
with:
233+
start: echo 'hi'
234+
wait-on: "http://localhost:4200"
235+
wait-on-timeout: 120
236+
browser: chrome
237+
record: false
238+
spec: cypress/e2e/db/*
239+
config-file: cypress.config.ts
240+
working-directory: eform-angular-frontend/eform-client
241+
command-prefix: "--"
242+
- name: Change rabbitmq hostname
243+
run: docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"'
244+
- name: Enable plugins
245+
if: matrix.test != 'a'
246+
run: |
247+
docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_Angular.EformPlugins set Status = 2'
248+
docker restart my-container
249+
sleep 15
250+
- name: Get standard output
251+
run: |
252+
cat docker_run_log
253+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
254+
if [ $result -ne 1 ];then exit 1; fi
255+
- name: Wait for app
256+
run: npx wait-on http://localhost:4200 --timeout 120000
257+
- name: ${{ matrix.test }} playwright test
258+
run: |
259+
cd eform-angular-frontend/eform-client
260+
npx playwright test playwright/e2e/plugins/workflow-pn/${{ matrix.test }}/
261+
- name: Stop the newly build Docker container
262+
run: docker stop my-container
263+
- name: Get standard output
264+
run: |
265+
cat docker_run_log
266+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
267+
if [ $result -ne 1 ];then exit 1; fi
268+
- name: Get standard output
269+
if: ${{ failure() }}
270+
run: cat docker_run_log
271+
- name: Archive Playwright report
272+
if: failure()
273+
uses: actions/upload-artifact@v4
274+
with:
275+
name: playwright-report-${{ matrix.test }}
276+
path: eform-angular-frontend/eform-client/playwright-report/
277+
retention-days: 2

.github/workflows/dotnet-core-pr.yml

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
- name: Get standard output
125125
run: |
126126
cat docker_run_log
127-
result=`cat docker_run_log | grep "Now listening on: http://0.0.0.0:5000" -m 1 | wc -l`
127+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
128128
if [ $result -ne 1 ];then exit 1; fi
129129
- name: The job has failed
130130
if: ${{ failure() }}
@@ -155,4 +155,114 @@ jobs:
155155
- name: Build
156156
run: dotnet build eform-angular-workflow-plugin/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn.sln
157157
- name: Unit Tests
158-
run: dotnet test --no-restore -c Release -v n eform-angular-workflow-plugin/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn.Test/Workflow.Pn.Test.csproj
158+
run: dotnet test --no-restore -c Release -v n eform-angular-workflow-plugin/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn.Test/Workflow.Pn.Test.csproj
159+
workflow-playwright-test:
160+
needs: workflow-build
161+
runs-on: ubuntu-22.04
162+
strategy:
163+
fail-fast: false
164+
matrix:
165+
test: [a,b,c,d]
166+
steps:
167+
- uses: actions/checkout@v3
168+
with:
169+
path: eform-angular-workflow-plugin
170+
- name: Create docker network
171+
run: docker network create --driver bridge data
172+
- name: Start MariaDB
173+
run: |
174+
docker pull mariadb:10.8
175+
docker run --name mariadbtest --network data -e MYSQL_ROOT_PASSWORD=secretpassword -p 3306:3306 -d mariadb:10.8
176+
- name: Start rabbitmq
177+
run: |
178+
docker pull rabbitmq:latest
179+
docker run -d --hostname my-rabbit --name some-rabbit --network data -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=password rabbitmq:latest
180+
- uses: actions/download-artifact@v4
181+
with:
182+
name: workflow-container
183+
- run: docker load -i workflow-container.tar
184+
- name: Use Node.js
185+
uses: actions/setup-node@v3
186+
with:
187+
node-version: 22
188+
- name: 'Preparing Frontend checkout'
189+
uses: actions/checkout@v3
190+
with:
191+
repository: microting/eform-angular-frontend
192+
ref: stable
193+
path: eform-angular-frontend
194+
- name: Sleep 15 seconds
195+
run: sleep 15
196+
- name: Load DB dump
197+
run: |
198+
mysql -u root -h 127.0.0.1 --password=secretpassword -e 'create database `420_eform-angular-workflow-plugin`'
199+
mysql -u root -h 127.0.0.1 --password=secretpassword 420_eform-angular-workflow-plugin < eform-angular-workflow-plugin/420_eform-angular-workflow-plugin.sql
200+
- name: Copy dependencies
201+
run: |
202+
cp -av eform-angular-workflow-plugin/eform-client/src/app/plugins/modules/workflow-pn eform-angular-frontend/eform-client/src/app/plugins/modules/workflow-pn
203+
mkdir -p eform-angular-frontend/eform-client/playwright/e2e/plugins/
204+
cp -av eform-angular-workflow-plugin/eform-client/playwright/e2e/plugins/workflow-pn eform-angular-frontend/eform-client/playwright/e2e/plugins/workflow-pn
205+
cp -av eform-angular-workflow-plugin/eform-client/playwright.config.ts eform-angular-frontend/eform-client/playwright.config.ts
206+
mkdir -p eform-angular-frontend/eFormAPI/eFormAPI.Web/Plugins
207+
cd eform-angular-frontend/eform-client && ../../eform-angular-workflow-plugin/testinginstallpn.sh
208+
- name: Start the newly build Docker container
209+
id: docker-run
210+
run: docker run --name my-container -p 4200:5000 --network data microtingas/workflow-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 &
211+
- name: Sleep 15 seconds
212+
run: sleep 15
213+
- name: Get standard output
214+
run: cat docker_run_log
215+
- name: Pretest changes to work with Docker container
216+
run: sed -i 's/localhost/mariadbtest/g' eform-angular-frontend/eform-client/e2e/Constants/DatabaseConfigurationConstants.ts
217+
- name: yarn install
218+
run: cd eform-angular-frontend/eform-client && yarn install
219+
- name: Install Playwright browsers
220+
run: cd eform-angular-frontend/eform-client && npx playwright install --with-deps chromium
221+
- name: DB Configuration
222+
uses: cypress-io/github-action@v4
223+
with:
224+
start: echo 'hi'
225+
wait-on: "http://localhost:4200"
226+
wait-on-timeout: 120
227+
browser: chrome
228+
record: false
229+
spec: cypress/e2e/db/*
230+
config-file: cypress.config.ts
231+
working-directory: eform-angular-frontend/eform-client
232+
command-prefix: "--"
233+
- name: Change rabbitmq hostname
234+
run: docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"'
235+
- name: Enable plugins
236+
if: matrix.test != 'a'
237+
run: |
238+
docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_Angular.EformPlugins set Status = 2'
239+
docker restart my-container
240+
sleep 15
241+
- name: Get standard output
242+
run: |
243+
cat docker_run_log
244+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
245+
if [ $result -ne 1 ];then exit 1; fi
246+
- name: Wait for app
247+
run: npx wait-on http://localhost:4200 --timeout 120000
248+
- name: ${{ matrix.test }} playwright test
249+
run: |
250+
cd eform-angular-frontend/eform-client
251+
npx playwright test playwright/e2e/plugins/workflow-pn/${{ matrix.test }}/
252+
- name: Stop the newly build Docker container
253+
run: docker stop my-container
254+
- name: Get standard output
255+
run: |
256+
cat docker_run_log
257+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
258+
if [ $result -ne 1 ];then exit 1; fi
259+
- name: Get standard output
260+
if: ${{ failure() }}
261+
run: cat docker_run_log
262+
- name: Archive Playwright report
263+
if: failure()
264+
uses: actions/upload-artifact@v4
265+
with:
266+
name: playwright-report-${{ matrix.test }}
267+
path: eform-angular-frontend/eform-client/playwright-report/
268+
retention-days: 2

eform-client/playwright.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// eform-client/playwright.config.ts
2+
import { defineConfig, devices } from '@playwright/test';
3+
4+
export default defineConfig({
5+
testDir: './playwright/e2e',
6+
fullyParallel: false,
7+
forbidOnly: !!process.env.CI,
8+
retries: process.env.CI ? 1 : 0,
9+
workers: 1,
10+
reporter: [
11+
['html', { open: 'never' }],
12+
['json', { outputFile: 'playwright-report/results.json' }],
13+
],
14+
timeout: 120_000,
15+
use: {
16+
baseURL: 'http://localhost:4200',
17+
viewport: { width: 1920, height: 1080 },
18+
video: 'retain-on-failure',
19+
screenshot: 'only-on-failure',
20+
trace: 'retain-on-failure',
21+
},
22+
projects: [
23+
{
24+
name: 'chromium',
25+
use: { ...devices['Desktop Chrome'] },
26+
},
27+
],
28+
});

0 commit comments

Comments
 (0)