@@ -379,3 +379,63 @@ def test_special_permissions_distributable_false_for_draft_publish(self):
379379 license_obj .distributable ,
380380 "distributable must stay False for draft publishes" ,
381381 )
382+
383+ def test_draft_publish_populates_channel_snapshot_fields (self ):
384+ """
385+ After the first draft publish, channel_name, channel_description,
386+ channel_thumbnail_encoding, and channel_language on the draft
387+ ChannelVersion reflect the channel's state at publish time.
388+ """
389+ self .channel .name = "Snapshot Channel"
390+ self .channel .description = "Snapshot description"
391+ self .channel .thumbnail_encoding = {"base64" : "abc123" }
392+ self .channel .save ()
393+
394+ self ._run_draft_publish ()
395+ draft_version = self ._get_draft_version ()
396+
397+ self .assertEqual (draft_version .channel_name , "Snapshot Channel" )
398+ self .assertEqual (draft_version .channel_description , "Snapshot description" )
399+ self .assertEqual (draft_version .channel_thumbnail_encoding , {"base64" : "abc123" })
400+ self .assertEqual (draft_version .channel_language_id , self .channel .language_id )
401+
402+ def test_second_draft_publish_refreshes_channel_snapshot_fields (self ):
403+ """
404+ A second draft publish after mutating channel metadata must overwrite
405+ the stale snapshot values on the existing draft ChannelVersion row —
406+ for all four snapshot fields.
407+
408+ channel.language is changed from "en" to "fr" to confirm the refresh
409+ is not vacuous (the language snapshot must change to the new value).
410+ """
411+ self .channel .name = "Old Name"
412+ self .channel .description = "Old description"
413+ self .channel .thumbnail_encoding = {"base64" : "old_thumb" }
414+ # language is already "en" from testdata.channel(); no need to set it
415+ self .channel .save ()
416+
417+ self ._run_draft_publish ()
418+ draft_version = self ._get_draft_version ()
419+
420+ self .assertEqual (draft_version .channel_name , "Old Name" )
421+ self .assertEqual (
422+ draft_version .channel_thumbnail_encoding , {"base64" : "old_thumb" }
423+ )
424+ self .assertEqual (draft_version .channel_language_id , "en" )
425+
426+ # Mutate all four fields; language changes from "en" to "fr"
427+ self .channel .name = "New Name"
428+ self .channel .description = "New description"
429+ self .channel .thumbnail_encoding = {"base64" : "new_thumb" }
430+ self .channel .language_id = "fr"
431+ self .channel .save ()
432+
433+ self ._run_draft_publish ()
434+ draft_version .refresh_from_db ()
435+
436+ self .assertEqual (draft_version .channel_name , "New Name" )
437+ self .assertEqual (draft_version .channel_description , "New description" )
438+ self .assertEqual (
439+ draft_version .channel_thumbnail_encoding , {"base64" : "new_thumb" }
440+ )
441+ self .assertEqual (draft_version .channel_language_id , "fr" )
0 commit comments