Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): Fix broken integration test that never fails in CI #3115

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 0 additions & 193 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions packages/server/lib/controllers/connect/postSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const postConnectSessions = asyncWrapper<PostConnectSessions>(async (req,

const { account, environment } = res.locals;

await db.knex.transaction(async (trx) => {
const { status, body } = await db.knex.transaction(async (trx) => {
// Check if the endUser exists in the database
const getEndUser = await endUserService.getEndUser(trx, {
endUserId: req.body.end_user.id,
Expand All @@ -67,8 +67,7 @@ export const postConnectSessions = asyncWrapper<PostConnectSessions>(async (req,
let endUserInternalId: number;
if (getEndUser.isErr()) {
if (getEndUser.error.code !== 'not_found') {
res.status(500).send({ error: { code: 'server_error', message: 'Failed to get end user' } });
return;
return { status: 500, data: { error: { code: 'server_error', message: 'Failed to get end user' } } };
}
// create end user if it doesn't exist yet
const createEndUser = await endUserService.createEndUser(trx, {
Expand All @@ -85,8 +84,7 @@ export const postConnectSessions = asyncWrapper<PostConnectSessions>(async (req,
environmentId: environment.id
});
if (createEndUser.isErr()) {
res.status(500).send({ error: { code: 'server_error', message: 'Failed to create end user' } });
return;
return { status: 500, data: { error: { code: 'server_error', message: 'Failed to create end user' } } };
}
endUserInternalId = createEndUser.value.id;
} else {
Expand All @@ -110,8 +108,7 @@ export const postConnectSessions = asyncWrapper<PostConnectSessions>(async (req,
: null
});
if (updateEndUser.isErr()) {
res.status(500).send({ error: { code: 'server_error', message: 'Failed to update end user' } });
return;
return { status: 500, data: { error: { code: 'server_error', message: 'Failed to update end user' } } };
}
}
endUserInternalId = getEndUser.value.id;
Expand All @@ -133,8 +130,7 @@ export const postConnectSessions = asyncWrapper<PostConnectSessions>(async (req,
: null
});
if (createConnectSession.isErr()) {
res.status(500).send({ error: { code: 'server_error', message: 'Failed to create connect session' } });
return;
return { status: 500, data: { error: { code: 'server_error', message: 'Failed to create connect session' } } };
}
// create a private key for the connect session
const createPrivateKey = await keystore.createPrivateKey(trx, {
Expand All @@ -146,11 +142,11 @@ export const postConnectSessions = asyncWrapper<PostConnectSessions>(async (req,
ttlInMs: 30 * 60 * 1000 // 30 minutes
});
if (createPrivateKey.isErr()) {
res.status(500).send({ error: { code: 'server_error', message: 'Failed to create session token' } });
return;
return { status: 500, data: { error: { code: 'server_error', message: 'Failed to create session token' } } };
}
const [token, privateKey] = createPrivateKey.value;
res.status(201).send({ data: { token, expires_at: privateKey.expiresAt! } });
return;
return { status: 201, body: { data: { token, expires_at: privateKey.expiresAt! } } };
});

res.status(status).send(body);
});
Loading