Skip to content

Commit 4a3203d

Browse files
authored
Merge pull request #1205 from microting/feature/playwright-tests
Feature/playwright tests
2 parents 769a872 + 5995b1c commit 4a3203d

4 files changed

Lines changed: 279 additions & 18 deletions

File tree

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

Lines changed: 109 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,15 @@ jobs:
104104
- name: Create errorShots directory
105105
run: mkdir eform-angular-frontend/eform-client/errorShots
106106
- name: Pretest changes to work with Docker container
107-
run: sed -i 's/localhost/mariadbtest/g' eform-angular-frontend/eform-client/e2e/Constants/DatabaseConfigurationConstants.ts
108-
- name: Get standard output
109-
run: |
110-
cat docker_run_log
107+
run: sed -i 's/localhost/mariadbtest/g' eform-angular-frontend/eform-client/playwright/e2e/Constants/DatabaseConfigurationConstants.ts
108+
- name: yarn install
109+
run: cd eform-angular-frontend/eform-client && yarn install
110+
- name: Install Playwright browsers
111+
run: cd eform-angular-frontend/eform-client && npx playwright install --with-deps chromium
112+
- name: Wait for app
113+
run: npx wait-on http://localhost:4200 --timeout 120000
111114
- name: DB Configuration
112-
uses: cypress-io/github-action@v3
113-
with:
114-
start: echo 'hi'
115-
wait-on: "http://localhost:4200"
116-
wait-on-timeout: 120
117-
browser: chrome
118-
record: false
119-
spec: cypress/e2e/db/*
120-
config-file: cypress.config.ts
121-
working-directory: eform-angular-frontend/eform-client
115+
run: cd eform-angular-frontend/eform-client && npx playwright test playwright/e2e/Tests/database-configuration/
122116
- name: Change rabbitmq hostname
123117
run: docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"'
124118
#- name: Plugin testing
@@ -128,7 +122,7 @@ jobs:
128122
- name: Get standard output
129123
run: |
130124
cat docker_run_log
131-
result=`cat docker_run_log | grep "Now listening on: http://0.0.0.0:5000" -m 1 | wc -l`
125+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
132126
if [ $result -ne 1 ];then exit 1; fi
133127
- name: The job has failed
134128
if: always()
@@ -163,4 +157,103 @@ jobs:
163157
- name: Build
164158
run: dotnet build eform-angular-greate-belt-plugin/eFormAPI/Plugins/GreateBelt.Pn/GreateBelt.Pn.sln
165159
- name: Unit Tests
166-
run: dotnet test --no-restore -c Release -v n eform-angular-greate-belt-plugin/eFormAPI/Plugins/GreateBelt.Pn/GreateBelt.Pn.Test/GreateBelt.Pn.Test.csproj
160+
run: dotnet test --no-restore -c Release -v n eform-angular-greate-belt-plugin/eFormAPI/Plugins/GreateBelt.Pn/GreateBelt.Pn.Test/GreateBelt.Pn.Test.csproj
161+
greate-belt-playwright-test:
162+
needs: greate-belt-pn-build
163+
runs-on: ubuntu-22.04
164+
strategy:
165+
fail-fast: false
166+
matrix:
167+
test: [a]
168+
steps:
169+
- uses: actions/checkout@v3
170+
with:
171+
path: eform-angular-greate-belt-plugin
172+
- name: Extract branch name
173+
id: extract_branch
174+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
175+
- name: Create docker network
176+
run: docker network create --driver bridge --attachable data
177+
- name: Start MariaDB
178+
run: |
179+
docker pull mariadb:10.8
180+
docker run --name mariadbtest --network data -e MYSQL_ROOT_PASSWORD=secretpassword -p 3306:3306 -d mariadb:10.8
181+
- name: Start rabbitmq
182+
run: |
183+
docker pull rabbitmq:latest
184+
docker run -d --hostname my-rabbit --name some-rabbit --network data -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=password rabbitmq:latest
185+
- uses: actions/download-artifact@v4
186+
with:
187+
name: greate-belt-container
188+
- run: docker load -i greate-belt-container.tar
189+
- name: Use Node.js
190+
uses: actions/setup-node@v3
191+
with:
192+
node-version: 22
193+
- name: 'Preparing Frontend checkout'
194+
uses: actions/checkout@v3
195+
with:
196+
repository: microting/eform-angular-frontend
197+
ref: ${{ steps.extract_branch.outputs.branch }}
198+
path: eform-angular-frontend
199+
- name: 'Preparing ItemsPlanning checkout'
200+
uses: actions/checkout@v3
201+
with:
202+
repository: microting/eform-angular-items-planning-plugin
203+
ref: ${{ steps.extract_branch.outputs.branch }}
204+
path: eform-angular-items-planning-plugin
205+
- name: Sleep 15 seconds
206+
run: sleep 15
207+
- name: Copy dependencies
208+
run: |
209+
cp -av eform-angular-items-planning-plugin/eform-client/src/app/plugins/modules/items-planning-pn eform-angular-frontend/eform-client/src/app/plugins/modules/items-planning-pn
210+
cp -av eform-angular-greate-belt-plugin/eform-client/src/app/plugins/modules/greate-belt-pn eform-angular-frontend/eform-client/src/app/plugins/modules/greate-belt-pn
211+
mkdir -p eform-angular-frontend/eform-client/playwright/e2e/plugins/
212+
cp -av eform-angular-greate-belt-plugin/eform-client/playwright/e2e/plugins/greate-belt-pn eform-angular-frontend/eform-client/playwright/e2e/plugins/greate-belt-pn
213+
cp -av eform-angular-greate-belt-plugin/eform-client/playwright.config.ts eform-angular-frontend/eform-client/playwright.config.ts
214+
mkdir -p eform-angular-frontend/eFormAPI/eFormAPI.Web/Plugins
215+
cd eform-angular-frontend/eform-client && ../../eform-angular-items-planning-plugin/testinginstallpn.sh
216+
../../eform-angular-greate-belt-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/greate-belt-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/playwright/e2e/Constants/DatabaseConfigurationConstants.ts
226+
- name: Wait for app
227+
run: npx wait-on http://localhost:4200 --timeout 120000
228+
- name: DB Configuration
229+
run: cd eform-angular-frontend/eform-client && npx playwright test playwright/e2e/Tests/database-configuration/
230+
- name: Change rabbitmq hostname
231+
run: docker exec -i mariadbtest mysql -u root --password=secretpassword -e 'update 420_SDK.Settings set Value = "my-rabbit" where Name = "rabbitMqHost"'
232+
- name: Get standard output
233+
run: |
234+
cat docker_run_log
235+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
236+
if [ $result -ne 1 ];then exit 1; fi
237+
- name: Wait for app
238+
run: npx wait-on http://localhost:4200 --timeout 120000
239+
- name: ${{ matrix.test }} playwright test
240+
run: |
241+
cd eform-angular-frontend/eform-client
242+
npx playwright test playwright/e2e/plugins/greate-belt-pn/${{ matrix.test }}/
243+
- name: Stop the newly build Docker container
244+
run: docker stop my-container
245+
- name: Get standard output
246+
run: |
247+
cat docker_run_log
248+
result=`cat docker_run_log | grep "Now listening on:.*:5000" -m 1 | wc -l`
249+
if [ $result -ne 1 ];then exit 1; fi
250+
- name: Get standard output
251+
if: ${{ failure() }}
252+
run: cat docker_run_log
253+
- name: Archive Playwright report
254+
if: failure()
255+
uses: actions/upload-artifact@v4
256+
with:
257+
name: playwright-report-${{ matrix.test }}
258+
path: eform-angular-frontend/eform-client/playwright-report/
259+
retention-days: 2

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

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

eform-client/playwright.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './playwright/e2e',
5+
fullyParallel: false,
6+
workers: 1,
7+
timeout: 120_000,
8+
use: {
9+
baseURL: 'http://localhost:4200',
10+
viewport: { width: 1920, height: 1080 },
11+
video: 'retain-on-failure',
12+
screenshot: 'only-on-failure',
13+
trace: 'retain-on-failure',
14+
},
15+
projects: [
16+
{
17+
name: 'chromium',
18+
use: { ...devices['Desktop Chrome'] },
19+
},
20+
],
21+
});
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { test, expect } from '@playwright/test';
2+
import { LoginPage } from '../../../Page objects/Login.page';
3+
import { MyEformsPage } from '../../../Page objects/MyEforms.page';
4+
import { PluginPage } from '../../../Page objects/Plugin.page';
5+
6+
const pluginName = 'Microting Greate Belt Plugin';
7+
8+
let page;
9+
10+
test.describe('Application settings page - site header section', () => {
11+
test.beforeAll(async ({ browser }) => {
12+
page = await browser.newPage();
13+
});
14+
15+
test.afterAll(async () => {
16+
await page.close();
17+
});
18+
19+
test('should go to plugin settings page', async () => {
20+
const loginPage = new LoginPage(page);
21+
const myEformsPage = new MyEformsPage(page);
22+
const pluginPage = new PluginPage(page);
23+
24+
await loginPage.open('/auth');
25+
await loginPage.login();
26+
await myEformsPage.Navbar.goToPluginsPage();
27+
28+
const plugin = await pluginPage.getPluginRowObjByName(pluginName);
29+
expect(plugin).not.toBeNull();
30+
expect(plugin!.name.trim()).toBe(pluginName);
31+
expect(plugin!.status.trim()).toBe('toggle_off');
32+
});
33+
34+
test('should activate the plugin', async () => {
35+
test.setTimeout(240000);
36+
const pluginPage = new PluginPage(page);
37+
38+
const plugin = await pluginPage.getPluginRowObjByName(pluginName);
39+
expect(plugin).not.toBeNull();
40+
await plugin!.enableOrDisablePlugin();
41+
42+
const pluginAfter = await pluginPage.getPluginRowObjByName(pluginName);
43+
expect(pluginAfter).not.toBeNull();
44+
expect(pluginAfter!.name.trim()).toBe(pluginName);
45+
expect(pluginAfter!.status.trim()).toBe('toggle_on');
46+
});
47+
});

0 commit comments

Comments
 (0)