Skip to content

Commit 09ee2df

Browse files
authored
Add e2e tests (#20)
* feat: add multiple tab support * feat: add search history * feat: add keyboard support to the search * chore: unused import * chore: remove unusued hook * chore: rename the custom scroll component argument * chore: update playground for easier debugging * feat: add hideTabs option and fix styles * feat: add a credentials form to playground * fix: use cloudflare version of redis to avoid direct process access * feat: add persistance support * fix: prevent useEffect from working when tab is not active * fix: automatically rescan until a result shows up * fix: only fetch when the tab is active * fix: skeleton and empty styles * fix: refactor tabs and improve next tab selection logic when current tab is removed * feat: add useOverflow utility hook * fix: make the tooltip use portals * fix: search recomendations overflowing * feat: show tooltip only when tabs is overflowing * fix: adding new key sometimes throwing error * fix: not being able to click anywhere after closing delete key modal * feat: add "copy key" to dropdown menu * feat: make the "delete key" item red * fix: add zustand migration * feat: add e2e tests * test: improve key delete tests
1 parent a45ecea commit 09ee2df

File tree

14 files changed

+5189
-52
lines changed

14 files changed

+5189
-52
lines changed

.github/workflows/playwright.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
env:
23+
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
24+
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
25+
- uses: actions/upload-artifact@v4
26+
if: ${{ !cancelled() }}
27+
with:
28+
name: playwright-report
29+
path: playwright-report/
30+
retention-days: 30

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ next-env.d.ts
3939

4040
.turbo
4141
dist
42+
43+
# Playwright
44+
node_modules/
45+
/test-results/
46+
/playwright-report/
47+
/blob-report/
48+
/playwright/.cache/

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"zustand": "5.0.0"
5454
},
5555
"devDependencies": {
56-
"postcss-prefix-selector": "^2.1.0",
56+
"@playwright/test": "^1.53.1",
5757
"@types/node": "^22.8.4",
5858
"@types/react": "^18.3.12",
5959
"@types/react-dom": "^18.3.1",
@@ -63,9 +63,11 @@
6363
"autoprefixer": "^10.4.14",
6464
"class-variance-authority": "^0.7.0",
6565
"clsx": "^2.0.0",
66+
"dotenv": "^16.5.0",
6667
"eslint": "9.10.0",
6768
"eslint-plugin-unicorn": "55.0.0",
6869
"postcss": "^8.4.31",
70+
"postcss-prefix-selector": "^2.1.0",
6971
"prettier": "^3.0.3",
7072
"prettier-plugin-tailwindcss": "^0.5.5",
7173
"react": "^18.3.1",
@@ -82,4 +84,4 @@
8284
"react": "^18.2.0 || ^19",
8385
"react-dom": "^18.2.0 || ^19"
8486
}
85-
}
87+
}

playwright.config.ts

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

0 commit comments

Comments
 (0)