Skip to content

Commit 8c389c4

Browse files
committed
test: add test/ui
1 parent c788cca commit 8c389c4

File tree

43 files changed

+470
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+470
-4
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": "[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"

packages/components/react/src/Panels/EditorPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function FileTab({ i18n, editorDocument, helpAction, onHelpClick }: FileTabProps
125125
<span className="text-sm">{fileName}</span>
126126
</div>
127127
{!!helpAction && (
128-
<button onClick={onHelpClick} className="panel-button px-2 py-0.5 -mr-1 -my-1">
128+
<button onClick={onHelpClick} disabled={!onHelpClick} className="panel-button px-2 py-0.5 -mr-1 -my-1">
129129
{helpAction === 'solve' && <div className="i-ph-lightbulb-duotone text-lg" />}
130130
{helpAction === 'solve' && i18n.solveButtonText}
131131
{helpAction === 'reset' && <div className="i-ph-clock-counter-clockwise-duotone" />}

packages/components/react/src/Panels/WorkspacePanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function WorkspacePanel({ tutorialStore, theme }: Props) {
4040

4141
const selectedFile = useStore(tutorialStore.selectedFile);
4242
const currentDocument = useStore(tutorialStore.currentDocument);
43+
const lessonFullyLoaded = useStore(tutorialStore.lessonFullyLoaded);
4344

4445
const lesson = tutorialStore.lesson!;
4546

@@ -158,7 +159,7 @@ export function WorkspacePanel({ tutorialStore, theme }: Props) {
158159
i18n={lesson.data.i18n as I18n}
159160
hideRoot={lesson.data.hideRoot}
160161
helpAction={helpAction}
161-
onHelpClick={onHelpClick}
162+
onHelpClick={lessonFullyLoaded ? onHelpClick : undefined}
162163
onFileSelect={onFileSelect}
163164
selectedFile={selectedFile}
164165
onEditorScroll={onEditorScroll}

packages/components/react/src/core/CodeMirrorEditor/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ function newEditorState(
208208
return EditorState.create({
209209
doc: content,
210210
extensions: [
211+
EditorView.contentAttributes.of({ 'aria-label': 'Editor' }),
211212
EditorView.domEventHandlers({
212213
scroll: debounce((_event, view) => {
213214
onScrollRef.current?.({ left: view.scrollDOM.scrollLeft, top: view.scrollDOM.scrollTop });

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/cli/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# CLI Tests
2+
3+
> Tests for verifying `@tutorialkit/cli` works with the actual built template, including their package manager lockfiles.
4+
5+
## Running
6+
7+
- `cd <root of the project>`
8+
- `pnpm cli:build-release`
9+
- `cd test/cli`
10+
- `pnpm test`
11+

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+
```

0 commit comments

Comments
 (0)