Fix search result ordering

Add support for returning your own drafts in results
Added regression tests
This commit is contained in:
Tom Moor
2018-08-04 21:28:37 -07:00
parent 7ebbab7634
commit f5a1f59290
4 changed files with 129 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
// @flow
import { Share, Team, User } from '../models';
import { Share, Team, User, Document, Collection } from '../models';
import uuid from 'uuid';
let count = 0;
@@ -45,3 +45,53 @@ export async function buildUser(overrides: Object = {}) {
...overrides,
});
}
export async function buildCollection(overrides: Object = {}) {
count++;
if (!overrides.teamId) {
const team = await buildTeam();
overrides.teamId = team.id;
}
if (!overrides.userId) {
const user = await buildUser();
overrides.userId = user.id;
}
return Collection.create({
name: 'Test Collection',
description: 'Test collection description',
creatorId: overrides.userId,
type: 'atlas',
...overrides,
});
}
export async function buildDocument(overrides: Object = {}) {
count++;
if (!overrides.teamId) {
const team = await buildTeam();
overrides.teamId = team.id;
}
if (!overrides.userId) {
const user = await buildUser();
overrides.userId = user.id;
}
if (!overrides.atlasId) {
const collection = await buildCollection(overrides);
overrides.atlasId = collection.id;
}
return Document.create({
title: `Document ${count}`,
text: 'This is the text in an example document',
publishedAt: new Date(),
lastModifiedById: overrides.userId,
createdById: overrides.userId,
...overrides,
});
}