Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .copilot/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"],
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

Using @playwright/mcp@latest makes the MCP server version non-deterministic and can break unexpectedly (or pull in compromised releases). Consider pinning to a specific version (and updating deliberately), and/or adding it as a devDependency so it’s covered by the lockfile instead of fetching from the network at runtime.

Suggested change
"args": ["@playwright/mcp@latest"],
"args": ["@playwright/mcp@0.0.6"],

Copilot uses AI. Check for mistakes.
"type": "stdio"
Comment on lines +4 to +6
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

npx may prompt for confirmation when executing a package that isn’t installed locally (npm 7+), which can cause the MCP server startup to hang. Consider adding the appropriate non-interactive flag (e.g., --yes) or invoking a locally installed binary instead.

Copilot uses AI. Check for mistakes.
}
}
}
89 changes: 89 additions & 0 deletions .github/agents/playwright-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Playwright MCP Testing Skill

This skill provides guidance on using the Playwright MCP server for testing UI components in primer/view_components.

## When to Use Playwright MCP

Use Playwright MCP when:
- Making changes to component rendering (`.rb` files in `app/components/` or `html.erb` files)

Check failure on line 8 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "- Making changes to component ..."]

Check failure on line 8 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Modifying component styles (`.pcss` files)

Check failure on line 9 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Updating component JavaScript/TypeScript behavior

Check failure on line 10 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Adding new components or component variants

Check failure on line 11 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]
- Fixing visual bugs or accessibility issues

Check failure on line 12 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD004/ul-style Unordered list style [Expected: asterisk; Actual: dash]

## Repository Setup

### Demo Application

Check failure on line 16 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Demo Application"]
The demo app runs at `http://127.0.0.1:4000` and provides component previews.

### Preview URLs

Check failure on line 19 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Preview URLs"]
Component previews follow this pattern:
```

Check failure on line 21 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

Check failure on line 21 in .github/agents/playwright-testing.md

View workflow job for this annotation

GitHub Actions / markdown

MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
http://127.0.0.1:4000/rails/view_components/{component_path}
```

For example:
- Button: `/rails/view_components/primer/beta/button/default`
- ActionMenu: `/rails/view_components/primer/alpha/action_menu/default`

### Theme Testing
Add `?theme={theme_name}` to test different themes:
- `light`, `dark`, `dark_dimmed`
- `light_colorblind`, `dark_colorblind`
- `light_high_contrast`, `dark_high_contrast`
- `all` - Shows all themes at once

## Using Playwright MCP

### Starting the Demo Server
Before using Playwright MCP, ensure the demo server is running:
```bash
script/dev
```

### Common Playwright MCP Actions

#### 1. Test Interactions
```
Click the interactive element(s) and take a screenshot of the result
```

#### 2. Check Accessibility
```
Get the accessibility tree/ARIA snapshot of the component
```

#### 3. Test Focus States
```
Press Tab to focus interactive elements, then take a screenshot
```

## Existing Test Structure

### Test Files
- `test/playwright/snapshots.test.ts` - Main snapshot tests
- `test/playwright/helpers.ts` - Test utilities

### Snapshot Storage
- Visual snapshots: `.playwright/screenshots/`
- ARIA snapshots: `.playwright/screenshots/*/aria-snapshot.yml`

## Running Existing Tests

```bash
# Run all Playwright tests
npx playwright test

# Run specific test file
npx playwright test test/playwright/snapshots.test.ts

# Update snapshots
npx playwright test --update-snapshots
```

## Tips for PR Authors

1. **Before submitting**: Use Playwright MCP to visually verify your component changes
1. **Test interactions**: For interactive components, verify hover, focus, and active states
1. **Accessibility**: Ensure ARIA snapshots remain valid after your changes
1. **Screenshots**: If visual changes are intentional, the PR should include updated snapshots
28 changes: 28 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copilot Instructions for primer/view_components

This repository contains ViewComponents for the Primer Design System used by GitHub.

## Key Context

- **Framework**: Ruby on Rails ViewComponents with TypeScript/JavaScript
- **Testing**: Uses Playwright for visual regression and accessibility testing
- **Demo App**: Runs on port 4000 via `script/dev`

## When Making UI Changes

If your changes affect the visual appearance or behavior of a component:

1. Consider running Playwright tests to verify visual snapshots
2. Check ARIA snapshots for accessibility compliance
3. Test across all supported themes (light, dark, high contrast, colorblind variants)

## Playwright MCP Available

This repository has Playwright MCP configured. When working on UI-facing changes, you can use the Playwright MCP to:

- Navigate to component previews at `/rails/view_components/{component_path}`
- Take screenshots for visual verification
- Interact with components to test behavior
- Verify accessibility through ARIA snapshots

See `.github/agents/playwright-testing.md` for detailed guidance.
Loading