Skip to content

Commit 06668fd

Browse files
committed
Fix external DB sync tests
1 parent cbe7611 commit 06668fd

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-advanced.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ async function runQueryForCurrentProject(body: { query: string, params?: Record<
3030
}
3131

3232
async function waitForClickhouseUser(email: string, expectedDisplayName: string) {
33+
// ensure we definitely have project keys that don't expire (unlike an admin access token)
34+
await InternalApiKey.createAndSetProjectKeys();
35+
3336
const timeoutMs = 180_000;
3437
const intervalMs = 2_000;
3538
const start = performance.now();
@@ -42,8 +45,7 @@ async function waitForClickhouseUser(email: string, expectedDisplayName: string)
4245
expect(response).toMatchObject({
4346
status: 200,
4447
});
45-
if (response.body.result.length === 1) {
46-
expect(response.body.result[0].display_name).toBe(expectedDisplayName);
48+
if (response.body.result.length === 1 && response.body.result[0].display_name === expectedDisplayName) {
4749
return response;
4850
}
4951
await wait(intervalMs);

apps/e2e/tests/backend/endpoints/api/v1/external-db-sync-basics.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors"
22
import { wait } from "@stackframe/stack-shared/dist/utils/promises";
33
import { afterAll, beforeAll, describe, expect } from 'vitest';
44
import { test } from '../../../../helpers';
5-
import { Project, User, niceBackendFetch } from '../../../backend-helpers';
5+
import { InternalApiKey, Project, User, niceBackendFetch } from '../../../backend-helpers';
66
import {
77
TEST_TIMEOUT,
88
TestDbManager,
@@ -23,6 +23,9 @@ async function runQueryForCurrentProject(body: { query: string, params?: Record<
2323
}
2424

2525
async function waitForClickhouseUser(email: string, expectedDisplayName: string) {
26+
// ensure we definitely have project keys that don't expire (unlike an admin access token)
27+
await InternalApiKey.createAndSetProjectKeys();
28+
2629
const timeoutMs = 180_000;
2730
const intervalMs = 2_000;
2831
const start = performance.now();
@@ -34,11 +37,8 @@ async function waitForClickhouseUser(email: string, expectedDisplayName: string)
3437
email,
3538
},
3639
});
37-
expect(response).toMatchObject({
38-
status: 200,
39-
});
40-
if (response.body.result.length === 1) {
41-
expect(response.body.result[0].display_name).toBe(expectedDisplayName);
40+
expect(response.status).toBe(200);
41+
if (response.body.result.length === 1 && response.body.result[0].display_name === expectedDisplayName) {
4242
return response;
4343
}
4444
await wait(intervalMs);

0 commit comments

Comments
 (0)