fix: Drafts appear in document insert search (#1148)

* fix: Drafts appear in document insert search

* test
This commit is contained in:
Tom Moor
2020-01-05 17:24:57 -08:00
committed by GitHub
parent 9214be5645
commit 0ccbc6126b
5 changed files with 49 additions and 5 deletions

View File

@ -556,7 +556,28 @@ describe('#documents.search', async () => {
expect(body.data[0].document.id).toEqual(firstResult.id);
});
it('should return draft documents created by user', async () => {
it('should not return draft documents', async () => {
const { user } = await seed();
await buildDocument({
title: 'search term',
text: 'search term',
publishedAt: null,
userId: user.id,
teamId: user.teamId,
});
const res = await server.post('/api/documents.search', {
body: {
token: user.getJwtToken(),
query: 'search term',
},
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data.length).toEqual(0);
});
it('should return draft documents created by user if chosen', async () => {
const { user } = await seed();
const document = await buildDocument({
title: 'search term',
@ -566,7 +587,11 @@ describe('#documents.search', async () => {
teamId: user.teamId,
});
const res = await server.post('/api/documents.search', {
body: { token: user.getJwtToken(), query: 'search term' },
body: {
token: user.getJwtToken(),
query: 'search term',
includeDrafts: 'true',
},
});
const body = await res.json();
@ -584,7 +609,11 @@ describe('#documents.search', async () => {
teamId: user.teamId,
});
const res = await server.post('/api/documents.search', {
body: { token: user.getJwtToken(), query: 'search term' },
body: {
token: user.getJwtToken(),
query: 'search term',
includeDrafts: 'true',
},
});
const body = await res.json();