Skip to content

Commit da97530

Browse files
test: address comments, add agents.
1 parent ff15a3c commit da97530

3 files changed

Lines changed: 76 additions & 13 deletions

File tree

playwright/AGENTS.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: knighted-develop-playwright-agent
3+
description: Focused guidance for Playwright E2E authoring and triage in @knighted/develop.
4+
---
5+
6+
You are working in @knighted/develop Playwright E2E tests. Keep feedback loops short and avoid full-suite reruns unless explicitly requested.
7+
8+
## Scope
9+
10+
- Folder: playwright/
11+
- Focus: test behavior, selectors, test stability, and fixture/setup correctness
12+
- Keep changes minimal and localized to the failing behavior
13+
14+
## Fast Failure Loop
15+
16+
- Start with one browser at a time: Chromium first.
17+
- Run one spec file before running broader groups.
18+
- When possible, run only the failing test name(s).
19+
- Do not run full Playwright shards locally unless explicitly requested.
20+
21+
## Flake Triage
22+
23+
- Check failure output for network/CDN/API timing flakes first.
24+
- Retry flaky failures once.
25+
- If the same assertion fails again, treat it as deterministic and fix code/tests.
26+
- Prefer fixing stale expectations when product behavior intentionally changed.
27+
28+
## Test Authoring Rules
29+
30+
- Prefer semantic selectors: getByRole, getByLabel, getByText.
31+
- Use explicit accessible names for interactive controls.
32+
- Use locator() only when semantic selectors are not reliable.
33+
- For known WebKit dialog issues, prefer a stable dialog id and evaluate-based click for dialog confirmation controls.
34+
35+
## PR and Workspace Assertions
36+
37+
- When asserting Git payloads, prefer verifying exact file paths/content over fragile counts when defaults may evolve.
38+
- Keep assertions aligned with default workspace/tab contracts.
39+
40+
## Validation Commands
41+
42+
- Lint after JS/TS edits: npm run lint
43+
- For Playwright changes, prefer targeted execution first.
44+
45+
## Boundaries
46+
47+
- Do not change build/import-map scripts unless required by the test task.
48+
- Do not broaden CI scope or shard counts unless explicitly requested.
49+
- Do not modify generated outputs or lockfiles unless explicitly requested.

playwright/github-pr-drawer/open-pr-create.spec.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,19 @@ test('Open PR drawer confirms and submits default workspace filepaths', async ({
191191
expect(createdRefPayload?.ref).toBe('refs/heads/Develop/Open-Pr-Test')
192192
expect(createdRefPayload?.sha).toBe('abc123mainsha')
193193
expect(treeRequests).toHaveLength(1)
194-
const submittedPaths = (treeRequests[0]?.tree as Array<Record<string, unknown>>).map(
194+
const submittedTree = treeRequests[0]?.tree
195+
expect(Array.isArray(submittedTree)).toBe(true)
196+
const submittedPaths = (submittedTree as Array<Record<string, unknown>>).map(
195197
entry => entry.path,
196198
)
197-
expect(submittedPaths).toEqual([
198-
'src/components/App.tsx',
199-
'src/components/Counter.tsx',
200-
'src/styles/app.css',
201-
])
199+
expect(submittedPaths).toHaveLength(3)
200+
expect(submittedPaths).toEqual(
201+
expect.arrayContaining([
202+
'src/components/App.tsx',
203+
'src/components/Counter.tsx',
204+
'src/styles/app.css',
205+
]),
206+
)
202207
expect(commitRequests).toHaveLength(1)
203208
expect(commitRequests[0]?.message).toBe(customCommitMessage)
204209
expect(updateRefRequests).toHaveLength(1)
@@ -2090,14 +2095,19 @@ test('Open PR drawer uses Git Database API atomic commit path by default', async
20902095
)
20912096

20922097
expect(treeRequests).toHaveLength(1)
2093-
const submittedPaths = (treeRequests[0]?.tree as Array<Record<string, unknown>>).map(
2098+
const submittedTree = treeRequests[0]?.tree
2099+
expect(Array.isArray(submittedTree)).toBe(true)
2100+
const submittedPaths = (submittedTree as Array<Record<string, unknown>>).map(
20942101
entry => entry.path,
20952102
)
2096-
expect(submittedPaths).toEqual([
2097-
'src/components/App.tsx',
2098-
'src/components/Counter.tsx',
2099-
'src/styles/app.css',
2100-
])
2103+
expect(submittedPaths).toHaveLength(3)
2104+
expect(submittedPaths).toEqual(
2105+
expect.arrayContaining([
2106+
'src/components/App.tsx',
2107+
'src/components/Counter.tsx',
2108+
'src/styles/app.css',
2109+
]),
2110+
)
21012111
expect(commitRequests).toHaveLength(1)
21022112
expect(updateRefRequests).toHaveLength(1)
21032113
expect(updateRefRequests[0]?.sha).toBe('new-commit-sha')

src/modules/app-core/defaults.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export const defaultModuleJsx = [
1717
'}',
1818
'',
1919
'export const Counter = ({ label }: CounterProps) => {',
20-
" const el = <button class='counter-button' type='button'>{label}: 0</button> as HTMLButtonElement",
20+
' const el = (',
21+
" <button class='counter-button' type='button'>",
22+
' {label}: 0',
23+
' </button>',
24+
' ) as HTMLButtonElement',
2125
' let count = 0',
2226
'',
2327
' el.onclick = () => {',

0 commit comments

Comments
 (0)