Skip to content

Commit d5d3a57

Browse files
authored
Merge pull request #20 from raferdev/feature/integrated_tests
Feature/integrated tests
2 parents bcfdba0 + cd3b2da commit d5d3a57

28 files changed

Lines changed: 734 additions & 469 deletions

.dockerignore

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
Dockerfile
2-
.dockerignore
1+
Dockerfile.dockerignore
32
node_modules
4-
npm-debug.log
5-
README.md
6-
.next
7-
.git
8-
.husky
9-
.changeset
10-
.vscode
11-
tests
3+
npm - debug.log
4+
README.md.next.git.husky.changeset.vscode

.github/workflows/deploy.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
name: Build and Deploy
2+
concurrency:
3+
group: production
4+
cancel-in-progress: true
5+
26
on:
37
push:
48
branches: [main]
@@ -80,5 +84,5 @@ jobs:
8084
8185
- name: Update content
8286
run: |
83-
sudo docker cp ./out server:/www/data/
84-
sudo docker cp ./storybook-static server:/www/data/
87+
sudo docker cp ./out nginx_server:/www/data/
88+
sudo docker cp ./storybook-static nginx_server:/www/data/

.github/workflows/tests.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
name: Playwright Tests
22
on:
3-
push:
4-
branches: [main]
3+
pull_request:
4+
branches: [main, development]
55
jobs:
66
test:
77
timeout-minutes: 60
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
- name: Setup Node & Pnpm
13+
uses: pnpm/action-setup@v2
14+
with:
15+
version: 8.9.2
1116
- uses: actions/setup-node@v3
1217
with:
13-
node-version: 18
18+
node-version: '18'
19+
cache: 'pnpm'
20+
- name: Create env file
21+
run: |
22+
echo "${{ secrets.ENV_TEST_FILE }}" > .env.local
1423
- name: Install dependencies
15-
run: npm ci
24+
run: pnpm i
1625
- name: Install Playwright Browsers
1726
run: npx playwright install --with-deps
27+
- name: Build
28+
run: pnpm run build
1829
- name: Run Playwright tests
19-
run: npx playwright test
30+
run: pnpm run test.playwright
2031
- uses: actions/upload-artifact@v3
2132
if: always()
2233
with:

Dockerfile.test

Lines changed: 0 additions & 24 deletions
This file was deleted.

docker-compose.test.yaml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
version: '3'
22

33
services:
4-
ngnix:
5-
container_name: server
6-
restart: on-failure
7-
tty: true
8-
build: ./nginx/tests
9-
volumes:
10-
- builder_nginx_vol_tests:/www/data
11-
depends_on:
12-
- builder
4+
nginx:
5+
container_name: server_nginx
6+
restart: 'no'
7+
build:
8+
context: .
9+
dockerfile: ./nginx/tests/Dockerfile
1310
ports:
1411
- 3000:80
15-
16-
builder:
17-
env_file:
18-
- .env.local
19-
container_name: front-build
20-
build: '.'
21-
volumes:
22-
- builder_nginx_vol_tests:/app/build
12+
networks:
13+
- running-tests
2314

2415
volumes:
25-
builder_nginx_vol_tests:
16+
builder_nginx_vol:
17+
networks:
18+
running-tests:

nginx/nginx.conf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ http {
1111

1212
add_header X-Frame-Options "SAMEORIGIN";
1313
add_header X-XSS-Protection "1; mode=block";
14-
add_header Content-Security-Policy "worker-src blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googletagmanager.com *.datadoghq-browser-agent.com; frame-src 'none' *.youtube.com; object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none'; default-src 'none'; style-src 'self'; img-src 'self; font-src 'self';"
15-
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
14+
add_header Content-Security-Policy "worker-src blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googletagmanager.com *.datadoghq-browser-agent.com; frame-src 'none' *.youtube.com; object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none'; default-src 'none'; style-src 'self'; img-src 'self; font-src 'self'; manifest-src 'https://rafer.dev/';"
15+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
1616
add_header Referrer-Policy "strict-origin";
1717
add_header Permissions-Policy "geolocation=(self),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(),payment=()";
1818
add_header X-Content-Type-Options nosniff;
@@ -47,7 +47,7 @@ http {
4747
listen 80;
4848

4949
gzip on;
50-
gzip_types text/plain application/xml;
50+
gzip_types text/plain application/xml font/woff2;
5151
gzip_proxied no-cache no-store private expired auth;
5252
gzip_min_length 1000;
5353
gunzip on;
@@ -122,4 +122,7 @@ http {
122122

123123
error_page 404 /404.html;
124124
location = /404.html {
125-
internal;
125+
internal;
126+
}
127+
}
128+
}

nginx/tests/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ RUN mkdir /var/cache/nginx -p
77
RUN rm /etc/nginx/mime.types
88
RUN rm /etc/nginx/conf.d/default.conf
99

10-
COPY ./nginx.conf /etc/nginx/
11-
COPY ./mime.types /etc/nginx/conf/
10+
COPY ./nginx/tests/nginx.conf /etc/nginx/
11+
COPY ./nginx/tests/mime.types /etc/nginx/conf/
12+
COPY ./out /www/data/out
1213

1314
EXPOSE 80

nginx/tests/nginx.conf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ http {
1111

1212
add_header X-Frame-Options "SAMEORIGIN";
1313
add_header X-XSS-Protection "1; mode=block";
14-
add_header Content-Security-Policy "worker-src blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googletagmanager.com *.datadoghq-browser-agent.com; frame-src 'none' *.youtube.com; object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none'; default-src 'none'; style-src 'self'; img-src 'self; font-src 'self';"
15-
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
14+
add_header Content-Security-Policy "worker-src blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.googletagmanager.com *.datadoghq-browser-agent.com; frame-src *.youtube.com; object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; font-src 'self'; manifest-src 'http://localhost:3000/';";
15+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
1616
add_header Referrer-Policy "strict-origin";
1717
add_header Permissions-Policy "geolocation=(self),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(),payment=()";
1818
add_header X-Content-Type-Options nosniff;
@@ -41,7 +41,7 @@ http {
4141
listen 80;
4242

4343
gzip on;
44-
gzip_types text/plain application/xml;
44+
gzip_types text/plain application/xml font/woff2;
4545
gzip_proxied no-cache no-store private expired auth;
4646
gzip_min_length 1000;
4747
gunzip on;
@@ -116,4 +116,7 @@ http {
116116

117117
error_page 404 /404.html;
118118
location = /404.html {
119-
internal;
119+
internal;
120+
}
121+
}
122+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "next build",
1010
"build.storybook": "storybook build",
1111
"build.tailwind": "pnpm dlx tailwindcss -o ./src/styles/tailwind.css",
12+
"build.docker": "pnpm move.prod && tail -f /dev/null",
1213
"move.prod": "cp -fr out build && cp -fr storybook-static build",
1314
"prepare": "husky install",
1415
"__move-out-storybook": "cp out -fr out/_next/static/media/ .storybook/public && cp out -fr out/_next/static/css/ .storybook/public",
@@ -18,8 +19,8 @@
1819
"docker.prod": "docker compose up -f docker-compose.yaml --no-cache --log-level 0",
1920
"test": "docker-compose -f docker-compose.test.yaml up",
2021
"test.reset": "docker-compose -f docker-compose.test.yaml up --build",
21-
"test.playwright": "npx playwright test",
22-
"test.playwright.debug": "npx playwright test --debug",
22+
"test.playwright": "pnpm playwright test",
23+
"test.playwright.debug": "pnpm playwright test --debug",
2324
"types.check": "pnpm dlx tsc *.ts /*.tsx --noEmit",
2425
"check.eslint": "ESLINT_USE_FLAT_CONFIG=true eslint -c eslint.config.mjs --quiet --fix"
2526
},

playwright.config.ts

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default defineConfig({
88
workers: process.env.CI ? 1 : undefined,
99
reporter: 'html',
1010
use: {
11-
baseURL: 'http://127.0.0.1:3000',
11+
baseURL: process.env.WEB_SERVER_URL || 'http://localhost:3000',
1212

1313
trace: 'on-first-retry',
1414
},
@@ -18,40 +18,16 @@ export default defineConfig({
1818
name: 'chromium',
1919
use: { ...devices['Desktop Chrome'] },
2020
},
21-
22-
{
23-
name: 'firefox',
24-
use: { ...devices['Desktop Firefox'] },
25-
},
26-
27-
{
28-
name: 'webkit',
29-
use: { ...devices['Desktop Safari'] },
30-
},
31-
3221
{
3322
name: 'Mobile Chrome',
34-
use: { ...devices['Pixel 5'] },
35-
},
36-
{
37-
name: 'Mobile Safari',
38-
use: { ...devices['iPhone 12'] },
39-
},
40-
41-
{
42-
name: 'Microsoft Edge',
43-
use: { ...devices['Desktop Edge'], channel: 'msedge' },
44-
},
45-
{
46-
name: 'Google Chrome',
47-
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
23+
use: { ...devices['Galaxy S9+'] },
4824
},
4925
],
5026

5127
webServer: {
5228
command: 'npm run test',
53-
url: 'http://127.0.0.1:3000',
54-
reuseExistingServer: !process.env.CI,
55-
timeout: 120 * 1000,
29+
url: process.env.WEB_SERVER_URL || 'http://localhost:3000',
30+
reuseExistingServer: true,
31+
timeout: 20 * 60 * 1000,
5632
},
5733
})

0 commit comments

Comments
 (0)