Skip to content

Commit a235591

Browse files
committed
test(playwright): load test-story via demo runner ?story param
1 parent ea1941f commit a235591

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

results/validate-story.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[
2+
{
3+
"story": "/home/rgardler/projects/GEngine/web/stories/demo.ink",
4+
"pass": true,
5+
"steps": 21,
6+
"path": [
7+
3,
8+
0,
9+
1,
10+
1,
11+
1
12+
],
13+
"rotationOpportunity": true,
14+
"exhausted": false
15+
},
16+
{
17+
"story": "/home/rgardler/projects/GEngine/web/stories/test-story.ink",
18+
"pass": false,
19+
"steps": 0,
20+
"path": [],
21+
"error": "Parse/compile error: Compilation failed.",
22+
"rotationOpportunity": false,
23+
"exhausted": false
24+
},
25+
{
26+
"story": "/home/rgardler/projects/GEngine/web/stories/test.ink",
27+
"pass": true,
28+
"steps": 4,
29+
"path": [
30+
1
31+
],
32+
"rotationOpportunity": true,
33+
"exhausted": false
34+
},
35+
{
36+
"story": "/home/rgardler/projects/GEngine/web/stories/test_minimal.ink",
37+
"pass": true,
38+
"steps": 3,
39+
"path": [
40+
0
41+
],
42+
"rotationOpportunity": true,
43+
"exhausted": false
44+
}
45+
]

results/validate-test-story.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"story": "/home/rgardler/projects/GEngine/web/stories/test-story.ink",
4+
"pass": false,
5+
"steps": 0,
6+
"path": [],
7+
"error": "Parse/compile error: Compilation failed.",
8+
"rotationOpportunity": false,
9+
"exhausted": false
10+
}
11+
]

tests/load-test-story.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
async function collectConsoleErrors(page) {
4+
const errors: string[] = [];
5+
page.on('console', msg => {
6+
if (msg.type() === 'error') errors.push(msg.text());
7+
});
8+
return errors;
9+
}
10+
11+
test('demo loads test-story.ink via ?story and presents UI', async ({ page }) => {
12+
const errors = await collectConsoleErrors(page);
13+
14+
// Load the demo and request the test story explicitly
15+
await page.goto('/demo/?story=/stories/test-story.ink');
16+
17+
const story = page.locator('#story');
18+
await expect(story).toBeVisible();
19+
20+
// Wait until the story area has text content
21+
await page.waitForFunction(() => {
22+
const el = document.querySelector('#story');
23+
return !!el && el.textContent && el.textContent.trim().length > 0;
24+
}, undefined, { timeout: 5000 });
25+
26+
const choices = page.locator('.choice-btn');
27+
await expect.poll(async () => choices.count(), { timeout: 5000 }).toBeGreaterThan(0);
28+
29+
// No console errors
30+
expect(errors, 'Console errors should be empty').toEqual([]);
31+
});

0 commit comments

Comments
 (0)