From 3d6a875631090904cbeb8967cd3c4b4b72f87460 Mon Sep 17 00:00:00 2001 From: Apoorv Mishra Date: Tue, 2 May 2023 18:19:08 +0530 Subject: [PATCH] fix: allow null for subdomain (#5289) --- server/routes/api/teams/schema.ts | 2 +- server/routes/api/teams/teams.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/routes/api/teams/schema.ts b/server/routes/api/teams/schema.ts index 8c70cf797..20758f43f 100644 --- a/server/routes/api/teams/schema.ts +++ b/server/routes/api/teams/schema.ts @@ -9,7 +9,7 @@ export const TeamsUpdateSchema = BaseSchema.extend({ /** Avatar URL */ avatarUrl: z.string().optional(), /** The subdomain to access the team */ - subdomain: z.string().optional(), + subdomain: z.string().nullish(), /** Whether public sharing is enabled */ sharing: z.boolean().optional(), /** Whether siginin with email is enabled */ diff --git a/server/routes/api/teams/teams.test.ts b/server/routes/api/teams/teams.test.ts index 9de935e24..668e62f87 100644 --- a/server/routes/api/teams/teams.test.ts +++ b/server/routes/api/teams/teams.test.ts @@ -50,6 +50,17 @@ describe("#team.update", () => { expect(body.data.name).toEqual("New name"); }); + it("should not invalidate request if subdomain is sent as null", async () => { + const admin = await buildAdmin(); + const res = await server.post("/api/team.update", { + body: { + token: admin.getJwtToken(), + subdomain: null, + }, + }); + expect(res.status).not.toBe(400); + }); + it("should add new allowed Domains, removing empty string values", async () => { const { admin, team } = await seed(); const res = await server.post("/api/team.update", {