Merge branch 'master' into room-properties

This commit is contained in:
Moriz Wahl 2023-06-20 16:47:53 +02:00 committed by GitHub
commit 45602119ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

View File

@ -209,9 +209,17 @@ describe('Message', () => {
mutation: createMessageMutation(), mutation: createMessageMutation(),
variables: { variables: {
roomId, roomId,
content: 'Another nice message to other chatting user', content: 'A nice response message to chatting user',
} }
}) })
authenticatedUser = await chattingUser.toJson()
await mutate({
mutation: createMessageMutation(),
variables: {
roomId,
content: 'And another nice message to other chatting user',
}
})
}) })
it('returns the messages', async () => { it('returns the messages', async () => {
@ -233,11 +241,18 @@ describe('Message', () => {
}, },
{ {
id: expect.any(String), id: expect.any(String),
content: 'Another nice message to other chatting user', content: 'A nice response message to chatting user',
author: { author: {
id: 'other-chatting-user', id: 'other-chatting-user',
}, },
} },
{
id: expect.any(String),
content: 'And another nice message to other chatting user',
author: {
id: 'chatting-user',
},
}
], ],
}, },
}) })

View File

@ -24,11 +24,11 @@ export default {
const writeTxResultPromise = session.writeTransaction(async (transaction) => { const writeTxResultPromise = session.writeTransaction(async (transaction) => {
const createMessageCypher = ` const createMessageCypher = `
MATCH (currentUser:User { id: $currentUserId })-[:CHATS_IN]->(room:Room { id: $roomId }) MATCH (currentUser:User { id: $currentUserId })-[:CHATS_IN]->(room:Room { id: $roomId })
MERGE (currentUser)-[:CREATED]->(message:Message)-[:INSIDE]->(room) CREATE (currentUser)-[:CREATED]->(message:Message {
ON CREATE SET createdAt: toString(datetime()),
message.createdAt = toString(datetime()), id: apoc.create.uuid(),
message.id = apoc.create.uuid(), content: $content
message.content = $content })-[:INSIDE]->(room)
RETURN message { .* } RETURN message { .* }
` `
const createMessageTxResponse = await transaction.run( const createMessageTxResponse = await transaction.run(