Document emoji picker (#4338)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -2492,6 +2492,7 @@ describe("#documents.update", () => {
|
||||
const document = await buildDraftDocument({
|
||||
teamId: team.id,
|
||||
});
|
||||
|
||||
const res = await server.post("/api/documents.update", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
@@ -2503,6 +2504,7 @@ describe("#documents.update", () => {
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(400);
|
||||
|
||||
expect(body.message).toBe(
|
||||
"collectionId is required to publish a draft without collection"
|
||||
);
|
||||
@@ -2515,7 +2517,6 @@ describe("#documents.update", () => {
|
||||
text: "text",
|
||||
teamId: team.id,
|
||||
});
|
||||
|
||||
const res = await server.post("/api/documents.update", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
@@ -2551,6 +2552,36 @@ describe("#documents.update", () => {
|
||||
expect(res.status).toEqual(403);
|
||||
});
|
||||
|
||||
it("should fail to update an invalid emoji value", async () => {
|
||||
const { user, document } = await seed();
|
||||
|
||||
const res = await server.post("/api/documents.update", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
id: document.id,
|
||||
emoji: ":)",
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(400);
|
||||
|
||||
expect(body.message).toBe("emoji: Invalid");
|
||||
});
|
||||
|
||||
it("should successfully update the emoji", async () => {
|
||||
const { user, document } = await seed();
|
||||
const res = await server.post("/api/documents.update", {
|
||||
body: {
|
||||
token: user.getJwtToken(),
|
||||
id: document.id,
|
||||
emoji: "😂",
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.emoji).toBe("😂");
|
||||
});
|
||||
|
||||
it("should not add template to collection structure when publishing", async () => {
|
||||
const user = await buildUser();
|
||||
const collection = await buildCollection({
|
||||
|
||||
@@ -861,6 +861,7 @@ router.post(
|
||||
lastModifiedById: user.id,
|
||||
createdById: user.id,
|
||||
template: true,
|
||||
emoji: original.emoji,
|
||||
title: original.title,
|
||||
text: original.text,
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import emojiRegex from "emoji-regex";
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
import isUUID from "validator/lib/isUUID";
|
||||
import { z } from "zod";
|
||||
@@ -186,6 +187,9 @@ export const DocumentsUpdateSchema = BaseSchema.extend({
|
||||
/** Doc text to be updated */
|
||||
text: z.string().optional(),
|
||||
|
||||
/** Emoji displayed alongside doc title */
|
||||
emoji: z.string().regex(emojiRegex()).nullish(),
|
||||
|
||||
/** Boolean to denote if the doc should occupy full width */
|
||||
fullWidth: z.boolean().optional(),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user