원클릭으로
test-feature
Writes and runs tests for a tutti-belli feature — integration tests for lib functions and an e2e test for the happy-path form flow
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Writes and runs tests for a tutti-belli feature — integration tests for lib functions and an e2e test for the happy-path form flow
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | test-feature |
| description | Writes and runs tests for a tutti-belli feature — integration tests for lib functions and an e2e test for the happy-path form flow |
| user-invocable | true |
You are writing tests for a feature in the tutti-belli Astro 5 SSR app. Follow these steps exactly.
If $ARGUMENTS is provided, treat it as the feature name (e.g. groups, song-requests).
Otherwise, ask the user: "Which feature are you testing? Give the name (e.g. groups) and optionally describe the key actions (create/update/delete)."
From the feature name, derive:
<name> — lowercase, hyphen-separated (e.g. song-requests)<camelName> — camelCase (e.g. songRequests)Identify the relevant files:
src/lib/<name>.ts — lib functions to integration-testsrc/actions/<name>.ts — actions (tested indirectly via lib + e2e)src/pages/ensembles/[id]/<name>.astro or similarRead these files before writing any tests.
Create tests/integration/<name>.test.ts. Test each exported lib function that touches the DB.
Structure:
import { describe, it, expect } from 'vitest';
import { db, eq, <TableNames> } from 'astro:db';
import { createUser, createEnsemble, /* other fixtures */ } from './fixtures.ts';
import { myLibFunction, anotherLibFunction } from '../../src/lib/<name>.ts';
describe('<name> lib', () => {
describe('myLibFunction', () => {
it('does the happy path', async () => {
const user = await createUser();
const ensemble = await createEnsemble(user!.id);
// ... set up, call function, assert
});
it('handles edge case', async () => {
// ...
});
});
});
Rules:
./fixtures.ts — use createUser, createEnsemble, createMembership, createGroup, createSeason, createEvent, etc. as needed../../src/lib/<name>.tsstorage.ts, mock it at the top: vi.mock('../../src/lib/storage.ts')expect(...).toBeNull(), expect(...).toBe(...), expect(...).toHaveLength(...) etc.it block should be independent — create fresh fixtures, don't share stateWhat to cover:
Create tests/e2e/<name>.spec.ts. Cover the primary user flow and any permission boundaries.
Structure:
/**
* E2E tests for <name> flows.
* Uses the admin user's auth state (chromium-admin project).
*/
import { test, expect } from '@playwright/test';
async function navigateTo<PascalName>(page: ReturnType<typeof test['info']>['project']['use'] & any) {
await page.goto('/ensembles');
await page.locator('.card').filter({ hasText: 'Chamber Orchestra' }).locator('a').first().click();
await expect(page).toHaveURL(/\/ensembles\/.+/);
const ensembleUrl = page.url();
await page.goto(ensembleUrl + '/<name>');
await expect(page).toHaveURL(/<name>/);
}
test('<name> page loads without error', async ({ page }) => {
await navigateTo<PascalName>(page);
await expect(page.locator('body')).not.toContainText('500');
});
test('admin can create a <name>', async ({ page }) => {
await navigateTo<PascalName>(page);
// fill form, submit, assert result
});
Rules:
chromium-admin auth project (set via playwright.config.ts — no extra setup needed)page.url(), NOT by clicking navbar dropdown links (they require hover)form="formId" must be located with page.locator('button[type="submit"][form="formId"]')function uniqueEmail(label: string, workerIndex: number) {
return `e2e-${label}-${workerIndex}-${Date.now()}@example.com`;
}
// use: async ({ page }, workerInfo) => { ... uniqueEmail('label', workerInfo.workerIndex) }
await expect(page.locator('.notification')).toBeVisible() before page.goto() in Firefox-sensitive flows to avoid NS_BINDING_ABORTEDReturnType<typeof test['info']>['project']['use'] & any type for page helper function parametersWhat to cover:
Run integration tests:
pnpm test tests/integration/<name>.test.ts
Run e2e tests (requires dev server running on port 4321):
pnpm test:e2e --grep "<name>"
If tests fail:
Report:
fixtures.ts)