Skip to content
Snippets Groups Projects

Added createdAt date for follow and shout

Closed Hannes Heine requested to merge pr1853head into pr1853base

Created by: Tirokk

KapilJ22 Authored by KapilJ22 Merged


:cake: Pullrequest

Issues

  • None

Todo

  • None

Merge request reports

Closed by avatar (Jun 26, 2025 7:07am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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

    mattwr18 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 multiple expect in the same it block

  • Created by: Tirokk

    roschaefer 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

    mattwr18 Authored by mattwr18


    you can run await mutate({ mutation: mutationFollowUser, variables }) then this code

  • Created by: Tirokk

    KapilJ22 Authored by KapilJ22


    @mattwr18 - Much appreciated your review. Implemented changes as you requested.

  • Created by: Tirokk

    KapilJ22 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.

  • Hannes Heine
    Hannes Heine @Elweyn started a thread on commit aaa1fea5
  • 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

      mattwr18 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 run await mutate({ mutation: mutationShoutPost, variables }) then this code you added

    • Created by: Tirokk

      roschaefer Authored by roschaefer


      Same as above :point_up: in this test case we already have two assertions - because of a weakness in the shout resolver: Instead of returning the shouted post, we return Boolean. That's why we have to send another graphql query just to make sure it really got shouted by the current user.

    • Created by: Tirokk

      KapilJ22 Authored by KapilJ22


      Thanks again for review @mattwr18 . it's done as well.

    • Created by: Tirokk

      KapilJ22 Authored by KapilJ22


      Thanks @roschaefer for review. I made changes as requested.

  • Created by: Mogge

    Review: Changes requested

    hey really great stuff, just would love to see these tests in their own it block. see below

  • Created by: Mogge

    Review: Approved

    really great @drone-cloud thank you so much for you contribution and persistence!!

  • Please register or sign in to reply
    Loading