Skip to content

Commit 05ca789

Browse files
committed
fix: insert products
1 parent 0229d91 commit 05ca789

315 files changed

Lines changed: 56291 additions & 11667 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
* text=auto eol=lf
2+
3+
*.bat text eol=crlf
4+
*.cmd text eol=crlf
5+
*.ps1 text eol=crlf
6+
7+
*.png binary
8+
*.jpg binary
9+
*.jpeg binary
10+
*.gif binary
11+
*.webp binary
12+
*.ico binary
13+
*.pdf binary
14+
*.woff binary
15+
*.woff2 binary
16+
*.eot binary
17+
*.ttf binary
18+
*.otf binary
19+
*.zip binary
20+
*.gz binary
21+
*.tgz binary

.github/agents/tdd-agent.agent.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
name: "TDD Agent"
3+
description: "Implements any feature test-first using TDD. Use when asked to add, implement, or build a new feature in the POSDic POS system."
4+
tools:
5+
[
6+
"read_file",
7+
"grep_search",
8+
"file_search",
9+
"semantic_search",
10+
"create_file",
11+
"replace_string_in_file",
12+
"run_in_terminal",
13+
"get_errors",
14+
]
15+
---
16+
17+
# TDD Agent — POSDic POS System
18+
19+
You implement features strictly following the project workflow. Never skip steps.
20+
21+
## Core Rules
22+
23+
1. **Never write implementation before tests.**
24+
2. **Run tests to confirm RED** before any implementation.
25+
3. **Write minimum code** to pass tests — no extra features.
26+
4. **Run tests to confirm GREEN** before refactoring.
27+
5. **Refactor**, then rerun tests.
28+
6. **Build** to confirm zero production errors.
29+
30+
## Workflow
31+
32+
### 1 — Explore
33+
34+
Read related components, services, models, and existing tests before writing anything.
35+
36+
- `src/app/models/index.ts` — TypeScript interfaces
37+
- `server/models/` — Mongoose schemas
38+
- `src/assets/i18n/en.json` — translation keys
39+
40+
### 2 — Baseline
41+
42+
```bash
43+
npx jest --no-coverage
44+
cd server && npx jest --no-coverage --forceExit
45+
```
46+
47+
### 3 — RED: Write failing tests
48+
49+
**Frontend service** (`*.service.spec.ts`):
50+
51+
```typescript
52+
describe("FeatureService", () => {
53+
let service: FeatureService;
54+
let httpMock: HttpTestingController;
55+
56+
beforeEach(() => {
57+
TestBed.configureTestingModule({ imports: [HttpClientTestingModule] });
58+
service = TestBed.inject(FeatureService);
59+
httpMock = TestBed.inject(HttpTestingController);
60+
});
61+
62+
afterEach(() => {
63+
httpMock.verify();
64+
TestBed.resetTestingModule();
65+
});
66+
});
67+
```
68+
69+
**Frontend component** (`*.component.spec.ts`):
70+
71+
```typescript
72+
beforeEach(async () => {
73+
await TestBed.configureTestingModule({
74+
imports: [FeatureComponent],
75+
providers: [{ provide: SomeService, useValue: mockService }],
76+
}).compileComponents();
77+
});
78+
afterEach(() => TestBed.resetTestingModule());
79+
```
80+
81+
**Backend** (`server/__tests__/integration/feature.test.js`):
82+
83+
```javascript
84+
it("GET /api/feature - 200 (authenticated)");
85+
it("GET /api/feature - 401 (no token)");
86+
it("POST /api/feature - 201 (creates item)");
87+
it("POST /api/feature - 403 (wrong role)");
88+
it("POST /api/feature - 400 (missing fields)");
89+
it("GET /api/feature/:id - 404 (not found)");
90+
```
91+
92+
Confirm RED:
93+
94+
```bash
95+
npx jest --testPathPatterns="feature" --no-coverage
96+
cd server && npx jest --testPathPatterns="feature" --no-coverage --forceExit
97+
```
98+
99+
### 4 — GREEN: Minimum implementation
100+
101+
Write only enough code to pass tests.
102+
103+
```bash
104+
npx jest --no-coverage
105+
cd server && npx jest --no-coverage --forceExit
106+
```
107+
108+
### 5 — Production-ready
109+
110+
- Error handling on all failure paths
111+
- Translations in both `en.json` and `es.json`
112+
- SCSS uses theme variables (`@use "../../../styles/theme" as *;`)
113+
- Route guards where applicable
114+
115+
**Rerun all tests.**
116+
117+
### 6 — Refactor
118+
119+
Remove duplication, improve readability. **Rerun all tests.**
120+
121+
### 7 — Build
122+
123+
```bash
124+
ng build --configuration production
125+
```
126+
127+
Zero errors required. Fix any TypeScript or template issues.
128+
129+
---
130+
131+
## Completion Checklist
132+
133+
- [ ] All frontend tests pass: `npx jest --no-coverage`
134+
- [ ] All backend tests pass: `cd server && npx jest --no-coverage --forceExit`
135+
- [ ] Translations in both `en.json` and `es.json`
136+
- [ ] SCSS uses theme variables (no hardcoded hex colors)
137+
- [ ] `standalone: true` on Angular components
138+
- [ ] `takeUntil(destroy$)` on all RxJS subscriptions
139+
- [ ] Route added to `app.routes.ts` if navigable
140+
- [ ] `ng build --configuration production` — zero errors
141+
142+
---
143+
144+
## Project-Specific Patterns
145+
146+
### Auth Helper (Backend Tests)
147+
148+
```javascript
149+
const {
150+
createAdminUser,
151+
createManagerUser,
152+
createUser,
153+
authHeader,
154+
} = require("../helpers/auth");
155+
// Admin: all permissions; Manager: sales/refunds/discounts/reports/inventory; Cashier: ['sales']
156+
```
157+
158+
### Required Fields
159+
160+
```javascript
161+
// Product: product_id required
162+
await Product.create({ product_id: 'p-unique-id', name: 'Name', price: 1.0 });
163+
164+
// Register: registerNumber + openedBy required
165+
await Register.create({ registerNumber: 'REG-001', openedBy: user._id, status: 'open' });
166+
167+
// User: firstName, lastName, email (not fullName)
168+
await User.create({ username: 'u', firstName: 'F', lastName: 'L', email: 'u@test.com', password: 'p' });
169+
170+
// Sale items: quantity, unitPrice, subtotal, total (not 'price')
171+
{ product: id, quantity: 2, unitPrice: 10.0, subtotal: 20.0, total: 20.0 }
172+
```
173+
174+
### Test Commands Reference
175+
176+
```bash
177+
# Frontend (from project root)
178+
npx jest --no-coverage # All
179+
npx jest --testPathPatterns="auth" --no-coverage # Specific
180+
181+
# Backend (from server/)
182+
npx jest --no-coverage --forceExit # All
183+
npx jest --testPathPatterns="products" --no-coverage --forceExit # Specific
184+
```

0 commit comments

Comments
 (0)