@@ -172,3 +172,52 @@ def test_public_channel_lookup_channel_version_and_channel_tokens_have_same_keys
172172 set (channel_version_response .data [0 ].keys ()),
173173 set (channel_response .data [0 ].keys ()),
174174 )
175+
176+ def test_channel_version_token_returns_snapshot_info_not_current_channel_info (self ):
177+ """
178+ When a channel version token is used, the returned name, description, and
179+ thumbnail should come from the ChannelVersion snapshot captured at publish time,
180+ not from the channel's current (possibly updated) values.
181+ """
182+ self .channel .main_tree .published = True
183+ self .channel .main_tree .save ()
184+
185+ # Set the channel info BEFORE the ChannelVersion is created so that the
186+ # snapshot captures these values.
187+ self .channel .name = "Original Published Name"
188+ self .channel .description = "Original published description"
189+ self .channel .thumbnail_encoding = {"base64" : generated_base64encoding ()}
190+ self .channel .version = 3
191+ self .channel .published_data = {"3" : {"version_notes" : "v3 notes" }}
192+ self .channel .save ()
193+
194+ # The ChannelVersion for version == channel.version is auto-created by
195+ # Channel.on_update(); re-fetch it to get the snapshot that was captured.
196+ channel_version = ChannelVersion .objects .get (channel = self .channel , version = 3 )
197+ version_token = channel_version .new_token ().token
198+
199+ # Now mutate the channel's info AFTER the snapshot was taken.
200+ self .channel .name = "Updated Name — should NOT appear in response"
201+ self .channel .description = "Updated description — should NOT appear in response"
202+ self .channel .thumbnail_encoding = {"base64" : "UPDATED_ENCODING" }
203+ self .channel .save ()
204+
205+ lookup_url = reverse (
206+ "get_public_channel_lookup" ,
207+ kwargs = {"version" : "v1" , "identifier" : version_token },
208+ )
209+ response = self .client .get (lookup_url )
210+
211+ self .assertEqual (response .status_code , 200 )
212+ self .assertEqual (len (response .data ), 1 )
213+ result = response .data [0 ]
214+
215+ # Values must match the snapshot, not the current channel state.
216+ self .assertEqual (result ["name" ], "Original Published Name" )
217+ self .assertEqual (result ["description" ], "Original published description" )
218+ self .assertEqual (result ["icon_encoding" ], generated_base64encoding ())
219+
220+ # Sanity-check: confirm the channel itself now has the updated values.
221+ self .channel .refresh_from_db ()
222+ self .assertNotEqual (result ["name" ], self .channel .name )
223+ self .assertNotEqual (result ["description" ], self .channel .description )
0 commit comments