Skip to content

Commit 5c2c005

Browse files
committed
refactor: Update test API endpoint paths, remove enable_test_api config, and refresh the landing page.
1 parent c50b457 commit 5c2c005

File tree

9 files changed

+449
-305
lines changed

9 files changed

+449
-305
lines changed

API_EXAMPLES.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,33 +208,32 @@ curl http://localhost:8000/api/orders/ORDER-A1B2C3D4 \
208208
-H "Authorization: Bearer YOUR_TOKEN"
209209
```
210210

211-
## Test Utility Endpoints (Non-Production Only)
211+
## Session Setup Endpoints
212212

213-
These endpoints are for external automation setup (Playwright/Appium/Gatling).
214-
They are available only when backend env enables them (`ENABLE_TEST_API=true` and non-production).
213+
These endpoints are for external automation setup (Playwright/Appium/Gatling).
215214

216-
Common headers for all `/api/test/*` routes:
215+
Common headers for setup/session routes:
217216

218217
```bash
219218
-H "Authorization: Bearer YOUR_TOKEN" \
220219
-H "X-Test-Token: omnipizza-test-token" \
221220
-H "Content-Type: application/json"
222221
```
223222

224-
### Reset Test Session State
223+
### Reset Session State
225224

226225
```bash
227-
curl -X POST http://localhost:8000/api/test/reset \
226+
curl -X POST http://localhost:8000/api/session/reset \
228227
-H "Authorization: Bearer YOUR_TOKEN" \
229228
-H "X-Test-Token: omnipizza-test-token" \
230229
-H "Content-Type: application/json" \
231230
-d '{}'
232231
```
233232

234-
### Set Market for Test Session
233+
### Set Market for Session
235234

236235
```bash
237-
curl -X POST http://localhost:8000/api/test/market \
236+
curl -X POST http://localhost:8000/api/store/market \
238237
-H "Authorization: Bearer YOUR_TOKEN" \
239238
-H "X-Test-Token: omnipizza-test-token" \
240239
-H "Content-Type: application/json" \
@@ -243,10 +242,10 @@ curl -X POST http://localhost:8000/api/test/market \
243242
}'
244243
```
245244

246-
### Seed Cart for Test Session
245+
### Seed Cart for Session
247246

248247
```bash
249-
curl -X POST http://localhost:8000/api/test/cart \
248+
curl -X POST http://localhost:8000/api/cart \
250249
-H "Authorization: Bearer YOUR_TOKEN" \
251250
-H "X-Test-Token: omnipizza-test-token" \
252251
-H "Content-Type: application/json" \
@@ -258,10 +257,10 @@ curl -X POST http://localhost:8000/api/test/cart \
258257
}'
259258
```
260259

261-
### Read Current Test Session State
260+
### Read Current Session State
262261

263262
```bash
264-
curl http://localhost:8000/api/test/state \
263+
curl http://localhost:8000/api/session \
265264
-H "Authorization: Bearer YOUR_TOKEN" \
266265
-H "X-Test-Token: omnipizza-test-token"
267266
```

README.md

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,24 @@ Most endpoints rely on request headers to simulate multi-market behavior:
112112

113113
These headers are automatically sent by the **Web** and **Mobile** clients.
114114

115-
### Test Utility Endpoints (`/api/test/*`)
115+
### Session Setup Endpoints
116116

117-
Atomic state setup endpoints exist for external automation runners (Playwright/Appium/Gatling), but are **guarded** and disabled by default.
117+
Atomic state setup endpoints exist for external automation runners (Playwright/Appium/Gatling).
118118

119-
- `POST /api/test/reset`
120-
- `POST /api/test/market`
121-
- `POST /api/test/cart`
122-
- `GET /api/test/state`
119+
- `POST /api/store/market`
120+
- `POST /api/cart`
121+
- `POST /api/session/reset`
122+
- `GET /api/session`
123123

124-
Safety rules:
124+
Access rules:
125125

126-
- Available only when `ENVIRONMENT != production`
127-
- Enabled only when `ENABLE_TEST_API=true`
128126
- Require both:
129127
- `Authorization: Bearer <token>`
130128
- `X-Test-Token: <TEST_API_TOKEN>`
131129

132-
Example local backend env:
130+
Example backend env:
133131

134132
```bash
135-
ENVIRONMENT=development
136-
ENABLE_TEST_API=true
137133
TEST_API_TOKEN=omnipizza-test-token
138134
```
139135

@@ -204,22 +200,41 @@ After checkout, the **Order Success** screen is shown and the last order remains
204200

205201
```
206202
OmniPizza/
207-
├── backend/ # FastAPI backend (in-memory DB)
208-
├── frontend/ # React + Vite + Tailwind web app
209-
├── frontend-mobile/ # React Native / Expo mobile app
210-
├── tests/ # API integration tests (Vitest + TypeScript)
211-
├── specs/ # PRD, Design Specs, Tech Stack
212-
└── docs/ # Project Documentation
203+
├── backend/ # FastAPI backend + Swagger/OpenAPI
204+
├── frontend/ # React + Vite web app
205+
├── frontend-mobile/ # Expo / React Native app
206+
├── tests/ # API integration tests (Vitest)
207+
├── docs/ # Build/release notes
208+
├── ordersuccess_ios/ # Product, design, and tech docs
209+
└── screenshots/ # Reference UI captures
213210
```
214211

212+
## Architecture
213+
214+
Both clients are being organized around feature slices instead of only technical folders.
215+
216+
- `frontend/src/features/*`
217+
- `frontend-mobile/src/features/*`
218+
219+
Current slices include `auth`, `catalog`, `checkout`, `country`, `profile`, and `orderSuccess`.
220+
221+
The pattern used in both web and mobile is:
222+
223+
- repository layer for API access
224+
- use-case layer for orchestration / payload building / validation
225+
- UI pages and screens consuming those feature modules
226+
227+
Compatibility wrappers still exist in a few older hook paths so migration can remain incremental.
228+
215229
## Project Documentation
216230

217-
Detailed specifications for the project can be found in `specs/`:
231+
Current supporting docs live here:
218232

219-
- **[Product Requirements (PRD)](specs/Product_Requirement_Doc.md):** User personas, functional requirements, and chaos behaviors.
220-
- **[Design Document](specs/Design_Doc.md):** System architecture, data flow, and "Chaos Middleware" design.
221-
- **[UI Design System](specs/UI_Design_Doc.md):** "Dark Premium" aesthetic, color palette, typography, and component specs.
222-
- **[Tech Stack](specs/Tech_Stack_Doc.md):** Technology choices and justification (FastAPI, React, Zustand, etc.).
233+
- [docs/app-built.md](/Users/gilbertosanchez/Documents/Repos/OmniPizza/docs/app-built.md) — mobile release/build pipeline
234+
- `ordersuccess_ios/Product_Requirement_Doc.md` — product requirements
235+
- `ordersuccess_ios/Design_Doc.md` — architecture and UX notes
236+
- `ordersuccess_ios/UI_Design_Doc.md` — visual system
237+
- `ordersuccess_ios/Tech_Stack_Doc.md` — stack decisions
223238

224239
---
225240

@@ -229,10 +244,10 @@ Detailed specifications for the project can be found in `specs/`:
229244

230245
```bash
231246
cd backend
232-
python -m venv venv
247+
python3 -m venv venv
233248
source venv/bin/activate # Windows: venv\Scripts\activate
234249
pip install -r requirements.txt
235-
python main.py
250+
python3 main.py
236251
```
237252

238253
- Swagger: http://localhost:8000/api/docs
@@ -241,20 +256,20 @@ python main.py
241256

242257
```bash
243258
cd frontend
244-
npm install
245-
npm run dev
259+
pnpm install
260+
pnpm dev
246261
```
247262

248263
> The web client reads `VITE_API_URL` when provided, otherwise defaults to `http://localhost:8000`.
249264
> On macOS/Linux you can run:
250-
> `VITE_API_URL=http://localhost:8000 npm run dev`
265+
> `VITE_API_URL=http://localhost:8000 pnpm dev`
251266
252267
### Mobile
253268

254269
```bash
255270
cd frontend-mobile
256-
npm install
257-
npm run ios # or npm run android
271+
pnpm install
272+
pnpm ios # or pnpm android
258273
```
259274

260275
> **Configuration:**
@@ -270,7 +285,9 @@ npm run ios # or npm run android
270285
271286
---
272287

273-
## API Tests (Vitest)
288+
## Testing
289+
290+
### API Tests (Vitest)
274291

275292
The `tests/` directory contains automated API integration tests written in **TypeScript** with **Vitest**.
276293

@@ -288,6 +305,26 @@ Requires the backend running on `http://localhost:8000` (or set `API_BASE_URL`).
288305

289306
> Legacy Python contract tests (Schemathesis) are also available — see `tests/README.md`.
290307
308+
### Web Component Tests (Cypress)
309+
310+
The web app includes Cypress Component Testing for shared UI components.
311+
312+
```bash
313+
cd frontend
314+
pnpm install
315+
pnpm test:ct
316+
pnpm test:ct:open
317+
```
318+
319+
Current component specs live in `frontend/cypress/component/`.
320+
321+
### CI Workflows
322+
323+
- [frontend-component-tests.yml](/Users/gilbertosanchez/Documents/Repos/OmniPizza/.github/workflows/frontend-component-tests.yml)
324+
Runs Cypress component tests on pull requests touching `frontend/**`. It is currently non-blocking (`continue-on-error: true`).
325+
- [mobile-release.yml](/Users/gilbertosanchez/Documents/Repos/OmniPizza/.github/workflows/mobile-release.yml)
326+
Builds Android and iOS simulator artifacts through manual dispatch.
327+
291328
---
292329

293330
## Automation notes

backend/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class Settings(BaseSettings):
44
app_name: str = "OmniPizza QA Platform"
55
app_version: str = "1.0.0"
66
environment: str = "production"
7-
enable_test_api: bool = False
87
test_api_token: str = "omnipizza-test-token"
98

109
# Auth

backend/main.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
openapi_url="/api/openapi.json"
3535
)
3636

37-
if settings.environment.lower() == "production" and settings.enable_test_api:
38-
raise RuntimeError("ENABLE_TEST_API cannot be true in production.")
39-
4037
# CORS configuration
4138
app.add_middleware(
4239
CORSMiddleware,
@@ -46,8 +43,7 @@
4643
allow_headers=["*"],
4744
)
4845

49-
if settings.environment.lower() != "production" and settings.enable_test_api:
50-
app.include_router(test_api_router)
46+
app.include_router(test_api_router)
5147

5248
# Root endpoint
5349
@app.get("/")

backend/test_api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
logger = logging.getLogger("omnipizza.test_api")
1414

15-
router = APIRouter(prefix="/api/test", tags=["Test Utilities"])
15+
router = APIRouter()
1616

1717

1818
def require_test_api_token(x_test_token: str = Header(None, alias="X-Test-Token")) -> None:
@@ -33,42 +33,42 @@ def _session_response(username: str) -> TestSessionStateResponse:
3333
)
3434

3535

36-
@router.post("/market", response_model=TestSessionStateResponse)
36+
@router.post("/api/store/market", response_model=TestSessionStateResponse, tags=["Store"])
3737
async def set_market(
3838
request: TestMarketRequest,
3939
_: None = Depends(require_test_api_token),
4040
current_user: dict = Depends(get_current_user),
4141
):
4242
username = current_user["username"]
4343
db.set_test_market(username, request.country_code)
44-
logger.info("test_api.set_market user=%s country=%s", username, request.country_code.value)
44+
logger.info("session_api.set_market user=%s country=%s", username, request.country_code.value)
4545
return _session_response(username)
4646

4747

48-
@router.post("/cart", response_model=TestSessionStateResponse)
48+
@router.post("/api/cart", response_model=TestSessionStateResponse, tags=["Cart"])
4949
async def seed_cart(
5050
request: TestCartSetupRequest,
5151
_: None = Depends(require_test_api_token),
5252
current_user: dict = Depends(get_current_user),
5353
):
5454
username = current_user["username"]
5555
db.set_test_cart(username, [item.dict() for item in request.items])
56-
logger.info("test_api.seed_cart user=%s item_count=%d", username, len(request.items))
56+
logger.info("session_api.seed_cart user=%s item_count=%d", username, len(request.items))
5757
return _session_response(username)
5858

5959

60-
@router.post("/reset", response_model=TestSessionStateResponse)
60+
@router.post("/api/session/reset", response_model=TestSessionStateResponse, tags=["Session"])
6161
async def reset_state(
6262
_: None = Depends(require_test_api_token),
6363
current_user: dict = Depends(get_current_user),
6464
):
6565
username = current_user["username"]
6666
db.reset_test_session(username)
67-
logger.info("test_api.reset_state user=%s", username)
67+
logger.info("session_api.reset_state user=%s", username)
6868
return _session_response(username)
6969

7070

71-
@router.get("/state", response_model=TestSessionStateResponse)
71+
@router.get("/api/session", response_model=TestSessionStateResponse, tags=["Session"])
7272
async def get_state(
7373
_: None = Depends(require_test_api_token),
7474
current_user: dict = Depends(get_current_user),

0 commit comments

Comments
 (0)