Pinned documents (#608)
* Migrations and API for pinned documents * Documentation * Add pin icon * Fin. * v0.2.0 * Remove pin from DocumentPreview, add general menu Add Pinned documents header * Tidy * Fixed: Drafts appearing on collection home
This commit is contained in:
@ -248,6 +248,66 @@ describe('#documents.starred', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#documents.pin', async () => {
|
||||
it('should pin the document', async () => {
|
||||
const { user, document } = await seed();
|
||||
|
||||
const res = await server.post('/api/documents.pin', {
|
||||
body: { token: user.getJwtToken(), id: document.id },
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(body.data.pinned).toEqual(true);
|
||||
});
|
||||
|
||||
it('should require authentication', async () => {
|
||||
const res = await server.post('/api/documents.pin');
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(401);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should require authorization', async () => {
|
||||
const { document } = await seed();
|
||||
const user = await buildUser();
|
||||
const res = await server.post('/api/documents.pin', {
|
||||
body: { token: user.getJwtToken(), id: document.id },
|
||||
});
|
||||
expect(res.status).toEqual(403);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#documents.unpin', async () => {
|
||||
it('should unpin the document', async () => {
|
||||
const { user, document } = await seed();
|
||||
document.pinnedBy = user;
|
||||
await document.save();
|
||||
|
||||
const res = await server.post('/api/documents.unpin', {
|
||||
body: { token: user.getJwtToken(), id: document.id },
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(body.data.pinned).toEqual(false);
|
||||
});
|
||||
|
||||
it('should require authentication', async () => {
|
||||
const res = await server.post('/api/documents.unpin');
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(401);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should require authorization', async () => {
|
||||
const { document } = await seed();
|
||||
const user = await buildUser();
|
||||
const res = await server.post('/api/documents.unpin', {
|
||||
body: { token: user.getJwtToken(), id: document.id },
|
||||
});
|
||||
expect(res.status).toEqual(403);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#documents.star', async () => {
|
||||
it('should star the document', async () => {
|
||||
const { user, document } = await seed();
|
||||
|
Reference in New Issue
Block a user