Files
KArtSell.Aegis/frontend/src/features/sell-decision/tests/schema.spec.js
T
kjh2064 a3a844be76
ci / backend (push) Failing after 1s
Build & Test with Secrets / build (push) Failing after 1s
ci / static (push) Failing after 7s
Build & Test with Secrets / security-scan (push) Failing after 6s
ci / frontend (push) Failing after 1m15s
Build & Test with Secrets / frontend (push) Failing after 1m14s
Build & Test with Secrets / notification (push) Failing after 1s
Gate 5a: Fix Frontend UUID validation errors
Issue: Zod UUID schema enforces RFC 4122 v4 format strictly
- Version must be [1-8] (not 0)
- Variant must be [89abAB] (not 0)
Test data: '00000000-0000-0000-0000-000000000001' violates RFC 4122

Fix: Replace invalid UUIDs with RFC 4122 v4 compliant values
- Old: 00000000-0000-0000-0000-000000000001
- New: 550e8400-e29b-41d4-a716-446655440001

Files fixed:
- frontend/src/features/sell-decision/tests/schema.spec.ts
- frontend/src/features/sell-decision/tests/schema.spec.js
- frontend/src/features/data-quality/tests/schema.spec.ts
- frontend/src/features/data-quality/tests/schema.spec.js

Result:
 Unit Tests: 40/40 PASS (Vitest)
 TypeCheck: PASS (vue-tsc)
 Build: SUCCESS (1.66s, dist assembled)
⚠️  E2E: Playwright config issue (requires separate Playwright test runner)

AGENTS.md v16.0:
   Root cause fixed (RFC 4122 validation)
   Necessity: Frontend validation critical for Gate 5
   Right-way: Data validation corrected, not schema changed

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-03 16:03:02 +09:00

62 lines
2.2 KiB
JavaScript

import { describe, expect, it } from 'vitest';
import { researchSellPolicyRequestSchema, researchSellPolicyResponseSchema } from '../schema';
const baseRequest = {
positionLotId: '550e8400-e29b-41d4-a716-446655440001',
cycleId: '550e8400-e29b-41d4-a716-446655440002',
evidenceId: 'evidence-1',
datasetId: 'dataset-1',
modelVersion: 'model-1',
configVersion: 'config-1',
codeSha: 'sha-1',
asOf: '2026-08-01T07:00:00Z',
publishedAtCutoff: '2026-08-01T06:00:00Z',
currentSecurityPortfolioWeight: 0.6,
currentLotPortfolioWeight: 0.2,
strategicCoreFloorWeight: 0.3,
hardImpairmentApproved: false,
capitalFloorBreached: false,
survivalSellRatioOfLot: 0,
gapBelowFloorAtr: 0,
consecutiveCloseBreaches: 0,
cooldownSatisfied: true,
concentrationSellRatioOfLot: 0,
opportunityEdgeLowerBound: 0,
opportunitySellRatioOfLot: 0
};
describe('research sell policy contracts', () => {
it('accepts a valid point-in-time request', () => {
const result = researchSellPolicyRequestSchema.safeParse(baseRequest);
if (!result.success) {
console.error('Validation errors:', JSON.stringify(result.error.issues, null, 2));
}
expect(result.success).toBe(true);
});
it('rejects a lot weight above security weight', () => {
const result = researchSellPolicyRequestSchema.safeParse({
...baseRequest,
currentLotPortfolioWeight: 0.7
});
expect(result.success).toBe(false);
});
it('rejects a future published-at cutoff', () => {
const result = researchSellPolicyRequestSchema.safeParse({
...baseRequest,
publishedAtCutoff: '2026-08-01T08:00:00Z'
});
expect(result.success).toBe(false);
});
it('rejects an unknown production status', () => {
const result = researchSellPolicyResponseSchema.safeParse({
action: 'Hold',
sellRatioOfLot: 0,
targetSecurityPortfolioWeightAfter: 0.6,
policyId: 'ALG-HOLD-001',
reasonCode: 'NO_SELL_CONDITION',
reentryEligible: false,
policyTrace: [],
evidenceStatus: 'PRODUCTION'
});
expect(result.success).toBe(false);
});
});