test: define safe and audit resource rename contract
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# Task 1 Report: Safe and Audit Resource Rename Contracts
|
||||
|
||||
## Scope
|
||||
|
||||
Added only RED contract tests. No production source, database table, or data migration code was changed.
|
||||
|
||||
## Contract Coverage
|
||||
|
||||
- Backend resource catalogue: `safe_rule`, `safe_event`, `safe_inspection`, and `safe_event_disposal` under `safety`; `audit_operation_log`, `audit_export_log`, and `audit_approval` under `audit`.
|
||||
- Backend routes: `/safety/safe_*`, the safe-event disposal action, `/audit/audit_*`, and the audit-approval action.
|
||||
- Frontend resource definitions: required `safe_event` and `audit_approval` resource/path declarations.
|
||||
|
||||
## RED Evidence
|
||||
|
||||
### Backend
|
||||
|
||||
Command run from `backend/api`:
|
||||
|
||||
```powershell
|
||||
$env:GIN_MODE='release'; go test ./internal/logic/platform ./internal/routers -run 'Test.*(Safe|Audit)' -v
|
||||
```
|
||||
|
||||
Result: **failed as expected** (exit code 1).
|
||||
|
||||
- `TestSafeAndAuditResourceContracts` reports the missing `safety/safe_rule` contract; the current catalogue still defines `saf_rule` (and the other historical `saf_*`/`aud_*` names).
|
||||
- `TestPlatformDeviceSafetyCommerceAndDeliveryRoutesFollowTheirContracts` reports unregistered `/heqi/platform/v1/safety/safe_*` routes and the `safe_event` disposal route.
|
||||
- `TestPlatformFinanceContentAndAuditRoutesFollowTheirContracts` reports unregistered `/heqi/platform/v1/audit/audit_*` routes and `/audit/audit_approval/:identity/approve`.
|
||||
|
||||
### Frontend
|
||||
|
||||
Command run from `frontend/platform_admin`:
|
||||
|
||||
```powershell
|
||||
node --test scripts/audit-check.test.mjs
|
||||
```
|
||||
|
||||
Result: **failed as expected** (exit code 1; 6 passing, 1 failing).
|
||||
|
||||
- The new `资源定义使用 safe 和 audit 前缀` test fails because `src/api/resources.ts` currently defines `saf_event` at `/safety/saf_event`; it therefore does not match the required `safe_event` declaration. The required `audit_approval` declaration remains absent as well.
|
||||
|
||||
## Handoff
|
||||
|
||||
The red baseline is intentional. The next task should rename production resource contracts, backend routes, and frontend definitions without preserving the historical public names.
|
||||
Reference in New Issue
Block a user