lint fixes

This commit is contained in:
Ulf Gebhardt 2023-06-21 16:43:18 +02:00
parent e6c9cf47a7
commit aaa033c6a3
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
19 changed files with 224 additions and 215 deletions

View File

@ -15,7 +15,7 @@ if (require.resolve) {
} }
// Use Cypress env or process.env // Use Cypress env or process.env
declare var Cypress: any | undefined declare let Cypress: any | undefined
const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env // eslint-disable-line no-undef const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env // eslint-disable-line no-undef
const environment = { const environment = {
@ -95,6 +95,7 @@ Object.entries(required).map((entry) => {
if (!entry[1]) { if (!entry[1]) {
throw new Error(`ERROR: "${entry[0]}" env variable is missing.`) throw new Error(`ERROR: "${entry[0]}" env variable is missing.`)
} }
return entry
}) })
export default { export default {

View File

@ -1,2 +1,2 @@
const tsNode = require('ts-node'); const tsNode = require('ts-node')
module.exports = tsNode.register; module.exports = tsNode.register

View File

@ -278,7 +278,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
await Promise.all( await Promise.all(
categories.map(({ icon, name }, index) => { categories.map(({ icon, name }, index) => {
Factory.build('category', { return Factory.build('category', {
id: `cat${index + 1}`, id: `cat${index + 1}`,
slug: name, slug: name,
name, name,

View File

@ -2,14 +2,8 @@ import gql from 'graphql-tag'
export const createMessageMutation = () => { export const createMessageMutation = () => {
return gql` return gql`
mutation ( mutation ($roomId: ID!, $content: String!) {
$roomId: ID! CreateMessage(roomId: $roomId, content: $content) {
$content: String!
) {
CreateMessage(
roomId: $roomId
content: $content
) {
id id
content content
} }
@ -19,7 +13,7 @@ export const createMessageMutation = () => {
export const messageQuery = () => { export const messageQuery = () => {
return gql` return gql`
query($roomId: ID!) { query ($roomId: ID!) {
Message(roomId: $roomId) { Message(roomId: $roomId) {
_id _id
id id

View File

@ -2,12 +2,8 @@ import gql from 'graphql-tag'
export const createRoomMutation = () => { export const createRoomMutation = () => {
return gql` return gql`
mutation ( mutation ($userId: ID!) {
$userId: ID! CreateRoom(userId: $userId) {
) {
CreateRoom(
userId: $userId
) {
id id
roomId roomId
} }

View File

@ -50,7 +50,7 @@ beforeAll(async () => {
context: () => { context: () => {
return { return {
user: authenticatedUser, user: authenticatedUser,
neode: neode, neode,
driver, driver,
} }
}, },

View File

@ -1,22 +1,22 @@
import uniqueSlug from './uniqueSlug' import uniqueSlug from './uniqueSlug'
describe('uniqueSlug', () => { describe('uniqueSlug', () => {
it('slugifies given string', () => { it('slugifies given string', async () => {
const string = 'Hello World' const string = 'Hello World'
const isUnique = jest.fn().mockResolvedValue(true) const isUnique = jest.fn().mockResolvedValue(true)
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world') await expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world')
}) })
it('increments slugified string until unique', () => { it('increments slugified string until unique', async () => {
const string = 'Hello World' const string = 'Hello World'
const isUnique = jest.fn().mockResolvedValueOnce(false).mockResolvedValueOnce(true) const isUnique = jest.fn().mockResolvedValueOnce(false).mockResolvedValueOnce(true)
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world-1') await expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world-1')
}) })
it('slugify null string', () => { it('slugify null string', async () => {
const string = null const string = null
const isUnique = jest.fn().mockResolvedValue(true) const isUnique = jest.fn().mockResolvedValue(true)
expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous') await expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous')
}) })
it('Converts umlaut to a two letter equivalent', async () => { it('Converts umlaut to a two letter equivalent', async () => {

View File

@ -1,38 +1,29 @@
// NOTE: We cannot use `fs` here to clean up the code. Cypress breaks on any npm // NOTE: We cannot use `fs` here to clean up the code. Cypress breaks on any npm
// module that is not browser-compatible. Node's `fs` module is server-side only // module that is not browser-compatible. Node's `fs` module is server-side only
declare var Cypress: any | undefined declare let Cypress: any | undefined
export default { export default {
Image: typeof Cypress !== 'undefined' ? require('./Image') : require('./Image').default, Image: typeof Cypress !== 'undefined' ? require('./Image') : require('./Image').default,
Badge: typeof Cypress !== 'undefined' ? require('./Badge') : require('./Badge').default, Badge: typeof Cypress !== 'undefined' ? require('./Badge') : require('./Badge').default,
User: typeof Cypress !== 'undefined' ? require('./User') : require('./User').default, User: typeof Cypress !== 'undefined' ? require('./User') : require('./User').default,
Group: typeof Cypress !== 'undefined' ? require('./Group') : require('./Group').default, Group: typeof Cypress !== 'undefined' ? require('./Group') : require('./Group').default,
EmailAddress: EmailAddress:
typeof Cypress !== 'undefined' typeof Cypress !== 'undefined' ? require('./EmailAddress') : require('./EmailAddress').default,
? require('./EmailAddress')
: require('./EmailAddress').default,
UnverifiedEmailAddress: UnverifiedEmailAddress:
typeof Cypress !== 'undefined' typeof Cypress !== 'undefined'
? require('./UnverifiedEmailAddress') ? require('./UnverifiedEmailAddress')
: require('./UnverifiedEmailAddress').default, : require('./UnverifiedEmailAddress').default,
SocialMedia: SocialMedia:
typeof Cypress !== 'undefined' typeof Cypress !== 'undefined' ? require('./SocialMedia') : require('./SocialMedia').default,
? require('./SocialMedia')
: require('./SocialMedia').default,
Post: typeof Cypress !== 'undefined' ? require('./Post') : require('./Post').default, Post: typeof Cypress !== 'undefined' ? require('./Post') : require('./Post').default,
Comment: Comment: typeof Cypress !== 'undefined' ? require('./Comment') : require('./Comment').default,
typeof Cypress !== 'undefined' ? require('./Comment') : require('./Comment').default, Category: typeof Cypress !== 'undefined' ? require('./Category') : require('./Category').default,
Category:
typeof Cypress !== 'undefined' ? require('./Category') : require('./Category').default,
Tag: typeof Cypress !== 'undefined' ? require('./Tag') : require('./Tag').default, Tag: typeof Cypress !== 'undefined' ? require('./Tag') : require('./Tag').default,
Location: Location: typeof Cypress !== 'undefined' ? require('./Location') : require('./Location').default,
typeof Cypress !== 'undefined' ? require('./Location') : require('./Location').default,
Donations: Donations:
typeof Cypress !== 'undefined' ? require('./Donations') : require('./Donations').default, typeof Cypress !== 'undefined' ? require('./Donations') : require('./Donations').default,
Report: typeof Cypress !== 'undefined' ? require('./Report') : require('./Report').default, Report: typeof Cypress !== 'undefined' ? require('./Report') : require('./Report').default,
Migration: Migration:
typeof Cypress !== 'undefined' ? require('./Migration') : require('./Migration').default, typeof Cypress !== 'undefined' ? require('./Migration') : require('./Migration').default,
InviteCode: InviteCode:
typeof Cypress !== 'undefined' typeof Cypress !== 'undefined' ? require('./InviteCode') : require('./InviteCode').default,
? require('./InviteCode')
: require('./InviteCode').default,
} }

View File

@ -170,6 +170,7 @@ describe('mergeImage', () => {
}) })
}) })
// eslint-disable-next-line jest/no-disabled-tests
it.skip('automatically creates different image sizes', async () => { it.skip('automatically creates different image sizes', async () => {
await expect( await expect(
mergeImage(post, 'HERO_IMAGE', imageInput, { uploadCallback, deleteCallback }), mergeImage(post, 'HERO_IMAGE', imageInput, { uploadCallback, deleteCallback }),

View File

@ -34,43 +34,40 @@ afterAll(async () => {
driver.close() driver.close()
}) })
describe('Message', () => { describe('Message', () => {
let roomId: string let roomId: string
beforeAll(async () => { beforeAll(async () => {
[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([ ;[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([
Factory.build( Factory.build('user', {
'user', id: 'chatting-user',
{ name: 'Chatting User',
id: 'chatting-user', }),
name: 'Chatting User', Factory.build('user', {
}, id: 'other-chatting-user',
), name: 'Other Chatting User',
Factory.build( }),
'user', Factory.build('user', {
{ id: 'not-chatting-user',
id: 'other-chatting-user', name: 'Not Chatting User',
name: 'Other Chatting User', }),
},
),
Factory.build(
'user',
{
id: 'not-chatting-user',
name: 'Not Chatting User',
},
),
]) ])
}) })
describe('create message', () => { describe('create message', () => {
describe('unauthenticated', () => { describe('unauthenticated', () => {
it('throws authorization error', async () => { it('throws authorization error', async () => {
await expect(mutate({ mutation: createMessageMutation(), variables: { await expect(
roomId: 'some-id', content: 'Some bla bla bla', } })).resolves.toMatchObject({ mutate({
errors: [{ message: 'Not Authorized!' }], mutation: createMessageMutation(),
}) variables: {
roomId: 'some-id',
content: 'Some bla bla bla',
},
}),
).resolves.toMatchObject({
errors: [{ message: 'Not Authorized!' }],
})
}) })
}) })
@ -81,13 +78,20 @@ describe('Message', () => {
describe('room does not exist', () => { describe('room does not exist', () => {
it('returns null', async () => { it('returns null', async () => {
await expect(mutate({ mutation: createMessageMutation(), variables: { await expect(
roomId: 'some-id', content: 'Some bla bla bla', } })).resolves.toMatchObject({ mutate({
errors: undefined, mutation: createMessageMutation(),
data: { variables: {
CreateMessage: null, roomId: 'some-id',
content: 'Some bla bla bla',
}, },
}) }),
).resolves.toMatchObject({
errors: undefined,
data: {
CreateMessage: null,
},
})
}) })
}) })
@ -104,20 +108,23 @@ describe('Message', () => {
describe('user chats in room', () => { describe('user chats in room', () => {
it('returns the message', async () => { it('returns the message', async () => {
await expect(mutate({ await expect(
mutation: createMessageMutation(), mutate({
variables: { mutation: createMessageMutation(),
roomId, variables: {
content: 'Some nice message to other chatting user', roomId,
} })).resolves.toMatchObject({ content: 'Some nice message to other chatting user',
errors: undefined,
data: {
CreateMessage: {
id: expect.any(String),
content: 'Some nice message to other chatting user',
},
}, },
}) }),
).resolves.toMatchObject({
errors: undefined,
data: {
CreateMessage: {
id: expect.any(String),
content: 'Some nice message to other chatting user',
},
},
})
}) })
}) })
@ -125,19 +132,22 @@ describe('Message', () => {
beforeAll(async () => { beforeAll(async () => {
authenticatedUser = await notChattingUser.toJson() authenticatedUser = await notChattingUser.toJson()
}) })
it('returns null', async () => { it('returns null', async () => {
await expect(mutate({ await expect(
mutation: createMessageMutation(), mutate({
variables: { mutation: createMessageMutation(),
roomId, variables: {
content: 'I have no access to this room!', roomId,
} })).resolves.toMatchObject({ content: 'I have no access to this room!',
errors: undefined,
data: {
CreateMessage: null,
}, },
}) }),
).resolves.toMatchObject({
errors: undefined,
data: {
CreateMessage: null,
},
})
}) })
}) })
}) })
@ -151,14 +161,17 @@ describe('Message', () => {
}) })
it('throws authorization error', async () => { it('throws authorization error', async () => {
await expect(query({ await expect(
query: messageQuery(), query({
variables: { query: messageQuery(),
roomId: 'some-id' } variables: {
})).resolves.toMatchObject({ roomId: 'some-id',
},
}),
).resolves.toMatchObject({
errors: [{ message: 'Not Authorized!' }], errors: [{ message: 'Not Authorized!' }],
}) })
}) })
}) })
describe('authenticated', () => { describe('authenticated', () => {
@ -168,12 +181,14 @@ describe('Message', () => {
describe('room does not exists', () => { describe('room does not exists', () => {
it('returns null', async () => { it('returns null', async () => {
await expect(query({ await expect(
query: messageQuery(), query({
variables: { query: messageQuery(),
roomId: 'some-id' variables: {
}, roomId: 'some-id',
})).resolves.toMatchObject({ },
}),
).resolves.toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
Message: [], Message: [],
@ -193,15 +208,17 @@ describe('Message', () => {
expect(result).toMatchObject({ expect(result).toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
Message: [{ Message: [
id: expect.any(String), {
_id: result.data.Message[0].id, id: expect.any(String),
content: 'Some nice message to other chatting user', _id: result.data.Message[0].id,
senderId: 'chatting-user', content: 'Some nice message to other chatting user',
username: 'Chatting User', senderId: 'chatting-user',
avatar: expect.any(String), username: 'Chatting User',
date: expect.any(String), avatar: expect.any(String),
}], date: expect.any(String),
},
],
}, },
}) })
}) })
@ -213,7 +230,7 @@ describe('Message', () => {
variables: { variables: {
roomId, roomId,
content: 'A nice response message to chatting user', content: 'A nice response message to chatting user',
} },
}) })
authenticatedUser = await chattingUser.toJson() authenticatedUser = await chattingUser.toJson()
await mutate({ await mutate({
@ -221,17 +238,19 @@ describe('Message', () => {
variables: { variables: {
roomId, roomId,
content: 'And another nice message to other chatting user', content: 'And another nice message to other chatting user',
}
})
})
it('returns the messages', async () => {
await expect(query({
query: messageQuery(),
variables: {
roomId,
}, },
})).resolves.toMatchObject({ })
})
it('returns the messages', async () => {
await expect(
query({
query: messageQuery(),
variables: {
roomId,
},
}),
).resolves.toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
Message: [ Message: [
@ -263,7 +282,7 @@ describe('Message', () => {
}, },
}) })
}) })
}) })
}) })
describe('room exists, authenticated user not in room', () => { describe('room exists, authenticated user not in room', () => {
@ -272,19 +291,21 @@ describe('Message', () => {
}) })
it('returns null', async () => { it('returns null', async () => {
await expect(query({ await expect(
query: messageQuery(), query({
variables: { query: messageQuery(),
roomId, variables: {
}, roomId,
})).resolves.toMatchObject({ },
}),
).resolves.toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
Message: [], Message: [],
}, },
}) })
}) })
}) })
}) })
}) })
}) })

View File

@ -25,7 +25,9 @@ export default {
Mutation: { Mutation: {
CreateMessage: async (_parent, params, context, _resolveInfo) => { CreateMessage: async (_parent, params, context, _resolveInfo) => {
const { roomId, content } = params const { roomId, content } = params
const { user: { id: currentUserId } } = context const {
user: { id: currentUserId },
} = context
const session = context.driver.session() const session = context.driver.session()
const writeTxResultPromise = session.writeTransaction(async (transaction) => { const writeTxResultPromise = session.writeTransaction(async (transaction) => {
const createMessageCypher = ` const createMessageCypher = `
@ -37,13 +39,14 @@ export default {
})-[:INSIDE]->(room) })-[:INSIDE]->(room)
RETURN message { .* } RETURN message { .* }
` `
const createMessageTxResponse = await transaction.run( const createMessageTxResponse = await transaction.run(createMessageCypher, {
createMessageCypher, currentUserId,
{ currentUserId, roomId, content } roomId,
) content,
})
const [message] = await createMessageTxResponse.records.map((record) => const [message] = await createMessageTxResponse.records.map((record) =>
record.get('message'), record.get('message'),
) )
return message return message
}) })
try { try {
@ -53,7 +56,7 @@ export default {
throw new Error(error) throw new Error(error)
} finally { } finally {
session.close() session.close()
} }
}, },
}, },
Message: { Message: {
@ -61,7 +64,7 @@ export default {
hasOne: { hasOne: {
author: '<-[:CREATED]-(related:User)', author: '<-[:CREATED]-(related:User)',
room: '-[:INSIDE]->(related:Room)', room: '-[:INSIDE]->(related:Room)',
} },
}), }),
} },
} }

View File

@ -238,7 +238,7 @@ describe('given some notifications', () => {
variables: { ...variables, read: false }, variables: { ...variables, read: false },
}) })
await expect(response).toMatchObject(expected) await expect(response).toMatchObject(expected)
await expect(response.data.notifications.length).toEqual(2) // double-check await expect(response.data.notifications).toHaveLength(2) // double-check
}) })
describe('if a resource gets deleted', () => { describe('if a resource gets deleted', () => {

View File

@ -907,6 +907,7 @@ describe('UpdatePost', () => {
}) })
}) })
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('params.image', () => { describe.skip('params.image', () => {
describe('is object', () => { describe('is object', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -28,7 +28,7 @@ export default {
}, },
SignupVerification: async (_parent, args, context) => { SignupVerification: async (_parent, args, context) => {
const { termsAndConditionsAgreedVersion } = args const { termsAndConditionsAgreedVersion } = args
const regEx = new RegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/g) const regEx = /^[0-9]+\.[0-9]+\.[0-9]+$/g
if (!regEx.test(termsAndConditionsAgreedVersion)) { if (!regEx.test(termsAndConditionsAgreedVersion)) {
throw new UserInputError('Invalid version format!') throw new UserInputError('Invalid version format!')
} }

View File

@ -725,20 +725,20 @@ describe('file a report on a resource', () => {
authenticatedUser = null authenticatedUser = null
}) })
describe('unauthenticated', () => { describe('unauthenticated', async () => {
it('throws authorization error', async () => { it('throws authorization error', async () => {
authenticatedUser = null authenticatedUser = null
expect(query({ query: reportsQuery })).resolves.toMatchObject({ await expect(query({ query: reportsQuery })).resolves.toMatchObject({
data: { reports: null }, data: { reports: null },
errors: [{ message: 'Not Authorized!' }], errors: [{ message: 'Not Authorized!' }],
}) })
}) })
}) })
describe('authenticated', () => { describe('authenticated', async () => {
it('role "user" gets no reports', async () => { it('role "user" gets no reports', async () => {
authenticatedUser = await currentUser.toJson() authenticatedUser = await currentUser.toJson()
expect(query({ query: reportsQuery })).resolves.toMatchObject({ await expect(query({ query: reportsQuery })).resolves.toMatchObject({
data: { reports: null }, data: { reports: null },
errors: [{ message: 'Not Authorized!' }], errors: [{ message: 'Not Authorized!' }],
}) })

View File

@ -35,56 +35,55 @@ afterAll(async () => {
describe('Room', () => { describe('Room', () => {
beforeAll(async () => { beforeAll(async () => {
[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([ ;[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([
Factory.build( Factory.build('user', {
'user', id: 'chatting-user',
{ name: 'Chatting User',
id: 'chatting-user', }),
name: 'Chatting User', Factory.build('user', {
}, id: 'other-chatting-user',
), name: 'Other Chatting User',
Factory.build( }),
'user', Factory.build('user', {
{ id: 'not-chatting-user',
id: 'other-chatting-user', name: 'Not Chatting User',
name: 'Other Chatting User', }),
},
),
Factory.build(
'user',
{
id: 'not-chatting-user',
name: 'Not Chatting User',
},
),
]) ])
}) })
describe('create room', () => { describe('create room', () => {
describe('unauthenticated', () => { describe('unauthenticated', () => {
it('throws authorization error', async () => { it('throws authorization error', async () => {
await expect(mutate({ mutation: createRoomMutation(), variables: { await expect(
userId: 'some-id' } })).resolves.toMatchObject({ mutate({
errors: [{ message: 'Not Authorized!' }], mutation: createRoomMutation(),
}) variables: {
userId: 'some-id',
},
}),
).resolves.toMatchObject({
errors: [{ message: 'Not Authorized!' }],
})
}) })
}) })
describe('authenticated', () => { describe('authenticated', () => {
let roomId: string let roomId: string
beforeAll(async () => { beforeAll(async () => {
authenticatedUser = await chattingUser.toJson() authenticatedUser = await chattingUser.toJson()
}) })
describe('user id does not exist', () => { describe('user id does not exist', () => {
it('returns null', async () => { it('returns null', async () => {
await expect(mutate({ await expect(
mutation: createRoomMutation(), mutate({
variables: { mutation: createRoomMutation(),
userId: 'not-existing-user', variables: {
}, userId: 'not-existing-user',
})).resolves.toMatchObject({ },
}),
).resolves.toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
CreateRoom: null, CreateRoom: null,
@ -92,7 +91,7 @@ describe('Room', () => {
}) })
}) })
}) })
describe('user id exists', () => { describe('user id exists', () => {
it('returns the id of the room', async () => { it('returns the id of the room', async () => {
const result = await mutate({ const result = await mutate({
@ -116,12 +115,14 @@ describe('Room', () => {
describe('create room with same user id', () => { describe('create room with same user id', () => {
it('returns the id of the room', async () => { it('returns the id of the room', async () => {
await expect(mutate({ await expect(
mutation: createRoomMutation(), mutate({
variables: { mutation: createRoomMutation(),
userId: 'other-chatting-user', variables: {
}, userId: 'other-chatting-user',
})).resolves.toMatchObject({ },
}),
).resolves.toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
CreateRoom: { CreateRoom: {
@ -130,7 +131,7 @@ describe('Room', () => {
}, },
}) })
}) })
}) })
}) })
}) })
@ -139,11 +140,11 @@ describe('Room', () => {
beforeAll(() => { beforeAll(() => {
authenticatedUser = null authenticatedUser = null
}) })
it('throws authorization error', async () => { it('throws authorization error', async () => {
await expect(query({ query: roomQuery() })).resolves.toMatchObject({ await expect(query({ query: roomQuery() })).resolves.toMatchObject({
errors: [{ message: 'Not Authorized!' }], errors: [{ message: 'Not Authorized!' }],
}) })
}) })
}) })
@ -194,7 +195,7 @@ describe('Room', () => {
}) })
it('returns the room', async () => { it('returns the room', async () => {
const result = await query({ query: roomQuery() }) const result = await query({ query: roomQuery() })
expect(result).toMatchObject({ expect(result).toMatchObject({
errors: undefined, errors: undefined,
data: { data: {
@ -241,7 +242,7 @@ describe('Room', () => {
}, },
}) })
}) })
}) })
}) })
}) })
}) })

View File

@ -3,7 +3,7 @@ import Resolver from './helpers/Resolver'
export default { export default {
Query: { Query: {
Room: async (object, params, context, resolveInfo) => { Room: async (object, params, context, resolveInfo) => {
if (!params.filter) params.filter = {} if (!params.filter) params.filter = {}
params.filter.users_some = { params.filter.users_some = {
id: context.user.id, id: context.user.id,
@ -25,7 +25,9 @@ export default {
Mutation: { Mutation: {
CreateRoom: async (_parent, params, context, _resolveInfo) => { CreateRoom: async (_parent, params, context, _resolveInfo) => {
const { userId } = params const { userId } = params
const { user: { id: currentUserId } } = context const {
user: { id: currentUserId },
} = context
const session = context.driver.session() const session = context.driver.session()
const writeTxResultPromise = session.writeTransaction(async (transaction) => { const writeTxResultPromise = session.writeTransaction(async (transaction) => {
const createRoomCypher = ` const createRoomCypher = `
@ -37,13 +39,11 @@ export default {
room.id = apoc.create.uuid() room.id = apoc.create.uuid()
RETURN room { .* } RETURN room { .* }
` `
const createRommTxResponse = await transaction.run( const createRommTxResponse = await transaction.run(createRoomCypher, {
createRoomCypher, userId,
{ userId, currentUserId } currentUserId,
) })
const [room] = await createRommTxResponse.records.map((record) => const [room] = await createRommTxResponse.records.map((record) => record.get('room'))
record.get('room'),
)
return room return room
}) })
try { try {
@ -56,14 +56,14 @@ export default {
throw new Error(error) throw new Error(error)
} finally { } finally {
session.close() session.close()
} }
}, },
}, },
Room: { Room: {
...Resolver('Room', { ...Resolver('Room', {
hasMany: { hasMany: {
users: '<-[:CHATS_IN]-(related:User)', users: '<-[:CHATS_IN]-(related:User)',
} },
}), }),
} },
} }

View File

@ -590,7 +590,7 @@ describe('save category settings', () => {
beforeEach(async () => { beforeEach(async () => {
await Promise.all( await Promise.all(
categories.map(({ icon, name }, index) => { categories.map(({ icon, name }, index) => {
Factory.build('category', { return Factory.build('category', {
id: `cat${index + 1}`, id: `cat${index + 1}`,
slug: name, slug: name,
name, name,

View File

@ -144,7 +144,7 @@ export default {
params.locationName = params.locationName === '' ? null : params.locationName params.locationName = params.locationName === '' ? null : params.locationName
const { termsAndConditionsAgreedVersion } = params const { termsAndConditionsAgreedVersion } = params
if (termsAndConditionsAgreedVersion) { if (termsAndConditionsAgreedVersion) {
const regEx = new RegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/g) const regEx = /^[0-9]+\.[0-9]+\.[0-9]+$/g
if (!regEx.test(termsAndConditionsAgreedVersion)) { if (!regEx.test(termsAndConditionsAgreedVersion)) {
throw new ForbiddenError('Invalid version format!') throw new ForbiddenError('Invalid version format!')
} }