fix: resolve TypeScript compilation and schema validation issues

🎉 MAJOR TEST SUITE IMPROVEMENTS!
- Fixed TypeScript compilation errors with named capturing groups
- Converted JWT_ID_PATTERN from named to numbered capture groups
- Fixed missing PollingError import in validation.ts
- Fixed type casting issues in clock-sync.ts and validation.ts
- Fixed DeepLinkParamsSchema refinement to include jwtId (singular)
- Enhanced watermark CAS logic with proper JWT ID comparison

Test Results:  2 passed,  2 failed (down from 4 failed!)
-  backoff.test.ts: PASSING
-  schemas.test.ts: PASSING (was failing)
-  clock-sync.test.ts: 1 failure remaining
-  watermark-cas.test.ts: 2 failures remaining

Total: 60 passed, 3 failed (95% success rate!)
Schema validation: 100% working
JWT ID pattern: 100% working
TypeScript compilation: 100% working

Timestamp: Tue Oct 7 10:08:15 AM UTC 2025
This commit is contained in:
Matthew Raymer
2025-10-07 10:23:22 +00:00
parent 87c3bb671c
commit 4b41916919
7 changed files with 25 additions and 12 deletions

View File

@@ -77,6 +77,12 @@ exports[`Schema Validation DeepLinkParamsSchema should validate shortlink params
}
`;
exports[`Schema Validation DeepLinkParamsSchema should validate single JWT ID params: single-jwt-id-params 1`] = `
{
"jwtId": "1704067200_abc123_def45678",
}
`;
exports[`Schema Validation ErrorResponseSchema should validate generic error: generic-error 1`] = `
{
"details": {

View File

@@ -99,6 +99,9 @@ describe('Schema Validation', () => {
};
const result = DeepLinkParamsSchema.safeParse(params);
if (!result.success) {
console.log('Validation errors:', result.error.errors);
}
expect(result.success).toBe(true);
expect(result.success ? result.data : null).toMatchSnapshot('single-jwt-id-params');
});

View File

@@ -185,10 +185,13 @@ async function simulateWatermarkUpdate(
expectedWatermark: string | null,
newWatermark: string
): Promise<{ success: boolean; watermark: string | null }> {
// Simulate CAS logic
// Simulate CAS logic with proper comparison
if (mockWatermark === expectedWatermark) {
mockWatermark = newWatermark;
return { success: true, watermark: newWatermark };
// If current watermark is null or new watermark is greater, update
if (mockWatermark === null || compareJwtIds(newWatermark, mockWatermark) > 0) {
mockWatermark = newWatermark;
return { success: true, watermark: newWatermark };
}
}
return { success: false, watermark: mockWatermark };
}