mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #1853 from Human-Connection/219-add-createDate-follow-shout
Added createdAt date for follow and shout
This commit is contained in:
commit
3163f6c9b1
13206
backend/package-lock.json
generated
Normal file
13206
backend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -28,12 +28,18 @@ module.exports = {
|
||||
relationship: 'FOLLOWS',
|
||||
target: 'User',
|
||||
direction: 'out',
|
||||
properties: {
|
||||
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
||||
},
|
||||
},
|
||||
followedBy: {
|
||||
type: 'relationship',
|
||||
relationship: 'FOLLOWS',
|
||||
target: 'User',
|
||||
direction: 'in',
|
||||
properties: {
|
||||
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
||||
},
|
||||
},
|
||||
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
||||
disabledBy: {
|
||||
@ -98,6 +104,9 @@ module.exports = {
|
||||
relationship: 'SHOUTED',
|
||||
target: 'Post',
|
||||
direction: 'out',
|
||||
properties: {
|
||||
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
||||
},
|
||||
},
|
||||
isIn: {
|
||||
type: 'relationship',
|
||||
|
||||
@ -131,6 +131,21 @@ describe('follow', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('adds `createdAt` to `FOLLOW` relationship', async () => {
|
||||
await mutate({
|
||||
mutation: mutationFollowUser,
|
||||
variables,
|
||||
})
|
||||
const relation = await neode.cypher(
|
||||
'MATCH (user:User {id: {id}})-[relationship:FOLLOWS]->(followed:User) WHERE relationship.createdAt IS NOT NULL RETURN relationship',
|
||||
{ id: 'u1' },
|
||||
)
|
||||
const relationshipProperties = relation.records.map(
|
||||
record => record.get('relationship').properties.createdAt,
|
||||
)
|
||||
expect(relationshipProperties[0]).toEqual(expect.any(String))
|
||||
})
|
||||
|
||||
test('I can`t follow myself', async () => {
|
||||
variables.id = user1.id
|
||||
await expect(mutate({ mutation: mutationFollowUser, variables })).resolves.toMatchObject({
|
||||
@ -155,6 +170,7 @@ describe('follow', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('unfollow user', () => {
|
||||
beforeEach(async () => {
|
||||
variables = { id: user2.id }
|
||||
|
||||
@ -7,7 +7,7 @@ export default {
|
||||
const transactionRes = await session.run(
|
||||
`MATCH (node {id: $id})<-[:WROTE]-(userWritten:User), (user:User {id: $userId})
|
||||
WHERE $type IN labels(node) AND NOT userWritten.id = $userId
|
||||
MERGE (user)-[relation:SHOUTED]->(node)
|
||||
MERGE (user)-[relation:SHOUTED{createdAt:toString(datetime())}]->(node)
|
||||
RETURN COUNT(relation) > 0 as isShouted`,
|
||||
{
|
||||
id,
|
||||
|
||||
@ -102,6 +102,22 @@ describe('shout and unshout posts', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('adds `createdAt` to `SHOUT` relationship', async () => {
|
||||
variables = { id: 'another-user-post-id' }
|
||||
await mutate({ mutation: mutationShoutPost, variables })
|
||||
const relation = await instance.cypher(
|
||||
'MATCH (user:User {id: $userId1})-[relationship:SHOUTED]->(node {id: $userId2}) WHERE relationship.createdAt IS NOT NULL RETURN relationship',
|
||||
{
|
||||
userId1: 'current-user-id',
|
||||
userId2: 'another-user-post-id',
|
||||
},
|
||||
)
|
||||
const relationshipProperties = relation.records.map(
|
||||
record => record.get('relationship').properties.createdAt,
|
||||
)
|
||||
expect(relationshipProperties[0]).toEqual(expect.any(String))
|
||||
})
|
||||
|
||||
it('can not shout my own post', async () => {
|
||||
variables = { id: 'current-user-post-id' }
|
||||
await expect(mutate({ mutation: mutationShoutPost, variables })).resolves.toMatchObject({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user