-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcb666f
commit 9e72229
Showing
39 changed files
with
497 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ tsconfig.tsbuildinfo | |
tsconfig.build.tsbuildinfo | ||
.tmp | ||
.tmp-* | ||
/test/**/test-results | ||
/test/**/.astro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shell-emulator=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"build": "pnpm run --stream --filter=@tutorialkit/* --filter=create-tutorial build", | ||
"build": "pnpm run --stream --filter='@tutorialkit/*' --filter=create-tutorial build", | ||
"dev": "TUTORIALKIT_DEV=true pnpm -r --parallel --stream --filter='./packages/**' run dev", | ||
"changelog": "./scripts/changelog.mjs", | ||
"clean": "./scripts/clean.sh", | ||
|
@@ -16,7 +16,7 @@ | |
"demo": "pnpm run --filter=demo.tutorialkit.dev dev", | ||
"demo:build": "pnpm run build && pnpm run --filter=demo.tutorialkit.dev build", | ||
"lint": "eslint \"{packages,docs,extensions,integration}/**/*\"", | ||
"test": "pnpm run --stream --filter=@tutorialkit/* test --run" | ||
"test": "CI=true pnpm run --stream --filter='@tutorialkit/*' test" | ||
}, | ||
"license": "MIT", | ||
"packageManager": "[email protected]", | ||
|
@@ -30,6 +30,7 @@ | |
"eslint-plugin-astro": "^1.2.3", | ||
"husky": "^9.0.11", | ||
"is-ci": "^3.0.1", | ||
"playwright": "^1.46.0", | ||
"prettier": "^3.3.2", | ||
"prettier-plugin-astro": "^0.14.1", | ||
"tempfile": "^5.0.0" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# UI Tests | ||
|
||
> Tests for verifying TutorialKit works as expected in the browser. Tests are run against locally linked `@tutorialkit` packages. | ||
## Running | ||
|
||
- `pnpm exec playwright install chromium --with-deps` - When running the tests first time | ||
- `pnpm test` | ||
|
||
## Development | ||
|
||
- `pnpm start` - Starts example/fixture project's development server | ||
- `pnpm test:ui` - Start Playwright in UI mode | ||
|
||
## Structure | ||
|
||
Test cases are located in `test` directory. | ||
Each test file has its own `chapter`, that contains `lesson`s for test cases: | ||
|
||
For example Navigation tests: | ||
|
||
``` | ||
├── src/content/tutorial | ||
│ └── tests | ||
│ └──── navigation | ||
│ ├── page-one | ||
│ ├── page-three | ||
│ └── page-two | ||
└── test | ||
└── navigation.test.ts | ||
``` | ||
|
||
Or File Tree tests: | ||
|
||
``` | ||
├── src/content/tutorial | ||
│ └── tests | ||
│ └── file-tree | ||
│ └── lesson-and-solution | ||
└── test | ||
└── file-tree.test.ts | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createRequire } from 'node:module'; | ||
import { resolve } from 'node:path'; | ||
import tutorialkit from '@tutorialkit/astro'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const astroDist = resolve(require.resolve('astro/package.json'), '..'); | ||
const swapFunctionEntry = resolve(astroDist, 'dist/transitions/swap-functions.js'); | ||
|
||
export default defineConfig({ | ||
devToolbar: { enabled: false }, | ||
server: { port: 4329 }, | ||
integrations: [tutorialkit()], | ||
|
||
vite: { | ||
resolve: { | ||
alias: { | ||
// work-around for https://github.com/stackblitz/tutorialkit/pull/238 | ||
'node_modules/astro/dist/transitions/swap-functions': swapFunctionEntry, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@tutorialkit/test-ui", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "astro dev", | ||
"start": "astro dev", | ||
"preview": "astro build && astro preview", | ||
"test": "playwright test", | ||
"test:ui": "pnpm run test --ui" | ||
}, | ||
"devDependencies": { | ||
"@astrojs/react": "^3.6.0", | ||
"@iconify-json/ph": "^1.1.13", | ||
"@iconify-json/svg-spinners": "^1.1.2", | ||
"@playwright/test": "^1.46.0", | ||
"@tutorialkit/astro": "workspace:*", | ||
"@tutorialkit/components-react": "workspace:*", | ||
"@tutorialkit/runtime": "workspace:*", | ||
"@tutorialkit/theme": "workspace:*", | ||
"@tutorialkit/types": "workspace:*", | ||
"@types/node": "^22.2.0", | ||
"@unocss/reset": "^0.59.4", | ||
"@unocss/transformer-directives": "^0.62.0", | ||
"astro": "^4.12.0", | ||
"fast-glob": "^3.3.2", | ||
"playwright": "^1.46.0", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"unocss": "^0.59.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineConfig } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
expect: { | ||
timeout: process.env.CI ? 30_000 : 10_000, | ||
}, | ||
use: { | ||
baseURL: 'http://localhost:4329', | ||
}, | ||
webServer: { | ||
command: 'pnpm preview', | ||
url: 'http://localhost:4329', | ||
reuseExistingServer: !process.env.CI, | ||
stdout: 'ignore', | ||
stderr: 'pipe', | ||
}, | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { contentSchema } from '@tutorialkit/types'; | ||
import { defineCollection } from 'astro:content'; | ||
|
||
const tutorial = defineCollection({ | ||
type: 'content', | ||
schema: contentSchema, | ||
}); | ||
|
||
export const collections = { tutorial }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: tutorial | ||
mainCommand: '' | ||
prepareCommands: [] | ||
--- |
8 changes: 8 additions & 0 deletions
8
test/ui/src/content/tutorial/tests/file-tree/lesson-and-solution/_files/example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>Lesson file example.html title</title> | ||
</head> | ||
<body> | ||
Lesson file example.html content | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/ui/src/content/tutorial/tests/file-tree/lesson-and-solution/_files/example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'Lesson file example.js content'; |
8 changes: 8 additions & 0 deletions
8
test/ui/src/content/tutorial/tests/file-tree/lesson-and-solution/_solution/example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>Solution file example.html title</title> | ||
</head> | ||
<body> | ||
Solution file example.html content | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/ui/src/content/tutorial/tests/file-tree/lesson-and-solution/_solution/example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'Solution file example.js content'; |
6 changes: 6 additions & 0 deletions
6
test/ui/src/content/tutorial/tests/file-tree/lesson-and-solution/content.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
type: lesson | ||
title: Lesson and solution | ||
--- | ||
|
||
# File Tree test - Lesson and solution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: chapter | ||
title: File Tree | ||
--- |
8 changes: 8 additions & 0 deletions
8
test/ui/src/content/tutorial/tests/file-tree/no-solution/_files/example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>Lesson file example.html title</title> | ||
</head> | ||
<body> | ||
Lesson file example.html content | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
test/ui/src/content/tutorial/tests/file-tree/no-solution/_files/example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'Lesson file example.js content'; |
6 changes: 6 additions & 0 deletions
6
test/ui/src/content/tutorial/tests/file-tree/no-solution/content.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
type: lesson | ||
title: No solution | ||
--- | ||
|
||
# File Tree test - No solution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: part | ||
title: Tests | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
type: chapter | ||
title: Navigation | ||
lessons: | ||
- page-one | ||
- page-two | ||
- page-three | ||
mainCommand: '' | ||
prepareCommands: [] | ||
--- |
6 changes: 6 additions & 0 deletions
6
test/ui/src/content/tutorial/tests/navigation/page-one/content.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
type: lesson | ||
title: Page one | ||
--- | ||
|
||
# Navigation test - Page one |
6 changes: 6 additions & 0 deletions
6
test/ui/src/content/tutorial/tests/navigation/page-three/content.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
type: lesson | ||
title: Page three | ||
--- | ||
|
||
# Navigation test - Page three |
6 changes: 6 additions & 0 deletions
6
test/ui/src/content/tutorial/tests/navigation/page-two/content.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
type: lesson | ||
title: Page two | ||
--- | ||
|
||
# Navigation test - Page two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: chapter | ||
title: Preview | ||
mainCommand: 'pnpm start' | ||
--- |
9 changes: 9 additions & 0 deletions
9
test/ui/src/content/tutorial/tests/preview/multiple/content.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
type: lesson | ||
title: Multiple | ||
previews: | ||
- [8000, "First Server"] | ||
- [8000, "Second Server", "/about.html"] | ||
--- | ||
|
||
# Preview test - Multiple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
type: lesson | ||
title: Single | ||
previews: | ||
- [8000, "Node Server"] | ||
--- | ||
|
||
# Preview test - Single |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../.astro/types.d.ts" /> | ||
/// <reference types="@tutorialkit/astro/types" /> | ||
/// <reference types="astro/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Default template</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>Default template</h1> | ||
<h2>About</h2> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Default template</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>Default template</h1> | ||
<h2>Index</h2> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import http from 'node:http'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
const server = http.createServer((req, res) => { | ||
if (req.url === '/' || req.url === '/index.html') { | ||
res.writeHead(200, { 'Content-Type': 'text/html' }); | ||
res.end(readFileSync('./index.html', 'utf8')); | ||
|
||
return; | ||
} | ||
|
||
if (req.url === '/about.html') { | ||
res.writeHead(200, { 'Content-Type': 'text/html' }); | ||
res.end(readFileSync('./about.html')); | ||
|
||
return; | ||
} | ||
|
||
res.writeHead(200, { 'Content-Type': 'text/html' }); | ||
res.end('Not found'); | ||
}); | ||
|
||
server.listen(8000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "default-template", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"start": "node ./index.mjs" | ||
} | ||
} |
Oops, something went wrong.