@ -809,7 +809,7 @@ router.post('documents.update', auth(), async ctx => {
|
|||||||
|
|
||||||
if (append) {
|
if (append) {
|
||||||
document.text += text;
|
document.text += text;
|
||||||
} else if (text) {
|
} else if (text !== undefined) {
|
||||||
document.text = text;
|
document.text = text;
|
||||||
}
|
}
|
||||||
document.lastModifiedById = user.id;
|
document.lastModifiedById = user.id;
|
||||||
|
@ -1495,6 +1495,24 @@ describe('#documents.update', async () => {
|
|||||||
expect(body).toMatchSnapshot();
|
expect(body).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow setting empty text', async () => {
|
||||||
|
const { user, document } = await seed();
|
||||||
|
|
||||||
|
const res = await server.post('/api/documents.update', {
|
||||||
|
body: {
|
||||||
|
token: user.getJwtToken(),
|
||||||
|
id: document.id,
|
||||||
|
lastRevision: document.revision,
|
||||||
|
title: 'Updated Title',
|
||||||
|
text: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.text).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
it('should require authentication', async () => {
|
it('should require authentication', async () => {
|
||||||
const { document } = await seed();
|
const { document } = await seed();
|
||||||
const res = await server.post('/api/documents.update', {
|
const res = await server.post('/api/documents.update', {
|
||||||
|
Reference in New Issue
Block a user