mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-22 07:16:25 -04:00
Compare commits
8 Commits
e2e-tests-
...
notify-adm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
050ce753a2 | ||
|
|
038f9aead6 | ||
|
|
50e8e4bdb0 | ||
|
|
c05b0076fa | ||
|
|
2d8d2945b7 | ||
|
|
7c9fbe8417 | ||
|
|
4519a5a333 | ||
|
|
e600087266 |
@@ -133,7 +133,7 @@
|
||||
"filename": ".github/workflows/checks.yml",
|
||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||
"is_verified": false,
|
||||
"line_number": 68,
|
||||
"line_number": 71,
|
||||
"is_secret": false
|
||||
}
|
||||
],
|
||||
@@ -684,5 +684,5 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"generated_at": "2025-01-16T16:38:48Z"
|
||||
"generated_at": "2025-01-16T21:38:03Z"
|
||||
}
|
||||
|
||||
5
.github/pull_request_template.md
vendored
5
.github/pull_request_template.md
vendored
@@ -20,8 +20,3 @@ Please enter a detailed description here.
|
||||
* Consideration 1
|
||||
* Consideration 2
|
||||
* Consideration ...
|
||||
|
||||
## A11y Checks (if applicable)
|
||||
|
||||
* Conduct automated tests through [AxeDevTools](https://www.deque.com/axe/devtools/) and [WAVE](https://wave.webaim.org/)
|
||||
* Review the [Manual Checklist](https://docs.google.com/document/d/192bBXStebdXWtYhZQ73qaWMJhGcuSB1W6c9YBXhWZvc/edit?usp=sharing)
|
||||
|
||||
7
.github/workflows/checks.yml
vendored
7
.github/workflows/checks.yml
vendored
@@ -38,10 +38,13 @@ jobs:
|
||||
output: report-markdown
|
||||
annotations: failed-tests
|
||||
prnumber: ${{ steps.findPr.outputs.number }}
|
||||
- name: Check imports alphabetized
|
||||
run: poetry run isort ./app ./tests
|
||||
- name: Check pep8
|
||||
run: poetry run black ./app ./tests
|
||||
- name: Run style checks
|
||||
run: poetry run flake8 .
|
||||
- name: Check imports alphabetized
|
||||
run: poetry run isort --check-only ./app ./tests
|
||||
|
||||
- name: Check dead code
|
||||
run: make dead-code
|
||||
- name: Run js tests
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
width: 100%;
|
||||
max-width: 464px;
|
||||
box-sizing: border-box;
|
||||
padding: units(2);
|
||||
padding: units(1);
|
||||
background: color('gray-cool-10');
|
||||
border: 1px solid color('gray-cool-10');
|
||||
border-radius: 5px;
|
||||
|
||||
@@ -183,16 +183,6 @@ class E2ETest(Staging):
|
||||
"notify-admin-logo-upload-bucket-staging"
|
||||
)
|
||||
|
||||
API_HOST_NAME = "http://localhost:6011" # nosec B105 - only used in development
|
||||
# credential overrides
|
||||
DANGEROUS_SALT = "development-notify-salt"
|
||||
SECRET_KEY = "dev-notify-secret-key" # nosec B105 - only used in development
|
||||
# ADMIN_CLIENT_USER_NAME is called ADMIN_CLIENT_ID in api repo, they should match
|
||||
ADMIN_CLIENT_USER_NAME = "notify-admin"
|
||||
ADMIN_CLIENT_SECRET = (
|
||||
"dev-notify-secret-key" # nosec B105 - only used in development
|
||||
)
|
||||
|
||||
|
||||
class Demo(Staging):
|
||||
HEADER_COLOUR = "#6F72AF" # $mauve
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import csv
|
||||
from io import StringIO
|
||||
import re
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
@@ -28,6 +30,16 @@ class CsvFileValidator:
|
||||
self.message = message
|
||||
|
||||
def __call__(self, form, field):
|
||||
|
||||
data = Spreadsheet.from_file_form(form).as_dict
|
||||
data = data["data"]
|
||||
if data is not None and data != "":
|
||||
csv_file = StringIO(data)
|
||||
reader = csv.reader(csv_file)
|
||||
first_line = next(reader, None)
|
||||
if first_line is None or all(cell.strip() == "" for cell in first_line):
|
||||
raise ValidationError(f"No headers on row 1 in {field.data.filename}")
|
||||
|
||||
if not Spreadsheet.can_handle(field.data.filename):
|
||||
raise ValidationError(
|
||||
"{} is not a spreadsheet that Notify can read".format(
|
||||
|
||||
@@ -132,6 +132,7 @@ def send_messages(service_id, template_id):
|
||||
form = CsvUploadForm()
|
||||
if form.validate_on_submit():
|
||||
try:
|
||||
|
||||
upload_id = s3upload(
|
||||
service_id,
|
||||
Spreadsheet.from_file_form(form).as_dict,
|
||||
|
||||
@@ -42,7 +42,8 @@ class Spreadsheet:
|
||||
|
||||
@staticmethod
|
||||
def normalise_newlines(file_content):
|
||||
return "\r\n".join(file_content.read().decode("utf-8").splitlines())
|
||||
rows = file_content.read().decode("utf-8").splitlines()
|
||||
return "\r\n".join(rows)
|
||||
|
||||
@classmethod
|
||||
def from_rows(cls, rows, filename=""):
|
||||
|
||||
@@ -85,9 +85,8 @@ class NotifyAdminAPIClient(BaseAPIClient):
|
||||
abort(403)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
if os.getenv('NOTIFY_ENVIRONMENT') != "e2etest":
|
||||
self.check_inactive_service()
|
||||
self.check_inactive_user(args)
|
||||
self.check_inactive_service()
|
||||
self.check_inactive_user(args)
|
||||
return super().post(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import json
|
||||
|
||||
from app.extensions import redis_client
|
||||
from app.notify_client import NotifyAdminAPIClient
|
||||
|
||||
|
||||
@@ -18,19 +15,10 @@ class BillingAPIClient(NotifyAdminAPIClient):
|
||||
)
|
||||
|
||||
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(
|
||||
"/service/{0}/billing/free-sms-fragment-limit".format(service_id),
|
||||
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"]
|
||||
|
||||
def create_or_update_free_sms_fragment_limit(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from app.extensions import redis_client
|
||||
@@ -518,18 +517,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
return int(count)
|
||||
|
||||
def get_global_notification_count(self, 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
|
||||
return self.get("/service/{}/notification-count".format(service_id))
|
||||
|
||||
def get_service_invite_data(self, redis_key):
|
||||
"""
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% set page_title = "About Notify" %}
|
||||
|
||||
{% block per_page_title %}
|
||||
{{page_title}}
|
||||
{% endblock %}
|
||||
@@ -26,7 +27,7 @@
|
||||
{% set product_highlights = [
|
||||
{
|
||||
"svg_src": "#send",
|
||||
"card_heading": "Send customized one-way messages",
|
||||
"card_heading": "Send customized one-way customized messages",
|
||||
"p_text": "Upload a file with recipient phone numbers and Notify.gov sends customized messages",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -51,37 +51,35 @@
|
||||
{
|
||||
"image_src": asset_url('images/calendar.svg'),
|
||||
"card_heading": "Reminders",
|
||||
"p_text": "Your Quality Control food phone interview is on ((date)) at ((time)). Failure to
|
||||
"p_text": "In a text bubble // 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.",
|
||||
"alt_text": "reminder text example"
|
||||
},
|
||||
{
|
||||
"image_src": asset_url('images/alert.svg'),
|
||||
"card_heading": "Alerts to take action",
|
||||
"p_text": "Your household's Medicaid coverage is expiring. To keep getting Medicaid, you must
|
||||
"p_text": "In a text bubble // 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…",
|
||||
"alt_text": "alerts text example"
|
||||
},
|
||||
{
|
||||
"image_src": asset_url('images/alarm.svg'),
|
||||
"card_heading": "Important status updates",
|
||||
"p_text": "Your passport has been issued at the Los Angeles Passport Agency. Please come to the
|
||||
"p_text": "In a text bubble // 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…",
|
||||
"alt_text": "status update text example"
|
||||
},
|
||||
] %}
|
||||
{% for item in card_contents %}
|
||||
<div class="grid-container-tablet padding-3 radius-lg border-2px margin-left-0 ">
|
||||
<h3 class="usa-card__heading padding-y-2">{{item.card_heading}}</h3>
|
||||
<div class="grid-row grid-gap-3 flex-align-center">
|
||||
<div class="grid-col-auto ">
|
||||
<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 class="radius-lg border-2px maxw-tablet">
|
||||
<div class="grid-row grid-gap-4 padding-2 padding-x-3 flex-align-center">
|
||||
<div class="grid-col flex-3">
|
||||
<p><b>{{item.card_heading}}</b></p>
|
||||
<p>{{item.p_text}}</p>
|
||||
</div>
|
||||
{% if item.image_src %}
|
||||
<img src="{{item.image_src}}" alt="{{ item.alt_text }}" class="height-15" />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{% set product_highlights = [
|
||||
{
|
||||
"svg_src": "#chat",
|
||||
"card_heading": "Up to 100,000 messages to use over your first year*",
|
||||
"card_heading": "Up to 250,000 messages to use over your first year*",
|
||||
},
|
||||
{
|
||||
"svg_src": "#phone",
|
||||
|
||||
180
package-lock.json
generated
180
package-lock.json
generated
@@ -50,7 +50,7 @@
|
||||
"jest-environment-jsdom": "^29.2.2",
|
||||
"jshint": "2.13.6",
|
||||
"jshint-stylish": "2.2.1",
|
||||
"rollup": "^4.31.0",
|
||||
"rollup": "^4.30.1",
|
||||
"rollup-plugin-commonjs": "10.1.0",
|
||||
"rollup-plugin-node-resolve": "5.2.0"
|
||||
},
|
||||
@@ -2621,247 +2621,228 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.31.0.tgz",
|
||||
"integrity": "sha512-9NrR4033uCbUBRgvLcBrJofa2KY9DzxL2UKZ1/4xA/mnTNyhZCWBuD8X3tPm1n4KxcgaraOYgrFKSgwjASfmlA==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.30.1.tgz",
|
||||
"integrity": "sha512-pSWY+EVt3rJ9fQ3IqlrEUtXh3cGqGtPDH1FQlNZehO2yYxCHEX1SPsz1M//NXwYfbTlcKr9WObLnJX9FsS9K1Q==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm64": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.31.0.tgz",
|
||||
"integrity": "sha512-iBbODqT86YBFHajxxF8ebj2hwKm1k8PTBQSojSt3d1FFt1gN+xf4CowE47iN0vOSdnd+5ierMHBbu/rHc7nq5g==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.30.1.tgz",
|
||||
"integrity": "sha512-/NA2qXxE3D/BRjOJM8wQblmArQq1YoBVJjrjoTSBS09jgUisq7bqxNHJ8kjCHeV21W/9WDGwJEWSN0KQ2mtD/w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.31.0.tgz",
|
||||
"integrity": "sha512-WHIZfXgVBX30SWuTMhlHPXTyN20AXrLH4TEeH/D0Bolvx9PjgZnn4H677PlSGvU6MKNsjCQJYczkpvBbrBnG6g==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.30.1.tgz",
|
||||
"integrity": "sha512-r7FQIXD7gB0WJ5mokTUgUWPl0eYIH0wnxqeSAhuIwvnnpjdVB8cRRClyKLQr7lgzjctkbp5KmswWszlwYln03Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-x64": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.31.0.tgz",
|
||||
"integrity": "sha512-hrWL7uQacTEF8gdrQAqcDy9xllQ0w0zuL1wk1HV8wKGSGbKPVjVUv/DEwT2+Asabf8Dh/As+IvfdU+H8hhzrQQ==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.30.1.tgz",
|
||||
"integrity": "sha512-x78BavIwSH6sqfP2xeI1hd1GpHL8J4W2BXcVM/5KYKoAD3nNsfitQhvWSw+TFtQTLZ9OmlF+FEInEHyubut2OA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-arm64": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.31.0.tgz",
|
||||
"integrity": "sha512-S2oCsZ4hJviG1QjPY1h6sVJLBI6ekBeAEssYKad1soRFv3SocsQCzX6cwnk6fID6UQQACTjeIMB+hyYrFacRew==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.30.1.tgz",
|
||||
"integrity": "sha512-HYTlUAjbO1z8ywxsDFWADfTRfTIIy/oUlfIDmlHYmjUP2QRDTzBuWXc9O4CXM+bo9qfiCclmHk1x4ogBjOUpUQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-x64": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.31.0.tgz",
|
||||
"integrity": "sha512-pCANqpynRS4Jirn4IKZH4tnm2+2CqCNLKD7gAdEjzdLGbH1iO0zouHz4mxqg0uEMpO030ejJ0aA6e1PJo2xrPA==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.30.1.tgz",
|
||||
"integrity": "sha512-1MEdGqogQLccphhX5myCJqeGNYTNcmTyaic9S7CG3JhwuIByJ7J05vGbZxsizQthP1xpVx7kd3o31eOogfEirw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.31.0.tgz",
|
||||
"integrity": "sha512-0O8ViX+QcBd3ZmGlcFTnYXZKGbFu09EhgD27tgTdGnkcYXLat4KIsBBQeKLR2xZDCXdIBAlWLkiXE1+rJpCxFw==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.30.1.tgz",
|
||||
"integrity": "sha512-PaMRNBSqCx7K3Wc9QZkFx5+CX27WFpAMxJNiYGAXfmMIKC7jstlr32UhTgK6T07OtqR+wYlWm9IxzennjnvdJg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.31.0.tgz",
|
||||
"integrity": "sha512-w5IzG0wTVv7B0/SwDnMYmbr2uERQp999q8FMkKG1I+j8hpPX2BYFjWe69xbhbP6J9h2gId/7ogesl9hwblFwwg==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.30.1.tgz",
|
||||
"integrity": "sha512-B8Rcyj9AV7ZlEFqvB5BubG5iO6ANDsRKlhIxySXcF1axXYUyqwBok+XZPgIYGBgs7LDXfWfifxhw0Ik57T0Yug==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.31.0.tgz",
|
||||
"integrity": "sha512-JyFFshbN5xwy6fulZ8B/8qOqENRmDdEkcIMF0Zz+RsfamEW+Zabl5jAb0IozP/8UKnJ7g2FtZZPEUIAlUSX8cA==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.30.1.tgz",
|
||||
"integrity": "sha512-hqVyueGxAj3cBKrAI4aFHLV+h0Lv5VgWZs9CUGqr1z0fZtlADVV1YPOij6AhcK5An33EXaxnDLmJdQikcn5NEw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.31.0.tgz",
|
||||
"integrity": "sha512-kpQXQ0UPFeMPmPYksiBL9WS/BDiQEjRGMfklVIsA0Sng347H8W2iexch+IEwaR7OVSKtr2ZFxggt11zVIlZ25g==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.30.1.tgz",
|
||||
"integrity": "sha512-i4Ab2vnvS1AE1PyOIGp2kXni69gU2DAUVt6FSXeIqUCPIR3ZlheMW3oP2JkukDfu3PsexYRbOiJrY+yVNSk9oA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-loongarch64-gnu": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.31.0.tgz",
|
||||
"integrity": "sha512-pMlxLjt60iQTzt9iBb3jZphFIl55a70wexvo8p+vVFK+7ifTRookdoXX3bOsRdmfD+OKnMozKO6XM4zR0sHRrQ==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.30.1.tgz",
|
||||
"integrity": "sha512-fARcF5g296snX0oLGkVxPmysetwUk2zmHcca+e9ObOovBR++9ZPOhqFUM61UUZ2EYpXVPN1redgqVoBB34nTpQ==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.31.0.tgz",
|
||||
"integrity": "sha512-D7TXT7I/uKEuWiRkEFbed1UUYZwcJDU4vZQdPTcepK7ecPhzKOYk4Er2YR4uHKme4qDeIh6N3XrLfpuM7vzRWQ==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.30.1.tgz",
|
||||
"integrity": "sha512-GLrZraoO3wVT4uFXh67ElpwQY0DIygxdv0BNW9Hkm3X34wu+BkqrDrkcsIapAY+N2ATEbvak0XQ9gxZtCIA5Rw==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.31.0.tgz",
|
||||
"integrity": "sha512-wal2Tc8O5lMBtoePLBYRKj2CImUCJ4UNGJlLwspx7QApYny7K1cUYlzQ/4IGQBLmm+y0RS7dwc3TDO/pmcneTw==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.30.1.tgz",
|
||||
"integrity": "sha512-0WKLaAUUHKBtll0wvOmh6yh3S0wSU9+yas923JIChfxOaaBarmb/lBKPF0w/+jTVozFnOXJeRGZ8NvOxvk/jcw==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.31.0.tgz",
|
||||
"integrity": "sha512-O1o5EUI0+RRMkK9wiTVpk2tyzXdXefHtRTIjBbmFREmNMy7pFeYXCFGbhKFwISA3UOExlo5GGUuuj3oMKdK6JQ==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.30.1.tgz",
|
||||
"integrity": "sha512-GWFs97Ruxo5Bt+cvVTQkOJ6TIx0xJDD/bMAOXWJg8TCSTEK8RnFeOeiFTxKniTc4vMIaWvCplMAFBt9miGxgkA==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.31.0.tgz",
|
||||
"integrity": "sha512-zSoHl356vKnNxwOWnLd60ixHNPRBglxpv2g7q0Cd3Pmr561gf0HiAcUBRL3S1vPqRC17Zo2CX/9cPkqTIiai1g==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.30.1.tgz",
|
||||
"integrity": "sha512-UtgGb7QGgXDIO+tqqJ5oZRGHsDLO8SlpE4MhqpY9Llpzi5rJMvrK6ZGhsRCST2abZdBqIBeXW6WPD5fGK5SDwg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.31.0.tgz",
|
||||
"integrity": "sha512-ypB/HMtcSGhKUQNiFwqgdclWNRrAYDH8iMYH4etw/ZlGwiTVxBz2tDrGRrPlfZu6QjXwtd+C3Zib5pFqID97ZA==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.30.1.tgz",
|
||||
"integrity": "sha512-V9U8Ey2UqmQsBT+xTOeMzPzwDzyXmnAoO4edZhL7INkwQcaW1Ckv3WJX3qrrp/VHaDkEWIBWhRwP47r8cdrOow==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.31.0.tgz",
|
||||
"integrity": "sha512-JuhN2xdI/m8Hr+aVO3vspO7OQfUFO6bKLIRTAy0U15vmWjnZDLrEgCZ2s6+scAYaQVpYSh9tZtRijApw9IXyMw==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.30.1.tgz",
|
||||
"integrity": "sha512-WabtHWiPaFF47W3PkHnjbmWawnX/aE57K47ZDT1BXTS5GgrBUEpvOzq0FI0V/UYzQJgdb8XlhVNH8/fwV8xDjw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.31.0.tgz",
|
||||
"integrity": "sha512-U1xZZXYkvdf5MIWmftU8wrM5PPXzyaY1nGCI4KI4BFfoZxHamsIe+BtnPLIvvPykvQWlVbqUXdLa4aJUuilwLQ==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.30.1.tgz",
|
||||
"integrity": "sha512-pxHAU+Zv39hLUTdQQHUVHf4P+0C47y/ZloorHpzs2SXMRqeAWmGghzAhfOlzFHHwjvgokdFAhC4V+6kC1lRRfw==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.31.0.tgz",
|
||||
"integrity": "sha512-ul8rnCsUumNln5YWwz0ted2ZHFhzhRRnkpBZ+YRuHoRAlUji9KChpOUOndY7uykrPEPXVbHLlsdo6v5yXo/TXw==",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.30.1.tgz",
|
||||
"integrity": "sha512-D6qjsXGcvhTjv0kI4fU8tUuBDF/Ueee4SVX79VfNDXZa64TfCW1Slkb6Z7O1p7vflqZjcmOVdZlqf8gvJxc6og==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
@@ -12742,10 +12723,9 @@
|
||||
"license": "Unlicense"
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "4.31.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.31.0.tgz",
|
||||
"integrity": "sha512-9cCE8P4rZLx9+PjoyqHLs31V9a9Vpvfo4qNcs6JCiGWYhw2gijSetFbH6SSy1whnkgcefnUwr8sad7tgqsGvnw==",
|
||||
"license": "MIT",
|
||||
"version": "4.30.1",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.30.1.tgz",
|
||||
"integrity": "sha512-mlJ4glW020fPuLi7DkM/lN97mYEZGWeqBnrljzN0gs7GLctqX3lNWxKQ7Gl712UAX+6fog/L3jh4gb7R6aVi3w==",
|
||||
"dependencies": {
|
||||
"@types/estree": "1.0.6"
|
||||
},
|
||||
@@ -12757,25 +12737,25 @@
|
||||
"npm": ">=8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-android-arm-eabi": "4.31.0",
|
||||
"@rollup/rollup-android-arm64": "4.31.0",
|
||||
"@rollup/rollup-darwin-arm64": "4.31.0",
|
||||
"@rollup/rollup-darwin-x64": "4.31.0",
|
||||
"@rollup/rollup-freebsd-arm64": "4.31.0",
|
||||
"@rollup/rollup-freebsd-x64": "4.31.0",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.31.0",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.31.0",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.31.0",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.31.0",
|
||||
"@rollup/rollup-linux-loongarch64-gnu": "4.31.0",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu": "4.31.0",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.31.0",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.31.0",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.31.0",
|
||||
"@rollup/rollup-linux-x64-musl": "4.31.0",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.31.0",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.31.0",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.31.0",
|
||||
"@rollup/rollup-android-arm-eabi": "4.30.1",
|
||||
"@rollup/rollup-android-arm64": "4.30.1",
|
||||
"@rollup/rollup-darwin-arm64": "4.30.1",
|
||||
"@rollup/rollup-darwin-x64": "4.30.1",
|
||||
"@rollup/rollup-freebsd-arm64": "4.30.1",
|
||||
"@rollup/rollup-freebsd-x64": "4.30.1",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.30.1",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.30.1",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.30.1",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.30.1",
|
||||
"@rollup/rollup-linux-loongarch64-gnu": "4.30.1",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu": "4.30.1",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.30.1",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.30.1",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.30.1",
|
||||
"@rollup/rollup-linux-x64-musl": "4.30.1",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.30.1",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.30.1",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.30.1",
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
"jest-environment-jsdom": "^29.2.2",
|
||||
"jshint": "2.13.6",
|
||||
"jshint-stylish": "2.2.1",
|
||||
"rollup": "^4.31.0",
|
||||
"rollup": "^4.30.1",
|
||||
"rollup-plugin-commonjs": "10.1.0",
|
||||
"rollup-plugin-node-resolve": "5.2.0"
|
||||
}
|
||||
|
||||
@@ -898,6 +898,67 @@ def test_upload_csv_invalid_extension(
|
||||
assert "invalid.txt is not a spreadsheet that Notify can read" in page.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("file_contents", "expected_error"),
|
||||
[
|
||||
(
|
||||
"""
|
||||
|
||||
phone number, name
|
||||
+12028675109, example
|
||||
+12028675109,
|
||||
+12028675109, example
|
||||
""",
|
||||
(
|
||||
"There’s a problem with example.csv "
|
||||
"You need to put the column headers in row 1."
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_upload_csv_file_with_extra_blank_lines_is_flagged(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_service_template_with_placeholders,
|
||||
mock_get_users_by_service,
|
||||
mock_get_service_statistics,
|
||||
mock_get_job_doesnt_exist,
|
||||
mock_get_jobs,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
file_contents,
|
||||
expected_error,
|
||||
):
|
||||
|
||||
mocker.patch("app.main.views.send.set_metadata_on_csv_upload")
|
||||
|
||||
mocker.patch(
|
||||
"app.main.views.send.get_csv_metadata",
|
||||
return_value={"original_file_name": "example.csv"},
|
||||
)
|
||||
mocker.patch("app.main.views.send.s3upload", return_value=sample_uuid())
|
||||
|
||||
mocker.patch("app.main.views.send.s3download", return_value=file_contents)
|
||||
|
||||
page = client_request.post(
|
||||
"main.send_messages",
|
||||
service_id=service_one["id"],
|
||||
template_id=fake_uuid,
|
||||
_data={"file": (BytesIO("".encode("utf-8")), "example.csv")},
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
with client_request.session_transaction() as session:
|
||||
assert "file_uploads" not in session
|
||||
|
||||
assert page.select_one("input[type=file]").has_attr("accept")
|
||||
assert (
|
||||
page.select_one("input[type=file]")["accept"]
|
||||
== ".csv,.xlsx,.xls,.ods,.xlsm,.tsv"
|
||||
)
|
||||
assert normalize_spaces(page.select(".banner-dangerous")[0].text) == expected_error
|
||||
|
||||
|
||||
def test_upload_csv_size_too_big(
|
||||
client_request,
|
||||
mock_login,
|
||||
|
||||
@@ -10,15 +10,7 @@ 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)
|
||||
client = BillingAPIClient()
|
||||
|
||||
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")
|
||||
mock_get = mocker.patch("app.notify_client.billing_api_client.BillingAPIClient.get")
|
||||
|
||||
client.get_free_sms_fragment_limit_for_year(service_id, year=1999)
|
||||
mock_get.assert_called_once_with(
|
||||
@@ -36,11 +28,6 @@ def test_post_free_sms_fragment_limit_for_current_year_endpoint(
|
||||
)
|
||||
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(
|
||||
service_id=service_id, free_sms_fragment_limit=1111
|
||||
)
|
||||
|
||||
@@ -1,53 +1,11 @@
|
||||
import datetime
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from axe_core_python.sync_playwright import Axe
|
||||
from flask import Flask, current_app, url_for
|
||||
from flask import session as flask_session
|
||||
from flask_login import login_user
|
||||
from flask.testing import FlaskClient
|
||||
|
||||
from app import create_app
|
||||
from app.models.service import Service
|
||||
from app.models.user import User
|
||||
from app.notify_client.service_api_client import service_api_client
|
||||
from app.notify_client.user_api_client import user_api_client
|
||||
from notifications_python_client.errors import HTTPError
|
||||
from .. import TestClient
|
||||
|
||||
|
||||
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||
|
||||
|
||||
class TestClient(FlaskClient):
|
||||
def login(self, user, mocker=None, service=None):
|
||||
# Skipping authentication here and just log them in
|
||||
model_user = User(user)
|
||||
with self.session_transaction() as session:
|
||||
session["current_session_id"] = model_user.current_session_id
|
||||
session["user_id"] = model_user.id
|
||||
if mocker:
|
||||
mocker.patch("app.user_api_client.get_user", return_value=user)
|
||||
if mocker and service:
|
||||
with self.session_transaction() as session:
|
||||
session["service_id"] = service["id"]
|
||||
mocker.patch(
|
||||
"app.service_api_client.get_service", return_value={"data": service}
|
||||
)
|
||||
|
||||
with patch("app.events_api_client.create_event"):
|
||||
login_user(model_user, force=True) # forces the user to be logged in.
|
||||
with self.session_transaction() as test_session:
|
||||
for key, value in flask_session.items():
|
||||
test_session[key] = value
|
||||
|
||||
def logout(self, user):
|
||||
self.get(url_for("main.sign_out"))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def end_to_end_context(browser):
|
||||
context = browser.new_context()
|
||||
@@ -78,107 +36,3 @@ def check_axe_report(page):
|
||||
"minor",
|
||||
"moderate",
|
||||
], f"Accessibility violation: {violation}"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def notify_admin_e2e():
|
||||
os.environ["NOTIFY_ENVIRONMENT"] = "e2etest"
|
||||
|
||||
application = Flask("app")
|
||||
create_app(application)
|
||||
|
||||
application.test_client_class = TestClient
|
||||
|
||||
with application.app_context():
|
||||
yield application
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def default_user(notify_admin_e2e):
|
||||
user_data = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
|
||||
return user_data
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(notify_admin_e2e, default_user):
|
||||
"""
|
||||
Do not use this fixture directly – use `client_request` instead
|
||||
"""
|
||||
with notify_admin_e2e.test_request_context(), notify_admin_e2e.test_client() as client:
|
||||
client.allow_subdomain_redirects = True
|
||||
try:
|
||||
client.login(default_user)
|
||||
yield client
|
||||
finally:
|
||||
client.logout(default_user)
|
||||
|
||||
|
||||
# Need e2e service defined here?
|
||||
@pytest.fixture()
|
||||
def default_service(browser, client, default_user):
|
||||
current_date_time = datetime.datetime.now()
|
||||
now = current_date_time.strftime("%m/%d/%Y %H:%M:%S")
|
||||
browser_type = browser.browser_type.name
|
||||
service_name = f"E2E Federal Test Service {now} - {browser_type}"
|
||||
|
||||
service_id = service_api_client.create_service(
|
||||
service_name=service_name,
|
||||
organization_type="federal",
|
||||
message_limit=current_app.config["DEFAULT_SERVICE_LIMIT"],
|
||||
restricted=True,
|
||||
user_id=default_user["id"],
|
||||
email_from=default_user["email_address"],
|
||||
)
|
||||
|
||||
print("*" * 80)
|
||||
print(service_id)
|
||||
|
||||
service_data = service_api_client.get_service(service_id)
|
||||
|
||||
service = Service(service_data)
|
||||
|
||||
from pprint import pprint
|
||||
pprint(dir(service))
|
||||
|
||||
try:
|
||||
yield service
|
||||
finally:
|
||||
service_api_client.archive_service(service.id, None)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def _set_up_user(
|
||||
default_service,
|
||||
name,
|
||||
email_addr,
|
||||
phone,
|
||||
password,
|
||||
auth_type,
|
||||
permissions,
|
||||
folder_permissions,
|
||||
):
|
||||
user = user_api_client.get_user_by_email_or_none(email_addr)
|
||||
if user is None:
|
||||
user = user_api_client.register_user(
|
||||
name, email_addr, phone, password, auth_type
|
||||
)
|
||||
user_api_client.add_user_to_service(
|
||||
default_service.id, user.id, permissions, folder_permissions
|
||||
)
|
||||
user_api_client.activate_user(user.id)
|
||||
yield user
|
||||
user_api_client.deactivate_user(user.id)
|
||||
service_api_client.remove_user_from_service(user.id, default_service.id)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin_user(default_service):
|
||||
with _set_up_user(
|
||||
default_service,
|
||||
"E2E Admin Test",
|
||||
"admin@nowhere.huh",
|
||||
"1234567890",
|
||||
"password",
|
||||
"sms",
|
||||
) as user:
|
||||
yield user
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from tests.conftest import create_user
|
||||
from tests.end_to_end.conftest import check_axe_report
|
||||
|
||||
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||
|
||||
|
||||
def create_new_template(page):
|
||||
|
||||
current_service_link = page.get_by_text("Current service")
|
||||
expect(current_service_link).to_be_visible()
|
||||
current_service_link.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
send_messages_button = page.get_by_role("link", name="Send messages")
|
||||
expect(send_messages_button).to_be_visible()
|
||||
send_messages_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
create_template_button = page.get_by_role("button", name="New template")
|
||||
expect(create_template_button).to_be_visible()
|
||||
create_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
start_with_a_blank_template_radio = page.get_by_text("Start with a blank template")
|
||||
expect(start_with_a_blank_template_radio).to_be_visible()
|
||||
start_with_a_blank_template_radio.click()
|
||||
|
||||
continue_button = page.get_by_role("button", name="Continue")
|
||||
|
||||
# continue_button = page.get_by_text("Continue")
|
||||
expect(continue_button).to_be_visible()
|
||||
continue_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
template_name_input = page.get_by_text("Template name")
|
||||
expect(template_name_input).to_be_visible()
|
||||
template_name = str(uuid.uuid4())
|
||||
template_name_input.fill(template_name)
|
||||
message_input = page.get_by_role("textbox", name="Message")
|
||||
expect(message_input).to_be_visible()
|
||||
message = "Test message for e2e test"
|
||||
message_input.fill(message)
|
||||
|
||||
save_button = page.get_by_text("Save")
|
||||
expect(save_button).to_be_visible()
|
||||
save_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
assert template_name in page.content()
|
||||
assert message in page.content()
|
||||
|
||||
|
||||
def update_template(page):
|
||||
# Check update template button is visible
|
||||
update_template_button = page.get_by_text("Edit this template")
|
||||
expect(update_template_button).to_be_visible()
|
||||
update_template_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
assert "Edit text message template" in page.content()
|
||||
|
||||
# Update template name and message
|
||||
template_name_input = page.get_by_text("Template name")
|
||||
expect(template_name_input).to_be_visible()
|
||||
template_name = str(uuid.uuid4())
|
||||
template_name_input.fill(template_name)
|
||||
message_input = page.get_by_role("textbox", name="Message")
|
||||
expect(message_input).to_be_visible()
|
||||
message = "Test message is updated for e2e test"
|
||||
message_input.fill(message)
|
||||
|
||||
# Save new template info
|
||||
save_button = page.get_by_text("Save")
|
||||
expect(save_button).to_be_visible()
|
||||
save_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
# Check new template name, message and last edited text are on page.
|
||||
assert template_name in page.content()
|
||||
assert message in page.content()
|
||||
# assert "Last edited just now" in page.content()
|
||||
|
||||
|
||||
def delete_template(page):
|
||||
# Check delete template link is visible
|
||||
delete_template_link = page.get_by_text("Delete this template")
|
||||
expect(delete_template_link).to_be_visible()
|
||||
delete_template_link.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
# Check confirmation text is visible
|
||||
assert "Are you sure you want to delete" in page.content()
|
||||
|
||||
# Check that the delete button is visible
|
||||
delete_button = page.get_by_text("Yes, delete")
|
||||
expect(delete_button).to_be_visible()
|
||||
delete_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
assert "Select or create a template" in page.content()
|
||||
|
||||
|
||||
def test_campaign_manager_core_user_story(default_service, end_to_end_context):
|
||||
create_user()
|
||||
page = end_to_end_context.new_page()
|
||||
# page.goto(f"{E2E_TEST_URI}/sign-in")
|
||||
# Wait for the next page to fully load.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
current_date_time = datetime.datetime.now()
|
||||
# new_service_name = "E2E Federal Test Service {now} - {browser_type}".format(
|
||||
# now=current_date_time.strftime("%m/%d/%Y %H:%M:%S"),
|
||||
# browser_type=page.context.browser.browser_type.name,
|
||||
# )
|
||||
# page.goto(f"{E2E_TEST_URI}/accounts")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# page.wait_for_load_state("domcontentloaded")
|
||||
# check_axe_report(page)
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# Check the page title exists and matches what we expect.
|
||||
# expect(page).to_have_title(re.compile("Choose service"))
|
||||
|
||||
# Check for the sign in heading.
|
||||
# sign_in_heading = page.get_by_role("heading", name="Choose service")
|
||||
# expect(sign_in_heading).to_be_visible()
|
||||
|
||||
# Retrieve some prominent elements on the page for testing.
|
||||
# add_service_button = page.get_by_role(
|
||||
# "button", name=re.compile("Add a new service")
|
||||
# )
|
||||
|
||||
# expect(add_service_button).to_be_visible()
|
||||
|
||||
# existing_service_link = page.get_by_role("link", name=new_service_name)
|
||||
|
||||
# Check to see if the service was already created - if so, we should fail.
|
||||
# TODO: Figure out how to make this truly isolated, and/or work in a
|
||||
# delete service workflow.
|
||||
# expect(existing_service_link).to_have_count(0)
|
||||
|
||||
# Click on add a new service.
|
||||
a # dd_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# page.wait_for_load_state("domcontentloaded")
|
||||
# check_axe_report(page)
|
||||
|
||||
# Check for the sign in heading.
|
||||
# about_heading = page.get_by_role("heading", name="About your service")
|
||||
# expect(about_heading).to_be_visible()
|
||||
|
||||
# Retrieve some prominent elements on the page for testing.
|
||||
# service_name_input = page.locator('xpath=//input[@name="name"]')
|
||||
# add_service_button = page.get_by_role("button", name=re.compile("Add service"))
|
||||
|
||||
# expect(service_name_input).to_be_visible()
|
||||
# expect(add_service_button).to_be_visible()
|
||||
|
||||
# Fill in the form.
|
||||
# service_name_input.fill(new_service_name)
|
||||
|
||||
# Click on add service.
|
||||
# add_service_button.click()
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# page.wait_for_load_state("domcontentloaded")
|
||||
# check_axe_report(page)
|
||||
|
||||
# TODO this fails on staging due to duplicate results on 'get_by_text'
|
||||
# Check for the service name title and heading.
|
||||
# service_heading = page.get_by_text(new_service_name, exact=True)
|
||||
# expect(service_heading).to_be_visible()
|
||||
|
||||
print("*" * 80)
|
||||
print(default_service.name)
|
||||
print("*" * 80)
|
||||
|
||||
expect(page).to_have_title(re.compile(default_service.name))
|
||||
|
||||
create_new_template(page)
|
||||
|
||||
update_template(page)
|
||||
|
||||
delete_template(page)
|
||||
|
||||
_teardown(page)
|
||||
|
||||
|
||||
def _teardown(page):
|
||||
page.click("text='Settings'")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
page.click("text='Delete this service'")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
page.click("text='Yes, delete'")
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
page.wait_for_load_state("domcontentloaded")
|
||||
check_axe_report(page)
|
||||
|
||||
# Check to make sure that we've arrived at the next page.
|
||||
# Check the page title exists and matches what we expect.
|
||||
expect(page).to_have_title(re.compile("Choose service"))
|
||||
Reference in New Issue
Block a user