chore: Upgrade Babel, Jest, Eslint (#1437)

* chore: Upgrade Prettier 1.8 -> 2.0

* chore: Upgrade Babel 6 -> 7

* chore: Upgrade eslint plugins

* chore: Add eslint import/order rules

* chore: Update flow-typed deps
This commit is contained in:
Tom Moor
2020-08-08 22:53:59 -07:00
committed by GitHub
parent e312b264a6
commit 449dc55aaa
317 changed files with 16474 additions and 12183 deletions

View File

@@ -2,10 +2,10 @@
import Router from "koa-router";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import { presentApiKey } from "../presenters";
import { ApiKey, Event } from "../models";
import policy from "../policies";
import { presentApiKey } from "../presenters";
import pagination from "./middlewares/pagination";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,8 +1,11 @@
// @flow
import format from "date-fns/format";
import Router from "koa-router";
import uuid from "uuid";
import format from "date-fns/format";
import { NotFoundError } from "../errors";
import auth from "../middlewares/authentication";
import { Attachment, Document, Event } from "../models";
import policy from "../policies";
import {
makePolicy,
getSignature,
@@ -10,9 +13,6 @@ import {
makeCredential,
getSignedImageUrl,
} from "../utils/s3";
import auth from "../middlewares/authentication";
import { NotFoundError } from "../errors";
import policy from "../policies";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,20 +1,20 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import app from "../app";
import { flushdb } from "../test/support";
import {
buildUser,
buildCollection,
buildAttachment,
buildDocument,
} from "../test/factories";
import { flushdb } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#attachments.redirect", async () => {
describe("#attachments.redirect", () => {
it("should require authentication", async () => {
const res = await server.post("/api/attachments.redirect");
expect(res.status).toEqual(401);

View File

@@ -1,11 +1,11 @@
// @flow
import Router from "koa-router";
import { reject } from "lodash";
import auth from "../middlewares/authentication";
import { presentUser, presentTeam, presentPolicies } from "../presenters";
import { Team } from "../models";
import { signin } from "../../shared/utils/routeHelpers";
import { parseDomain, isCustomSubdomain } from "../../shared/utils/domains";
import { signin } from "../../shared/utils/routeHelpers";
import auth from "../middlewares/authentication";
import { Team } from "../models";
import { presentUser, presentTeam, presentPolicies } from "../presenters";
const router = new Router();

View File

@@ -1,17 +1,9 @@
// @flow
import fs from "fs";
import Router from "koa-router";
import { Op } from "../sequelize";
import { ValidationError } from "../errors";
import { exportCollections } from "../logistics";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import {
presentCollection,
presentUser,
presentPolicies,
presentMembership,
presentGroup,
presentCollectionGroupMembership,
} from "../presenters";
import {
Collection,
CollectionUser,
@@ -21,10 +13,18 @@ import {
User,
Group,
} from "../models";
import { ValidationError } from "../errors";
import { exportCollections } from "../logistics";
import { archiveCollection, archiveCollections } from "../utils/zip";
import policy from "../policies";
import {
presentCollection,
presentUser,
presentPolicies,
presentMembership,
presentGroup,
presentCollectionGroupMembership,
} from "../presenters";
import { Op } from "../sequelize";
import { archiveCollection, archiveCollections } from "../utils/zip";
import pagination from "./middlewares/pagination";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,15 +1,15 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import app from "../app";
import { flushdb, seed } from "../test/support";
import { buildUser, buildGroup, buildCollection } from "../test/factories";
import { Collection, CollectionUser, CollectionGroup } from "../models";
import { buildUser, buildGroup, buildCollection } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#collections.list", async () => {
describe("#collections.list", () => {
it("should require authentication", async () => {
const res = await server.post("/api/collections.list");
const body = await res.json();
@@ -104,7 +104,7 @@ describe("#collections.list", async () => {
});
});
describe("#collections.export", async () => {
describe("#collections.export", () => {
it("should now allow export of private collection not a member", async () => {
const { user } = await seed();
const collection = await buildCollection({
@@ -176,7 +176,7 @@ describe("#collections.export", async () => {
});
});
describe("#collections.export_all", async () => {
describe("#collections.export_all", () => {
it("should require authentication", async () => {
const res = await server.post("/api/collections.export_all");
const body = await res.json();
@@ -215,7 +215,7 @@ describe("#collections.export_all", async () => {
});
});
describe("#collections.add_user", async () => {
describe("#collections.add_user", () => {
it("should add user to collection", async () => {
const user = await buildUser();
const collection = await buildCollection({
@@ -279,7 +279,7 @@ describe("#collections.add_user", async () => {
});
});
describe("#collections.add_group", async () => {
describe("#collections.add_group", () => {
it("should add group to collection", async () => {
const user = await buildUser({ isAdmin: true });
const collection = await buildCollection({
@@ -342,7 +342,7 @@ describe("#collections.add_group", async () => {
});
});
describe("#collections.remove_group", async () => {
describe("#collections.remove_group", () => {
it("should remove group from collection", async () => {
const user = await buildUser({ isAdmin: true });
const collection = await buildCollection({
@@ -418,7 +418,7 @@ describe("#collections.remove_group", async () => {
});
});
describe("#collections.remove_user", async () => {
describe("#collections.remove_user", () => {
it("should remove user from collection", async () => {
const user = await buildUser();
const collection = await buildCollection({
@@ -491,7 +491,7 @@ describe("#collections.remove_user", async () => {
});
});
describe("#collections.users", async () => {
describe("#collections.users", () => {
it("should return users in private collection", async () => {
const { collection, user } = await seed();
collection.private = true;
@@ -531,7 +531,7 @@ describe("#collections.users", async () => {
});
});
describe("#collections.group_memberships", async () => {
describe("#collections.group_memberships", () => {
it("should return groups in private collection", async () => {
const user = await buildUser();
const group = await buildGroup({ teamId: user.teamId });
@@ -680,7 +680,7 @@ describe("#collections.group_memberships", async () => {
});
});
describe("#collections.memberships", async () => {
describe("#collections.memberships", () => {
it("should return members in private collection", async () => {
const { collection, user } = await seed();
collection.private = true;
@@ -783,7 +783,7 @@ describe("#collections.memberships", async () => {
});
});
describe("#collections.info", async () => {
describe("#collections.info", () => {
it("should return collection", async () => {
const { user, collection } = await seed();
const res = await server.post("/api/collections.info", {
@@ -845,7 +845,7 @@ describe("#collections.info", async () => {
});
});
describe("#collections.create", async () => {
describe("#collections.create", () => {
it("should require authentication", async () => {
const res = await server.post("/api/collections.create");
const body = await res.json();
@@ -884,7 +884,7 @@ describe("#collections.create", async () => {
});
});
describe("#collections.update", async () => {
describe("#collections.update", () => {
it("should require authentication", async () => {
const collection = await buildCollection();
const res = await server.post("/api/collections.update", {
@@ -1029,7 +1029,7 @@ describe("#collections.update", async () => {
});
});
describe("#collections.delete", async () => {
describe("#collections.delete", () => {
it("should require authentication", async () => {
const res = await server.post("/api/collections.delete");
const body = await res.json();

View File

@@ -1,14 +1,9 @@
// @flow
import Router from "koa-router";
import Sequelize from "sequelize";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import documentMover from "../commands/documentMover";
import {
presentDocument,
presentCollection,
presentPolicies,
} from "../presenters";
import { InvalidRequestError } from "../errors";
import auth from "../middlewares/authentication";
import {
Collection,
Document,
@@ -20,9 +15,14 @@ import {
Backlink,
User,
} from "../models";
import { InvalidRequestError } from "../errors";
import policy from "../policies";
import {
presentDocument,
presentCollection,
presentPolicies,
} from "../presenters";
import { sequelize } from "../sequelize";
import pagination from "./middlewares/pagination";
const Op = Sequelize.Op;
const { authorize, cannot } = policy;

View File

@@ -9,20 +9,20 @@ import {
Backlink,
CollectionUser,
} from "../models";
import { flushdb, seed } from "../test/support";
import {
buildShare,
buildCollection,
buildUser,
buildDocument,
} from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#documents.info", async () => {
describe("#documents.info", () => {
it("should return published document", async () => {
const { user, document } = await seed();
const res = await server.post("/api/documents.info", {
@@ -210,7 +210,7 @@ describe("#documents.info", async () => {
});
});
describe("#documents.export", async () => {
describe("#documents.export", () => {
it("should return published document", async () => {
const { user, document } = await seed();
const res = await server.post("/api/documents.export", {
@@ -392,7 +392,7 @@ describe("#documents.export", async () => {
});
});
describe("#documents.list", async () => {
describe("#documents.list", () => {
it("should return documents", async () => {
const { user, document } = await seed();
@@ -524,7 +524,7 @@ describe("#documents.list", async () => {
});
});
describe("#documents.pinned", async () => {
describe("#documents.pinned", () => {
it("should return pinned documents", async () => {
const { user, document } = await seed();
document.pinnedById = user.id;
@@ -585,7 +585,7 @@ describe("#documents.pinned", async () => {
});
});
describe("#documents.drafts", async () => {
describe("#documents.drafts", () => {
it("should return unpublished documents", async () => {
const { user, document } = await seed();
document.publishedAt = null;
@@ -618,7 +618,7 @@ describe("#documents.drafts", async () => {
});
});
describe("#documents.search", async () => {
describe("#documents.search", () => {
it("should return results", async () => {
const { user } = await seed();
const res = await server.post("/api/documents.search", {
@@ -947,7 +947,7 @@ describe("#documents.search", async () => {
});
});
describe("#documents.archived", async () => {
describe("#documents.archived", () => {
it("should return archived documents", async () => {
const { user } = await seed();
const document = await buildDocument({
@@ -1007,7 +1007,7 @@ describe("#documents.archived", async () => {
});
});
describe("#documents.viewed", async () => {
describe("#documents.viewed", () => {
it("should return empty result if no views", async () => {
const { user } = await seed();
const res = await server.post("/api/documents.viewed", {
@@ -1071,7 +1071,7 @@ describe("#documents.viewed", async () => {
});
});
describe("#documents.starred", async () => {
describe("#documents.starred", () => {
it("should return empty result if no stars", async () => {
const { user } = await seed();
const res = await server.post("/api/documents.starred", {
@@ -1107,7 +1107,7 @@ describe("#documents.starred", async () => {
});
});
describe("#documents.pin", async () => {
describe("#documents.pin", () => {
it("should pin the document", async () => {
const { user, document } = await seed();
@@ -1224,7 +1224,7 @@ describe("#documents.restore", () => {
});
});
describe("#documents.unpin", async () => {
describe("#documents.unpin", () => {
it("should unpin the document", async () => {
const { user, document } = await seed();
document.pinnedBy = user;
@@ -1256,7 +1256,7 @@ describe("#documents.unpin", async () => {
});
});
describe("#documents.star", async () => {
describe("#documents.star", () => {
it("should star the document", async () => {
const { user, document } = await seed();
@@ -1288,7 +1288,7 @@ describe("#documents.star", async () => {
});
});
describe("#documents.unstar", async () => {
describe("#documents.unstar", () => {
it("should unstar the document", async () => {
const { user, document } = await seed();
await Star.create({ documentId: document.id, userId: user.id });
@@ -1320,7 +1320,7 @@ describe("#documents.unstar", async () => {
});
});
describe("#documents.create", async () => {
describe("#documents.create", () => {
it("should create as a new document", async () => {
const { user, collection } = await seed();
const res = await server.post("/api/documents.create", {
@@ -1406,7 +1406,7 @@ describe("#documents.create", async () => {
});
});
describe("#documents.update", async () => {
describe("#documents.update", () => {
it("should update document details in the root", async () => {
const { user, document } = await seed();
@@ -1677,7 +1677,7 @@ describe("#documents.update", async () => {
});
});
describe("#documents.archive", async () => {
describe("#documents.archive", () => {
it("should allow archiving document", async () => {
const { user, document } = await seed();
const res = await server.post("/api/documents.archive", {
@@ -1699,7 +1699,7 @@ describe("#documents.archive", async () => {
});
});
describe("#documents.delete", async () => {
describe("#documents.delete", () => {
it("should allow deleting document", async () => {
const { user, document } = await seed();
const res = await server.post("/api/documents.delete", {

View File

@@ -1,11 +1,11 @@
// @flow
import Sequelize from "sequelize";
import Router from "koa-router";
import Sequelize from "sequelize";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import { presentEvent } from "../presenters";
import { Event, Team, User } from "../models";
import policy from "../policies";
import { presentEvent } from "../presenters";
import pagination from "./middlewares/pagination";
const Op = Sequelize.Op;
const { authorize } = policy;

View File

@@ -1,15 +1,15 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import app from "../app";
import { flushdb, seed } from "../test/support";
import { buildEvent } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#events.list", async () => {
describe("#events.list", () => {
it("should only return activity events", async () => {
const { user, admin, document, collection } = await seed();

View File

@@ -1,18 +1,18 @@
// @flow
import Router from "koa-router";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import { Op } from "../sequelize";
import { MAX_AVATAR_DISPLAY } from "../../shared/constants";
import auth from "../middlewares/authentication";
import { User, Event, Group, GroupUser } from "../models";
import policy from "../policies";
import {
presentGroup,
presentPolicies,
presentUser,
presentGroupMembership,
} from "../presenters";
import { User, Event, Group, GroupUser } from "../models";
import policy from "../policies";
import { Op } from "../sequelize";
import pagination from "./middlewares/pagination";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,16 +1,16 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import app from "../app";
import { flushdb } from "../test/support";
import { buildUser, buildGroup } from "../test/factories";
import { Event } from "../models";
import { buildUser, buildGroup } from "../test/factories";
import { flushdb } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#groups.create", async () => {
describe("#groups.create", () => {
it("should create a group", async () => {
const name = "hello I am a group";
const user = await buildUser({ isAdmin: true });
@@ -26,7 +26,7 @@ describe("#groups.create", async () => {
});
});
describe("#groups.update", async () => {
describe("#groups.update", () => {
it("should require authentication", async () => {
const group = await buildGroup();
const res = await server.post("/api/groups.update", {
@@ -57,7 +57,7 @@ describe("#groups.update", async () => {
expect(res.status).toEqual(403);
});
describe("when user is admin", async () => {
describe("when user is admin", () => {
let user, group;
beforeEach(async () => {
@@ -112,7 +112,7 @@ describe("#groups.update", async () => {
});
});
describe("#groups.list", async () => {
describe("#groups.list", () => {
it("should require authentication", async () => {
const res = await server.post("/api/groups.list");
const body = await res.json();
@@ -173,7 +173,7 @@ describe("#groups.list", async () => {
});
});
describe("#groups.info", async () => {
describe("#groups.info", () => {
it("should return group if admin", async () => {
const user = await buildUser({ isAdmin: true });
const group = await buildGroup({ teamId: user.teamId });
@@ -232,7 +232,7 @@ describe("#groups.info", async () => {
});
});
describe("#groups.delete", async () => {
describe("#groups.delete", () => {
it("should require authentication", async () => {
const group = await buildGroup();
const res = await server.post("/api/groups.delete", {
@@ -277,7 +277,7 @@ describe("#groups.delete", async () => {
});
});
describe("#groups.memberships", async () => {
describe("#groups.memberships", () => {
it("should return members in a group", async () => {
const user = await buildUser();
const group = await buildGroup({ teamId: user.teamId });
@@ -342,7 +342,7 @@ describe("#groups.memberships", async () => {
});
});
describe("#groups.add_user", async () => {
describe("#groups.add_user", () => {
it("should add user to group", async () => {
const user = await buildUser({ isAdmin: true });
const group = await buildGroup({
@@ -410,7 +410,7 @@ describe("#groups.add_user", async () => {
});
});
describe("#groups.remove_user", async () => {
describe("#groups.remove_user", () => {
it("should remove user from group", async () => {
const user = await buildUser({ isAdmin: true });
const group = await buildGroup({

View File

@@ -2,20 +2,20 @@
import TestServer from "fetch-test-server";
import app from "../app";
import { Authentication } from "../models";
import { flushdb, seed } from "../test/support";
import { buildDocument } from "../test/factories";
import * as Slack from "../slack";
import { buildDocument } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
jest.mock("../slack", () => ({
post: jest.fn(),
}));
describe("#hooks.unfurl", async () => {
describe("#hooks.unfurl", () => {
it("should return documents", async () => {
const { user, document } = await seed();
await Authentication.create({
@@ -49,7 +49,7 @@ describe("#hooks.unfurl", async () => {
});
});
describe("#hooks.slack", async () => {
describe("#hooks.slack", () => {
it("should return no matches", async () => {
const { user, team } = await seed();
@@ -210,7 +210,7 @@ describe("#hooks.slack", async () => {
});
});
describe("#hooks.interactive", async () => {
describe("#hooks.interactive", () => {
it("should respond with replacement message", async () => {
const { user, team } = await seed();
const document = await buildDocument({

View File

@@ -1,31 +1,31 @@
// @flow
import bodyParser from "koa-bodyparser";
import Koa from "koa";
import bodyParser from "koa-bodyparser";
import Router from "koa-router";
import auth from "./auth";
import events from "./events";
import users from "./users";
import collections from "./collections";
import documents from "./documents";
import revisions from "./revisions";
import views from "./views";
import hooks from "./hooks";
import apiKeys from "./apiKeys";
import shares from "./shares";
import groups from "./groups";
import team from "./team";
import integrations from "./integrations";
import notificationSettings from "./notificationSettings";
import utils from "./utils";
import attachments from "./attachments";
import { NotFoundError } from "../errors";
import errorHandling from "../middlewares/errorHandling";
import validation from "../middlewares/validation";
import methodOverride from "../middlewares/methodOverride";
import validation from "../middlewares/validation";
import apiKeys from "./apiKeys";
import attachments from "./attachments";
import auth from "./auth";
import collections from "./collections";
import documents from "./documents";
import events from "./events";
import groups from "./groups";
import hooks from "./hooks";
import integrations from "./integrations";
import apiWrapper from "./middlewares/apiWrapper";
import editor from "./middlewares/editor";
import notificationSettings from "./notificationSettings";
import revisions from "./revisions";
import shares from "./shares";
import team from "./team";
import users from "./users";
import utils from "./utils";
import views from "./views";
const api = new Koa();
const router = new Router();

View File

@@ -4,17 +4,17 @@ import app from "../app";
import { flushdb } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("POST unknown endpoint", async () => {
describe("POST unknown endpoint", () => {
it("should be not found", async () => {
const res = await server.post("/api/blah");
expect(res.status).toEqual(404);
});
});
describe("GET unknown endpoint", async () => {
describe("GET unknown endpoint", () => {
it("should be not found", async () => {
const res = await server.get("/api/blah");
expect(res.status).toEqual(404);

View File

@@ -1,11 +1,11 @@
// @flow
import Router from "koa-router";
import Integration from "../models/Integration";
import pagination from "./middlewares/pagination";
import auth from "../middlewares/authentication";
import { Event } from "../models";
import { presentIntegration } from "../presenters";
import Integration from "../models/Integration";
import policy from "../policies";
import { presentIntegration } from "../presenters";
import pagination from "./middlewares/pagination";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,7 +1,7 @@
// @flow
import semver from "semver";
import { type Context } from "koa";
import pkg from "rich-markdown-editor/package.json";
import semver from "semver";
import { EditorUpdateError } from "../../errors";
export default function editor() {

View File

@@ -1,7 +1,7 @@
// @flow
import querystring from "querystring";
import { InvalidRequestError } from "../../errors";
import { type Context } from "koa";
import { InvalidRequestError } from "../../errors";
export default function pagination(options?: Object) {
return async function paginationMiddleware(

View File

@@ -5,10 +5,10 @@ import { flushdb, seed } from "../../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#pagination", async () => {
describe("#pagination", () => {
it("should allow offset and limit", async () => {
const { user } = await seed();
const res = await server.post("/api/users.list", {

View File

@@ -3,8 +3,8 @@ import Router from "koa-router";
import auth from "../middlewares/authentication";
import { NotificationSetting } from "../models";
import { presentNotificationSetting } from "../presenters";
import policy from "../policies";
import { presentNotificationSetting } from "../presenters";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,11 +1,11 @@
// @flow
import Router from "koa-router";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import { presentRevision } from "../presenters";
import { Document, Revision } from "../models";
import { NotFoundError } from "../errors";
import auth from "../middlewares/authentication";
import { Document, Revision } from "../models";
import policy from "../policies";
import { presentRevision } from "../presenters";
import pagination from "./middlewares/pagination";
const { authorize } = policy;
const router = new Router();

View File

@@ -1,16 +1,16 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import app from "../app";
import { flushdb, seed } from "../test/support";
import { buildDocument, buildUser } from "../test/factories";
import Revision from "../models/Revision";
import { buildDocument, buildUser } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#revisions.info", async () => {
describe("#revisions.info", () => {
it("should return a document revision", async () => {
const { user, document } = await seed();
const revision = await Revision.findOne({
@@ -49,7 +49,7 @@ describe("#revisions.info", async () => {
});
});
describe("#revisions.list", async () => {
describe("#revisions.list", () => {
it("should return a document's revisions", async () => {
const { user, document } = await seed();
const res = await server.post("/api/revisions.list", {

View File

@@ -1,12 +1,12 @@
// @flow
import Router from "koa-router";
import Sequelize from "sequelize";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import { presentShare, presentPolicies } from "../presenters";
import { Document, User, Event, Share, Team } from "../models";
import { NotFoundError } from "../errors";
import auth from "../middlewares/authentication";
import { Document, User, Event, Share, Team } from "../models";
import policy from "../policies";
import { presentShare, presentPolicies } from "../presenters";
import pagination from "./middlewares/pagination";
const Op = Sequelize.Op;
const { authorize } = policy;

View File

@@ -2,15 +2,15 @@
import TestServer from "fetch-test-server";
import app from "../app";
import { CollectionUser } from "../models";
import { flushdb, seed } from "../test/support";
import { buildUser, buildShare } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#shares.list", async () => {
describe("#shares.list", () => {
it("should only return shares created by user", async () => {
const { user, admin, document } = await seed();
await buildShare({
@@ -117,7 +117,7 @@ describe("#shares.list", async () => {
});
});
describe("#shares.create", async () => {
describe("#shares.create", () => {
it("should allow creating a share record for document", async () => {
const { user, document } = await seed();
const res = await server.post("/api/shares.create", {
@@ -216,7 +216,7 @@ describe("#shares.create", async () => {
});
});
describe("#shares.info", async () => {
describe("#shares.info", () => {
it("should allow reading share by id", async () => {
const { user, document } = await seed();
const share = await buildShare({
@@ -299,7 +299,7 @@ describe("#shares.info", async () => {
});
});
describe("#shares.update", async () => {
describe("#shares.update", () => {
it("should allow author to update a share", async () => {
const { user, document } = await seed();
const share = await buildShare({
@@ -367,7 +367,7 @@ describe("#shares.update", async () => {
});
});
describe("#shares.revoke", async () => {
describe("#shares.revoke", () => {
it("should allow author to revoke a share", async () => {
const { user, document } = await seed();
const share = await buildShare({

View File

@@ -1,10 +1,10 @@
// @flow
import Router from "koa-router";
import auth from "../middlewares/authentication";
import { Team } from "../models";
import auth from "../middlewares/authentication";
import { presentTeam, presentPolicies } from "../presenters";
import policy from "../policies";
import { presentTeam, presentPolicies } from "../presenters";
const { authorize } = policy;
const router = new Router();

View File

@@ -6,10 +6,10 @@ import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#team.update", async () => {
describe("#team.update", () => {
it("should update team details", async () => {
const { admin } = await seed();
const res = await server.post("/api/team.update", {

View File

@@ -1,12 +1,12 @@
// @flow
import Router from "koa-router";
import { Op } from "../sequelize";
import { Event, User, Team } from "../models";
import auth from "../middlewares/authentication";
import pagination from "./middlewares/pagination";
import userInviter from "../commands/userInviter";
import { presentUser } from "../presenters";
import auth from "../middlewares/authentication";
import { Event, User, Team } from "../models";
import policy from "../policies";
import { presentUser } from "../presenters";
import { Op } from "../sequelize";
import pagination from "./middlewares/pagination";
const { authorize } = policy;
const router = new Router();

View File

@@ -2,15 +2,15 @@
import TestServer from "fetch-test-server";
import app from "../app";
import { flushdb, seed } from "../test/support";
import { buildUser } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#users.list", async () => {
describe("#users.list", () => {
it("should allow filtering by user name", async () => {
const user = await buildUser({ name: "Tester" });
@@ -85,7 +85,7 @@ describe("#users.list", async () => {
});
});
describe("#users.info", async () => {
describe("#users.info", () => {
it("should return known user", async () => {
const user = await buildUser();
const res = await server.post("/api/users.info", {
@@ -104,7 +104,7 @@ describe("#users.info", async () => {
});
});
describe("#users.invite", async () => {
describe("#users.invite", () => {
it("should return sent invites", async () => {
const user = await buildUser();
const res = await server.post("/api/users.invite", {
@@ -124,7 +124,7 @@ describe("#users.invite", async () => {
});
});
describe("#users.delete", async () => {
describe("#users.delete", () => {
it("should not allow deleting without confirmation", async () => {
const user = await buildUser();
const res = await server.post("/api/users.delete", {
@@ -189,7 +189,7 @@ describe("#users.delete", async () => {
});
});
describe("#users.update", async () => {
describe("#users.update", () => {
it("should update user profile information", async () => {
const { user } = await seed();
const res = await server.post("/api/users.update", {
@@ -210,7 +210,7 @@ describe("#users.update", async () => {
});
});
describe("#users.promote", async () => {
describe("#users.promote", () => {
it("should promote a new admin", async () => {
const { admin, user } = await seed();
@@ -235,7 +235,7 @@ describe("#users.promote", async () => {
});
});
describe("#users.demote", async () => {
describe("#users.demote", () => {
it("should demote an admin", async () => {
const { admin, user } = await seed();
await user.update({ isAdmin: true }); // Make another admin
@@ -279,7 +279,7 @@ describe("#users.demote", async () => {
});
});
describe("#users.suspend", async () => {
describe("#users.suspend", () => {
it("should suspend an user", async () => {
const { admin, user } = await seed();
@@ -321,7 +321,7 @@ describe("#users.suspend", async () => {
});
});
describe("#users.activate", async () => {
describe("#users.activate", () => {
it("should activate a suspended user", async () => {
const { admin, user } = await seed();
await user.update({

View File

@@ -1,7 +1,7 @@
// @flow
import subDays from "date-fns/sub_days";
import debug from "debug";
import Router from "koa-router";
import subDays from "date-fns/sub_days";
import { AuthenticationError } from "../errors";
import { Document, Attachment } from "../models";
import { Op } from "../sequelize";

View File

@@ -1,18 +1,18 @@
/* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server";
import subDays from "date-fns/sub_days";
import TestServer from "fetch-test-server";
import app from "../app";
import { Document } from "../models";
import { sequelize } from "../sequelize";
import { flushdb } from "../test/support";
import { buildDocument } from "../test/factories";
import { flushdb } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#utils.gc", async () => {
describe("#utils.gc", () => {
it("should destroy documents deleted more than 30 days ago", async () => {
const document = await buildDocument({
publishedAt: new Date(),

View File

@@ -1,9 +1,9 @@
// @flow
import Router from "koa-router";
import auth from "../middlewares/authentication";
import { presentView } from "../presenters";
import { View, Document, Event } from "../models";
import policy from "../policies";
import { presentView } from "../presenters";
const { authorize } = policy;
const router = new Router();

View File

@@ -2,15 +2,15 @@
import TestServer from "fetch-test-server";
import app from "../app";
import { View, CollectionUser } from "../models";
import { flushdb, seed } from "../test/support";
import { buildUser } from "../test/factories";
import { flushdb, seed } from "../test/support";
const server = new TestServer(app.callback());
beforeEach(flushdb);
afterAll(server.close);
beforeEach(() => flushdb());
afterAll(() => server.close());
describe("#views.list", async () => {
describe("#views.list", () => {
it("should return views for a document", async () => {
const { user, document } = await seed();
await View.increment({ documentId: document.id, userId: user.id });
@@ -70,7 +70,7 @@ describe("#views.list", async () => {
});
});
describe("#views.create", async () => {
describe("#views.create", () => {
it("should allow creating a view record for document", async () => {
const { user, document } = await seed();
const res = await server.post("/api/views.create", {