@@ -12,7 +12,7 @@ function KeyboardShortcuts() {
|
||||
return (
|
||||
<Flex column>
|
||||
<HelpText>
|
||||
Atlas is designed to be super fast and easy to use.
|
||||
Atlas is designed to be super fast and easy to use.
|
||||
All of your usual keyboard shortcuts work here.
|
||||
</HelpText>
|
||||
<HtmlContent dangerouslySetInnerHTML={{ __html: htmlContent }} />
|
||||
|
||||
@@ -171,6 +171,7 @@ type Props = {
|
||||
const isEditing = !!this.props.match.params.edit || isNew;
|
||||
const isFetching = !this.document;
|
||||
const titleText = get(this.document, 'title', 'Loading');
|
||||
const document = this.document;
|
||||
|
||||
return (
|
||||
<Container column auto>
|
||||
@@ -185,9 +186,9 @@ type Props = {
|
||||
<LoadingState />
|
||||
</CenteredContent>}
|
||||
{!isFetching &&
|
||||
this.document &&
|
||||
document &&
|
||||
<StyledDropToImport
|
||||
documentId={this.document.id}
|
||||
documentId={document.id}
|
||||
history={this.props.history}
|
||||
onDragEnter={this.onStartDragging}
|
||||
onDragLeave={this.onStopDragging}
|
||||
@@ -196,20 +197,20 @@ type Props = {
|
||||
>
|
||||
<Flex justify="center" auto>
|
||||
<Prompt
|
||||
when={this.document.hasPendingChanges}
|
||||
when={document.hasPendingChanges}
|
||||
message={DISCARD_CHANGES}
|
||||
/>
|
||||
<Editor
|
||||
key={this.document.id}
|
||||
text={this.document.text}
|
||||
key={document.id}
|
||||
text={document.text}
|
||||
onImageUploadStart={this.onImageUploadStart}
|
||||
onImageUploadStop={this.onImageUploadStop}
|
||||
onChange={this.onChange}
|
||||
onSave={this.onSave}
|
||||
onCancel={this.onCancel}
|
||||
onStar={this.document.star}
|
||||
onUnstar={this.document.unstar}
|
||||
starred={this.document.starred}
|
||||
onStar={document.star}
|
||||
onUnstar={document.unstar}
|
||||
starred={document.starred}
|
||||
heading={this.renderHeading(!!isEditing)}
|
||||
readOnly={!isEditing}
|
||||
/>
|
||||
@@ -225,7 +226,7 @@ type Props = {
|
||||
/>
|
||||
: <a onClick={this.onClickEdit}>Edit</a>}
|
||||
</HeaderAction>
|
||||
{!isEditing && <Menu document={this.document} />}
|
||||
{!isEditing && <Menu document={document} />}
|
||||
</Flex>
|
||||
</Meta>
|
||||
</Flex>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
client: {
|
||||
post: jest.fn(() => Promise.resolve),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"sequelize:migrate": "sequelize db:migrate",
|
||||
"test": "npm run test:frontend && npm run test:server",
|
||||
"test:frontend": "jest",
|
||||
"test:server": "jest --config=server/.jestconfig.json --runInBand",
|
||||
"test:server": "jest --config=server/.jestconfig.json --runInBand --forceExit",
|
||||
"precommit": "lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
@@ -48,7 +48,7 @@
|
||||
"frontend"
|
||||
],
|
||||
"setupFiles": [
|
||||
"<rootDir>/frontend/utils/setupJest.js",
|
||||
"<rootDir>/setupJest.js",
|
||||
"<rootDir>/__mocks__/window.js"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -91,7 +91,7 @@ router.post('auth.slack', async ctx => {
|
||||
const body = {
|
||||
client_id: process.env.SLACK_KEY,
|
||||
client_secret: process.env.SLACK_SECRET,
|
||||
redirect_uri: `${process.env.URL}/auth/slack`,
|
||||
redirect_uri: `${process.env.URL || ''}/auth/slack`,
|
||||
code,
|
||||
};
|
||||
|
||||
@@ -108,7 +108,8 @@ router.post('auth.slack', async ctx => {
|
||||
if (!data.ok) throw httpErrors.BadRequest(data.error);
|
||||
|
||||
// Temp to block
|
||||
const allowedSlackDomains = process.env.ALLOWED_SLACK_DOMAINS.split(',');
|
||||
const allowedSlackDomains = (process.env.ALLOWED_SLACK_DOMAINS || '')
|
||||
.split(',');
|
||||
if (!allowedSlackDomains.includes(data.team.domain)) {
|
||||
throw apiError(
|
||||
400,
|
||||
@@ -171,7 +172,7 @@ router.post('auth.slackCommands', async ctx => {
|
||||
const body = {
|
||||
client_id: process.env.SLACK_KEY,
|
||||
client_secret: process.env.SLACK_SECRET,
|
||||
redirect_uri: `${process.env.URL}/auth/slack/commands`,
|
||||
redirect_uri: `${process.env.URL || ''}/auth/slack/commands`,
|
||||
code,
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { flushdb, seed } from '../test/support';
|
||||
const server = new TestServer(app.callback());
|
||||
|
||||
beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(server.close);
|
||||
|
||||
describe.skip('#auth.signup', async () => {
|
||||
it('should signup a new user', async () => {
|
||||
|
||||
@@ -13,12 +13,13 @@ router.post('documents.list', auth(), pagination(), async ctx => {
|
||||
if (direction !== 'ASC') direction = 'DESC';
|
||||
|
||||
const user = ctx.state.user;
|
||||
const documents = await Document.findAll({
|
||||
const userId = user.id;
|
||||
const starredScope = { method: ['withStarred', userId] };
|
||||
const documents = await Document.scope('defaultScope', starredScope).findAll({
|
||||
where: { teamId: user.teamId },
|
||||
order: [[sort, direction]],
|
||||
offset: ctx.state.pagination.offset,
|
||||
limit: ctx.state.pagination.limit,
|
||||
include: [{ model: Star, as: 'starred', where: { userId: user.id } }],
|
||||
});
|
||||
|
||||
const data = await Promise.all(
|
||||
|
||||
@@ -6,7 +6,7 @@ import { flushdb, seed } from '../test/support';
|
||||
const server = new TestServer(app.callback());
|
||||
|
||||
beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(server.close);
|
||||
|
||||
describe('#documents.list', async () => {
|
||||
it('should return documents', async () => {
|
||||
|
||||
@@ -3,12 +3,12 @@ import TestServer from 'fetch-test-server';
|
||||
import app from '..';
|
||||
import { User } from '../models';
|
||||
|
||||
import { flushdb, seed, sequelize } from '../test/support';
|
||||
import { flushdb, seed } from '../test/support';
|
||||
|
||||
const server = new TestServer(app.callback());
|
||||
|
||||
beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(server.close);
|
||||
|
||||
describe('#user.info', async () => {
|
||||
it('should return known user', async () => {
|
||||
|
||||
@@ -130,6 +130,11 @@ Document.associate = models => {
|
||||
},
|
||||
{ override: true }
|
||||
);
|
||||
Document.addScope('withStarred', userId => ({
|
||||
include: [
|
||||
{ model: models.Star, as: 'starred', where: { userId }, required: false },
|
||||
],
|
||||
}));
|
||||
};
|
||||
|
||||
Document.findById = async id => {
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import { User } from '.';
|
||||
|
||||
import { flushdb, sequelize } from '../test/support';
|
||||
import { flushdb, seed } from '../test/support';
|
||||
|
||||
beforeEach(flushdb);
|
||||
|
||||
it('should set JWT secret and password digest', async () => {
|
||||
const user = User.build({
|
||||
username: 'user',
|
||||
name: 'User',
|
||||
email: 'user1@example.com',
|
||||
password: 'test123!',
|
||||
});
|
||||
await user.save();
|
||||
|
||||
const { user } = await seed();
|
||||
expect(user.passwordDigest).toBeTruthy();
|
||||
expect(user.getJwtToken()).toBeTruthy();
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ const seed = async () => {
|
||||
type: 'atlas',
|
||||
});
|
||||
|
||||
let document = await Document.create({
|
||||
const document = await Document.create({
|
||||
parentDocumentId: null,
|
||||
atlasId: collection.id,
|
||||
teamId: collection.teamId,
|
||||
teamId: team.id,
|
||||
userId: collection.creatorId,
|
||||
lastModifiedById: collection.creatorId,
|
||||
createdById: collection.creatorId,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/* eslint-disable */
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import toJson from 'enzyme-to-json';
|
||||
import localStorage from '../../__mocks__/localStorage';
|
||||
import localStorage from './__mocks__/localStorage';
|
||||
|
||||
const snap = children => {
|
||||
const wrapper = shallow(children);
|
||||
Reference in New Issue
Block a user