mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge branch 'master' of github.com:Human-Connection/Human-Connection into quickfix_for_nullpointer_error_in_user_vue
This commit is contained in:
commit
ce659b8c56
@ -12,7 +12,7 @@ install:
|
|||||||
- yarn global add wait-on
|
- yarn global add wait-on
|
||||||
# Install Codecov
|
# Install Codecov
|
||||||
- yarn install
|
- yarn install
|
||||||
- cp cypress.env.template.json cypress.env.json
|
- cp backend/.env.template backend/.env
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- docker-compose -f docker-compose.yml build --parallel
|
- docker-compose -f docker-compose.yml build --parallel
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
import { v1 as neo4j } from 'neo4j-driver'
|
import { v1 as neo4j } from 'neo4j-driver'
|
||||||
import CONFIG from './../config'
|
import CONFIG from './../config'
|
||||||
import setupNeode from './neode'
|
import Neode from 'neode'
|
||||||
|
import models from '../models'
|
||||||
|
|
||||||
let driver
|
let driver
|
||||||
|
const defaultOptions = {
|
||||||
|
uri: CONFIG.NEO4J_URI,
|
||||||
|
username: CONFIG.NEO4J_USERNAME,
|
||||||
|
password: CONFIG.NEO4J_PASSWORD,
|
||||||
|
}
|
||||||
|
|
||||||
export function getDriver(options = {}) {
|
export function getDriver(options = {}) {
|
||||||
const {
|
const { uri, username, password } = { ...defaultOptions, ...options }
|
||||||
uri = CONFIG.NEO4J_URI,
|
|
||||||
username = CONFIG.NEO4J_USERNAME,
|
|
||||||
password = CONFIG.NEO4J_PASSWORD,
|
|
||||||
} = options
|
|
||||||
if (!driver) {
|
if (!driver) {
|
||||||
driver = neo4j.driver(uri, neo4j.auth.basic(username, password))
|
driver = neo4j.driver(uri, neo4j.auth.basic(username, password))
|
||||||
}
|
}
|
||||||
@ -17,10 +19,11 @@ export function getDriver(options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let neodeInstance
|
let neodeInstance
|
||||||
export function neode() {
|
export function getNeode(options = {}) {
|
||||||
if (!neodeInstance) {
|
if (!neodeInstance) {
|
||||||
const { NEO4J_URI: uri, NEO4J_USERNAME: username, NEO4J_PASSWORD: password } = CONFIG
|
const { uri, username, password } = { ...defaultOptions, ...options }
|
||||||
neodeInstance = setupNeode({ uri, username, password })
|
neodeInstance = new Neode(uri, username, password).with(models)
|
||||||
|
return neodeInstance
|
||||||
}
|
}
|
||||||
return neodeInstance
|
return neodeInstance
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
import Neode from 'neode'
|
|
||||||
import models from '../models'
|
|
||||||
|
|
||||||
export default function setupNeode(options) {
|
|
||||||
const { uri, username, password } = options
|
|
||||||
const neodeInstance = new Neode(uri, username, password)
|
|
||||||
neodeInstance.with(models)
|
|
||||||
return neodeInstance
|
|
||||||
}
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import Factory from '../seed/factories/index'
|
import Factory from '../seed/factories/index'
|
||||||
import { getDriver, neode as getNeode } from '../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../bootstrap/neo4j'
|
||||||
import decode from './decode'
|
import decode from './decode'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import { neode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let server
|
let server
|
||||||
@ -11,7 +11,7 @@ let hashtagingUser
|
|||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
const categoryIds = ['cat9']
|
const categoryIds = ['cat9']
|
||||||
const createPostMutation = gql`
|
const createPostMutation = gql`
|
||||||
mutation($id: ID, $title: String!, $postContent: String!, $categoryIds: [ID]!) {
|
mutation($id: ID, $title: String!, $postContent: String!, $categoryIds: [ID]!) {
|
||||||
@ -36,7 +36,7 @@ beforeAll(() => {
|
|||||||
context: () => {
|
context: () => {
|
||||||
return {
|
return {
|
||||||
user: authenticatedUser,
|
user: authenticatedUser,
|
||||||
neode: instance,
|
neode,
|
||||||
driver,
|
driver,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -48,14 +48,14 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
hashtagingUser = await instance.create('User', {
|
hashtagingUser = await neode.create('User', {
|
||||||
id: 'you',
|
id: 'you',
|
||||||
name: 'Al Capone',
|
name: 'Al Capone',
|
||||||
slug: 'al-capone',
|
slug: 'al-capone',
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
})
|
||||||
await instance.create('Category', {
|
await neode.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
icon: 'university',
|
icon: 'university',
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import { neode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let server
|
let server
|
||||||
@ -11,7 +11,7 @@ let notifiedUser
|
|||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
const categoryIds = ['cat9']
|
const categoryIds = ['cat9']
|
||||||
const createPostMutation = gql`
|
const createPostMutation = gql`
|
||||||
mutation($id: ID, $title: String!, $postContent: String!, $categoryIds: [ID]!) {
|
mutation($id: ID, $title: String!, $postContent: String!, $categoryIds: [ID]!) {
|
||||||
@ -44,7 +44,7 @@ beforeAll(() => {
|
|||||||
context: () => {
|
context: () => {
|
||||||
return {
|
return {
|
||||||
user: authenticatedUser,
|
user: authenticatedUser,
|
||||||
neode: instance,
|
neode: neode,
|
||||||
driver,
|
driver,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -56,14 +56,14 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
notifiedUser = await instance.create('User', {
|
notifiedUser = await neode.create('User', {
|
||||||
id: 'you',
|
id: 'you',
|
||||||
name: 'Al Capone',
|
name: 'Al Capone',
|
||||||
slug: 'al-capone',
|
slug: 'al-capone',
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
})
|
||||||
await instance.create('Category', {
|
await neode.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
icon: 'university',
|
icon: 'university',
|
||||||
@ -146,7 +146,7 @@ describe('notifications', () => {
|
|||||||
describe('commenter is not me', () => {
|
describe('commenter is not me', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
commentContent = 'Commenters comment.'
|
commentContent = 'Commenters comment.'
|
||||||
commentAuthor = await instance.create('User', {
|
commentAuthor = await neode.create('User', {
|
||||||
id: 'commentAuthor',
|
id: 'commentAuthor',
|
||||||
name: 'Mrs Comment',
|
name: 'Mrs Comment',
|
||||||
slug: 'mrs-comment',
|
slug: 'mrs-comment',
|
||||||
@ -228,7 +228,7 @@ describe('notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
postAuthor = await instance.create('User', {
|
postAuthor = await neode.create('User', {
|
||||||
id: 'postAuthor',
|
id: 'postAuthor',
|
||||||
name: 'Mrs Post',
|
name: 'Mrs Post',
|
||||||
slug: 'mrs-post',
|
slug: 'mrs-post',
|
||||||
@ -432,7 +432,7 @@ describe('notifications', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
commentContent =
|
commentContent =
|
||||||
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
||||||
commentAuthor = await instance.create('User', {
|
commentAuthor = await neode.create('User', {
|
||||||
id: 'commentAuthor',
|
id: 'commentAuthor',
|
||||||
name: 'Mrs Comment',
|
name: 'Mrs Comment',
|
||||||
slug: 'mrs-comment',
|
slug: 'mrs-comment',
|
||||||
@ -442,7 +442,7 @@ describe('notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('sends only one notification with reason mentioned_in_comment', async () => {
|
it('sends only one notification with reason mentioned_in_comment', async () => {
|
||||||
postAuthor = await instance.create('User', {
|
postAuthor = await neode.create('User', {
|
||||||
id: 'MrPostAuthor',
|
id: 'MrPostAuthor',
|
||||||
name: 'Mr Author',
|
name: 'Mr Author',
|
||||||
slug: 'mr-author',
|
slug: 'mr-author',
|
||||||
@ -518,7 +518,7 @@ describe('notifications', () => {
|
|||||||
await postAuthor.relateTo(notifiedUser, 'blocked')
|
await postAuthor.relateTo(notifiedUser, 'blocked')
|
||||||
commentContent =
|
commentContent =
|
||||||
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
||||||
commentAuthor = await instance.create('User', {
|
commentAuthor = await neode.create('User', {
|
||||||
id: 'commentAuthor',
|
id: 'commentAuthor',
|
||||||
name: 'Mrs Comment',
|
name: 'Mrs Comment',
|
||||||
slug: 'mrs-comment',
|
slug: 'mrs-comment',
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
import Factory from '../seed/factories'
|
import Factory from '../seed/factories'
|
||||||
import { neode as getNeode, getDriver } from '../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../bootstrap/neo4j'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { rule, shield, deny, allow, or } from 'graphql-shield'
|
import { rule, shield, deny, allow, or } from 'graphql-shield'
|
||||||
import { neode } from '../bootstrap/neo4j'
|
import { getNeode } from '../bootstrap/neo4j'
|
||||||
import CONFIG from '../config'
|
import CONFIG from '../config'
|
||||||
|
|
||||||
const debug = !!CONFIG.DEBUG
|
const debug = !!CONFIG.DEBUG
|
||||||
const allowExternalErrors = true
|
const allowExternalErrors = true
|
||||||
|
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
const isAuthenticated = rule({
|
const isAuthenticated = rule({
|
||||||
cache: 'contextual',
|
cache: 'contextual',
|
||||||
@ -36,7 +36,7 @@ const isMyOwn = rule({
|
|||||||
const isMySocialMedia = rule({
|
const isMySocialMedia = rule({
|
||||||
cache: 'no_cache',
|
cache: 'no_cache',
|
||||||
})(async (_, args, { user }) => {
|
})(async (_, args, { user }) => {
|
||||||
let socialMedia = await instance.find('SocialMedia', args.id)
|
let socialMedia = await neode.find('SocialMedia', args.id)
|
||||||
socialMedia = await socialMedia.toJson()
|
socialMedia = await socialMedia.toJson()
|
||||||
return socialMedia.ownedBy.node.id === user.id
|
return socialMedia.ownedBy.node.id === user.id
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { createTestClient } from 'apollo-server-testing'
|
|||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
import Factory from '../seed/factories'
|
import Factory from '../seed/factories'
|
||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
import { getDriver, neode as getNeode } from '../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../bootstrap/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../seed/factories'
|
import Factory from '../seed/factories'
|
||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../bootstrap/neo4j'
|
||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import Factory from '../seed/factories'
|
import Factory from '../seed/factories'
|
||||||
import { neode } from '../bootstrap/neo4j'
|
import { getNeode } from '../bootstrap/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await factory.cleanDatabase()
|
||||||
@ -10,7 +10,7 @@ afterEach(async () => {
|
|||||||
|
|
||||||
describe('role', () => {
|
describe('role', () => {
|
||||||
it('defaults to `user`', async () => {
|
it('defaults to `user`', async () => {
|
||||||
const user = await instance.create('User', { name: 'John' })
|
const user = await neode.create('User', { name: 'John' })
|
||||||
await expect(user.toJson()).resolves.toEqual(
|
await expect(user.toJson()).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
@ -21,7 +21,7 @@ describe('role', () => {
|
|||||||
|
|
||||||
describe('slug', () => {
|
describe('slug', () => {
|
||||||
it('normalizes to lowercase letters', async () => {
|
it('normalizes to lowercase letters', async () => {
|
||||||
const user = await instance.create('User', { slug: 'Matt' })
|
const user = await neode.create('User', { slug: 'Matt' })
|
||||||
await expect(user.toJson()).resolves.toEqual(
|
await expect(user.toJson()).resolves.toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
slug: 'matt',
|
slug: 'matt',
|
||||||
@ -30,9 +30,9 @@ describe('slug', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('must be unique', async done => {
|
it('must be unique', async done => {
|
||||||
await instance.create('User', { slug: 'Matt' })
|
await neode.create('User', { slug: 'Matt' })
|
||||||
try {
|
try {
|
||||||
await expect(instance.create('User', { slug: 'Matt' })).rejects.toThrow('already exists')
|
await expect(neode.create('User', { slug: 'Matt' })).rejects.toThrow('already exists')
|
||||||
done()
|
done()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`
|
throw new Error(`
|
||||||
@ -54,7 +54,7 @@ describe('slug', () => {
|
|||||||
|
|
||||||
describe('characters', () => {
|
describe('characters', () => {
|
||||||
const createUser = attrs => {
|
const createUser = attrs => {
|
||||||
return instance.create('User', attrs).then(user => user.toJson())
|
return neode.create('User', attrs).then(user => user.toJson())
|
||||||
}
|
}
|
||||||
|
|
||||||
it('-', async () => {
|
it('-', async () => {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import Factory from '../../seed/factories'
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let mutate, query, authenticatedUser, variables
|
let mutate, query, authenticatedUser, variables
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver, neode as getNeode } from '../../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { neode as getNeode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { getDriver, neode as getNeode } from '../../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { neode } from '../../../bootstrap/neo4j'
|
import { getNeode } from '../../../bootstrap/neo4j'
|
||||||
|
|
||||||
export const undefinedToNullResolver = list => {
|
export const undefinedToNullResolver = list => {
|
||||||
const resolvers = {}
|
const resolvers = {}
|
||||||
@ -11,7 +11,7 @@ export const undefinedToNullResolver = list => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Resolver(type, options = {}) {
|
export default function Resolver(type, options = {}) {
|
||||||
const instance = neode()
|
const instance = getNeode()
|
||||||
const {
|
const {
|
||||||
idAttribute = 'id',
|
idAttribute = 'id',
|
||||||
undefinedToNull = [],
|
undefinedToNull = [],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createPasswordReset from './helpers/createPasswordReset'
|
import createPasswordReset from './helpers/createPasswordReset'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { UserInputError } from 'apollo-server'
|
import { UserInputError } from 'apollo-server'
|
||||||
import { neode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
import fileUpload from './fileUpload'
|
import fileUpload from './fileUpload'
|
||||||
import encryptPassword from '../../helpers/encryptPassword'
|
import encryptPassword from '../../helpers/encryptPassword'
|
||||||
import generateNonce from './helpers/generateNonce'
|
import generateNonce from './helpers/generateNonce'
|
||||||
import existingEmailAddress from './helpers/existingEmailAddress'
|
import existingEmailAddress from './helpers/existingEmailAddress'
|
||||||
import normalizeEmail from './helpers/normalizeEmail'
|
import normalizeEmail from './helpers/normalizeEmail'
|
||||||
|
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
@ -16,7 +16,7 @@ export default {
|
|||||||
let emailAddress = await existingEmailAddress({ args, context })
|
let emailAddress = await existingEmailAddress({ args, context })
|
||||||
if (emailAddress) return emailAddress
|
if (emailAddress) return emailAddress
|
||||||
try {
|
try {
|
||||||
emailAddress = await instance.create('EmailAddress', args)
|
emailAddress = await neode.create('EmailAddress', args)
|
||||||
return emailAddress.toJson()
|
return emailAddress.toJson()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new UserInputError(e.message)
|
throw new UserInputError(e.message)
|
||||||
@ -32,7 +32,7 @@ export default {
|
|||||||
|
|
||||||
let { nonce, email } = args
|
let { nonce, email } = args
|
||||||
email = normalizeEmail(email)
|
email = normalizeEmail(email)
|
||||||
const result = await instance.cypher(
|
const result = await neode.cypher(
|
||||||
`
|
`
|
||||||
MATCH(email:EmailAddress {nonce: {nonce}, email: {email}})
|
MATCH(email:EmailAddress {nonce: {nonce}, email: {email}})
|
||||||
WHERE NOT (email)-[:BELONGS_TO]->()
|
WHERE NOT (email)-[:BELONGS_TO]->()
|
||||||
@ -40,12 +40,12 @@ export default {
|
|||||||
`,
|
`,
|
||||||
{ nonce, email },
|
{ nonce, email },
|
||||||
)
|
)
|
||||||
const emailAddress = await instance.hydrateFirst(result, 'email', instance.model('Email'))
|
const emailAddress = await neode.hydrateFirst(result, 'email', neode.model('Email'))
|
||||||
if (!emailAddress) throw new UserInputError('Invalid email or nonce')
|
if (!emailAddress) throw new UserInputError('Invalid email or nonce')
|
||||||
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
||||||
args = await encryptPassword(args)
|
args = await encryptPassword(args)
|
||||||
try {
|
try {
|
||||||
const user = await instance.create('User', args)
|
const user = await neode.create('User', args)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
user.relateTo(emailAddress, 'primaryEmail'),
|
user.relateTo(emailAddress, 'primaryEmail'),
|
||||||
emailAddress.relateTo(user, 'belongsTo'),
|
emailAddress.relateTo(user, 'belongsTo'),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver, neode as getNeode } from '../../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { createTestClient } from 'apollo-server-testing'
|
|||||||
import createServer from '../.././server'
|
import createServer from '../.././server'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver, neode as getNeode } from '../../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../../bootstrap/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { neode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
import { UserInputError } from 'apollo-server'
|
import { UserInputError } from 'apollo-server'
|
||||||
|
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
const getUserAndBadge = async ({ badgeKey, userId }) => {
|
const getUserAndBadge = async ({ badgeKey, userId }) => {
|
||||||
const user = await instance.first('User', 'id', userId)
|
const user = await neode.first('User', 'id', userId)
|
||||||
const badge = await instance.first('Badge', 'id', badgeKey)
|
const badge = await neode.first('Badge', 'id', badgeKey)
|
||||||
if (!user) throw new UserInputError("Couldn't find a user with that id")
|
if (!user) throw new UserInputError("Couldn't find a user with that id")
|
||||||
if (!badge) throw new UserInputError("Couldn't find a badge with that id")
|
if (!badge) throw new UserInputError("Couldn't find a badge with that id")
|
||||||
return { user, badge }
|
return { user, badge }
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let mutate, query, authenticatedUser, variables
|
let mutate, query, authenticatedUser, variables
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import { neode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
import Resolver from './helpers/Resolver'
|
import Resolver from './helpers/Resolver'
|
||||||
|
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
CreateSocialMedia: async (object, params, context, resolveInfo) => {
|
CreateSocialMedia: async (object, params, context, resolveInfo) => {
|
||||||
const [user, socialMedia] = await Promise.all([
|
const [user, socialMedia] = await Promise.all([
|
||||||
instance.find('User', context.user.id),
|
neode.find('User', context.user.id),
|
||||||
instance.create('SocialMedia', params),
|
neode.create('SocialMedia', params),
|
||||||
])
|
])
|
||||||
await socialMedia.relateTo(user, 'ownedBy')
|
await socialMedia.relateTo(user, 'ownedBy')
|
||||||
const response = await socialMedia.toJson()
|
const response = await socialMedia.toJson()
|
||||||
@ -16,14 +16,14 @@ export default {
|
|||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
UpdateSocialMedia: async (object, params, context, resolveInfo) => {
|
UpdateSocialMedia: async (object, params, context, resolveInfo) => {
|
||||||
const socialMedia = await instance.find('SocialMedia', params.id)
|
const socialMedia = await neode.find('SocialMedia', params.id)
|
||||||
await socialMedia.update({ url: params.url })
|
await socialMedia.update({ url: params.url })
|
||||||
const response = await socialMedia.toJson()
|
const response = await socialMedia.toJson()
|
||||||
|
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
DeleteSocialMedia: async (object, { id }, context, resolveInfo) => {
|
DeleteSocialMedia: async (object, { id }, context, resolveInfo) => {
|
||||||
const socialMedia = await instance.find('SocialMedia', id)
|
const socialMedia = await neode.find('SocialMedia', id)
|
||||||
if (!socialMedia) return null
|
if (!socialMedia) return null
|
||||||
await socialMedia.delete()
|
await socialMedia.delete()
|
||||||
return socialMedia.toJson()
|
return socialMedia.toJson()
|
||||||
|
|||||||
@ -2,11 +2,11 @@ import { createTestClient } from 'apollo-server-testing'
|
|||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
describe('SocialMedia', () => {
|
describe('SocialMedia', () => {
|
||||||
let socialMediaAction, someUser, ownerNode, owner
|
let socialMediaAction, someUser, ownerNode, owner
|
||||||
@ -27,15 +27,15 @@ describe('SocialMedia', () => {
|
|||||||
const newUrl = 'https://twitter.com/bullerby'
|
const newUrl = 'https://twitter.com/bullerby'
|
||||||
|
|
||||||
const setUpSocialMedia = async () => {
|
const setUpSocialMedia = async () => {
|
||||||
const socialMediaNode = await instance.create('SocialMedia', { url })
|
const socialMediaNode = await neode.create('SocialMedia', { url })
|
||||||
await socialMediaNode.relateTo(ownerNode, 'ownedBy')
|
await socialMediaNode.relateTo(ownerNode, 'ownedBy')
|
||||||
return socialMediaNode.toJson()
|
return socialMediaNode.toJson()
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const someUserNode = await instance.create('User', userParams)
|
const someUserNode = await neode.create('User', userParams)
|
||||||
someUser = await someUserNode.toJson()
|
someUser = await someUserNode.toJson()
|
||||||
ownerNode = await instance.create('User', ownerParams)
|
ownerNode = await neode.create('User', ownerParams)
|
||||||
owner = await ownerNode.toJson()
|
owner = await ownerNode.toJson()
|
||||||
|
|
||||||
socialMediaAction = async (user, mutation, variables) => {
|
socialMediaAction = async (user, mutation, variables) => {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let query, authenticatedUser
|
let query, authenticatedUser
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import encode from '../../jwt/encode'
|
import encode from '../../jwt/encode'
|
||||||
import bcrypt from 'bcryptjs'
|
import bcrypt from 'bcryptjs'
|
||||||
import { AuthenticationError } from 'apollo-server'
|
import { AuthenticationError } from 'apollo-server'
|
||||||
import { neode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
import normalizeEmail from './helpers/normalizeEmail'
|
import normalizeEmail from './helpers/normalizeEmail'
|
||||||
|
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Query: {
|
Query: {
|
||||||
@ -13,7 +13,7 @@ export default {
|
|||||||
},
|
},
|
||||||
currentUser: async (object, params, ctx, resolveInfo) => {
|
currentUser: async (object, params, ctx, resolveInfo) => {
|
||||||
if (!ctx.user) return null
|
if (!ctx.user) return null
|
||||||
const user = await instance.find('User', ctx.user.id)
|
const user = await neode.find('User', ctx.user.id)
|
||||||
return user.toJson()
|
return user.toJson()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -53,7 +53,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
changePassword: async (_, { oldPassword, newPassword }, { driver, user }) => {
|
changePassword: async (_, { oldPassword, newPassword }, { driver, user }) => {
|
||||||
const currentUser = await instance.find('User', user.id)
|
const currentUser = await neode.find('User', user.id)
|
||||||
|
|
||||||
const encryptedPassword = currentUser.get('encryptedPassword')
|
const encryptedPassword = currentUser.get('encryptedPassword')
|
||||||
if (!(await bcrypt.compareSync(oldPassword, encryptedPassword))) {
|
if (!(await bcrypt.compareSync(oldPassword, encryptedPassword))) {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { gql } from '../../helpers/jest'
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer, { context } from '../../server'
|
import createServer, { context } from '../../server'
|
||||||
import encode from '../../jwt/encode'
|
import encode from '../../jwt/encode'
|
||||||
import { neode as getNeode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||||
import fileUpload from './fileUpload'
|
import fileUpload from './fileUpload'
|
||||||
import { neode } from '../../bootstrap/neo4j'
|
import { getNeode } from '../../bootstrap/neo4j'
|
||||||
import { UserInputError, ForbiddenError } from 'apollo-server'
|
import { UserInputError, ForbiddenError } from 'apollo-server'
|
||||||
import Resolver from './helpers/Resolver'
|
import Resolver from './helpers/Resolver'
|
||||||
|
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
export const getBlockedUsers = async context => {
|
export const getBlockedUsers = async context => {
|
||||||
const { neode } = context
|
const { neode } = context
|
||||||
@ -73,7 +73,7 @@ export default {
|
|||||||
block: async (object, args, context, resolveInfo) => {
|
block: async (object, args, context, resolveInfo) => {
|
||||||
const { user: currentUser } = context
|
const { user: currentUser } = context
|
||||||
if (currentUser.id === args.id) return null
|
if (currentUser.id === args.id) return null
|
||||||
await instance.cypher(
|
await neode.cypher(
|
||||||
`
|
`
|
||||||
MATCH(u:User {id: $currentUser.id})-[r:FOLLOWS]->(b:User {id: $args.id})
|
MATCH(u:User {id: $currentUser.id})-[r:FOLLOWS]->(b:User {id: $args.id})
|
||||||
DELETE r
|
DELETE r
|
||||||
@ -81,8 +81,8 @@ export default {
|
|||||||
{ currentUser, args },
|
{ currentUser, args },
|
||||||
)
|
)
|
||||||
const [user, blockedUser] = await Promise.all([
|
const [user, blockedUser] = await Promise.all([
|
||||||
instance.find('User', currentUser.id),
|
neode.find('User', currentUser.id),
|
||||||
instance.find('User', args.id),
|
neode.find('User', args.id),
|
||||||
])
|
])
|
||||||
await user.relateTo(blockedUser, 'blocked')
|
await user.relateTo(blockedUser, 'blocked')
|
||||||
return blockedUser.toJson()
|
return blockedUser.toJson()
|
||||||
@ -90,14 +90,14 @@ export default {
|
|||||||
unblock: async (object, args, context, resolveInfo) => {
|
unblock: async (object, args, context, resolveInfo) => {
|
||||||
const { user: currentUser } = context
|
const { user: currentUser } = context
|
||||||
if (currentUser.id === args.id) return null
|
if (currentUser.id === args.id) return null
|
||||||
await instance.cypher(
|
await neode.cypher(
|
||||||
`
|
`
|
||||||
MATCH(u:User {id: $currentUser.id})-[r:BLOCKED]->(b:User {id: $args.id})
|
MATCH(u:User {id: $currentUser.id})-[r:BLOCKED]->(b:User {id: $args.id})
|
||||||
DELETE r
|
DELETE r
|
||||||
`,
|
`,
|
||||||
{ currentUser, args },
|
{ currentUser, args },
|
||||||
)
|
)
|
||||||
const blockedUser = await instance.find('User', args.id)
|
const blockedUser = await neode.find('User', args.id)
|
||||||
return blockedUser.toJson()
|
return blockedUser.toJson()
|
||||||
},
|
},
|
||||||
UpdateUser: async (object, args, context, resolveInfo) => {
|
UpdateUser: async (object, args, context, resolveInfo) => {
|
||||||
@ -111,7 +111,7 @@ export default {
|
|||||||
}
|
}
|
||||||
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
args = await fileUpload(args, { file: 'avatarUpload', url: 'avatar' })
|
||||||
try {
|
try {
|
||||||
const user = await instance.find('User', args.id)
|
const user = await neode.find('User', args.id)
|
||||||
if (!user) return null
|
if (!user) return null
|
||||||
await user.update({ ...args, updatedAt: new Date().toISOString() })
|
await user.update({ ...args, updatedAt: new Date().toISOString() })
|
||||||
return user.toJson()
|
return user.toJson()
|
||||||
@ -173,7 +173,7 @@ export default {
|
|||||||
if (typeof parent.email !== 'undefined') return parent.email
|
if (typeof parent.email !== 'undefined') return parent.email
|
||||||
const { id } = parent
|
const { id } = parent
|
||||||
const statement = `MATCH(u:User {id: {id}})-[:PRIMARY_EMAIL]->(e:EmailAddress) RETURN e`
|
const statement = `MATCH(u:User {id: {id}})-[:PRIMARY_EMAIL]->(e:EmailAddress) RETURN e`
|
||||||
const result = await instance.cypher(statement, { id })
|
const result = await neode.cypher(statement, { id })
|
||||||
const [{ email }] = result.records.map(r => r.get('e').properties)
|
const [{ email }] = result.records.map(r => r.get('e').properties)
|
||||||
return email
|
return email
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import Factory from '../../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@ import { createTestClient } from 'apollo-server-testing'
|
|||||||
import createServer from '../../../server'
|
import createServer from '../../../server'
|
||||||
import Factory from '../../../seed/factories'
|
import Factory from '../../../seed/factories'
|
||||||
import { gql } from '../../../helpers/jest'
|
import { gql } from '../../../helpers/jest'
|
||||||
import { neode, getDriver } from '../../../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../../../bootstrap/neo4j'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const instance = neode()
|
const neode = getNeode()
|
||||||
|
|
||||||
let currentUser
|
let currentUser
|
||||||
let blockedUser
|
let blockedUser
|
||||||
@ -20,7 +20,7 @@ beforeEach(() => {
|
|||||||
return {
|
return {
|
||||||
user: authenticatedUser,
|
user: authenticatedUser,
|
||||||
driver,
|
driver,
|
||||||
neode: instance,
|
neode,
|
||||||
cypherParams: {
|
cypherParams: {
|
||||||
currentUserId: authenticatedUser ? authenticatedUser.id : null,
|
currentUserId: authenticatedUser ? authenticatedUser.id : null,
|
||||||
},
|
},
|
||||||
@ -55,11 +55,11 @@ describe('blockedUsers', () => {
|
|||||||
|
|
||||||
describe('authenticated and given a blocked user', () => {
|
describe('authenticated and given a blocked user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await instance.create('User', {
|
currentUser = await neode.create('User', {
|
||||||
name: 'Current User',
|
name: 'Current User',
|
||||||
id: 'u1',
|
id: 'u1',
|
||||||
})
|
})
|
||||||
blockedUser = await instance.create('User', {
|
blockedUser = await neode.create('User', {
|
||||||
name: 'Blocked User',
|
name: 'Blocked User',
|
||||||
id: 'u2',
|
id: 'u2',
|
||||||
})
|
})
|
||||||
@ -113,7 +113,7 @@ describe('block', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await instance.create('User', {
|
currentUser = await neode.create('User', {
|
||||||
name: 'Current User',
|
name: 'Current User',
|
||||||
id: 'u1',
|
id: 'u1',
|
||||||
})
|
})
|
||||||
@ -138,7 +138,7 @@ describe('block', () => {
|
|||||||
|
|
||||||
describe('given a to-be-blocked user', () => {
|
describe('given a to-be-blocked user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
blockedUser = await instance.create('User', {
|
blockedUser = await neode.create('User', {
|
||||||
name: 'Blocked User',
|
name: 'Blocked User',
|
||||||
id: 'u2',
|
id: 'u2',
|
||||||
})
|
})
|
||||||
@ -181,11 +181,11 @@ describe('block', () => {
|
|||||||
let postQuery
|
let postQuery
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const post1 = await instance.create('Post', {
|
const post1 = await neode.create('Post', {
|
||||||
id: 'p12',
|
id: 'p12',
|
||||||
title: 'A post written by the current user',
|
title: 'A post written by the current user',
|
||||||
})
|
})
|
||||||
const post2 = await instance.create('Post', {
|
const post2 = await neode.create('Post', {
|
||||||
id: 'p23',
|
id: 'p23',
|
||||||
title: 'A post written by the blocked user',
|
title: 'A post written by the blocked user',
|
||||||
})
|
})
|
||||||
@ -323,7 +323,7 @@ describe('unblock', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await instance.create('User', {
|
currentUser = await neode.create('User', {
|
||||||
name: 'Current User',
|
name: 'Current User',
|
||||||
id: 'u1',
|
id: 'u1',
|
||||||
})
|
})
|
||||||
@ -348,7 +348,7 @@ describe('unblock', () => {
|
|||||||
|
|
||||||
describe('given another user', () => {
|
describe('given another user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
blockedUser = await instance.create('User', {
|
blockedUser = await neode.create('User', {
|
||||||
name: 'Blocked User',
|
name: 'Blocked User',
|
||||||
id: 'u2',
|
id: 'u2',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getDriver, neode } from '../../bootstrap/neo4j'
|
import { getDriver, getNeode } from '../../bootstrap/neo4j'
|
||||||
import createBadge from './badges.js'
|
import createBadge from './badges.js'
|
||||||
import createUser from './users.js'
|
import createUser from './users.js'
|
||||||
import createPost from './posts.js'
|
import createPost from './posts.js'
|
||||||
@ -39,7 +39,7 @@ export const cleanDatabase = async (options = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Factory(options = {}) {
|
export default function Factory(options = {}) {
|
||||||
const { neo4jDriver = getDriver(), neodeInstance = neode() } = options
|
const { neo4jDriver = getDriver(), neodeInstance = getNeode() } = options
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
neo4jDriver,
|
neo4jDriver,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import sample from 'lodash/sample'
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
import Factory from './factories'
|
import Factory from './factories'
|
||||||
import { neode as getNeode, getDriver } from '../bootstrap/neo4j'
|
import { getNeode, getDriver } from '../bootstrap/neo4j'
|
||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
|
|
||||||
const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import helmet from 'helmet'
|
|||||||
import { ApolloServer } from 'apollo-server-express'
|
import { ApolloServer } from 'apollo-server-express'
|
||||||
import CONFIG, { requiredConfigs } from './config'
|
import CONFIG, { requiredConfigs } from './config'
|
||||||
import middleware from './middleware'
|
import middleware from './middleware'
|
||||||
import { neode as getNeode, getDriver } from './bootstrap/neo4j'
|
import { getNeode, getDriver } from './bootstrap/neo4j'
|
||||||
import decode from './jwt/decode'
|
import decode from './jwt/decode'
|
||||||
import schema from './schema'
|
import schema from './schema'
|
||||||
import webfinger from './activitypub/routes/webfinger'
|
import webfinger from './activitypub/routes/webfinger'
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"BACKEND_HOST": "http://localhost:4000",
|
|
||||||
"NEO4J_URI": "bolt://localhost:7687",
|
|
||||||
"NEO4J_USERNAME": "neo4j",
|
|
||||||
"NEO4J_PASSWORD": "letmein"
|
|
||||||
}
|
|
||||||
@ -16,12 +16,7 @@ First, you have to tell cypress how to connect to your local neo4j database
|
|||||||
among other things. You can copy our template configuration and change the new
|
among other things. You can copy our template configuration and change the new
|
||||||
file according to your needs.
|
file according to your needs.
|
||||||
|
|
||||||
Make sure you are at the root level of the project. Then:
|
To start the services that are required for cypress testing, run:
|
||||||
```bash
|
|
||||||
# in the top level folder Human-Connection/
|
|
||||||
$ cp cypress.env.template.json cypress.env.json
|
|
||||||
```
|
|
||||||
To start the services that are required for cypress testing, run this:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# in the top level folder Human-Connection/
|
# in the top level folder Human-Connection/
|
||||||
|
|||||||
@ -3,6 +3,14 @@ import { When, Then } from "cypress-cucumber-preprocessor/steps";
|
|||||||
const narratorAvatar =
|
const narratorAvatar =
|
||||||
"https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg";
|
"https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg";
|
||||||
|
|
||||||
|
When("I type in a comment with {int} characters", size => {
|
||||||
|
var c="";
|
||||||
|
for (var i = 0; i < size; i++) {
|
||||||
|
c += "c"
|
||||||
|
}
|
||||||
|
cy.get(".editor .ProseMirror").type(c);
|
||||||
|
});
|
||||||
|
|
||||||
Then("I click on the {string} button", text => {
|
Then("I click on the {string} button", text => {
|
||||||
cy.get("button")
|
cy.get("button")
|
||||||
.contains(text)
|
.contains(text)
|
||||||
@ -23,6 +31,16 @@ Then("I should see my comment", () => {
|
|||||||
.should("contain", "today at");
|
.should("contain", "today at");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Then("I should see the entirety of my comment", () => {
|
||||||
|
cy.get("div.comment")
|
||||||
|
.should("not.contain", "show more")
|
||||||
|
});
|
||||||
|
|
||||||
|
Then("I should see an abreviated version of my comment", () => {
|
||||||
|
cy.get("div.comment")
|
||||||
|
.should("contain", "show more")
|
||||||
|
});
|
||||||
|
|
||||||
Then("the editor should be cleared", () => {
|
Then("the editor should be cleared", () => {
|
||||||
cy.get(".ProseMirror p").should("have.class", "is-empty");
|
cy.get(".ProseMirror p").should("have.class", "is-empty");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
|
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
|
||||||
import { VERSION } from '../../constants/terms-and-conditions-version.js'
|
import { VERSION } from '../../constants/terms-and-conditions-version.js'
|
||||||
|
import { gql } from '../../../backend/src/helpers/jest'
|
||||||
|
|
||||||
/* global cy */
|
/* global cy */
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ Given('somebody reported the following posts:', table => {
|
|||||||
cy.factory()
|
cy.factory()
|
||||||
.create('User', submitter)
|
.create('User', submitter)
|
||||||
.authenticateAs(submitter)
|
.authenticateAs(submitter)
|
||||||
.mutate(`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
.mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
||||||
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
|
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,3 +20,19 @@ Feature: Post Comment
|
|||||||
Then my comment should be successfully created
|
Then my comment should be successfully created
|
||||||
And I should see my comment
|
And I should see my comment
|
||||||
And the editor should be cleared
|
And the editor should be cleared
|
||||||
|
|
||||||
|
Scenario: View medium length comments
|
||||||
|
Given I visit "post/bWBjpkTKZp/101-essays"
|
||||||
|
And I type in a comment with 305 characters
|
||||||
|
And I click on the "Comment" button
|
||||||
|
Then my comment should be successfully created
|
||||||
|
And I should see the entirety of my comment
|
||||||
|
And the editor should be cleared
|
||||||
|
|
||||||
|
Scenario: View long comments
|
||||||
|
Given I visit "post/bWBjpkTKZp/101-essays"
|
||||||
|
And I type in a comment with 1205 characters
|
||||||
|
And I click on the "Comment" button
|
||||||
|
Then my comment should be successfully created
|
||||||
|
And I should see an abreviated version of my comment
|
||||||
|
And the editor should be cleared
|
||||||
|
|||||||
@ -18,8 +18,8 @@ import helpers from "./helpers";
|
|||||||
import users from "../fixtures/users.json";
|
import users from "../fixtures/users.json";
|
||||||
import { GraphQLClient, request } from 'graphql-request'
|
import { GraphQLClient, request } from 'graphql-request'
|
||||||
import { gql } from '../../backend/src/helpers/jest'
|
import { gql } from '../../backend/src/helpers/jest'
|
||||||
|
import config from '../../backend/src/config'
|
||||||
|
|
||||||
const backendHost = Cypress.env('BACKEND_HOST')
|
|
||||||
const switchLang = name => {
|
const switchLang = name => {
|
||||||
cy.get(".locale-menu").click();
|
cy.get(".locale-menu").click();
|
||||||
cy.contains(".locale-menu-popover a", name).click();
|
cy.contains(".locale-menu-popover a", name).click();
|
||||||
@ -31,7 +31,7 @@ const authenticatedHeaders = async (variables) => {
|
|||||||
login(email: $email, password: $password)
|
login(email: $email, password: $password)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const response = await request(backendHost, mutation, variables)
|
const response = await request(config.GRAPHQL_URI, mutation, variables)
|
||||||
return { authorization: `Bearer ${response.login}` }
|
return { authorization: `Bearer ${response.login}` }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +100,7 @@ Cypress.Commands.add(
|
|||||||
'authenticateAs',
|
'authenticateAs',
|
||||||
async ({email, password}) => {
|
async ({email, password}) => {
|
||||||
const headers = await authenticatedHeaders({ email, password })
|
const headers = await authenticatedHeaders({ email, password })
|
||||||
console.log(headers)
|
return new GraphQLClient(config.GRAPHQL_URI, { headers })
|
||||||
return new GraphQLClient(backendHost, { headers })
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,10 @@
|
|||||||
import Factory from '../../backend/src/seed/factories'
|
import Factory from '../../backend/src/seed/factories'
|
||||||
import { getDriver, neode as getNeode } from '../../backend/src/bootstrap/neo4j'
|
import { getDriver, getNeode } from '../../backend/src/bootstrap/neo4j'
|
||||||
import setupNeode from '../../backend/src/bootstrap/neode'
|
|
||||||
import neode from 'neode'
|
import neode from 'neode'
|
||||||
|
|
||||||
const backendHost = Cypress.env('SEED_SERVER_HOST')
|
const neo4jDriver = getDriver()
|
||||||
const neo4jConfigs = {
|
const neodeInstance = getNeode()
|
||||||
uri: Cypress.env('NEO4J_URI'),
|
const factoryOptions = { neo4jDriver, neodeInstance }
|
||||||
username: Cypress.env('NEO4J_USERNAME'),
|
|
||||||
password: Cypress.env('NEO4J_PASSWORD')
|
|
||||||
}
|
|
||||||
const neo4jDriver = getDriver(neo4jConfigs)
|
|
||||||
const factoryOptions = { seedServerHost: backendHost, neo4jDriver, neodeInstance: setupNeode(neo4jConfigs)}
|
|
||||||
const factory = Factory(factoryOptions)
|
const factory = Factory(factoryOptions)
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@ -18,7 +12,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add('neode', () => {
|
Cypress.Commands.add('neode', () => {
|
||||||
return setupNeode(neo4jConfigs)
|
return neodeInstance
|
||||||
})
|
})
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
'first',
|
'first',
|
||||||
|
|||||||
@ -6,14 +6,15 @@
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# install all dependencies
|
# install all dependencies
|
||||||
|
$ cd webapp/
|
||||||
$ yarn install
|
$ yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
Copy:
|
Copy:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
# in webapp/
|
||||||
cp .env.template .env
|
cp .env.template .env
|
||||||
cp cypress.env.template.json cypress.env.json
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Configure the files according to your needs and your local setup.
|
Configure the files according to your needs and your local setup.
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
export const COMMENT_MIN_LENGTH = 1
|
export const COMMENT_MIN_LENGTH = 1
|
||||||
export const COMMENT_MAX_UNTRUNCATED_LENGTH = 300
|
export const COMMENT_MAX_UNTRUNCATED_LENGTH = 1200
|
||||||
export const COMMENT_TRUNCATE_TO_LENGTH = 180
|
export const COMMENT_TRUNCATE_TO_LENGTH = 180
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@human-connection/styleguide": "0.5.21",
|
"@human-connection/styleguide": "0.5.22",
|
||||||
"@nuxtjs/apollo": "^4.0.0-rc18",
|
"@nuxtjs/apollo": "^4.0.0-rc18",
|
||||||
"@nuxtjs/axios": "~5.8.0",
|
"@nuxtjs/axios": "~5.8.0",
|
||||||
"@nuxtjs/dotenv": "~1.4.1",
|
"@nuxtjs/dotenv": "~1.4.1",
|
||||||
|
|||||||
@ -1141,10 +1141,10 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@hapi/hoek" "6.x.x"
|
"@hapi/hoek" "6.x.x"
|
||||||
|
|
||||||
"@human-connection/styleguide@0.5.21":
|
"@human-connection/styleguide@0.5.22":
|
||||||
version "0.5.21"
|
version "0.5.22"
|
||||||
resolved "https://registry.yarnpkg.com/@human-connection/styleguide/-/styleguide-0.5.21.tgz#ef577325bef8577d2846f3b29567ca15856f2e39"
|
resolved "https://registry.yarnpkg.com/@human-connection/styleguide/-/styleguide-0.5.22.tgz#444ec98b8f8d1c438e2e99736dcffe432b302755"
|
||||||
integrity sha512-psGiIfrDRfwsZ5UtFGDiq2uB/nLkfPsNpAv5c2RAI3QpK+YOp5c3W1MuHASij7Z9iFaxZ0qkuzXiOg+mVAZbdg==
|
integrity sha512-zYDhWWoDIEcUhAJPSrb2azBPxBfcr6igVtTx1Bz/FNMW2bIWfZIRv9U4LaJ9RG/GgjKNcVE+OPdB8zCcwqyQyA==
|
||||||
dependencies:
|
dependencies:
|
||||||
vue "^2.6.10"
|
vue "^2.6.10"
|
||||||
|
|
||||||
@ -14301,6 +14301,11 @@ serve-static@1.14.1, serve-static@^1.14.1:
|
|||||||
version "1.14.1"
|
version "1.14.1"
|
||||||
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9"
|
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9"
|
||||||
integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==
|
integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==
|
||||||
|
dependencies:
|
||||||
|
encodeurl "~1.0.2"
|
||||||
|
escape-html "~1.0.3"
|
||||||
|
parseurl "~1.3.3"
|
||||||
|
send "0.17.1"
|
||||||
|
|
||||||
server-destroy@^1.0.1:
|
server-destroy@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user