@@ -311,6 +311,63 @@ def test_group_is_created(self):
311311 set (("qgisfeed.add_qgisfeedentry" , "qgisfeed.view_qgisfeedentry" )),
312312 )
313313
314+ def test_action_text_shown_on_qgis3_hidden_on_qgis4 (self ):
315+ """action_text must be appended to content for QGIS 3 clients and
316+ omitted for QGIS 4+ clients, regardless of the language used."""
317+ author = User .objects .get (username = "admin" )
318+ entry = QgisFeedEntry .objects .create (
319+ title = "Action-text test entry" ,
320+ content = "<p>Some real content here.</p>" ,
321+ action_text = "Double-cliquez ici pour en savoir plus." ,
322+ url = "https://www.example.com" ,
323+ author = author ,
324+ status = QgisFeedEntry .PUBLISHED ,
325+ publish_from = "2019-05-05T12:00:00Z" ,
326+ )
327+
328+ # --- QGIS 3 client ---
329+ c3 = Client (
330+ HTTP_USER_AGENT = "Mozilla/5.0 QGIS/33600/Fedora Linux (Workstation Edition)"
331+ )
332+ response = c3 .get ("/" )
333+ data = json .loads (response .content )
334+
335+ # action_text appended for QGIS 3
336+ match = next ((d for d in data if d ["title" ] == "Action-text test entry" ), None )
337+ self .assertIsNotNone (match )
338+ self .assertIn ("Double-cliquez ici pour en savoir plus." , match ["content" ])
339+ self .assertIn ("Some real content here" , match ["content" ])
340+
341+ # --- QGIS 4 client ---
342+ c4 = Client (
343+ HTTP_USER_AGENT = "Mozilla/5.0 QGIS/40000/Fedora Linux (Workstation Edition)"
344+ )
345+ response = c4 .get ("/" )
346+ data = json .loads (response .content )
347+
348+ # action_text must NOT appear in content for QGIS 4
349+ match = next ((d for d in data if d ["title" ] == "Action-text test entry" ), None )
350+ self .assertIsNotNone (match )
351+ self .assertNotIn ("Double-cliquez ici pour en savoir plus." , match ["content" ])
352+ self .assertIn ("Some real content here" , match ["content" ])
353+ self .assertNotIn ("action_text" , match )
354+
355+ # Entry with no action_text: content unchanged for all versions
356+ entry_no_action = QgisFeedEntry .objects .create (
357+ title = "No-action-text entry" ,
358+ content = "<p>Plain content.</p>" ,
359+ action_text = None ,
360+ url = "https://www.example.com" ,
361+ author = author ,
362+ status = QgisFeedEntry .PUBLISHED ,
363+ publish_from = "2019-05-05T12:00:00Z" ,
364+ )
365+ response = c4 .get ("/" )
366+ data = json .loads (response .content )
367+ match = next ((d for d in data if d ["title" ] == "No-action-text entry" ), None )
368+ self .assertIsNotNone (match )
369+ self .assertEqual (match ["content" ], "<p>Plain content.</p>" )
370+
314371 def test_admin_publish_from (self ):
315372 """Test that published entries have publish_from set"""
316373
0 commit comments