Added createdAt date for follow and shout
Merge request reports
Activity
131 131 }) 132 132 }) 133 133 134 test('adds `createdAt` to `FOLLOW` relationship', async () => { 135 await mutate({ 136 mutation: mutationFollowUser, 137 variables, 138 }) 139 const relation = await neode.cypher( 140 'MATCH (user:User {id: {id}})-[relationship:FOLLOWS]->(followed:User) WHERE relationship.createdAt IS NOT NULL RETURN relationship', 141 { id: 'u1' }, 142 ) 143 const relationshipProperties = relation.records.map( 144 record => record.get('relationship').properties.createdAt, 145 ) 146 expect(relationshipProperties[0]).toEqual(expect.any(String)) Created by: Tirokk
Authored by mattwr18
Outdated (history rewrite) - original diff
@@ -129,6 +129,16 @@ describe('follow', () => { data: { followUser: expectedUser }, errors: undefined, }) + + // Test to make sure FOLLOWS relationship has "createdAt" date. + 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))
can you please place this into it's own
it
block? we should avoid multipleexpect
in the same it blockCreated by: Tirokk
Authored by roschaefer
Usually you would try to have one assertion per spec. You can easily create a new spec by saying:
it('adds `createdAt` to `FOLLOW` relationship', async () => { ... })
Redundancy is not a problem with software tests.
Created by: Tirokk
Authored by mattwr18
you can run
await mutate({ mutation: mutationFollowUser, variables })
then this codeCreated by: Tirokk
Authored by KapilJ22
@mattwr18 - Much appreciated your review. Implemented changes as you requested.
Created by: Tirokk
Authored by KapilJ22
@roschaefer I like your suggestion - "Redundancy is not a problem with software tests." I was thinking in terms of code. Much appreciated your review. Implemented changes as you requested.
103 103 }) 104 104 105 it('adds `createdAt` to `SHOUT` relationship', async () => { 106 variables = { id: 'another-user-post-id' } 107 await mutate({ mutation: mutationShoutPost, variables }) 108 const relation = await instance.cypher( 109 'MATCH (user:User {id: $userId1})-[relationship:SHOUTED]->(node {id: $userId2}) WHERE relationship.createdAt IS NOT NULL RETURN relationship', 110 { 111 userId1: 'current-user-id', 112 userId2: 'another-user-post-id', 113 }, 114 ) 115 const relationshipProperties = relation.records.map( 116 record => record.get('relationship').properties.createdAt, 117 ) 118 expect(relationshipProperties[0]).toEqual(expect.any(String)) Created by: Tirokk
Authored by mattwr18
Outdated (history rewrite) - original diff
@@ -100,6 +100,18 @@ describe('shout and unshout posts', () => { data: { Post: [{ id: 'another-user-post-id', shoutedBy: [{ id: 'current-user-id' }] }] }, errors: undefined, }) + // Test to make sure SHOUT relationship has "createdAt" date. + 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))
same as above... you can have an
it
block where you add a description for the test instead of a comment then runawait mutate({ mutation: mutationShoutPost, variables })
then this code you addedCreated by: Tirokk
Authored by roschaefer
Same as above
in this test case we already have two assertions - because of a weakness in theshout
resolver: Instead of returning the shouted post, we returnBoolean
. That's why we have to send another graphql query just to make sure it really got shouted by the current user.