Commit Graph

2928 Commits

Author SHA1 Message Date
Chris Hill-Scott
6ff9dac161 Merge pull request #3254 from alphagov/letter-validation-short-messages
Add separate messages for precompiled letters that have failed validation
2020-01-21 10:02:58 +00:00
Chris Hill-Scott
34f209a08b Fix mixed-up error messages
The too many pages error was being returned when the file couldn’t be
read. This commit corrects the error message, and adds a test to make
sure this case is covered.
2020-01-20 15:54:07 +00:00
Chris Hill-Scott
1fc0f58541 Add test for plural form of error message 2020-01-20 15:50:16 +00:00
Chris Hill-Scott
bc7deebcc7 Split test in two for readability 2020-01-20 15:46:03 +00:00
Chris Hill-Scott
32105b3328 Don’t assume jobs status will be present
The API response for jobs includes a field called `job_status`. The API
response for uploads doesn’t.

The `Job` mode handles uploads and jobs, so it needs to account for the
possibility of the field not being there.
2020-01-20 15:25:47 +00:00
Tom Byers
62f1c5a88e Fix associated test 2020-01-20 10:05:15 +00:00
Tom Byers
a67cd65f47 Make Google Analytics cookies expire in 1 year 2020-01-20 10:05:06 +00:00
Tom Byers
1d9c5e5da9 Default the cookie banner to be hidden
It should only be shown if JS is available and the
cookieMessage JS finds consent has not been set.
2020-01-20 10:04:58 +00:00
Tom Byers
1a97c6028c Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-20 10:04:56 +00:00
Tom Byers
b17140ac46 Fix test description 2020-01-20 10:03:47 +00:00
Tom Byers
8a0d0a15a8 Hide cookie banner if no-js
Decided in discussions with @quis and @yahoopete
that users without JS available cannot
accept/reject analytics cookies so the banner has
no use.
2020-01-20 10:03:47 +00:00
Tom Byers
9a0d522964 Add JS tests for analytics & cookies JS
Includes:
- tests for the analytics interface ported from
  GOVUK Frontend Toolkit
- tests for the cookie banner that appears on all
  pages except the cookies page
- tests for the cookies page JS
- tests for the hasConsentFor function
- adding a deleteCookie helper to remove
  cookies during tests
- polyfill for insertAdjacentText

The last one is because JSDOM doesn't support
insertAdjacentText but our target browsers
do. This polyfill also includes one for
insertAdjacentHTML.
2020-01-20 10:03:36 +00:00
Tom Byers
28140104f1 Fix python tests broken by cookie banner 2020-01-20 10:03:19 +00:00
Chris Hill-Scott
a5fe50ce72 Merge pull request #3262 from alphagov/rename-model-property
Rename `client` property on `ModelLists`
2020-01-17 11:08:08 +00:00
Chris Hill-Scott
fa4fd1c896 Account for missing scheduled for field
Jobs have a `scheduled_for` field. Single letter uploads don’t.

At the moment we treat both of them as `Job`s. So the `Job` model needs
to account for when the `scheduled_for` field is missing.
2020-01-17 10:01:39 +00:00
Chris Hill-Scott
c4818eb7f2 Rename property on ModelLists
The property doesn’t represent the whole client, but just one method on
it. So this commit renames the property to better describe what it is
designed to store.
2020-01-16 16:31:20 +00:00
Chris Hill-Scott
721134dc17 Merge pull request #3251 from alphagov/job-model
Make models for individual jobs and collections of jobs
2020-01-16 15:52:21 +00:00
Leo Hemsted
66db735e09 Revert "Merge pull request #3238 from alphagov/cookies-update"
This reverts commit eec4bec761, reversing
changes made to 64480e2fff.
2020-01-15 14:40:48 +00:00
Tom Byers
b86398ddda Fix associated test 2020-01-15 12:03:44 +00:00
Chris Hill-Scott
3762daad84 Add a redirect for the letter specification
This way we have a URL we can give people that always points to the
latest version of the spec.

And it makes our code more Flask-idiomatic to be using `url_for` to be
generating a URL, rather than passing around a constant.
2020-01-15 11:54:14 +00:00
Tom Byers
eec4bec761 Merge pull request #3238 from alphagov/cookies-update
New cookies banner and page
2020-01-15 10:37:14 +00:00
Tom Byers
dce6a46df6 Make Google Analytics cookies expire in 1 year 2020-01-14 14:16:00 +00:00
Chris Hill-Scott
0b6744854b Fix test that fails 1 in 60 times
This test looks for how many times the string `50` appears in the text
of the `<main>` element of the page. The `<main>` element also contains
some times, for example 1:23pm.

This means that when the time reaches 1:50pm, 2:50pm, etc the number of
times the string `50` appears in the page changes. Which causes the test
assertions to fail.
2020-01-14 14:06:04 +00:00
Chris Hill-Scott
b57e4a0d0d Test URLs separately
It’s hard to read the tests when they have HTML bundled up with content.
So this commit:
- introduces BeautifulSoup to parse the HTML
- asserts separately on the text and any links found in the HTML
2020-01-14 13:50:22 +00:00
Chris Hill-Scott
4552587829 Merge pull request #3256 from alphagov/fix-session-bug-change-user-email
Fix session bug when changing user’s email address
2020-01-14 13:46:03 +00:00
Chris Hill-Scott
540945539b Add some summaries of letter validation errors
We show letter validation errors in two places:

1. In response to a user uploading a PDF
   Here we use the error banner pattern because the problem is as a
   direct consequence of a user’s action, and is blocking them from
   continuing.

2. Once a PDF provided through the API has been validated
   We use a less prominent pattern of red text with no border because
   the message is reporting on something that’s already happened, and
   which wasn’t a direct consequence of the user clicking something

Because the context and patterns used are different we need slightly
different content in each of these situations. Previously we tried to
reuse the same content to make the code cleaner and less repetitive. But
ultimately a clear interface trumps clear code.
2020-01-14 13:34:18 +00:00
Chris Hill-Scott
72abd89fe0 Fix indentation and trailing commas
This will make the diffs introducing substative changes easier to read.
Consistent indenting and always having trailing commas on lists and
dictionaries makes for smaller diffs.
2020-01-14 13:31:29 +00:00
Chris Hill-Scott
e3670de6c4 Remove the title from the short errors
This undoes some of the temporary work we did previously in order to
ship the new ‘address is empty’ error message.
2020-01-14 13:30:31 +00:00
Tom Byers
4a303cf0d8 Merge branch 'master' into cookies-update 2020-01-14 13:17:21 +00:00
Tom Byers
c18cb1e984 Default the cookie banner to be hidden
It should only be shown if JS is available and the
cookieMessage JS finds consent has not been set.
2020-01-14 12:11:40 +00:00
Tom Byers
b6e37a6ac8 Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-14 11:28:06 +00:00
Chris Hill-Scott
e9ad2e9c42 Only put the overlay on bad pages
This will make it easier to find errors in your file, because you won’t
spent time looking for them on pages which are OK.
2020-01-13 17:42:44 +00:00
Chris Hill-Scott
7d52ac97f1 Move stats to the model
The API clients should just deal with calling the API and returning the
data from it.

Inferring things from the data is more logically done at the model
layer. But we couldn’t do that before, because we didn’t have a model
layer for jobs.
2020-01-13 15:10:16 +00:00
Chris Hill-Scott
25464a141b Use a ModelList for lists of jobs
This follows the pattern of what we’ve done with services, users and
events.

It gives us a way of neatly instantiating a model for each item in the
list we get back from the API and reduces the complexity of the view
layer code.

Now is a good time to do this because we’re going to be making a bunch
of changes to the jobs pages, and those changes will be easier to code
and understand with a sensible model behind them.
2020-01-13 15:10:10 +00:00
Rebecca Law
e7928512e8 Merge pull request #3240 from alphagov/recipient-address
Show the first line of the address from the to field.
2020-01-13 14:29:33 +00:00
Rebecca Law
68bf013a0c Removed method from conftest, that's not being used. 2020-01-13 14:19:20 +00:00
Chris Hill-Scott
5e7ec3e30d Make a job model for individual jobs
This follows the pattern of what we’ve done with services, users and
events.

It gives us a better interface to the data we get back from the API than
dealing with the raw JSON directly.

Now is a good time to do this because we’re going to be making a bunch
of changes to the jobs pages, and those changes will be easier to code
and understand with a sesnsible model behind them.
2020-01-13 13:05:35 +00:00
Chris Hill-Scott
72eb6ef99a Fix session bug when changing user’s email address
The session key we use is global.

This means if you open the edit page for two different users in two
different tabs the session for the first tab is overwritten with the
session from the second tab. This means the two users are both set to
the same email address, which causes an exception (email addresses are
unique).

This commit fixes that bug by including the user ID in the session ID.
2020-01-13 12:03:39 +00:00
Chris Hill-Scott
c391729dc0 Merge pull request #3247 from alphagov/buttony
Make create account button more buttony
2020-01-13 10:35:34 +00:00
Rebecca Law
8067634447 Fix merge conflict 2020-01-10 16:16:11 +00:00
Rebecca Law
40575bbb75 Rebase pytest 5 changes
Add to field in creation of notification
2020-01-10 16:06:04 +00:00
Rebecca Law
9d1f92a752 Strip the trailing comma on the first line of an address block. 2020-01-10 16:06:04 +00:00
Rebecca Law
f7b3f9b06a - Remove the trailing comma from the first line of the "to" field
- Add client_reference to the activity CSV report
- Show the recipient on the CSV report the same way as the view activity page.
2020-01-10 16:00:40 +00:00
Rebecca Law
f8e7635a1d Show the first line of the address from the to field.
Now persisting the address to the "to" field of the Notification, after the notification has been validated.
If the letter is pending validation, then "Checking..." will appear as the identifier for the letter.
If the letter has passed validation, then the first line of the address (now persisted in the "to" field) will be displayed, with the client reference underneath.
If the letter has failed validation the "Provided as PDF" will show be displayed, which is now the initial value of the "to" field.
2020-01-10 16:00:40 +00:00
Rebecca Law
47ec4912db Merge pull request #3253 from alphagov/new-no-address-message
Added a new error message when the letter is missing an address block.
2020-01-10 15:44:47 +00:00
Rebecca Law
70276cb526 Added a new error message when the letter is mising an address block.
Before deploying a change to template-preview to return a validation error for letters that are missing the address block, we need to add the new erorr message to admin.

Some content changes have been made to other messages.
The format of the message has changed.
2020-01-10 14:42:56 +00:00
Katie Smith
8e9b7ae368 Remove arguments from fixtures
These can't be used, since we fixtures can no longer be called as if
they were functions, so we can simply the code by removing them.
2020-01-10 12:17:56 +00:00
Katie Smith
17f72dc4cd Delete unused fixtures 2020-01-10 10:52:40 +00:00
Katie Smith
0ec086cd24 Use fixtures for templates in a Pytest 5 compatible way 2020-01-09 09:48:16 +00:00
Katie Smith
9e3f21cd39 Stop calling mock_get_notications as if it's a function
By creating a new function in conftest.py, `create_notifications`, which
can be used instead.
2020-01-09 09:48:16 +00:00