Skip to content

Commit a526fe1

Browse files
authored
Playwright & testcontainers (#366)
* added playwright & testcontainers * add compose testcontainer abilities * fix test
1 parent 7955292 commit a526fe1

File tree

11 files changed

+2366
-1410
lines changed

11 files changed

+2366
-1410
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm install -g pnpm && pnpm install
18+
- name: Install Playwright Browsers
19+
run: pnpm exec playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: pnpm exec playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: ${{ !cancelled() }}
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

frontend/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ next-env.d.ts
3939
*.log
4040
# Switches based on env
4141
.env
42+
43+
# Playwright
44+
node_modules/
45+
/test-results/
46+
/playwright-report/
47+
/blob-report/
48+
/playwright/.cache/

frontend/__tests__/Bookmark/NewBookmarkCard.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ describe("Success Toast", () => {
327327
scrapable: true,
328328
};
329329

330-
axiosMock.onPost(tagsAPI, ["testtag"]).reply(() => {
331-
return [200, expectedResult];
330+
axiosMock.onPost(tagsAPI).reply(() => {
331+
return [200, JSON.stringify(expectedResult)];
332332
});
333333

334334
axiosMock
@@ -339,14 +339,14 @@ describe("Success Toast", () => {
339339
scrapable: true,
340340
})
341341
.reply(() => {
342-
return [200, expectedBookmark];
342+
return [200, JSON.stringify(expectedBookmark)];
343343
});
344344

345345
await user.click(submit);
346346

347347
// Wait for the success toast to appear
348348
expect(
349-
await screen.findByText("Bookmark added successfully!")
349+
await screen.findByText("Bookmark added successfully!"),
350350
).toBeInTheDocument();
351351
});
352352
});

frontend/api/Api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ instance.interceptors.response.use(
2323
return response;
2424
},
2525
(error) => {
26+
console.log(error);
2627
if (error.response.status === 401) {
2728
console.log("Error on fetch");
2829
if (failCount > 1) {

frontend/package.json

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@
2020
"@types/react": "19.0.2",
2121
"@types/react-dom": "19.0.2",
2222
"autoprefixer": "10.4.20",
23-
"axios": "^1.7.9",
23+
"axios": "^1.9.0",
2424
"axios-mock-adapter": "^2.1.0",
25-
"bootstrap": "^5.3.3",
25+
"bootstrap": "^5.3.5",
2626
"bootstrap-icons": "^1.11.3",
27-
"dotenv": "^16.4.7",
27+
"dotenv": "^16.5.0",
2828
"eslint": "9.17.0",
2929
"eslint-config-next": "15.1.3",
3030
"formik": "^2.4.6",
3131
"jest": "^29.7.0",
32-
"next": "15.1.3",
32+
"next": "^15.3.1",
3333
"next-router-mock": "^0.9.13",
34-
"postcss": "^8.5.1",
34+
"postcss": "^8.5.3",
3535
"react": "19.0.0",
3636
"react-bootstrap": "^2.10.9",
3737
"react-dom": "19.0.0",
38-
"react-toastify": "^11.0.3",
39-
"rxjs": "^7.8.1",
40-
"sass": "^1.83.4",
38+
"react-toastify": "^11.0.5",
39+
"rxjs": "^7.8.2",
40+
"sass": "^1.87.0",
4141
"tailwindcss": "3.4.17",
4242
"typescript": "5.7.2",
4343
"use-file-picker": "^2.1.2",
@@ -46,14 +46,16 @@
4646
"yup": "^1.6.1"
4747
},
4848
"devDependencies": {
49+
"@playwright/test": "^1.52.0",
4950
"@testing-library/jest-dom": "^6.6.3",
50-
"@testing-library/react": "^16.2.0",
51+
"@testing-library/react": "^16.3.0",
5152
"@testing-library/user-event": "^14.6.1",
52-
"@vitejs/plugin-react": "^4.3.4",
53-
"@vitest/coverage-v8": "^2.1.8",
54-
"@vitest/ui": "^2.1.8",
53+
"@vitejs/plugin-react": "^4.4.1",
54+
"@vitest/coverage-v8": "^3.1.2",
55+
"@vitest/ui": "^3.1.2",
5556
"jsdom": "^25.0.1",
56-
"vitest": "^2.1.9"
57+
"testcontainers": "^10.24.2",
58+
"vitest": "^3.1.2"
5759
},
5860
"pnpm": {
5961
"overrides": {
@@ -66,8 +68,15 @@
6668
"qs": "6.5.3",
6769
"moment": "^2.29.4",
6870
"@types/react": "19.0.2",
69-
"@types/react-dom": "19.0.2"
71+
"@types/react-dom": "19.0.2",
72+
"esbuild@<=0.24.2": ">=0.25.0",
73+
"vite@<=4.5.5": ">=4.5.6",
74+
"vite@<4.5.10": ">=4.5.10",
75+
"next@>=15.0.0 <15.2.3": ">=15.2.3",
76+
"vite@<4.5.11": ">=4.5.11",
77+
"vite@<4.5.12": ">=4.5.12",
78+
"vite@<4.5.13": ">=4.5.13"
7079
}
7180
},
72-
"packageManager": "pnpm@10.4.0+sha512.6b849d0787d97f8f4e1f03a9b8ff8f038e79e153d6f11ae539ae7c435ff9e796df6a862c991502695c7f9e8fac8aeafc1ac5a8dab47e36148d183832d886dd52"
81+
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
7382
}

frontend/playwright.config.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// import path from 'path';
9+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10+
11+
/**
12+
* See https://playwright.dev/docs/test-configuration.
13+
*/
14+
export default defineConfig({
15+
globalSetup: require.resolve('./tests_e2e/setup.ts'),
16+
globalTeardown: require.resolve('./tests_e2e/teardown.ts'),
17+
testDir: './tests_e2e',
18+
/* Run tests in files in parallel */
19+
fullyParallel: true,
20+
/* Fail the build on CI if you accidentally left test.only in the source code. */
21+
forbidOnly: !!process.env.CI,
22+
/* Retry on CI only */
23+
retries: process.env.CI ? 2 : 0,
24+
/* Opt out of parallel tests on CI. */
25+
workers: process.env.CI ? 1 : undefined,
26+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
27+
reporter: 'html',
28+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
29+
use: {
30+
/* Base URL to use in actions like `await page.goto('/')`. */
31+
// baseURL: 'http://127.0.0.1:3000',
32+
33+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
34+
trace: 'on-first-retry',
35+
},
36+
/* Configure projects for major browsers */
37+
projects: [
38+
{
39+
name: 'chromium',
40+
use: { ...devices['Desktop Chrome'] },
41+
},
42+
43+
{
44+
name: 'firefox',
45+
use: { ...devices['Desktop Firefox'] },
46+
},
47+
48+
{
49+
name: 'webkit',
50+
use: { ...devices['Desktop Safari'] },
51+
},
52+
53+
/* Test against mobile viewports. */
54+
// {
55+
// name: 'Mobile Chrome',
56+
// use: { ...devices['Pixel 5'] },
57+
// },
58+
// {
59+
// name: 'Mobile Safari',
60+
// use: { ...devices['iPhone 12'] },
61+
// },
62+
63+
/* Test against branded browsers. */
64+
// {
65+
// name: 'Microsoft Edge',
66+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
67+
// },
68+
// {
69+
// name: 'Google Chrome',
70+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
71+
// },
72+
],
73+
74+
/* Run your local dev server before starting the tests */
75+
// webServer: {
76+
// command: 'npm run start',
77+
// url: 'http://127.0.0.1:3000',
78+
// reuseExistingServer: !process.env.CI,
79+
// },
80+
});

0 commit comments

Comments
 (0)