Skip to content

Commit 7c0eeb0

Browse files
committed
test: add tests for ui
1 parent d46ec03 commit 7c0eeb0

File tree

27 files changed

+760
-1
lines changed

27 files changed

+760
-1
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

package.json

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

test/ui/playwright.config.ts

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

test/ui/src/content/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { contentSchema } from '@tutorialkit/types';
2+
import { defineCollection } from 'astro:content';
3+
4+
const tutorial = defineCollection({
5+
type: 'content',
6+
schema: contentSchema,
7+
});
8+
9+
export const collections = { tutorial };

test/ui/src/content/tutorial/meta.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
type: tutorial
3+
mainCommand: ''
4+
prepareCommands: []
5+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
type: part
3+
title: Tests
4+
---

0 commit comments

Comments
 (0)