Skip to content

updatedAt is not updated when saving drafts #10436

Closed

Description

@franciscolourenco

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

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Jan 8, 2025
  2. added and removed
    validate-reproduction
    on Jan 8, 2025
  3. changed the title [-]`updatedAt` is not udpated when saving drafts[/-] [+]`updatedAt` is not updated when saving drafts[/+] on Jan 8, 2025
  4. added
    status: verified
    and removed
    status: needs-triage
    on Jan 9, 2025
  5. DanRibbens commented on Jan 10, 2025

    @DanRibbens
    Contributor
  6. removed
    status: verified
    on Jan 13, 2025
  7. github-actions commented on Jan 13, 2025

    @github-actions
    Contributor

    🚀 This is included in version v3.17.0

  8. github-actions commented on Jan 15, 2025

    @github-actions
    Contributor

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

  9. locked as resolved and limited conversation to collaborators on Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions