@@ -1269,11 +1269,16 @@ def test_execute_action_with_stakeholder_email(self):
12691269 stakeholder
12701270 )
12711271 self .version .file .update (is_signed = True )
1272+ self .another_version .file .update (approval_date = datetime (2025 , 2 , 3 ))
12721273 self .make_addon_promoted (self .addon , PROMOTED_GROUP_CHOICES .RECOMMENDED )
12731274 self ._test_reject_version (content_review = False , expected_emails_from_action = 1 )
12741275 assert len (mail .outbox ) == 4
12751276 assert mail .outbox [0 ].recipients () == [stakeholder .email ]
12761277 assert mail .outbox [0 ].subject == f'Rejection issued for { self .addon .name } '
1278+ assert (
1279+ f'{ self .another_version .version } will be the new current version of the '
1280+ 'Extension; first approved 2025-02-03.' in mail .outbox [0 ].body
1281+ )
12771282
12781283 def test_execute_action_after_reporter_appeal (self ):
12791284 original_job = CinderJob .objects .create (
@@ -1401,6 +1406,7 @@ def test_execute_action_delayed_with_stakeholder_email(self):
14011406 stakeholder
14021407 )
14031408 self .version .file .update (is_signed = True )
1409+ self .another_version .file .update (approval_date = datetime (2025 , 2 , 3 ))
14041410 self .make_addon_promoted (self .addon , PROMOTED_GROUP_CHOICES .RECOMMENDED )
14051411 self ._test_reject_version_delayed (
14061412 content_review = False , expected_emails_from_action = 1
@@ -1411,6 +1417,10 @@ def test_execute_action_delayed_with_stakeholder_email(self):
14111417 mail .outbox [0 ].subject
14121418 == f'14 day delayed rejection issued for { self .addon .name } '
14131419 )
1420+ assert (
1421+ f'{ self .another_version .version } will be the new current version of the '
1422+ 'Extension; first approved 2025-02-03.' in mail .outbox [0 ].body
1423+ )
14141424
14151425 def test_execute_action_delayed_after_reporter_appeal (self ):
14161426 original_job = CinderJob .objects .create (
@@ -1527,6 +1537,7 @@ def test_notify_stakeholders(self):
15271537 stakeholder
15281538 )
15291539 self .decision .update (private_notes = '' , reasoning = 'Bad things!' )
1540+ self .another_version .file .update (approval_date = datetime (2025 , 1 , 2 ))
15301541
15311542 # the addon is not promoted
15321543 assert self .addon .publicly_promoted_groups == []
@@ -1537,33 +1548,68 @@ def test_notify_stakeholders(self):
15371548 self .make_addon_promoted (self .addon , PROMOTED_GROUP_CHOICES .RECOMMENDED )
15381549 action .notify_stakeholders ('teh reason' )
15391550 assert len (mail .outbox ) == 1
1551+ body = mail .outbox [0 ].body
15401552 assert mail .outbox [0 ].recipients () == [stakeholder .email ]
15411553 assert mail .outbox [0 ].subject == f'teh reason issued for { self .addon .name } '
1542- assert 'Bad things!' in mail . outbox [ 0 ]. body
1543- assert 'Private notes:' not in mail . outbox [ 0 ]. body
1554+ assert 'Bad things!' in body
1555+ assert 'Private notes:' not in body
15441556 assert (
1545- f'teh reason for versions:\n { listed_version .version } ' in mail .outbox [0 ].body
1557+ f'teh reason for versions:\n '
1558+ f'[Listed] { listed_version .version } \n '
1559+ '[Unlisted] \n ' in body
1560+ )
1561+ assert f'/review-listed/{ self .addon .id } ' in body
1562+ assert f'/review-unlisted/{ self .addon .id } ' not in body
1563+ assert self .addon .get_absolute_url () in body
1564+
1565+ assert (
1566+ f'{ self .another_version .version } will be the new current version of the '
1567+ 'Extension; first approved 2025-01-02' in body
15461568 )
1547- assert f'/review-listed/{ self .addon .id } ' in mail .outbox [0 ].body
1548- assert f'/review-unlisted/{ self .addon .id } ' not in mail .outbox [0 ].body
1549- assert self .addon .get_absolute_url () in mail .outbox [0 ].body
15501569
15511570 # an unlisted version should result in second link to the unlisted review page
15521571 self .decision .target_versions .add (unlisted_version )
15531572 action .notify_stakeholders ('teh reason' )
15541573 assert len (mail .outbox ) == 2 # another email
1574+ body = mail .outbox [1 ].body
1575+ assert (
1576+ 'teh reason for versions:\n '
1577+ f'[Listed] { listed_version .version } \n '
1578+ f'[Unlisted] { unlisted_version .version } \n '
1579+ ) in body
1580+ assert f'/review-listed/{ self .addon .id } | ' in body
1581+ assert f'/review-unlisted/{ self .addon .id } ' in body
1582+ assert (
1583+ f'{ self .another_version .version } will be the new current version of the '
1584+ 'Extension; first approved 2025-01-02.' in body
1585+ )
1586+
1587+ # if the listed version(s) affected are the last approved versions indicate that
1588+ self .another_version .file .update (status = amo .STATUS_DISABLED )
1589+ self .old_version .file .update (status = amo .STATUS_AWAITING_REVIEW )
1590+ action .notify_stakeholders ('teh reason' )
1591+ assert len (mail .outbox ) == 3 # another email
1592+ body = mail .outbox [2 ].body
15551593 assert (
15561594 'teh reason for versions:\n '
1557- f'{ listed_version .version } , { unlisted_version .version } '
1558- ) in mail .outbox [1 ].body
1559- assert f'/review-listed/{ self .addon .id } | ' in mail .outbox [1 ].body
1560- assert f'/review-unlisted/{ self .addon .id } ' in mail .outbox [1 ].body
1595+ f'[Listed] { listed_version .version } \n '
1596+ f'[Unlisted] { unlisted_version .version } \n '
1597+ ) in body
1598+ assert 'The add-on will no longer be publicly viewable on AMO.' in body
1599+
1600+ # if no listed versions are affected we don't mention about the current version
1601+ self .decision .target_versions .set ([unlisted_version ])
1602+ action .notify_stakeholders ('teh reason' )
1603+ assert len (mail .outbox ) == 4 # another email
1604+ body = mail .outbox [3 ].body
1605+ assert 'will be the current' not in body
1606+ assert 'no longer' not in body
15611607
15621608 # And check that if no versions were signed we don't send an email
15631609 listed_version .file .update (is_signed = False )
15641610 unlisted_version .file .update (is_signed = False )
15651611 action .notify_stakeholders ('teh reason' )
1566- assert len (mail .outbox ) == 2 # still two
1612+ assert len (mail .outbox ) == 4
15671613
15681614 def test_notify_stakeholders_with_private_notes (self ):
15691615 stakeholder = user_factory ()
0 commit comments