fix: Allow user to remove team logo (#7095)
This commit is contained in:
@@ -104,7 +104,7 @@ function Details() {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleAvatarChange = async (avatarUrl: string) => {
|
const handleAvatarChange = async (avatarUrl: string | null) => {
|
||||||
await team.save({ avatarUrl });
|
await team.save({ avatarUrl });
|
||||||
toast.success(t("Logo updated"));
|
toast.success(t("Logo updated"));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export const TeamsUpdateSchema = BaseSchema.extend({
|
|||||||
/** Team name */
|
/** Team name */
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
/** Avatar URL */
|
/** Avatar URL */
|
||||||
avatarUrl: z.string().optional(),
|
avatarUrl: z.string().nullish(),
|
||||||
/** The subdomain to access the team */
|
/** The subdomain to access the team */
|
||||||
subdomain: z.string().nullish(),
|
subdomain: z.string().nullish(),
|
||||||
/** Whether public sharing is enabled */
|
/** Whether public sharing is enabled */
|
||||||
|
|||||||
@@ -56,6 +56,34 @@ describe("#team.update", () => {
|
|||||||
expect(body.data.name).toEqual(name);
|
expect(body.data.name).toEqual(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should add avatar", async () => {
|
||||||
|
const team = await buildTeam();
|
||||||
|
const admin = await buildAdmin({ teamId: team.id });
|
||||||
|
const res = await server.post("/api/team.update", {
|
||||||
|
body: {
|
||||||
|
token: admin.getJwtToken(),
|
||||||
|
avatarUrl: "https://random-url.com",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.avatarUrl).toEqual("https://random-url.com");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should remove avatar", async () => {
|
||||||
|
const team = await buildTeam({ avatarUrl: "https://random-url.com" });
|
||||||
|
const admin = await buildAdmin({ teamId: team.id });
|
||||||
|
const res = await server.post("/api/team.update", {
|
||||||
|
body: {
|
||||||
|
token: admin.getJwtToken(),
|
||||||
|
avatarUrl: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.avatarUrl).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it("should not invalidate request if subdomain is sent as null", async () => {
|
it("should not invalidate request if subdomain is sent as null", async () => {
|
||||||
const admin = await buildAdmin();
|
const admin = await buildAdmin();
|
||||||
const res = await server.post("/api/team.update", {
|
const res = await server.post("/api/team.update", {
|
||||||
|
|||||||
Reference in New Issue
Block a user