Spaces:
Paused
Paused
fix(test): correct retry logic in frontend test and add postgres service to ci
Browse files
.github/workflows/ci.yml
CHANGED
|
@@ -13,6 +13,22 @@ jobs:
|
|
| 13 |
test:
|
| 14 |
name: Test & Lint
|
| 15 |
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
permissions:
|
| 17 |
contents: read
|
| 18 |
|
|
|
|
| 13 |
test:
|
| 14 |
name: Test & Lint
|
| 15 |
runs-on: ubuntu-latest
|
| 16 |
+
env:
|
| 17 |
+
DATABASE_URL: "postgresql://postgres:password@localhost:5432/widgetdc_test"
|
| 18 |
+
services:
|
| 19 |
+
postgres:
|
| 20 |
+
image: pgvector/pgvector:pg16
|
| 21 |
+
env:
|
| 22 |
+
POSTGRES_USER: postgres
|
| 23 |
+
POSTGRES_PASSWORD: password
|
| 24 |
+
POSTGRES_DB: widgetdc_test
|
| 25 |
+
ports:
|
| 26 |
+
- 5432:5432
|
| 27 |
+
options: >-
|
| 28 |
+
--health-cmd pg_isready
|
| 29 |
+
--health-interval 10s
|
| 30 |
+
--health-timeout 5s
|
| 31 |
+
--health-retries 5
|
| 32 |
permissions:
|
| 33 |
contents: read
|
| 34 |
|
apps/matrix-frontend/src/services/UnifiedDataService.test.ts
CHANGED
|
@@ -226,11 +226,16 @@ describe('UnifiedDataService - Retry Logic', () => {
|
|
| 226 |
|
| 227 |
const fetchWithRetry = async () => {
|
| 228 |
while (attempts < maxRetries) {
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
}
|
| 233 |
-
return { success: true };
|
| 234 |
}
|
| 235 |
throw new Error('Max retries exceeded');
|
| 236 |
};
|
|
|
|
| 226 |
|
| 227 |
const fetchWithRetry = async () => {
|
| 228 |
while (attempts < maxRetries) {
|
| 229 |
+
try {
|
| 230 |
+
attempts++;
|
| 231 |
+
if (attempts < 3) {
|
| 232 |
+
throw new Error('Network error');
|
| 233 |
+
}
|
| 234 |
+
return { success: true };
|
| 235 |
+
} catch (error: any) {
|
| 236 |
+
if (attempts >= maxRetries) throw error;
|
| 237 |
+
// continue to next attempt
|
| 238 |
}
|
|
|
|
| 239 |
}
|
| 240 |
throw new Error('Max retries exceeded');
|
| 241 |
};
|