Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Problem

Storybook test-runner failing on 11 stories with ReferenceError: __test is not defined during page.evaluate() in smoke tests. Affected form_extras.stories.tsx (Toggle, ToggleGroup, etc.) and object-grid.stories.tsx (WithActions).

Changes

Created .storybook/test-runner.ts to inject window.__test into Playwright's browser context before each story visit:

declare global {
  interface Window {
    __test?: boolean;
  }
}

const config: TestRunnerConfig = {
  async preVisit(page) {
    await page.evaluate(() => {
      window.__test = true;
    });
  },
};

The test-runner's internal evaluation code expects this global to exist but doesn't provide it by default.

Reference

https://github.com/objectstack-ai/objectui/actions/runs/21475614104/job/61858765955#step:7:1

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21475614104/job/61858765955#step:7:1


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
objectui Canceled Canceled Jan 29, 2026 11:25am
objectui-components Ready Ready Preview, Comment Jan 29, 2026 11:25am
objectui-crm-app Error Error Jan 29, 2026 11:25am

Request Review

Copilot AI and others added 3 commits January 29, 2026 11:14
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong marked this pull request as ready for review January 29, 2026 11:24
Copilot AI review requested due to automatic review settings January 29, 2026 11:24
Copilot AI changed the title [WIP] Fix action job error in CI pipeline Add test-runner config to inject __test global for Storybook smoke tests Jan 29, 2026
@hotlong hotlong merged commit eec1662 into copilot/update-crm-app-to-msw-mode Jan 29, 2026
7 of 9 checks passed
Copilot AI requested a review from hotlong January 29, 2026 11:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Storybook test-runner configuration to prevent CI failures caused by an expected (but previously undefined) __test global in the Playwright browser context.

Changes:

  • Introduce .storybook/test-runner.ts with a preVisit hook that sets window.__test = true before each story visit
  • Add a TypeScript Window interface augmentation for type-safe access to window.__test

@github-actions
Copy link

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants