Skip to content

Commit 2c3cec8

Browse files
test: add specs before refactor.
1 parent 8c0c5f6 commit 2c3cec8

2 files changed

Lines changed: 61 additions & 2 deletions

File tree

docs/next-steps.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Focused follow-up work for `@knighted/develop`.
1515
- Prefer CDN-delivered tooling where possible and preserve graceful fallback behavior when unavailable.
1616

1717
4. **In-browser component type checking**
18-
- Explore TypeScript/JSX type checking for component source in-browser using CDN-delivered tooling.
19-
- Keep diagnostics responsive and surface clear inline/editor feedback without blocking the preview loop.
18+
- Add editor-linked diagnostics navigation so each issue can jump to the exact line/column in the component source.
19+
- Surface line/column context directly in the diagnostics UI (not just message text) to speed up triage.
20+
- Continue improving typecheck performance for first-run and large sources while keeping the preview loop non-blocking.
2021

2122
5. **In-browser component testing**
2223
- Explore authoring and running component-focused tests in-browser (for example, a Vitest-compatible flow) using CDN-delivered tooling.

playwright/app.spec.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,61 @@ test('clearing styles keeps diagnostics error state but resets status styling',
263263
)
264264
await expect(page.locator('#diagnostics-toggle')).toHaveText(/Diagnostics \([1-9]\d*\)/)
265265
})
266+
267+
test('clear component diagnostics removes type errors and restores rendered status', async ({
268+
page,
269+
}) => {
270+
await waitForInitialRender(page)
271+
272+
await setComponentEditorSource(
273+
page,
274+
["const count: number = 'oops'", 'const App = () => <button>ready</button>'].join(
275+
'\n',
276+
),
277+
)
278+
279+
await page.getByRole('button', { name: 'Typecheck' }).click()
280+
await expect(page.locator('#diagnostics-toggle')).toHaveClass(
281+
/diagnostics-toggle--error/,
282+
)
283+
await expect(page.locator('#status')).toHaveText(/Rendered \(Type errors: [1-9]\d*\)/)
284+
285+
await page.locator('#diagnostics-toggle').click()
286+
await page.locator('#diagnostics-clear-component').click()
287+
288+
await expect(page.locator('#diagnostics-component')).toContainText(
289+
'No diagnostics yet.',
290+
)
291+
await expect(page.locator('#diagnostics-toggle')).toHaveText('Diagnostics')
292+
await expect(page.locator('#diagnostics-toggle')).toHaveClass(
293+
/diagnostics-toggle--neutral/,
294+
)
295+
await expect(page.locator('#status')).toHaveText('Rendered')
296+
await expect(page.locator('#status')).toHaveClass(/status--neutral/)
297+
})
298+
299+
test('clear all diagnostics removes style compile diagnostics', async ({ page }) => {
300+
await waitForInitialRender(page)
301+
302+
await page.locator('#style-mode').selectOption('sass')
303+
await setStylesEditorSource(page, '.card { color: $missing; }')
304+
305+
await expect(page.locator('#diagnostics-toggle')).toHaveClass(
306+
/diagnostics-toggle--error/,
307+
)
308+
309+
await page.locator('#diagnostics-toggle').click()
310+
await expect(page.locator('#diagnostics-styles')).toContainText(
311+
'Style compilation failed.',
312+
)
313+
314+
await page.locator('#diagnostics-clear-all').click()
315+
await expect(page.locator('#diagnostics-component')).toContainText(
316+
'No diagnostics yet.',
317+
)
318+
await expect(page.locator('#diagnostics-styles')).toContainText('No diagnostics yet.')
319+
await expect(page.locator('#diagnostics-toggle')).toHaveText('Diagnostics')
320+
await expect(page.locator('#diagnostics-toggle')).toHaveClass(
321+
/diagnostics-toggle--neutral/,
322+
)
323+
})

0 commit comments

Comments
 (0)