Merge pull request #970 from othrayte/improve-e2e-test-reliability

website: Improve reliability of e2e tests
This commit is contained in:
AbdBarho
2023-01-29 09:18:35 +01:00
committed by GitHub
13 changed files with 174 additions and 115 deletions
@@ -1,4 +1,6 @@
import { withoutRole } from "src/lib/auth";
import { ERROR_CODES } from "src/lib/constants";
import { OasstError } from "src/lib/oasst_api_client";
import { createApiClientFromUser } from "src/lib/oasst_client_factory";
import prisma from "src/lib/prismadb";
import { getBackendUserCore, getUserLanguage } from "src/lib/users";
@@ -22,8 +24,12 @@ const handler = withoutRole("banned", async (req, res, token) => {
try {
task = await oasstApiClient.fetchTask(task_type as string, user, userLanguage);
} catch (err) {
console.error(err);
res.status(500).json(err);
if (err instanceof OasstError && err.errorCode === ERROR_CODES.TASK_REQUESTED_TYPE_NOT_AVAILABLE) {
res.status(503).json({});
} else {
console.error(err);
res.status(500).json(err);
}
return;
}