Repository: cisagov/manage.get.gov

Issue:
Expiration date modal shows wrong "new expiration date"
### Current Behavior

When the expiration date is in the past, the expiration date shown in the modal window for domain renewal is showing a value that is the current date +number of extension years. (

### Expected Behavior

The date displayed should use the expiration date not the current date for printing the "new expiration date" value. Ie if it expired october 5th, 2023 and today is january 1st 2024, the number of years to extend by should be 2, and the date displayed should be October 5th, 2025

### Steps to Reproduce

1.have a domain that expired in the past
2. click the renewal button
3. see the date is wrong

hint stable has plenty that expired in the past, easier to use it for a visual


### Environment

any

### Additional Context

![image](https://github.com/cisagov/manage.get.gov/assets/109625347/1cd34ea5-fdf9-4bcb-a53b-25025533f261)
should just be a online code change, change line 1538 to not use date.today and instead use domain.registry_expiration_date 


### Issue Links

_No response_


Discussion:
Looks like this bug comes from a carryover when get calculated years from exp date wasn't a function yet. We should remove the if statement on lines 1537-1541 and just replace it with the content in 1540-1541

Resolving patch:
diff --git a/src/registrar/admin.py b/src/registrar/admin.py
--- a/src/registrar/admin.py
+++ b/src/registrar/admin.py
@@ -1600,12 +1600,8 @@ def changeform_view(self, request, object_id=None, form_url="", extra_context=No
                 # No expiration date was found. Return none.
                 extra_context["extended_expiration_date"] = None
                 return super().changeform_view(request, object_id, form_url, extra_context)
-
-            if curr_exp_date < date.today():
-                extra_context["extended_expiration_date"] = date.today() + relativedelta(years=years_to_extend_by)
-            else:
-                new_date = domain.registry_expiration_date + relativedelta(years=years_to_extend_by)
-                extra_context["extended_expiration_date"] = new_date
+            new_date = curr_exp_date + relativedelta(years=years_to_extend_by)
+            extra_context["extended_expiration_date"] = new_date
         else:
             extra_context["extended_expiration_date"] = None
 


Test patch:
diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py
--- a/src/registrar/tests/test_admin.py
+++ b/src/registrar/tests/test_admin.py
@@ -74,11 +74,10 @@ def setUp(self):
         )
         super().setUp()
 
-    @skip("TODO for another ticket. This test case is grabbing old db data.")
     @patch("registrar.admin.DomainAdmin._get_current_date", return_value=date(2024, 1, 1))
     def test_extend_expiration_date_button(self, mock_date_today):
         """
-        Tests if extend_expiration_date button extends correctly
+        Tests if extend_expiration_date modal gives an accurate date
         """
 
         # Create a ready domain with a preset expiration date
@@ -105,17 +104,11 @@ def test_extend_expiration_date_button(self, mock_date_today):
             # Follow the response
             response = response.follow()
 
-        # refresh_from_db() does not work for objects with protected=True.
-        # https://github.com/viewflow/django-fsm/issues/89
-        new_domain = Domain.objects.get(id=domain.id)
-
-        # Check that the current expiration date is what we expect
-        self.assertEqual(new_domain.expiration_date, date(2025, 5, 25))
-
         # Assert that everything on the page looks correct
         self.assertEqual(response.status_code, 200)
         self.assertContains(response, domain.name)
         self.assertContains(response, "Extend expiration date")
+        self.assertContains(response, "New expiration date: <b>May 25, 2025</b>")
 
         # Ensure the message we recieve is in line with what we expect
         expected_message = "Successfully extended the expiration date."
@@ -127,6 +120,7 @@ def test_extend_expiration_date_button(self, mock_date_today):
             extra_tags="",
             fail_silently=False,
         )
+
         mock_add_message.assert_has_calls([expected_call], 1)
 
     @less_console_noise_decorator