Skip to content

Commit 4de8180

Browse files
KrumTyttsvtkovvalkirilovpawelangelow
authored
[RI-6570] Add Playwright E2E tests (#4615)
* initial setup * documentation and some additional scripts * added selector module * add e2e tests workflow trigger * feat: configure code coverage reports for the playwright e2e tests (#4722) --------- Co-authored-by: ttsvtkov <[email protected]> Co-authored-by: Valentin Kirilov <[email protected]> Co-authored-by: Pavel Angelov <[email protected]>
1 parent ba98a4c commit 4de8180

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6284
-82
lines changed

.github/workflows/code-coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ jobs:
101101
continue-on-error: true
102102

103103
- name: Post or Update Coverage Summary Comment
104+
if: ${{ steps.findPr.outputs.number != '' }}
104105
uses: actions/github-script@v7
105106
if: ${{ steps.findPr.outputs.number != '' }}
106107
with:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: ✅ E2E Approve
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
e2e-approve:
9+
runs-on: ubuntu-latest
10+
if: github.event.review.state == 'approved'
11+
steps:
12+
- name: Add "e2e-approved" Label
13+
uses: actions-ecosystem/action-add-labels@v1
14+
with:
15+
labels: e2e-approved

.github/workflows/tests-e2e-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
TEST_BIG_DB_DUMP=$TEST_BIG_DB_DUMP \
8484
RI_SERVER_TLS_CERT="$RI_SERVER_TLS_CERT" \
8585
RI_SERVER_TLS_KEY="$RI_SERVER_TLS_KEY" \
86-
docker compose \
86+
docker compose --profile e2e \
8787
-f tests/e2e/rte.docker-compose.yml \
8888
-f tests/e2e/docker.web.docker-compose.yml \
8989
up --abort-on-container-exit --force-recreate
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Playwright E2E Tests
2+
on:
3+
workflow_call:
4+
inputs:
5+
debug:
6+
description: SSH Debug
7+
default: false
8+
type: boolean
9+
env:
10+
E2E_CLOUD_DATABASE_USERNAME: ${{ secrets.E2E_CLOUD_DATABASE_USERNAME }}
11+
E2E_CLOUD_DATABASE_PASSWORD: ${{ secrets.E2E_CLOUD_DATABASE_PASSWORD }}
12+
E2E_CLOUD_API_ACCESS_KEY: ${{ secrets.E2E_CLOUD_API_ACCESS_KEY }}
13+
E2E_CLOUD_DATABASE_HOST: ${{ secrets.E2E_CLOUD_DATABASE_HOST }}
14+
E2E_CLOUD_DATABASE_PORT: ${{ secrets.E2E_CLOUD_DATABASE_PORT }}
15+
E2E_CLOUD_DATABASE_NAME: ${{ secrets.E2E_CLOUD_DATABASE_NAME }}
16+
E2E_CLOUD_API_SECRET_KEY: ${{ secrets.E2E_CLOUD_API_SECRET_KEY }}
17+
18+
E2E_RI_ENCRYPTION_KEY: ${{ secrets.E2E_RI_ENCRYPTION_KEY }}
19+
RI_ENCRYPTION_KEY: ${{ secrets.RI_ENCRYPTION_KEY }}
20+
RI_SERVER_TLS_CERT: ${{ secrets.RI_SERVER_TLS_CERT }}
21+
RI_SERVER_TLS_KEY: ${{ secrets.RI_SERVER_TLS_KEY }}
22+
TEST_BIG_DB_DUMP: ${{ secrets.TEST_BIG_DB_DUMP }}
23+
E2E_VOLUME_PATH: '/usr/src/app'
24+
25+
jobs:
26+
e2e-playwright-chromium-docker:
27+
name: E2E Playwright Chromium Docker Build Tests
28+
timeout-minutes: 60
29+
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Install dependencies for Playwright tests
36+
uses: ./.github/actions/install-deps
37+
with:
38+
dir-path: './tests/playwright'
39+
40+
- name: Install Playwright Browsers
41+
working-directory: ./tests/playwright
42+
run: yarn playwright install --with-deps
43+
44+
- name: Download Docker Artifacts
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: docker-builds
48+
path: ./release
49+
50+
- name: Load built docker image from workspace
51+
run: |
52+
docker image load -i ./release/docker/docker-linux-alpine.amd64.tar
53+
54+
- name: Set up redis test environments
55+
run: |
56+
TEST_BIG_DB_DUMP=$TEST_BIG_DB_DUMP \
57+
docker compose -p e2e-rte \
58+
-f tests/e2e/rte.docker-compose.yml \
59+
up --detach --force-recreate
60+
61+
- name: Set up RI docker image
62+
run: |
63+
E2E_RI_ENCRYPTION_KEY="$E2E_RI_ENCRYPTION_KEY" \
64+
RI_SERVER_TLS_CERT="$RI_SERVER_TLS_CERT" \
65+
RI_SERVER_TLS_KEY="$RI_SERVER_TLS_KEY" \
66+
docker compose -p e2e-ri-docker \
67+
-f tests/e2e/docker.web.docker-compose.yml \
68+
up --detach --force-recreate
69+
sleep 30
70+
71+
- name: Run Playwright tests
72+
timeout-minutes: 80
73+
working-directory: ./tests/playwright
74+
if: ${{ !cancelled() }}
75+
run: |
76+
yarn test:chromium:docker
77+
78+
- uses: actions/upload-artifact@v4
79+
if: ${{ !cancelled() }}
80+
with:
81+
name: playwright-report
82+
path: |
83+
./tests/playwright/test-results
84+
./tests/playwright/allure-results
85+
./tests/playwright/playwright-report
86+
retention-days: 10
87+
88+
- name: Clean up redis test environments
89+
if: always()
90+
run: |
91+
docker compose -p e2e-rte \
92+
-f tests/e2e/rte.docker-compose.yml \
93+
down --volumes --remove-orphans
94+
95+
- name: Clean up RI docker image
96+
if: always()
97+
run: |
98+
docker compose -p e2e-ri-docker \
99+
-f tests/e2e/docker.web.docker-compose.yml \
100+
down --volumes --remove-orphans

.github/workflows/tests-e2e.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: ✅ E2E Tests
2+
3+
on:
4+
pull_request:
5+
types: [labeled]
6+
7+
workflow_dispatch:
8+
inputs:
9+
debug:
10+
description: Enable SSH Debug (IT and E2E)
11+
default: false
12+
type: boolean
13+
14+
# Cancel a previous run workflow
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}-e2e
17+
cancel-in-progress: true
18+
19+
jobs:
20+
# E2E Approve
21+
e2e-approve:
22+
runs-on: ubuntu-latest
23+
if: github.event.action == 'labeled' && contains(github.event.label.name, 'e2e-approved') || github.event_name == 'workflow_dispatch'
24+
name: Approve E2E tests
25+
steps:
26+
- name: Add "e2e-approved" Label
27+
uses: actions-ecosystem/action-add-labels@v1
28+
with:
29+
labels: e2e-approved
30+
31+
# E2E Docker
32+
build-docker:
33+
uses: ./.github/workflows/pipeline-build-docker.yml
34+
needs: e2e-approve
35+
secrets: inherit
36+
with:
37+
debug: ${{ inputs.debug || false }}
38+
for_e2e_tests: true
39+
40+
e2e-docker-tests:
41+
needs: build-docker
42+
uses: ./.github/workflows/tests-e2e-docker.yml
43+
secrets: inherit
44+
with:
45+
debug: ${{ inputs.debug || false }}
46+
47+
tests-e2e-playwright:
48+
needs: build-docker
49+
uses: ./.github/workflows/tests-e2e-playwright.yml
50+
secrets: inherit
51+
with:
52+
debug: ${{ inputs.debug || false }}
53+
54+
# E2E AppImage
55+
build-appimage:
56+
uses: ./.github/workflows/pipeline-build-linux.yml
57+
needs: e2e-approve
58+
secrets: inherit
59+
with:
60+
target: build_linux_appimage_x64
61+
debug: ${{ inputs.debug || false }}
62+
63+
e2e-appimage-tests:
64+
needs: build-appimage
65+
uses: ./.github/workflows/tests-e2e-appimage.yml
66+
secrets: inherit
67+
with:
68+
debug: ${{ inputs.debug || false }}
69+
70+
clean:
71+
uses: ./.github/workflows/clean-deployments.yml
72+
if: always()
73+
needs: [e2e-docker-tests, e2e-appimage-tests, tests-e2e-playwright]
74+
75+
# Remove artifacts from github actions
76+
remove-artifacts:
77+
name: Remove artifacts
78+
needs: [e2e-docker-tests, e2e-appimage-tests, tests-e2e-playwright]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
- name: Remove all artifacts
83+
uses: ./.github/actions/remove-artifacts

.github/workflows/tests.yml

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,12 @@ on:
66
- 'fe/**'
77
- 'be/**'
88
- 'fe-be/**'
9-
- 'e2e/**'
109
- 'feature/**'
1110
- 'bugfix/**'
1211
- 'ric/**'
1312

1413
workflow_dispatch:
1514
inputs:
16-
group_tests:
17-
description: Run group of tests
18-
default: 'all'
19-
type: choice
20-
options:
21-
- all
22-
- without_e2e
23-
- only_e2e
24-
2515
redis_client:
2616
description: Library to use for redis connection
2717
default: 'ioredis'
@@ -42,10 +32,6 @@ on:
4232

4333
workflow_call:
4434
inputs:
45-
group_tests:
46-
description: Run group of tests
47-
type: string
48-
default: 'without_e2e'
4935
short_rte_list:
5036
description: Use short rte list
5137
type: boolean
@@ -71,7 +57,6 @@ jobs:
7157
frontend: ${{ steps.filter.outputs.frontend }}
7258
backend: ${{ steps.filter.outputs.backend }}
7359
desktop: ${{ steps.filter.outputs.desktop }}
74-
e2e: ${{ steps.filter.outputs.e2e }}
7560
steps:
7661
- uses: actions/checkout@v4
7762
- uses: dorny/[email protected]
@@ -85,12 +70,10 @@ jobs:
8570
- 'redisinsight/api/**'
8671
desktop:
8772
- 'redisinsight/desktop/**'
88-
e2e:
89-
- 'tests/e2e/**'
9073
9174
frontend-tests:
9275
needs: changes
93-
if: inputs.group_tests == 'all' || inputs.group_tests == 'without_e2e' || startsWith(github.ref_name, 'fe/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/')
76+
if: startsWith(github.ref_name, 'fe/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/')
9477
uses: ./.github/workflows/tests-frontend.yml
9578
secrets: inherit
9679

@@ -104,7 +87,7 @@ jobs:
10487

10588
backend-tests:
10689
needs: changes
107-
if: inputs.group_tests == 'all' || inputs.group_tests == 'without_e2e' || startsWith(github.ref_name, 'be/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/')
90+
if: startsWith(github.ref_name, 'be/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/')
10891
uses: ./.github/workflows/tests-backend.yml
10992
secrets: inherit
11093

@@ -118,7 +101,7 @@ jobs:
118101

119102
integration-tests:
120103
needs: changes
121-
if: inputs.group_tests == 'all' || inputs.group_tests == 'without_e2e' || startsWith(github.ref_name, 'be/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/')
104+
if: startsWith(github.ref_name, 'be/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/')
122105
uses: ./.github/workflows/tests-integration.yml
123106
secrets: inherit
124107
with:
@@ -134,49 +117,6 @@ jobs:
134117
resource_name: integration-coverage
135118
type: integration
136119

137-
# # E2E Approve
138-
e2e-approve:
139-
runs-on: ubuntu-latest
140-
needs: changes
141-
if: inputs.group_tests == 'all' || inputs.group_tests == 'only_e2e' || startsWith(github.ref_name, 'e2e/')
142-
timeout-minutes: 60
143-
environment: ${{ startsWith(github.ref_name, 'e2e/') && 'e2e-approve' || 'staging' }}
144-
name: Approve E2E tests
145-
steps:
146-
- uses: actions/checkout@v4
147-
148-
# E2E Docker
149-
build-docker:
150-
uses: ./.github/workflows/pipeline-build-docker.yml
151-
needs: e2e-approve
152-
secrets: inherit
153-
with:
154-
debug: ${{ inputs.debug || false }}
155-
for_e2e_tests: true
156-
157-
e2e-docker-tests:
158-
needs: build-docker
159-
uses: ./.github/workflows/tests-e2e-docker.yml
160-
secrets: inherit
161-
with:
162-
debug: ${{ inputs.debug || false }}
163-
164-
# E2E AppImage
165-
build-appimage:
166-
uses: ./.github/workflows/pipeline-build-linux.yml
167-
needs: e2e-approve
168-
secrets: inherit
169-
with:
170-
target: build_linux_appimage_x64
171-
debug: ${{ inputs.debug || false }}
172-
173-
e2e-appimage-tests:
174-
needs: build-appimage
175-
uses: ./.github/workflows/tests-e2e-appimage.yml
176-
secrets: inherit
177-
with:
178-
debug: ${{ inputs.debug || false }}
179-
180120
clean:
181121
uses: ./.github/workflows/clean-deployments.yml
182122
if: always()
@@ -185,8 +125,6 @@ jobs:
185125
frontend-tests,
186126
backend-tests,
187127
integration-tests,
188-
e2e-docker-tests,
189-
e2e-appimage-tests,
190128
]
191129

192130
# Remove artifacts from github actions
@@ -197,8 +135,6 @@ jobs:
197135
frontend-tests,
198136
backend-tests,
199137
integration-tests,
200-
e2e-docker-tests,
201-
e2e-appimage-tests,
202138
]
203139
runs-on: ubuntu-latest
204140
steps:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"private": true,
77
"scripts": {
88
"dev:ui": "cross-env yarn --cwd redisinsight/ui dev",
9+
"dev:ui:coverage": "cross-env COLLECT_COVERAGE=true yarn --cwd redisinsight/ui dev",
910
"dev:api": "cross-env yarn --cwd redisinsight/api start:dev",
1011
"dev:electron:ui": "cross-env RI_APP_PORT=8080 RI_APP_TYPE=ELECTRON NODE_ENV=development yarn --cwd redisinsight/ui dev",
1112
"dev:electron:api": "cross-env RI_APP_PORT=5540 RI_APP_TYPE=ELECTRON NODE_ENV=development USE_TCP_CLOUD_AUTH=true yarn --cwd redisinsight/api start:dev",
@@ -222,6 +223,7 @@
222223
"vite-plugin-ejs": "^1.7.0",
223224
"vite-plugin-electron": "^0.28.6",
224225
"vite-plugin-electron-renderer": "^0.14.5",
226+
"vite-plugin-istanbul": "^7.1.0",
225227
"vite-plugin-react-click-to-component": "^3.0.0",
226228
"vite-plugin-svgr": "^4.2.0",
227229
"webpack": "^5.95.0",

0 commit comments

Comments
 (0)