Repository: cal-itp/benefits

Issue:
Engineering: Back-end - Combine logic for Agency Index and Getting Started page
_As a MST Senior Rider, when I go to benefits.calitp.org, I should see the new Introduction page design and content._

- Change the app logic to the following -
1. When there is only 1 transit agency, go directly to the agency index page (/mst)
2. From the agency index page, go directly to the verifier selection page (/eligibility/)
3. When there is only 1 eligibility verifier, go directly to the only start page (Login.gov verifier)

- Write tests for this new logic
- Update sample data for this new logic (??) so we can adequately test this in Dev, Staging

## How it is now

```mermaid
graph LR
    A[core:index] -->|redirect| B(core:agency_index)
    B -->|user clicks button| C(eligiblity:index)
    C -->|redirect| D(eligibility:start)
```

## After this is implemented

```mermaid
graph LR
    A[core:index] -->|redirect| B(core:agency_index)
    B -->|*redirect*| C(eligiblity:index)
    C -->|redirect| D(eligibility:start)
```



Discussion:

Resolving patch:
diff --git a/benefits/core/views.py b/benefits/core/views.py
--- a/benefits/core/views.py
+++ b/benefits/core/views.py
@@ -59,6 +59,9 @@ def agency_index(request, agency):
     session.reset(request)
     session.update(request, agency=agency, origin=agency.index_url)
 
+    if len(agency.eligibility_verifiers.all()) == 1:
+        return redirect(reverse("eligibility:index"))
+
     button = viewmodels.Button.primary(text=_("core.pages.index.continue"), url=reverse("eligibility:index"))
     button.label = _("core.pages.agency_index.button.label")
 


Test patch:
diff --git a/tests/cypress/specs/ui/eligibility-no-auth.cy.js b/tests/cypress/specs/ui/eligibility-no-auth.cy.js
--- a/tests/cypress/specs/ui/eligibility-no-auth.cy.js
+++ b/tests/cypress/specs/ui/eligibility-no-auth.cy.js
@@ -9,7 +9,6 @@ describe("Single verifier: Eligibility confirmation page spec", () => {
     cy.visit("/");
     // Selecting DEFTl will go down the single verifier flow
     cy.contains(agencies[1].fields.short_name).click();
-    cy.contains("Get started").click();
     cy.contains("Continue").click();
     cy.url().should("include", eligibility_confirm_url);
   });
diff --git a/tests/cypress/specs/ui/enrollment.cy.js b/tests/cypress/specs/ui/enrollment.cy.js
--- a/tests/cypress/specs/ui/enrollment.cy.js
+++ b/tests/cypress/specs/ui/enrollment.cy.js
@@ -5,7 +5,6 @@ describe("Single Verifier, No AuthProvider: Enrollment success page", () => {
     cy.visit("/");
     // Selecting DEFTl will go down the single verifier flow
     cy.contains(agencies[1].fields.short_name).click();
-    cy.contains("Get started").click();
     cy.contains("Continue").click();
     // https://github.com/cypress-io/cypress/issues/18690
     cy.window().then((win) => (win.location.href = "/enrollment/success"));
diff --git a/tests/pytest/core/test_views.py b/tests/pytest/core/test_views.py
--- a/tests/pytest/core/test_views.py
+++ b/tests/pytest/core/test_views.py
@@ -24,6 +24,21 @@ def test_homepage_single_agency(mocker, client):
     assert response.url == agencies[0].index_url
 
 
+@pytest.mark.django_db
+def test_homepage_single_agency_single_verifier(mocker, client):
+    # Agency set to DEFTl, which only has 1 verifier
+    agencies = TransitAgency.all_active()[1:]
+    mocker.patch("benefits.core.models.TransitAgency.all_active", return_value=agencies)
+
+    response = client.get(reverse("core:index"), follow=True)
+
+    # Setting follow to True allows the test to go thorugh redirects and returns the redirect_chain attr
+    # https://docs.djangoproject.com/en/3.2/topics/testing/tools/#making-requests
+    assert response.redirect_chain[0] == ("/deftl", 302)
+    assert response.redirect_chain[1] == ("/eligibility/", 302)
+    assert response.redirect_chain[-1] == ("/eligibility/start", 302)
+
+
 @pytest.mark.django_db
 def test_help(client):
     path = reverse("core:help")