Skip to content

Commit f0e87fb

Browse files
feat(#1304624): Add e2e tests and add the service that lauches them in docker compose
1 parent 50af708 commit f0e87fb

File tree

19 files changed

+654
-6
lines changed

19 files changed

+654
-6
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ jobs:
7575
command: require gally/gally-premium:${{ env.composer_version }}
7676
env:
7777
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
78+
- name: Install sample data package
79+
working-directory: api
80+
run: composer require "gally/gally-sample-data:${{ env.composer_version }} as ${{ inputs.last_published_version }}"
81+
env:
82+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
7883
- name: Pull images
7984
run: ${{env.docker_compose_cmd}} pull --ignore-pull-failures || true
8085
- name: Start services
@@ -144,6 +149,9 @@ jobs:
144149
- name: Jest
145150
run: ${{env.docker_compose_cmd}} exec -T pwa yarn test:ci
146151

152+
- name: e2e
153+
run: ${{env.docker_compose_cmd}} exec -T e2e yarn test:ci
154+
147155
- name: Frontend Coverage Report
148156
uses: 5monkeys/cobertura-action@v12
149157
if: ${{ github.event_name == 'pull_request' }}

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ phpunit: ## Run php unit tests, pass the parameter "p=" to launch tests on a spe
143143
jest: ## Run jest unit tests
144144
@$(DOCKER_COMP) exec pwa yarn test
145145

146+
e2e: ## Run e2e tests
147+
@$(DOCKER_COMP) exec e2e yarn test
148+
146149
jest_update: ## Run jest unit tests
147150
@$(DOCKER_COMP) exec pwa yarn test:update
148151

compose.ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,28 @@ services:
1313
environment:
1414
- APP_ENV=dev
1515
- XDEBUG_MODE=off
16+
- TRUSTED_HOSTS=${TRUSTED_HOSTS:-^${SERVER_NAME:-|gally.localhost}|localhost|${E2E_SERVER_NAME:-gally.e2e}|php$$}
1617

1718
pwa:
1819
build:
1920
target: gally_pwa_ci
2021
volumes:
2122
- ./front/example-app/coverage:/usr/src/front/example-app/coverage:rw,cached,z
2223
- ./front/pwa/coverage:/usr/src/front/pwa/coverage:rw,cached,z
23-
24+
environment:
25+
- NEXT_PUBLIC_ENTRYPOINT=
26+
- NEXT_PUBLIC_API_URL=
27+
- REACT_APP_API_URL=
2428
example:
2529
build:
2630
context: ./docker/front
2731
target: gally_example_ci
2832
additional_contexts:
2933
front_src: ./front
34+
35+
e2e:
36+
extends:
37+
file: ./compose.e2e.yml
38+
service: e2e
39+
environment:
40+
- CI=true

compose.e2e.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# E2E environment override
2+
services:
3+
e2e:
4+
build:
5+
context: .
6+
dockerfile: ./docker/front/Dockerfile.e2e
7+
environment:
8+
- SERVER_BASE_URL=https://${E2E_SERVER_NAME:-gally.e2e}
9+
- API_SERVER_BASE_URL=https://${E2E_SERVER_NAME:-gally.e2e}/${API_ROUTE_PREFIX:-api}
10+
depends_on:
11+
- proxy
12+
extra_hosts:
13+
- ${E2E_SERVER_NAME:-gally.e2e}:host-gateway

compose.override.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
- ./docker/php/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro,z
2222
environment:
2323
- APP_ENV=${APP_ENV:-dev}
24+
- TRUSTED_HOSTS=${TRUSTED_HOSTS:-^${SERVER_NAME:-|gally.localhost}|localhost|${E2E_SERVER_NAME:-gally.e2e}|php$$}
2425
# See https://xdebug.org/docs/all_settings#mode
2526
- XDEBUG_MODE=${XDEBUG_MODE:-off}
2627
- PHP_IDE_CONFIG=serverName=gally
@@ -41,6 +42,9 @@ services:
4142
environment:
4243
# On Linux, you may want to comment the following line for improved performance
4344
- WATCHPACK_POLLING="true"
45+
- NEXT_PUBLIC_ENTRYPOINT=
46+
- NEXT_PUBLIC_API_URL=
47+
- REACT_APP_API_URL=
4448

4549
example:
4650
user: ${UUID?You must set UUID env var}:${GUID?You must set GUID env var}
@@ -56,3 +60,10 @@ services:
5660
environment:
5761
- PUBLIC_URL=https://${SERVER_NAME:-gally.localhost}/example
5862
- REACT_APP_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-api}
63+
64+
e2e:
65+
extends:
66+
file: ./compose.e2e.yml
67+
service: e2e
68+
volumes:
69+
- ./front/e2e/:/usr/src/app:rw,cached,z

docker/front/Dockerfile.e2e

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM mcr.microsoft.com/playwright:v1.39.0
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY ./front/e2e/ .
6+
7+
RUN yarn install --frozen-lockfile
8+
9+
RUN npx playwright install chromium
10+
RUN npx playwright install-deps chromium
11+
12+
CMD ["sleep", "infinity"]

front/e2e/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
/test-results/
3+
/playwright-report/
4+
/blob-report/
5+
/playwright/.cache/

front/e2e/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "e2e",
3+
"private": "false",
4+
"version": "1.0.0",
5+
"main": "index.js",
6+
"license": "MIT",
7+
"devDependencies": {
8+
"@playwright/test": "^1.47.2",
9+
"@types/node": "^22.6.1"
10+
},
11+
"scripts": {
12+
"test": "yarn playwright test",
13+
"test:ci": "yarn playwright test",
14+
"test:standard": "yarn playwright test --grep @standard",
15+
"test:premium": "yarn playwright test --grep @premium"
16+
},
17+
"dependencies": {}
18+
}

front/e2e/playwright.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
export default defineConfig({
4+
testDir: './tests',
5+
fullyParallel: false,
6+
forbidOnly: !!process.env.CI,
7+
retries: process.env.CI ? 2 : 0,
8+
workers: process.env.CI ? 1 : undefined,
9+
reporter: 'line',
10+
use: {
11+
baseURL: process.env.SERVER_BASE_URL || "https://gally.local",
12+
trace: 'on',
13+
headless: true,
14+
ignoreHTTPSErrors: true,
15+
},
16+
projects: [
17+
{
18+
name: 'chromium',
19+
use: { ...devices['Desktop Chrome'] },
20+
},
21+
],
22+
})
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { test, expect } from '@playwright/test'
2+
import { randomUUID } from 'crypto'
3+
import { login } from '../helper/auth'
4+
import { navigateTo } from '../helper/menu'
5+
import { Dropdown } from '../helper/dropdown'
6+
7+
test('Boosts', async ({ page }) => {
8+
await login(page)
9+
await navigateTo(page, 'Boosts', '/fr/admin/merchandize/boost/grid')
10+
11+
const createButton = await page.getByTestId('createButtonResourceGrid')
12+
13+
/*
14+
Grid Boost
15+
*/
16+
// TO DO
17+
18+
/*
19+
Create Boost
20+
*/
21+
await createButton.click()
22+
await expect(page).toHaveURL('/fr/admin/merchandize/boost/create')
23+
24+
// isActive Switch
25+
const isActiveInput = await page.getByTestId('isActive')
26+
const isActiveCheckbox = await isActiveInput.locator("input[type='checkbox']")
27+
28+
await expect(isActiveCheckbox).toBeChecked()
29+
await isActiveInput.click()
30+
await expect(isActiveCheckbox).not.toBeChecked()
31+
await isActiveInput.click()
32+
await expect(isActiveCheckbox).toBeChecked()
33+
34+
// Boost Preview
35+
const previewFieldSet = await page.getByTestId('previewFieldSet')
36+
await expect(
37+
await previewFieldSet.getByTestId('previewRequiredMessage')
38+
).toBeVisible()
39+
40+
// name InputText
41+
const nameInput = await page.getByTestId('name')
42+
const newName = randomUUID()
43+
44+
await expect(nameInput).toBeEmpty()
45+
await nameInput.fill(newName)
46+
await expect(nameInput).toHaveValue(newName)
47+
48+
// // Localized Catalogs Multiple Dropdown
49+
const localizedCatalogs = new Dropdown(page, 'localizedCatalogs', true)
50+
await localizedCatalogs.selectValue([
51+
'COM French Catalog',
52+
'COM English Catalog',
53+
'FR French Catalog',
54+
'EN French Catalog',
55+
])
56+
57+
// Request types Multiple Dropdown
58+
const requestTypesDropdown = new Dropdown(page, 'requestTypesDropdown', true)
59+
await requestTypesDropdown.selectValue(['Category listing', 'Search result'])
60+
61+
// Model Dropdown
62+
const modelDropdown = new Dropdown(page, 'model')
63+
await modelDropdown.selectValue('Constante')
64+
65+
// Preview Boost Required Message
66+
await expect(
67+
await previewFieldSet.getByTestId('previewRequiredMessage')
68+
).not.toBeVisible()
69+
70+
// Create the Boost and verify his existence
71+
const saveButton = await page.getByTestId('submitButtonResourceForm')
72+
await saveButton.click()
73+
await expect(page).toHaveURL('/fr/admin/merchandize/boost/grid')
74+
await expect(await page.getByText(newName)).toBeDefined() // TO DO : Manipulate the grid instead of research in the page.
75+
76+
/*
77+
Edit Boost
78+
*/
79+
// TO DO
80+
81+
/*
82+
Delete Boost
83+
*/
84+
// TO DO
85+
})

0 commit comments

Comments
 (0)