**Version:** 1.0.0
Write failing tests first for all components before implementation. Use this during TDD RED phase to verify test correctness by ensuring all tests fail due to missing code.
/plugin marketplace add nguyenthienthanh/ccpm-team-agents/plugin install nguyenthienthanh-aura-frog-aura-frog-2@nguyenthienthanh/ccpm-team-agentsworkflow/Version: 1.0.0
Purpose: Execute Phase 5a - Write Tests (RED Phase of TDD)
Trigger: Auto-triggered after Phase 4 approval OR manual /workflow:phase:5a
Write failing tests FIRST before any implementation.
Deliverables:
This is verification that tests are correct!
Agent: qa-automation + primary dev agent
For each component/module:
// Example: PostCaptionEditor.test.tsx
import { render, fireEvent, waitFor } from '@testing-library/react-native';
import { PostCaptionEditor } from '../PostCaptionEditor';
describe('PostCaptionEditor', () => {
it('should render caption input', () => {
const { getByPlaceholderText } = render(
<PostCaptionEditor caption="" onCaptionChange={jest.fn()} />
);
expect(getByPlaceholderText('Enter caption...')).toBeTruthy();
});
it('should call onCaptionChange when text changes', () => {
const onCaptionChange = jest.fn();
const { getByPlaceholderText } = render(
<PostCaptionEditor caption="" onCaptionChange={onCaptionChange} />
);
fireEvent.changeText(getByPlaceholderText('Enter caption...'), 'New caption');
expect(onCaptionChange).toHaveBeenCalledWith('New caption');
});
it('should show generate button when enabled', () => {
const { getByText } = render(
<PostCaptionEditor
caption=""
onCaptionChange={jest.fn()}
onGenerate={jest.fn()}
canGenerate={true}
/>
);
expect(getByText('Generate Caption')).toBeTruthy();
});
// ... more tests
});
Cover:
npm test
# Expected output:
FAIL src/features/.../PostCaptionEditor.test.tsx
PostCaptionEditor
โ should render caption input (5 ms)
โ should call onCaptionChange when text changes (3 ms)
โ should show generate button when enabled (2 ms)
Reason: Cannot find module '../PostCaptionEditor'
Test Suites: 1 failed, 0 passed, 1 total
Tests: 15 failed, 0 passed, 15 total
This is GOOD! Tests failing as expected! ๐ด
# Phase 5a: Test Report (RED)
## Tests Written
### Component Tests (5 files, 53 tests)
- PostCaptionEditor.test.tsx: 12 tests
- PlatformSelector.test.tsx: 8 tests
- MediaPreviewSection.test.tsx: 10 tests
- PostActionButtons.test.tsx: 8 tests
- SocialMarketingCompositePost.test.tsx: 15 tests
### Hook Tests (1 file, 20 tests)
- useSocialMarketingCompositePostLogic.test.ts: 20 tests
## Test Execution Results
Total: 73 tests
Passing: 0 โ
Failing: 73 โ (Expected!)
## Coverage Setup
- Coverage threshold: 85%
- Coverage reporters: text, html, lcov
- Coverage directory: coverage/
## Next Step
Phase 5b: Implement code to make these tests pass (GREEN)
Phase 5a complete when:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฏ PHASE 5a COMPLETE: Write Tests (RED)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Summary:
Wrote 73 tests for all components and hooks
๐ฆ Deliverables:
๐งช PostCaptionEditor.test.tsx (12 tests)
๐งช PlatformSelector.test.tsx (8 tests)
๐งช MediaPreviewSection.test.tsx (10 tests)
๐งช PostActionButtons.test.tsx (8 tests)
๐งช SocialMarketingCompositePost.test.tsx (15 tests)
๐งช useSocialMarketingCompositePostLogic.test.ts (20 tests)
๐ด Test Results (RED Phase):
Total: 73 tests
Passing: 0 โ
Failing: 73 โ (EXPECTED!)
Failure reason: Modules not implemented yet โ
โ
Success Criteria:
โ
All test files created
โ
73 tests written
โ
All tests failing (correct TDD RED phase)
โ
Coverage configured (85% target)
โญ๏ธ Next Phase: Phase 5b - Implementation (GREEN)
Write minimum code to make all tests pass
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ ACTION REQUIRED
Type "/workflow:approve" โ Proceed to Phase 5b (Implementation)
Type "/workflow:reject" โ Revise tests
Type "/workflow:modify <feedback>" โ Adjust test cases
Your response:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Before allowing Phase 5b:
// Validate RED phase
const validation = {
testsExist: true,
testsRun: true,
allTestsFail: true, // MUST BE TRUE!
failureReason: 'Module not found / Not implemented',
coverageSetup: true
};
if (!validation.allTestsFail) {
throw new Error('TDD violation: Tests must fail in RED phase!');
}
// WRONG in Phase 5a!
export const PostCaptionEditor = ({ caption }) => {
return <View>...</View>;
};
// WRONG - mocking too much!
jest.mock('../PostCaptionEditor', () => ({
PostCaptionEditor: () => <View testID="mocked" />
}));
// CORRECT - test for non-existent module
import { PostCaptionEditor } from '../PostCaptionEditor';
// This import will fail โ test fails โ RED phase correct!
test('should render', () => {
render(<PostCaptionEditor {...props} />);
// Will fail because PostCaptionEditor doesn't exist yet
});
src/features/socialMarketing/
โโโ components/
โโโ SocialMarketingCompositePost/
โโโ __tests__/
โโโ PostCaptionEditor.test.tsx โญ
โโโ PlatformSelector.test.tsx โญ
โโโ MediaPreviewSection.test.tsx โญ
โโโ PostActionButtons.test.tsx โญ
โโโ SocialMarketingCompositePost.test.tsx โญ
โโโ useSocialMarketingCompositePostLogic.test.ts โญ
logs/contexts/{workflow-id}/deliverables/
โโโ PHASE_5A_TEST_REPORT.md
After approval โ /workflow:phase:5b:
Status: Active command
Related: workflow:phase:4, workflow:phase:5b, workflow:approve
Remember: ๐ด RED = GOOD! Tests failing means they're correctly testing non-existent code!