Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updatedAt is not updated when saving drafts #10436

Closed
franciscolourenco opened this issue Jan 8, 2025 · 3 comments · Fixed by #10503
Closed

updatedAt is not updated when saving drafts #10436

franciscolourenco opened this issue Jan 8, 2025 · 3 comments · Fixed by #10503

Comments

@franciscolourenco
Copy link
Contributor

franciscolourenco commented Jan 8, 2025

Describe the Bug

The updatedAt field is not being updated when saving new drafts, only when publishing documents.

Screen.Recording.2025-01-08.at.06.53.04.mp4

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/compare/franciscolourenco:reproduce-updated-at-in-drafts

Test results
ALL RESULTS
    [PASS] _Community Tests > updatedAt in published documents > should change when a document is updated (1046ms)
    [FAIL] _Community Tests > updatedAt in drafts > should change when a new draft is created (1037ms)
    [FAIL] _Community Tests > updatedAt in drafts > should change when a new draft is created (foundDraft.updatedAt) (1043ms)
    [FAIL] _Community Tests > updatedAt in drafts > should change when a new draft is created (version.version.updatedAt) (1041ms)
  ● _Community Tests › updatedAt in drafts › should change when a new draft is created

    expect(received).toBeGreaterThan(expected)

    Expected: > 1736314503000
    Received:   1736314503000

       97 |
       98 |       expect(updatedDraft.title).toEqual('changed')
    >  99 |       expect(+new Date(updatedDraft.updatedAt)).toBeGreaterThan(+new Date(post.updatedAt))
          |                                                 ^
      100 |     })
      101 |
      102 |     // failing test

      at Object.toBeGreaterThan (_community/int.spec.ts:99:49)

  ● _Community Tests › updatedAt in drafts › should change when a new draft is created (foundDraft.updatedAt)

    expect(received).toBeGreaterThan(expected)

    Expected: > 1736314504000
    Received:   1736314504000

      127 |
      128 |       expect(foundDraft.title).toEqual('changed')
    > 129 |       expect(+new Date(foundDraft.updatedAt)).toBeGreaterThan(+new Date(post.updatedAt))
          |                                               ^
      130 |     })
      131 |
      132 |     // failing test

      at Object.toBeGreaterThan (_community/int.spec.ts:129:47)

  ● _Community Tests › updatedAt in drafts › should change when a new draft is created (version.version.updatedAt)

    expect(received).toBeGreaterThan(expected)

    Expected: > 1736314505000
    Received:   1736314505000

      162 |
      163 |       expect(foundVersion.version.title).toEqual('changed')
    > 164 |       expect(+new Date(foundVersion.version.updatedAt)).toBeGreaterThan(+new Date(post.updatedAt))
          |                                                         ^
      165 |     })
      166 |   })
      167 | })

      at Object.toBeGreaterThan (_community/int.spec.ts:164:57)


Executed 4 of 4 (skipped 0) FAILED (16.201 secs)
TOTAL: 3 FAILED

Reproduction Steps

  1. Publish a document with drafts enabled
  2. Save a new draft
  3. Observe that the updatedAt field didn't change

Also check included tests.

Which area(s) are affected? (Select all that apply)

db-mongodb, area: ui, area: core

Environment Info

Payload: 3.15.1
Node: 22.8.0
Next: 15.1.3
@franciscolourenco franciscolourenco added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction labels Jan 8, 2025
@franciscolourenco franciscolourenco changed the title updatedAt is not udpated when saving drafts updatedAt is not updated when saving drafts Jan 8, 2025
@DanRibbens DanRibbens added status: verified If an issue has been reproduced and removed status: needs-triage Possible bug which hasn't been reproduced yet labels Jan 9, 2025
@DanRibbens
Copy link
Contributor

@paulpopus #9230

paulpopus added a commit that referenced this issue Jan 13, 2025
… when drafts are updated (#10503)

Fixes #10436

Fixes an issue where drafts' updatedAt timestamp is not being updated.
We weren't updating the `versionData` to have the right timestamp in the
saveVersion operation when drafts were being updated.

Added e2e tests to make sure 'Last Modified' is always different in both
autosave and non-autosave drafts.
@github-actions github-actions bot removed the status: verified If an issue has been reproduced label Jan 13, 2025
Copy link
Contributor

🚀 This is included in version v3.17.0

Copy link
Contributor

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants