feat(interests): wire yachtId, enforce ownership + stage-gate
- Add yachtId (optional) to createInterestSchema + listInterestsSchema (updateInterestSchema inherits it via partial() automatically). - Add assertYachtBelongsToClient helper that accepts direct client ownership OR company-represented clients with an active membership in the owning company. - createInterest + updateInterest validate yacht ownership whenever yachtId is supplied/changed. - changeInterestStage rejects moving out of stage=open with yachtId null (ValidationError). - listInterests filter supports yachtId. - Integration tests cover all 7 paths; validator test for yachtId. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -131,6 +131,14 @@ describe('createInterestSchema', () => {
|
||||
const result = createInterestSchema.safeParse({ clientId: 'c1', reminderDays: 0 });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('createInterestSchema accepts yachtId', () => {
|
||||
const result = createInterestSchema.safeParse({
|
||||
clientId: 'c1',
|
||||
yachtId: 'y1',
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('changeStageSchema', () => {
|
||||
|
||||
Reference in New Issue
Block a user