test
Write unit tests, run coverage checks, and create e2e tests
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Write unit tests, run coverage checks, and create e2e tests
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Top-level workflow controller that manages phase transitions for OCMUI bug resolution
Root cause analysis for bugs
Create PR description and recommend Jira updates
Implement bug fix following UHC Portal standards
Create draft pull request
Systematically reproduce bugs in a controlled environment
| name | test |
| description | Write unit tests, run coverage checks, and create e2e tests |
Write comprehensive unit tests following UHC Portal standards, verify test coverage with yarn test-changes, and create Playwright e2e tests when UI changes are involved.
Load implementation notes to understand:
Follow UHC Portal unit testing standards (from .cursor/rules/unit-test-rules.mdc):
Testing Principles:
React Testing Library:
render, screen from ~/testUtilsuser from render for interactions (not fireEvent)getByRole > getByLabelText > getByPlaceholderText > getByText > getByTestIdwaitFor for async operationscheckAccessibility utility when appropriateBest Practices:
jest.clearAllMocks() in beforeEach or afterEachjest.spyOn for mocking specific methodsjest.mock at module level for consistencyExample Test Structure:
import { render, screen } from '~/testUtils';
import { MyComponent } from './MyComponent';
describe('MyComponent', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('should handle cluster selection correctly', async () => {
// Arrange
const mockOnSelect = jest.fn();
const { user } = render(<MyComponent onSelect={mockOnSelect} />);
// Act
await user.click(screen.getByRole('button', { name: /select cluster/i }));
// Assert
expect(mockOnSelect).toHaveBeenCalledWith(expect.objectContaining({
id: 'cluster-123'
}));
});
it('should display error message when API fails', async () => {
// Arrange
jest.spyOn(console, 'error').mockImplementation();
const { user } = render(<MyComponent />);
// Act
await user.click(screen.getByRole('button', { name: /submit/i }));
// Assert
await waitFor(() => {
expect(screen.getByText(/error occurred/i)).toBeInTheDocument();
});
});
});
Write a test that:
This ensures the bug doesn't come back.
Run modified file tests:
yarn test {test-file-path}
Run full test suite:
yarn test
Ensure all tests pass.
Critical step for UHC Portal:
yarn test-changes
This shows coverage for only the changed code.
Coverage expectations:
If coverage is low, add more tests.
When e2e tests are needed:
Playwright e2e standards (from .cursor/rules/playwright-e2e-tests-rules.mdc):
Page Objects:
BasePage{feature}-page.ts, class: {Feature}PageLocator)Promise<void>)is{PageName}() method for validationgetByRole > getByLabel > getByText > getByTestIdTest Specs:
test, expect from custom fixtures (../../fixtures/pages)test.describe.serial for multi-step flows with shared statetest.describe for independent tests{ tag: ['@smoke', '@ci', '@rosa'] }navigateTo fixture for navigationis{PageName}() in test.beforeAll to validate@ci for fast, side-effect-free tests@smoke for critical Day 0/Day 1 paths@day1 or @day2 to indicate lifecycle phasepage.waitForTimeout() or page.waitForLoadState('networkidle')Example e2e test:
import { test, expect } from '../../fixtures/pages';
test.describe.serial('Cluster list filtering', { tag: ['@ci', '@day1', '@rosa'] }, () => {
test.beforeAll(async ({ navigateTo, clusterListPage }) => {
await navigateTo('/clusters');
await clusterListPage.isClusterListPage();
});
test('should filter clusters by name', async ({ clusterListPage }) => {
await clusterListPage.filterByName('test-cluster');
expect(await clusterListPage.getClusterCount()).toBe(1);
});
});
Create artifacts/bugfix/tests/verification-{issue-key}.md:
# Test Verification Report: {Issue Key}
## Bug Summary
- **Issue**: {OCMUI-XXXX}
- **Files tested**: {list test files}
## Unit Tests
### New Tests Added
**{test-file-1}.test.tsx**
- `should {description}` — {what this tests}
- `should {description}` — {what this tests}
**{test-file-2}.test.tsx**
- `should {description}` — {what this tests}
### Regression Test
✅ **Test that proves bug is fixed:**
- Test: `{test name}`
- File: `{test-file}.test.tsx`
- **Without fix**: ❌ Fails (verifies bug existed)
- **With fix**: ✅ Passes (proves it's fixed)
### Test Results
```
yarn test
{paste relevant output}
PASS src/components/ClusterList.test.tsx
PASS src/hooks/useClusterFilter.test.tsx
Test Suites: 2 passed, 2 total
Tests: 8 passed, 8 total
```
## Coverage Check
```
yarn test-changes
{paste output}
File | Stmts | Branch | Funcs | Lines
---------------------------|-------|--------|-------|-------
src/components/ClusterList.tsx | 95.2 | 87.5 | 100 | 94.8
src/hooks/useClusterFilter.ts | 88.9 | 75.0 | 100 | 88.9
```
**Coverage Assessment:**
- Modified code coverage: {percentage}%
- Edge cases tested: {yes/no}
- Error paths tested: {yes/no}
{If low coverage, explain why or note that more tests are needed}
## E2E Tests
{If applicable:}
**Tests added:**
- `{spec-file}.spec.ts` — {what it tests}
**Test execution:**
```
yarn test:e2e
{relevant output}
```
{If not applicable: E2E tests not required for this change}
## Manual Verification
✅ **Manual test checklist:**
- [ ] Original bug reproduction steps no longer trigger the bug
- [ ] Related functionality still works
- [ ] Edge cases tested (empty states, errors, etc.)
- [ ] No new console errors
- [ ] No new TypeScript errors
- [ ] Accessibility checked (keyboard navigation, screen readers)
## Test Quality
**Standards followed:**
- [ ] Arrange-Act-Assert pattern used
- [ ] Descriptive test names
- [ ] Testing behavior, not implementation
- [ ] Mocks are simple and focused
- [ ] React Testing Library best practices followed
- [ ] Accessibility testing included (if UI changes)
## Issues Found During Testing
{If tests revealed issues:}
- {Issue 1} — {how you addressed it}
- {Issue 2} — {how you addressed it}
{If no issues: No issues found}
## Confidence Level
**High** / **Medium** / **Low**
{Explain your confidence in the fix based on test results}
## Next Steps
Ready to proceed to `/document` phase to prepare PR description.
After generating the test report, re-read .claude/skills/controller/SKILL.md and return control to the controller for next step recommendations.
artifacts/bugfix/tests/verification-{issue-key}.md — Test verification reportAfter running this phase:
yarn test-changes run to verify coverage