Skip to content

Commit

Permalink
Add test for editing session ping when latest revision has no associa…
Browse files Browse the repository at this point in the history
…ted user
  • Loading branch information
laymonage committed Jul 12, 2024
1 parent c58e156 commit 1f67b5a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions wagtail/admin/tests/test_editing_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,47 @@ def test_ping_with_multiple_revisions_since_own_revision(self):
self.assertEqual(self.session.last_seen_at, TIMESTAMP_NOW)
self.assertFalse(self.session.is_editing)

@freeze_time(TIMESTAMP_NOW)
def test_ping_with_new_revision_that_has_no_user(self):
# Create a new revision without any user
with freeze_time(TIMESTAMP_3):
latest_revision = self.page.save_revision()

response = self.client.post(
reverse(
"wagtailadmin_editing_sessions:ping",
args=("wagtailcore", "page", self.page.id, self.session.id),
),
{"revision_id": self.original_revision.id},
)
self.assertEqual(response.status_code, 200)
response_json = response.json()
self.assertEqual(response_json["session_id"], self.session.id)

self.assertEqual(
response_json["other_sessions"],
[
{
# Should work even if the revision has no associated user
"session_id": None,
"user": "",
"last_seen_at": TIMESTAMP_3.isoformat(),
"is_editing": False,
"revision_id": latest_revision.id,
},
{
"session_id": self.other_session.id,
"user": "Vic Otheruser",
"last_seen_at": TIMESTAMP_2.isoformat(),
"is_editing": False,
"revision_id": None,
},
],
)
self.session.refresh_from_db()
self.assertEqual(self.session.last_seen_at, TIMESTAMP_NOW)
self.assertFalse(self.session.is_editing)

@freeze_time(TIMESTAMP_NOW)
def test_ping_session_ordering(self):
fourth_user = self.create_user(
Expand Down

0 comments on commit 1f67b5a

Please sign in to comment.