diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 6de4bd181..89760ce24 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -890,7 +890,8 @@ class TestDomainRequestAdmin(MockEppLib): @less_console_noise_decorator def test_status_logs(self): """ - Tests that the status changes are shown in a table on the domain request change form + Tests that the status changes are shown in a table on the domain request change form, + accurately and in chronological order. """ # Create a fake domain request and domain @@ -907,9 +908,7 @@ class TestDomainRequestAdmin(MockEppLib): self.assertEqual(response.status_code, 200) self.assertContains(response, domain_request.requested_domain.name) - # Table will contain From None To Started - self.assertContains(response, '') - self.assertContains(response, "None") + # Table will contain one row for Started self.assertContains(response, "Started", count=1) self.assertNotContains(response, "Submitted") @@ -921,11 +920,63 @@ class TestDomainRequestAdmin(MockEppLib): follow=True, ) - # Table will contain From None To Started - # Table will contain From Started To Submitted - self.assertContains(response, "None") - self.assertContains(response, "Started", count=2) - self.assertContains(response, "Submitted") + # Table will contain and extra row for Submitted + self.assertContains(response, "Started", count=1) + self.assertContains(response, "Submitted", count=1) + + domain_request.in_review() + domain_request.save() + + response = self.client.get( + "/admin/registrar/domainrequest/{}/change/".format(domain_request.pk), + follow=True, + ) + + # Table will contain and extra row for In review + self.assertContains(response, "Started", count=1) + self.assertContains(response, "Submitted", count=1) + self.assertContains(response, "In review", count=1) + + domain_request.action_needed() + domain_request.save() + + response = self.client.get( + "/admin/registrar/domainrequest/{}/change/".format(domain_request.pk), + follow=True, + ) + + # Table will contain and extra row for Action needed + self.assertContains(response, "Started", count=1) + self.assertContains(response, "Submitted", count=1) + self.assertContains(response, "In review", count=1) + self.assertContains(response, "Action needed", count=1) + + domain_request.in_review() + domain_request.save() + + response = self.client.get( + "/admin/registrar/domainrequest/{}/change/".format(domain_request.pk), + follow=True, + ) + + # Define the expected sequence of status changes + expected_status_changes = [ + "Started", + "Submitted", + "In review", + "Action needed", + "In review", + ] + + # Test for the order of status changes + for status_change in expected_status_changes: + self.assertContains(response, status_change, html=True) + + # Table now contains 2 rows for Approved + self.assertContains(response, "Started", count=1) + self.assertContains(response, "Submitted", count=1) + self.assertContains(response, "In review", count=2) + self.assertContains(response, "Action needed", count=1) @less_console_noise_decorator def test_analyst_can_see_and_edit_alternative_domain(self):