feat: update M2/M3 milestones to include testing infrastructure

M2 (Backend):
- Add tests/ folder with pytest test files
- Add pytest.ini for test configuration and coverage
- Update scoring to require unit tests (Score 4+)

M3 (Frontend):
- Add tests/ folder with Vitest component unit tests
- Add playwright/e2e/ folder with E2E Playwright tests
- Add @playwright/test dependency and configuration
- Update scoring to require both unit and E2E tests (Score 5)

README.md updated with all milestone links and test requirements
This commit is contained in:
Daniel Samson committed 2026-10-29 15:54:10 +00:00
1 parent d66fe178c3
commit 85490bc0a2
5 files changed
+216 -65

No files matched your search

+89 -43
View File
@@ -18,8 +18,15 @@ Create the frontend infrastructure for **newzy** news web application using Reac
│ │ │ └── index.ts
│ │ ├── api/
│ │ │ └── client.ts
│ │ ├── tests/
│ │ │ ├── Header.test.tsx
│ │ │ └── components/
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── playwright/
│ │ └── e2e/
│ │ ├── home.spec.ts
│ │ └── api.spec.ts
│ ├── .gitignore
│ ├── Dockerfile
│ ├── docker-compose.yml
@@ -31,77 +38,96 @@ Create the frontend infrastructure for **newzy** news web application using Reac
2. Initialize Vite project with React and TypeScript template:
- Use Node.js 18 or later
- Install dependencies: react, react-dom, typescript, @types/react, @types/react-dom, vite
- Install dependencies: react, react-dom, typescript, @types/react, @types/react-dom, vite, vitest (test runner)
3. Configure Vite with:
- Base path configuration
- Build output directory (dist/)
- Development server on port 5173
4. Create TypeScript type definitions in `src/types/`:
4. Install Playwright and configure for E2E testing:
- @playwright/test
- Run npx playwright install
- Configure paths in playwright.config.ts
5. Create TypeScript type definitions in `src/types/`:
- Article interface (id, title, content, author, category, published, createdAt)
- Author interface (id, name, email, bio)
- Category interface (id, name, slug)
- API response types
5. Create React components:
6. Create React components:
- `Header.tsx` with logo and navigation placeholder
- `Home.tsx` page component for listing articles
- Reusable UI components (ArticleCard, AuthorAvatar, CategoryBadge)
6. Set up API client in `src/api/client.ts`:
7. Set up API client in `src/api/client.ts`:
- Base URL configuration (relative path /api)
- Fetch wrapper with error handling
- Type-safe request/response functions
7. Create `package.json` scripts:
- dev: Development server
- build: Production build
- preview: Preview production build
- lint: ESLint check
8. Create component tests using Vitest in `src/tests/`:
- Test Header renders correctly
- Test Home page loads without errors
- Use react-dom/testing-library for rendering
8. Create `.gitignore` to exclude node_modules, dist/, .env files, IDE configs
9. Create Playwright E2E tests in `playwright/e2e/`:
- Test home page accessibility and layout
- Test article list renders with data
- Test API client makes requests correctly
9. Create `Dockerfile` for React + Vite with:
- Node.js base image
- Install dependencies
- Build frontend
- Nginx layer for serving static files in production
- Multi-stage build for optimization
10. Create `package.json` scripts:
- dev: Development server
- build: Production build
- preview: Preview production build
- test: Run unit tests (vitest)
- e2e: Run Playwright E2E tests
- lint: ESLint check
10. Update `docker-compose.yml` at project root with frontend service:
11. Create `.gitignore` to exclude node_modules, dist/, .env files, IDE configs, playwright trace files
12. Create `Dockerfile` for React + Vite with:
- Node.js base image
- Install dependencies
- Build frontend
- Nginx layer for serving static files in production
- Multi-stage build for optimization
13. Update `docker-compose.yml` at project root with frontend service:
- Port mapping 3000:80
- Links to backend service for API calls
11. Document setup process in `frontend/README.md` with examples
14. Document setup process in `frontend/README.md` with examples
12. Configure ESLint rules in .eslintrc.cjs or vite.config.ts
15. Configure ESLint rules in .eslintrc.cjs or vite.config.ts
Remember: Focus ONLY on frontend infrastructure. No complex UI features required yet.
## Description
This milestone sets up the React + TypeScript frontend for newzy news application using Vite as the build tool. The scope includes project scaffolding, type definitions, basic components, and Docker containerization—no complex UI implementations or user interactions.
This milestone sets up the React + TypeScript frontend for newzy news application using Vite as the build tool. The scope includes project scaffolding, type definitions, basic components, and comprehensive testing setup with Playwright E2E tests—no complex UI implementations or user interactions.
**Purpose**: Create a responsive, type-safe frontend ready to consume the backend API built in M2.
**Purpose**: Create a responsive, type-safe frontend ready to consume the backend API built in M2, with robust test coverage from both unit and E2E perspectives.
**Target Audience**: Frontend developers who need to understand the structure and extend components for features in subsequent milestones.
**Expected Outcomes**: A functioning React application that can load from browser or Docker container, with typed interfaces matching backend models and basic page layout in place.
**Expected Outcomes**: A functioning React application that can load from browser or Docker container, with typed interfaces matching backend models, basic page layout in place, and a complete testing setup (unit tests + Playwright E2E).
## Acceptance Criteria
- [ ] Vite project initialized with React and TypeScript
- [ ] Project structure includes: public/, src/, components/, pages/, types/, api/ folders
- [ ] Project structure includes: public/, src/, components/, pages/, types/, api/, tests/ folders
- [ ] Playwright installed and configured for E2E testing
- [ ] TypeScript type definitions for Article, Author, Category models
- [ ] Header component created with navigation placeholder
- [ ] Home page component rendering article listing layout
- [ ] API client configured with base URL and fetch wrapper
- [ ] package.json has dev, build, preview scripts working correctly
- [ ] .gitignore excludes node_modules, dist/, IDE configs
- [ ] Dockerfile builds production-ready static files
- [ ] Unit tests in src/tests/ using Vitest (react-testing-library)
- [ ] Playwright E2E tests in playwright/e2e/ covering core flows
- [ ] package.json has dev, build, preview, test, e2e scripts working correctly
- [ ] .gitignore excludes node_modules, dist/, IDE configs, and playwright artifacts
- [ ] Dockerfile builds production-ready static files with Nginx serving
- [ ] docker-compose.yml includes frontend service linked to backend
- [ ] Nginx configuration in Dockerfile for serving built files
- [ ] ESLint rules configured and passing
## Technical Details
@@ -124,19 +150,26 @@ newzy/
│ │ │ └── index.ts # TypeScript interfaces
│ │ ├── api/
│ │ │ └── client.ts # API request wrapper
│ │ ├── tests/
│ │ │ ├── Header.test.tsx # Component unit test
│ │ │ └── components/ # Additional component tests
│ │ ├── App.tsx # Root component
│ │ └── main.tsx # React entry point
│ ├── playwright/
│ │ └── e2e/
│ │ ├── home.spec.ts # E2E test for homepage
│ │ └── api.spec.ts # E2E test for API interactions
│ ├── .gitignore
│ ├── Dockerfile
│ ├── docker-compose.yml # Frontend service config
│ ├── docker-compose.yml # Frontend service config
│ ├── package.json
│ ├── tsconfig.json
│ ├── vite.config.ts
│ └── README.md # Setup and API documentation
├── backend/ # Backend from M2
│ └── README.md # Setup and API documentation
├── backend/ # Backend from M2
├── LICENSE # MIT License
├── README.md # Main project docs
└── docker-compose.yml # Full application orchestration
├── README.md # Main project docs
└── docker-compose.yml # Full application orchestration
```
### TypeScript Type Definitions
@@ -211,7 +244,9 @@ export const apiClient = {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint src/"
"lint": "eslint src/",
"test": "vitest",
"e2e": "playwright test"
}
}
```
@@ -283,35 +318,43 @@ services:
## QA Notes
### Testing Checklist
- [ ] npm install completes without errors
- [ ] npm run dev starts Vite dev server successfully
- [ ] npm run build creates dist/ folder with all assets
- [ ] TypeScript compilation passes (no errors)
- [ ] ESLint check passes on codebase
- [ ] Components render correctly in browser
### Unit Testing Checklist (Vitest + React Testing Library)
- [ ] Tests discover and run correctly with `npm test`
- [ ] Header component renders with correct structure
- [ ] Home page loads without TypeScript errors
- [ ] API client returns properly typed responses
- [ ] Docker image builds without warnings
- [ ] Frontend container serves index.html at root
- [ ] nginx configuration routes requests to React SPA
- [ ] Component props are type-safe
- [ ] Test coverage >50% on tested components
### E2E Testing Checklist (Playwright)
- [ ] Playwright configured in playwright.config.ts
- [ ] Tests discover and run with `npm run e2e`
- [ ] Home page accessibility verified (a11y checks pass)
- [ ] Article list renders with sample data
- [ ] API requests complete successfully via browser
- [ ] Browser console has no errors during E2E tests
- [ ] Tests use proper selectors and wait conditions
### Performance Considerations
- Vite uses ESBuild for fast HMR during development
- TypeScript checks on build, not incremental dev
- Nginx serves static files efficiently in production
- Multi-stage Docker builds reduce image size
- Playwright tests run in headless mode for faster execution
### Security Notes
- No sensitive data in client-side code
- API credentials should use backend proxy (not direct fetch)
- CORS must be configured on backend to accept frontend origin
- CSRF protection TBD for future milestones
- Playwright test artifacts (.vscode, traces) excluded from git
### Known Issues / Limitations
- No authentication flow implemented yet
- Static file serving requires nginx restart on rebuild
- Vite HMR doesn't work in Docker without hot-reload support
- TypeScript path aliases not configured (using relative imports)
- Playwright E2E tests may fail when backend service not available
### Success Metrics
- `npm run dev` starts within 30 seconds
@@ -320,3 +363,6 @@ services:
- Docker frontend image size <200MB
- All ESLint rules pass with zero warnings in critical code
- Browser console has no errors on page load
- Unit tests achieve >=50% coverage on components
- E2E tests complete in under 1 minute for core flows
- Playwright traces and video artifacts excluded from version control