Skip to content

Commit c40788d

Browse files
committed
Fix landing demo asset path on GitHub Pages
1 parent 07bfb90 commit c40788d

8 files changed

Lines changed: 67 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ jobs:
2020
- run: npm run test:e2e
2121
env:
2222
PLAYWRIGHT_PRODUCTION: 1
23+
- run: npm run test:pages

‎README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ header. See [SECURITY.md](SECURITY.md).
170170
npm run verify
171171
npx playwright install chromium
172172
npm run test:e2e
173+
npm run test:pages
173174
npm audit
174175
npm run preview
175176

@@ -189,6 +190,10 @@ unit tests, dependency audit, and Chromium end-to-end tests. Automated provider
189190
tests are mocked and never require a real key; live providers need a separate
190191
smoke test.
191192

193+
`npm run test:pages` builds with the `/pulsegraph/` deployment prefix and checks
194+
that the landing GIF and reduced-motion PNG load successfully, catching asset
195+
paths that work locally but break on GitHub Pages.
196+
192197
Regressions cover parsing (including stadium labels), malformed AI output, graph
193198
preservation, document round trips, framing limits, cycles, self-loops and a
194199
100-graph routing corpus. Browser tests cover editing, recovery, real exports,

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"format": "prettier --write .",
1414
"format:check": "prettier --check .",
1515
"test:e2e": "playwright test",
16+
"test:pages": "playwright test --config playwright.pages.config.ts",
1617
"verify": "npm run format:check && npm run lint && npm run build && npm run typecheck:tests && npm test",
1718
"typecheck:tests": "tsc -p tsconfig.tests.json"
1819
},

‎playwright.pages.config.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from '@playwright/test';
2+
import workspaceConfig from './playwright.config';
3+
4+
const pagesUrl = 'http://127.0.0.1:5179/pulsegraph/';
5+
6+
export default defineConfig(workspaceConfig, {
7+
testDir: './tests/pages',
8+
use: { ...workspaceConfig.use, baseURL: pagesUrl },
9+
webServer: {
10+
command:
11+
'npm run build -- --base=/pulsegraph/ && npm run preview -- --base=/pulsegraph/ --host 127.0.0.1 --port 5179 --strictPort',
12+
url: pagesUrl,
13+
reuseExistingServer: false,
14+
},
15+
});

‎src/components/LandingPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function BrowserShowcase() {
153153
</div>
154154
<div className="browser-screen">
155155
<img
156-
src="/pulsegraph-live-flow.gif?v=8"
156+
src={`${import.meta.env.BASE_URL}pulsegraph-live-flow.gif?v=8`}
157157
alt="PulseGraph animating a production API from customer and edge security through services, data stores and monitoring"
158158
width={2560}
159159
height={1440}

‎tests/e2e/workspace.spec.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ test('browser showcase adds responsive depth and respects reduced motion', async
143143
await stage.scrollIntoViewIfNeeded();
144144
await expect(shot).toBeVisible();
145145
await expect(shot.locator('img')).toHaveJSProperty('complete', true);
146+
await expect
147+
.poll(() =>
148+
shot.locator('img').evaluate((image) => (image as HTMLImageElement).naturalWidth),
149+
)
150+
.toBeGreaterThan(0);
146151

147152
const bounds = await stage.boundingBox();
148153
expect(bounds).not.toBeNull();

‎tests/pages/landing.spec.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('landing demo loads from the GitHub Pages subpath in both motion preferences', async ({
4+
page,
5+
}) => {
6+
await page.emulateMedia({ reducedMotion: 'no-preference' });
7+
const failedAssets: string[] = [];
8+
page.on('response', (response) => {
9+
if (response.status() >= 400) failedAssets.push(response.url());
10+
});
11+
await page.goto('./');
12+
const preview = page.locator('.browser-screen img');
13+
await preview.scrollIntoViewIfNeeded();
14+
await expect(preview).toHaveAttribute(
15+
'src',
16+
'/pulsegraph/pulsegraph-live-flow.gif?v=8',
17+
);
18+
await expect
19+
.poll(() => preview.evaluate((image) => (image as HTMLImageElement).naturalWidth))
20+
.toBe(2560);
21+
const gif = await page.request.get((await preview.getAttribute('src')) as string);
22+
expect(gif.status()).toBe(200);
23+
expect(gif.headers()['content-type']).toContain('image/gif');
24+
25+
const staticResponse = page.waitForResponse((response) =>
26+
response.url().endsWith('/pulsegraph/pulsegraph-live-flow-static.png'),
27+
);
28+
await page.emulateMedia({ reducedMotion: 'reduce' });
29+
expect((await staticResponse).status()).toBe(200);
30+
await expect(preview).toHaveCSS(
31+
'content',
32+
'url("http://127.0.0.1:5179/pulsegraph/pulsegraph-live-flow-static.png")',
33+
);
34+
expect(failedAssets).toEqual([]);
35+
await page
36+
.locator('.browser-shot')
37+
.screenshot({ path: 'test-results/pages-landing-demo.png' });
38+
});

‎tsconfig.tests.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"skipLibCheck": true,
1111
"types": ["node", "vite/client"]
1212
},
13-
"include": ["tests/**/*.ts", "playwright.config.ts"]
13+
"include": ["tests/**/*.ts", "playwright*.config.ts"]
1414
}

0 commit comments

Comments
 (0)