Merge branch 'main' of https://github.com/GSA/notifications-admin into 2200-contextual-tooltips

This commit is contained in:
Jonathan Bobel
2025-01-20 14:41:15 -05:00
9 changed files with 60 additions and 30 deletions

View File

@@ -555,7 +555,7 @@
"filename": "tests/app/main/views/test_register.py", "filename": "tests/app/main/views/test_register.py",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", "hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false, "is_verified": false,
"line_number": 200, "line_number": 199,
"is_secret": false "is_secret": false
}, },
{ {
@@ -563,7 +563,7 @@
"filename": "tests/app/main/views/test_register.py", "filename": "tests/app/main/views/test_register.py",
"hashed_secret": "bb5b7caa27d005d38039e3797c3ddb9bcd22c3c8", "hashed_secret": "bb5b7caa27d005d38039e3797c3ddb9bcd22c3c8",
"is_verified": false, "is_verified": false,
"line_number": 273, "line_number": 272,
"is_secret": false "is_secret": false
} }
], ],
@@ -684,5 +684,5 @@
} }
] ]
}, },
"generated_at": "2025-01-13T20:16:58Z" "generated_at": "2025-01-16T16:38:48Z"
} }

View File

@@ -8,7 +8,7 @@
width: 100%; width: 100%;
max-width: 464px; max-width: 464px;
box-sizing: border-box; box-sizing: border-box;
padding: units(1); padding: units(2);
background: color('gray-cool-10'); background: color('gray-cool-10');
border: 1px solid color('gray-cool-10'); border: 1px solid color('gray-cool-10');
border-radius: 5px; border-radius: 5px;

View File

@@ -32,11 +32,7 @@ def check_feature_flags():
@main.route("/test/feature-flags") @main.route("/test/feature-flags")
def test_feature_flags(): def test_feature_flags():
return jsonify( return jsonify(
{ {"FEATURE_ABOUT_PAGE_ENABLED": current_app.config["FEATURE_ABOUT_PAGE_ENABLED"]}
"FEATURE_ABOUT_PAGE_ENABLED": current_app.config[
"FEATURE_ABOUT_PAGE_ENABLED"
]
}
) )
@@ -235,7 +231,6 @@ def contact():
return render_template( return render_template(
"views/contact.html", "views/contact.html",
navigation_links=about_notify_nav(), navigation_links=about_notify_nav(),
) )
@@ -268,7 +263,6 @@ def join_notify():
return render_template( return render_template(
"views/join-notify.html", "views/join-notify.html",
navigation_links=about_notify_nav(), navigation_links=about_notify_nav(),
) )

View File

@@ -1,3 +1,6 @@
import json
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient from app.notify_client import NotifyAdminAPIClient
@@ -15,10 +18,19 @@ class BillingAPIClient(NotifyAdminAPIClient):
) )
def get_free_sms_fragment_limit_for_year(self, service_id, year=None): def get_free_sms_fragment_limit_for_year(self, service_id, year=None):
frag_limit = redis_client.get(f"free-sms-fragment-limit-{service_id}-{year}")
if frag_limit is not None:
return json.loads(frag_limit.decode("utf-8"))
result = self.get( result = self.get(
"/service/{0}/billing/free-sms-fragment-limit".format(service_id), "/service/{0}/billing/free-sms-fragment-limit".format(service_id),
params=dict(financial_year_start=year), params=dict(financial_year_start=year),
) )
redis_client.set(
f"free-sms-fragment-limit-{service_id}-{year}",
json.dumps(result["free_sms_fragment_limit"]),
ex=30,
)
return result["free_sms_fragment_limit"] return result["free_sms_fragment_limit"]
def create_or_update_free_sms_fragment_limit( def create_or_update_free_sms_fragment_limit(

View File

@@ -1,3 +1,4 @@
import json
from datetime import datetime, timezone from datetime import datetime, timezone
from app.extensions import redis_client from app.extensions import redis_client
@@ -517,7 +518,18 @@ class ServiceAPIClient(NotifyAdminAPIClient):
return int(count) return int(count)
def get_global_notification_count(self, service_id): def get_global_notification_count(self, service_id):
return self.get("/service/{}/notification-count".format(service_id)) notification_count = redis_client.get(f"notification-count-{service_id}")
if notification_count is not None:
return json.loads(notification_count.decode("utf-8"))
notification_count = self.get(
"/service/{}/notification-count".format(service_id)
)
redis_client.set(
f"notification-count-{service_id}", json.dumps(notification_count), ex=30
)
return notification_count
def get_service_invite_data(self, redis_key): def get_service_invite_data(self, redis_key):
""" """

View File

@@ -51,35 +51,37 @@
{ {
"image_src": asset_url('images/calendar.svg'), "image_src": asset_url('images/calendar.svg'),
"card_heading": "Reminders", "card_heading": "Reminders",
"p_text": "In a text bubble // Your Quality Control food phone interview is on ((date)) at ((time)). Failure to "p_text": "Your Quality Control food phone interview is on ((date)) at ((time)). Failure to
attend may lead to closure of your benefits. Call 1-800-222-3333 with questions.", attend may lead to closure of your benefits. Call 1-800-222-3333 with questions.",
"alt_text": "reminder text example" "alt_text": "reminder text example"
}, },
{ {
"image_src": asset_url('images/alert.svg'), "image_src": asset_url('images/alert.svg'),
"card_heading": "Alerts to take action", "card_heading": "Alerts to take action",
"p_text": "In a text bubble // Your household's Medicaid coverage is expiring. To keep getting Medicaid, you must "p_text": "Your household's Medicaid coverage is expiring. To keep getting Medicaid, you must
complete your renewal by ((date)). You can renew online at dhs.state.gov…", complete your renewal by ((date)). You can renew online at dhs.state.gov…",
"alt_text": "alerts text example" "alt_text": "alerts text example"
}, },
{ {
"image_src": asset_url('images/alarm.svg'), "image_src": asset_url('images/alarm.svg'),
"card_heading": "Important status updates", "card_heading": "Important status updates",
"p_text": "In a text bubble // Your passport has been issued at the Los Angeles Passport Agency. Please come to the "p_text": "Your passport has been issued at the Los Angeles Passport Agency. Please come to the
desk between 1:30pm and 2:30pm today to pick up your passport…", desk between 1:30pm and 2:30pm today to pick up your passport…",
"alt_text": "status update text example" "alt_text": "status update text example"
}, },
] %} ] %}
{% for item in card_contents %} {% for item in card_contents %}
<div class="radius-lg border-2px maxw-tablet"> <div class="grid-container-tablet padding-3 radius-lg border-2px margin-left-0 ">
<div class="grid-row grid-gap-4 padding-2 padding-x-3 flex-align-center"> <h3 class="usa-card__heading padding-y-2">{{item.card_heading}}</h3>
<div class="grid-col flex-3"> <div class="grid-row grid-gap-3 flex-align-center">
<p><b>{{item.card_heading}}</b></p> <div class="grid-col-auto ">
<p>{{item.p_text}}</p> <p class="sms-message-wrapper">{{item.p_text}}</p>
</div>
<div class="grid-col-fill">
{% if item.image_src %}
<img src="{{ item.image_src }}" alt="{{ item.alt_text }}" class="height-15" />
{% endif %}
</div> </div>
{% if item.image_src %}
<img src="{{item.image_src}}" alt="{{ item.alt_text }}" class="height-15" />
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View File

@@ -122,9 +122,7 @@ def test_static_pages(client_request, mock_get_organization_by_domain, view, moc
session["user_id"] = None session["user_id"] = None
request( request(
_expected_status=302, _expected_status=302,
_expected_redirect="/sign-in?next={}".format( _expected_redirect="/sign-in?next={}".format(url_for("main.{}".format(view))),
url_for("main.{}".format(view))
),
) )

View File

@@ -144,9 +144,8 @@ def test_should_return_200_when_email_is_not_gov_uk(
_expected_status=200, _expected_status=200,
) )
assert ( assert "Enter a public sector email address." in normalize_spaces(
"Enter a public sector email address." page.select_one(".usa-error-message").text
in normalize_spaces(page.select_one(".usa-error-message").text)
) )

View File

@@ -10,7 +10,15 @@ def test_get_free_sms_fragment_limit_for_year_correct_endpoint(mocker, api_user_
expected_url = "/service/{}/billing/free-sms-fragment-limit".format(service_id) expected_url = "/service/{}/billing/free-sms-fragment-limit".format(service_id)
client = BillingAPIClient() client = BillingAPIClient()
mock_get = mocker.patch("app.notify_client.billing_api_client.BillingAPIClient.get") mock_get = mocker.patch(
"app.notify_client.billing_api_client.BillingAPIClient.get",
return_value={"free_sms_fragment_limit": 0},
)
mocker.patch(
"app.notify_client.billing_api_client.redis_client.get", return_value=None
)
mocker.patch("app.notify_client.billing_api_client.redis_client.set")
client.get_free_sms_fragment_limit_for_year(service_id, year=1999) client.get_free_sms_fragment_limit_for_year(service_id, year=1999)
mock_get.assert_called_once_with( mock_get.assert_called_once_with(
@@ -28,6 +36,11 @@ def test_post_free_sms_fragment_limit_for_current_year_endpoint(
) )
client = BillingAPIClient() client = BillingAPIClient()
mocker.patch(
"app.notify_client.billing_api_client.redis_client.get", return_value=None
)
mocker.patch("app.notify_client.billing_api_client.redis_client.set")
client.create_or_update_free_sms_fragment_limit( client.create_or_update_free_sms_fragment_limit(
service_id=service_id, free_sms_fragment_limit=1111 service_id=service_id, free_sms_fragment_limit=1111
) )