Skip to content

Commit 557cce6

Browse files
committed
test: add test/ui
1 parent 96c60b7 commit 557cce6

File tree

39 files changed

+477
-2
lines changed

39 files changed

+477
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- name: Lint
3333
run: pnpm lint
3434

35+
- name: Install Playwright Dependencies
36+
run: pnpm exec playwright install chromium --with-deps
37+
3538
- name: Test
3639
run: pnpm test
3740

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ tsconfig.tsbuildinfo
2323
tsconfig.build.tsbuildinfo
2424
.tmp
2525
.tmp-*
26+
/test/**/test-results
27+
/test/**/.astro

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shell-emulator=true

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"scripts": {
4-
"build": "pnpm run --stream --filter=@tutorialkit/* --filter=create-tutorial build",
4+
"build": "pnpm run --stream --filter='@tutorialkit/*' --filter=create-tutorial build",
55
"dev": "TUTORIALKIT_DEV=true pnpm -r --parallel --stream --filter='./packages/**' run dev",
66
"changelog": "./scripts/changelog.mjs",
77
"clean": "./scripts/clean.sh",
@@ -16,7 +16,7 @@
1616
"demo": "pnpm run --filter=demo.tutorialkit.dev dev",
1717
"demo:build": "pnpm run build && pnpm run --filter=demo.tutorialkit.dev build",
1818
"lint": "eslint \"{packages,docs,extensions,integration}/**/*\"",
19-
"test": "pnpm run --stream --filter=@tutorialkit/* test --run"
19+
"test": "CI=true pnpm run --stream --filter='@tutorialkit/*' test"
2020
},
2121
"license": "MIT",
2222
"packageManager": "pnpm@8.15.6",
@@ -30,6 +30,7 @@
3030
"eslint-plugin-astro": "^1.2.3",
3131
"husky": "^9.0.11",
3232
"is-ci": "^3.0.1",
33+
"playwright": "^1.46.0",
3334
"prettier": "^3.3.2",
3435
"prettier-plugin-astro": "^0.14.1",
3536
"tempfile": "^5.0.0"

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/ui/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# UI Tests
2+
3+
> Tests for verifying TutorialKit works as expected in the browser. Tests are run against locally linked `@tutorialkit` packages.
4+
5+
## Running
6+
7+
- `pnpm exec playwright install chromium --with-deps` - When running the tests first time
8+
- `pnpm test`
9+
10+
## Development
11+
12+
- `pnpm start` - Starts example/fixture project's development server
13+
- `pnpm test:ui` - Start Playwright in UI mode
14+
15+
## Structure
16+
17+
Test cases are located in `test` directory.
18+
Each test file has its own `chapter`, that contains `lesson`s for test cases:
19+
20+
For example Navigation tests:
21+
22+
```
23+
├── src/content/tutorial
24+
│ └── tests
25+
│ └──── navigation
26+
│ ├── page-one
27+
│ ├── page-three
28+
│ └── page-two
29+
└── test
30+
└── navigation.test.ts
31+
```
32+
33+
Or File Tree tests:
34+
35+
```
36+
├── src/content/tutorial
37+
│ └── tests
38+
│ └── file-tree
39+
│ └── lesson-and-solution
40+
└── test
41+
└── file-tree.test.ts
42+
```

test/ui/astro.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import tutorialkit from '@tutorialkit/astro';
2+
import { defineConfig } from 'astro/config';
3+
4+
export default defineConfig({
5+
devToolbar: { enabled: false },
6+
server: { port: 4329 },
7+
integrations: [tutorialkit()],
8+
});

test/ui/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@tutorialkit/test-ui",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "astro dev",
7+
"start": "astro dev",
8+
"preview": "astro build && astro preview",
9+
"test": "playwright test",
10+
"test:ui": "pnpm run test --ui"
11+
},
12+
"devDependencies": {
13+
"@astrojs/react": "^3.6.0",
14+
"@iconify-json/ph": "^1.1.13",
15+
"@iconify-json/svg-spinners": "^1.1.2",
16+
"@playwright/test": "^1.46.0",
17+
"@tutorialkit/astro": "workspace:*",
18+
"@tutorialkit/components-react": "workspace:*",
19+
"@tutorialkit/runtime": "workspace:*",
20+
"@tutorialkit/theme": "workspace:*",
21+
"@tutorialkit/types": "workspace:*",
22+
"@types/node": "^22.2.0",
23+
"@unocss/reset": "^0.59.4",
24+
"@unocss/transformer-directives": "^0.62.0",
25+
"astro": "^4.12.0",
26+
"fast-glob": "^3.3.2",
27+
"playwright": "^1.46.0",
28+
"react": "^18.3.1",
29+
"react-dom": "^18.3.1",
30+
"unocss": "^0.59.4"
31+
}
32+
}

test/ui/playwright.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from '@playwright/test';
2+
3+
export default defineConfig({
4+
expect: {
5+
timeout: process.env.CI ? 30_000 : 10_000,
6+
},
7+
use: {
8+
baseURL: 'http://localhost:4329',
9+
},
10+
webServer: {
11+
command: 'pnpm preview',
12+
url: 'http://localhost:4329',
13+
reuseExistingServer: !process.env.CI,
14+
stdout: 'ignore',
15+
stderr: 'pipe',
16+
},
17+
});

test/ui/public/logo.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)