Demo mode, fixtures, Playwright CI, and release screenshots#6
Conversation
| runs-on: ubuntu-latest | ||
| needs: build-and-test | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 11.1.2 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| cache: pnpm | ||
|
|
||
| - run: pnpm install --frozen-lockfile | ||
| - run: pnpm build | ||
|
|
||
| - name: Install Playwright Chromium | ||
| working-directory: apps/studio | ||
| run: pnpm exec playwright install --with-deps chromium | ||
|
|
||
| - name: Run Studio smoke tests (demo mode) | ||
| working-directory: apps/studio | ||
| env: | ||
| CI: true | ||
| run: pnpm test:e2e |
| if (demoMode) { | ||
| const runtime = loadPublicConfig(); | ||
|
|
||
| if (pathParam.length > 0) { |
| const result = await loadDemoPost(pathParam, runtime); | ||
| res.status(result.status).json(result.body); | ||
| return; | ||
| } |
| @@ -114,6 +166,13 @@ app.post( | |||
| requireSameSiteRequest, | |||
| requireAuth, | |||
| @@ -126,6 +185,16 @@ app.post( | |||
| } | ||
|
|
||
| const envResult = loadPublishEnv(); | ||
| if (!envResult.ok) { |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa497a945a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,3 @@ | |||
| export const DEMO_CONTENT_DIR = "src/content/blog"; | |||
There was a problem hiding this comment.
Derive demo fixture paths from runtime config
When a project uses any contentDir other than the default, the demo sidebar still lists fixture paths under src/content/blog, but opening one calls loadDemoPost, which validates that clicked path against the runtime env.contentDir via safePostPath. In that configuration every seeded demo post is rejected as outside the configured content directory, so demo mode cannot open its own sample posts. The fixture paths need to be generated/remapped from the active demo/runtime content directory instead of this hard-coded default.
Useful? React with 👍 / 👎.
| const response = await fetch("/api/auth/status", AUTH_FETCH_OPTIONS); | ||
| const response = await fetch("/api/auth/status", { | ||
| ...AUTH_FETCH_OPTIONS, | ||
| signal: AbortSignal.timeout(AUTH_FETCH_TIMEOUT_MS), |
There was a problem hiding this comment.
Fall back when AbortSignal.timeout is unavailable
On browsers/devices that do not implement AbortSignal.timeout, this line throws before fetch is called, and the catch path reports { configured: false, authenticated: false, demoModeAvailable: false }. In that environment a correctly configured Studio shows the password-not-configured state and also hides the demo entry point, effectively blocking login/demo access even though the API is healthy. Use an AbortController timeout fallback or guard this static method before passing the signal.
Useful? React with 👍 / 👎.
| webServer: { | ||
| command: "SOURCEDRAFT_DEMO_MODE=true STUDIO_API_PORT=8787 pnpm --filter studio dev", | ||
| cwd: repoRoot, | ||
| url: "http://127.0.0.1:5173", |
There was a problem hiding this comment.
Wait for the API before starting smoke tests
The web server readiness check only waits for Vite on port 5173, but the configured dev script starts Vite and the Express API concurrently. If Vite serves the app before tsx watch server/index.ts is listening on 8787, the initial /api/auth/status call is proxied to a closed port, fetchAuthStatus falls back to demoModeAvailable: false, and the smoke tests cannot find the “Explore demo mode” button. Add an API readiness wait (for example /api/auth/status) before tests interact with the page, or make the webServer command block until both processes are reachable.
Useful? React with 👍 / 👎.
|
Closing retroactive split-stack review PR. Continuing from protected main with scoped feature PRs. |
PR 5 of 11. Demo mode, health checks, deterministic fixtures, Playwright smoke tests and CI.