Commit Graph

136 Commits

Author SHA1 Message Date
Kenneth Kehl
193e1f7952 fix duplicate test name 2024-08-08 13:16:29 -07:00
Kenneth Kehl
38a6c35afd add test 2024-08-08 13:11:58 -07:00
Kenneth Kehl
058a999ed0 ugh 2024-07-11 09:38:32 -07:00
stvnrlly
f600dd95d6 remove email branding 2023-12-18 16:10:12 -05:00
Kenneth Kehl
b487a915f6 fix remaining tests 2023-10-30 08:42:11 -07:00
Kenneth Kehl
bd2ea81081 more fixes 2023-10-26 11:38:03 -07:00
Carlo Costino
acb70b43cd Reformatted and cleaned up more tests.
Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-10-12 10:24:48 -04:00
Jonathan Bobel
a752566e2f Fixed a test 2023-09-18 12:29:40 -04:00
Jonathan Bobel
2e16d8d31b Updates after merging black 2023-08-28 12:12:21 -04:00
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Kenneth Kehl
dc342385ce notify-admin-641 let platform admins export listing of all users (#647)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
Co-authored-by: stvnrlly <steven.reilly@gsa.gov>
2023-07-26 12:08:55 -04:00
Steven Reilly
13d0e46b52 blunt rename of org (#620) 2023-07-12 12:09:44 -04:00
Jonathan Bobel
e0d2d74067 Update dashboard and template flow (#514)
* Updated header and footer
* Moved files around and updated gulpfile to correct the build process when it goes to production
* Updated fonts
* Adjusted grid templating
* Adding images to assets
* Updated account pages, dashboard, and pages in message sending flow
* Updated the styling for the landing pages in the account section once logged in
2023-06-08 13:12:00 -04:00
Ryan Ahearn
2ad21a6f4f Replace UK phone numbers in tests with US numbers 2023-01-06 11:19:56 -05:00
stvnrlly
59d4f09d01 a few more organisation edits 2023-01-05 21:33:15 -05:00
stvnrlly
6233e35902 more accurate css classes 2022-12-12 15:15:50 -05:00
stvnrlly
420845fac7 remove antivirus code (email does not allow attachments via ui) 2022-12-05 16:35:46 -05:00
stvnrlly
944715ac46 big commit with letters removal 2022-12-05 15:33:44 -05:00
stvnrlly
f16b5dd1c4 remove broadcast-related code 2022-10-04 03:04:13 +00:00
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
Chris Hill-Scott
8b7f2fbf04 Stop using _external=True in tests
It looks like, by default, Flask no longer makes full URLs, for example
`https://example.com/path`. Instead it does `/path`. This will still
work fine, and if anything is better because it reduces the number of
bytes of HTML we are sending.

It won’t mean that requests go over `http` instead of `https` without
the protocol because we set the appropriate HSTS header here:
0c57da7781/ansible/roles/paas-proxy/templates/admin.conf.j2 (L11)

This commit changes all our tests to reflect that URLs no longer have
the protocol and domain in them. `_external=True` is Flask’s way of
saying whether a URL should be generated with the domain and protocol
(`True`) or without it (`False`).

Again, I can’t find the changelog or diff where this was introuduced,
but if you’d like to go spelunking then here’s a starting point:
50374e3cfe/src/flask/helpers.py (L192)
2022-06-06 12:12:52 +01:00
Leo Hemsted
971101d07c clean up test_platform_admin string concatenation
make it consistent - always use a + to concatenate strings, always have
that + at the end of the line.

(also remove a rogue "when" from some test names)
2022-04-11 14:55:58 +01:00
Leo Hemsted
b3f5bb6435 add new daily sms provider volumes report
nearly identical to the daily-volumes-report but sms only, and split up
by provider
2022-04-11 14:40:31 +01:00
Rebecca Law
de46fb6477 Merge pull request #4183 from alphagov/volume_reports
Report for total notifications sent per day for each channel.
2022-03-09 15:15:03 +00:00
Rebecca Law
c6e67d1690 Fix column names
Add unit test
2022-03-09 15:02:52 +00:00
Ben Thorner
81d9c73543 Bump -utils to 55.0.0
This renames "delete_cache_keys_by_pattern" to match the new method
name, which will also catch exceptions if Redis is down [1].

Note that this also includes a change to RecipientCSV [2], which has
no effect because the new default is the same as the old behaviour.

[1]: https://github.com/alphagov/notifications-utils/pull/949
[2]: https://github.com/alphagov/notifications-utils/pull/947/files#diff-a8a994bf655634f89dc7439880708b4ff0d780ac1bd8033827d8aaa2692a8e0fR373
2022-03-07 13:53:57 +00:00
Ben Thorner
ebbfd20472 Make it easy to clear cache for all key formats
Having to submit the form for each choice separately slowed us down
during an incident where Redis was unavailable and came back with
stale data, which we had to clear manually.

Note: we don't want to use the "flush" feature in case there are other
keys in Redis, which may not be safe to remove.
2022-02-21 15:09:03 +00:00
Ben Thorner
16a14cd642 Rewrite test for clear cache radio buttons
This was missing an existing option to clear for broadcasts.
2022-02-21 14:11:53 +00:00
Ben Thorner
8396412ce1 Report all cache keys that were deleted
This will make it easier to add another test / feature to clear all
the cache keys. It's debatable which of "sum" and "max" is useful:

- "max" is a better (although still not accurate) indicator of the
number of "things" affected e.g. templates, services, etc.

- "sum" makes sense in places where "max" doesn't e.g. when we clear
the "organisations" group, which doesn't equate to individual orgs.

Using "sum() ... across" seems like a reasonable compromise and makes
it clear that we're iterating over different kinds of keys.

While the pluralisation is nice, I don't think it's worth the effort
to make it work for both "object(s)" and "format(s)".
2022-02-21 14:11:49 +00:00
Pea Tyczynska
f1d5c33fda Rename sms_fragments to sms_chargeable_units
This field caused some confusion and lots of unnecessary work
to our colleague because of unclear name.

The field was named sms_fragments, where in fact the value of
the field is: those sms fragments that go above free allowance
multiplied by the rate multiplier.

The new name was chosen through consultation with colleagues
who use billing report the most.
2022-01-18 18:05:07 +00:00
Chris Hill-Scott
7e707db4b2 Replace uses of client.get and client.post
We have a `client_request` fixture which does a bunch of useful stuff
like:
- checking the status code of the response
- returning a `BeautifulSoup` object

Lots of our tests still use an older fixture called `client`. This is
not as good because it:
- returns a raw `Response` object
- doesn’t do the additional checks
- means our tests contain a lot of repetetive boilerplate like `page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')`

This commit converts all the tests which had a `client.get(…)` or
`client.post(…)` statement to use their equivalents on `client_request`
instead.

Subsequent commits will remove uses of `client` in other tests, but
doing it this way means the work can be broken up into more manageable
chunks.
2022-01-10 14:39:45 +00:00
Chris Hill-Scott
8b93a977a0 Remove temporary raw_response argument
We added a new argument to `client_request.get` and
`client_request.post` to specify that it should return a raw `Response`
object rather than an instance of `BeautifulSoup`.

This is useful because sometimes we need to look at stuff like the
response headers.

However it turns out we already have a separate method for this, so
rather than invent something new I think it’s better to stick with the
thing we already have.
2022-01-10 14:39:45 +00:00
Chris Hill-Scott
50eae6f935 Stop using platform_admin_client fixture
We have a `client_request` fixture which does a bunch of useful stuff
like:
- checking the status code of the response
- returning a `BeautifulSoup` object

For most tests of a platform admin view we used `platform_admin_client`
instead. This is not as good because it returns a raw `Response` object
and doesn’t do the additional checks.

This commit converts all the tests using `platform_admin_client` to:
use new `client_request` and log in as `platform_admin_user` before
making any requests.

This is also nice because it makes any test easy to parametrize with
additional users, for example to test differences in behaviour dependant
on being platform admin or not.
2022-01-10 14:39:40 +00:00
Katie Smith
1862cd0223 Update data format for platform admin report
The format of dates returned from API for the "Monthly notification
statuses for live services" report has changed, so we no longer need to
format the dates here.

https://github.com/alphagov/notifications-api/pull/3279
2021-06-23 16:14:58 +01:00
Katie Smith
c1bfc280b7 Add total_letters to the billing report
This adds an extra column to the report that can be downloaded from
`platform-admin/reports/usage-for-all-services`.
2021-06-11 11:08:33 +01:00
Pea Tyczynska
38cfee6390 Rename usage report to billing report
Because only services with bills to pay are included, and
we started including billing details.

Also rename endpoints and file names to match this.
2021-03-30 14:13:54 +01:00
Pea Tyczynska
95f46ced8a Add billing details fields to Usage for all services report 2021-03-30 14:11:42 +01:00
Chris Hill-Scott
c8943cec8b Report performance platform report
We used to upload this to performance platform to show the list of
services and organisations.

There is no longer a performance platform to upload this file to.
2021-03-15 10:21:36 +00:00
Tom Byers
663df4a4f9 Remove <div>s from big_number text
An accessiblity audit done as part of Notify's
service assessment raised the following problem
with our big_number component.

When you turn CSS off, the sentence in the
component is split onto separate lines.

This was because the number part is wrapped in a
<div> which browsers were interpreting as being a
separate sentence to the label.

So "1 letter", where "letter" is the label, was
seen as:

"1"
"letter"

The accessibility expert consulted on this pointed
out that this would sound confusing for users of
screen readers when moving through the document
sentence by sentence.

These changes:
- make the <div>s into <span>s which are 'phrasing
  content' and so are interpreted as part of the
  same sentence
- change the CSS so the number will still sit
  on top of its label text

The HTML5 spec has a section on how browsers
should arrange text into paragraphs that explains
what was happening in more detail:

https://www.w3.org/TR/html52/dom.html#paragraphs
2021-01-05 11:39:18 +00:00
Tom Byers
b1d65f33c7 Convert radios on clear cache page (basic) 2020-12-02 16:00:32 +00:00
Chris Hill-Scott
d8b265b0ca Add comments to make test data clearer
It’s not clear where 103 is coming from unless you know that the code is
doing the slightly unintuitive thing of displaying the max of all return
values.
2020-10-12 14:14:12 +01:00
Chris Hill-Scott
54d4fb2a6c Allow platform admins to clear cached broadcasts
When we add a new property to the broadcast model, we need to delete any
cached broadcasts from Redis that are missing the new property. So this
adds an option to do this to the cache page in platform admin.

I’ve also tried to make it more obvious what the magic numbers in the
test fixture are doing.
2020-10-09 15:41:48 +01:00
Leo Hemsted
6eccc66115 delete template keys properly from platform admin page 2020-10-05 16:52:48 +01:00
Chris Hill-Scott
1e55a8cbbe Remove uses of .assert_not_called
I prefer to avoid `assert_not_called`, because if I make a typo like
this, the tests will still pass:
```
    app.invite_api_client.create_invite.asset_not_called()
```

It’s harder to have a false positive with the statement written this
way:
```
    assert app.invite_api_client.create_invite.called is False
```
2020-08-28 13:26:14 +01:00
Tom Byers
c715681f5c Convert DateFields to GovukDateFields
Changes those fields in the following forms:
- DateFilterForm
- RequiredDateFilterForm

Includes changes to templates that use this form
and associated tests.
2020-08-12 10:34:51 +01:00
Chris Hill-Scott
fb4076dc5b Don’t break statistics down by sending/failed/delivered
This should:
- make the page load faster because it has to render less HTML for each
  service
- make the page easier to scan for services that are sending lots of
  text messages or letters

We used to scan this page to look for services with high failure rates,
and the design of the page was gear towards this. Now we have alerting
for high failure rates, so the page can focus on volumes instead.

This commit also puts the service name above the statistics, so that
long service names don’t break the layout of the page.
2020-06-24 11:45:32 +01:00
Chris Hill-Scott
65bb72ef2f Bump WTForms to 2.3.1
This involves three changes which broke our code.

To validate email addresses, the optional dependency `email-validator`
must be installed<sup>1</sup>. But since we don’t use WTForms’ email
validation, we shouldn’t need to subclass it – it can just be its own
self contained thing. Then we don’t need to add the extra dependency.

When rendering textareas, and extra `\r\n` is inserted at the beginning
<sup>2</sup>. Browsers will strip this when displaying the textbox and
submitting the form, but some of our tests need updating to account for
this.

The error message for when you don’t choose an option from some radio
buttons has now changed. Rather than just accepting WTForms’ new
message, this commit makes the error messages like the examples from
the Design System<sup>3</sup>. By default it will say ‘Select an
option’, but by passing in an extra parameter (`thing`) it can be
customised to be more specific, for example ‘Select a type of
organisation’.

***

1. https://github.com/wtforms/wtforms/pull/429
2. https://github.com/wtforms/wtforms/issues/238
3. https://design-system.service.gov.uk/components/radios/#error-messages
2020-04-23 12:57:10 +01:00
Chris Hill-Scott
cc5701e870 Cache organisation name in Redis
A lot of pages in the admin app are now generated entirely from Redis,
without touching the API.

The one remaining API call that a lot of pages make, when the user is
platform admin or a member of an organisation, is to get the name of
the current service’s organisation.

This commit adds some code to start caching that as well, which should
speed up page load times for when we’re clicking around the admin app
(it’s typically 100ms just to get the organisation, and more than that
when the API is under load).

This means changing the service model to get the organisation from the
API by ID, not by service ID. Otherwise it would be very hard to clear
the cache if the name of the organisation ever changed.

We can’t cache the whole organisation because it has a
`count_of_live_services` field which can change at any time, without an
update being made.
2020-04-02 12:07:19 +01:00
Chris Hill-Scott
61d87bf6c0 Let platform admins delete returned letters cache
Just in case there’s ever a problem with something in these caches. We
missed this before.
2020-04-01 10:18:56 +01:00
Chris Hill-Scott
7fb8e1de92 Use statistics for returned letters on dashboard
This should be faster and more accurate than querying all the reports.
2020-04-01 10:18:55 +01:00