Commit Graph

2969 Commits

Author SHA1 Message Date
Katie Smith
9c927f950c Merge pull request #3296 from alphagov/add-letter-specification-guidance
Add letter specification guidance
2020-02-13 16:21:45 +00:00
Katie Smith
f425fe75cf Update link in error messages for uploaded letters 2020-02-13 16:14:11 +00:00
Chris Hill-Scott
4f32258a7b Merge pull request #3293 from alphagov/cache-returned-letter-summary
Cache returned letter summary in Redis
2020-02-12 13:48:51 +00:00
karlchillmaid
38fd842d33 Merge pull request #3213 from alphagov/add-guidance-content
Add first iteration of guidance content, including updating navigation menus and footer.
2020-02-12 11:43:07 +00:00
Chris Hill-Scott
af8395956e Cache returned letter summary in Redis
We’re going to start using the returned letters summary to show some
info on the dashboard.

This means we will be accessing it more often than it changes. And we
know exactly when it changes because it’s us manually submitting the
references we get from DVLA.

This makes it a good candidate for being cached, and Redis is where we
cache stuff that we’d otherwise go to the API for.
2020-02-12 11:42:06 +00:00
Chris Hill-Scott
6b703614b9 Merge pull request #3280 from alphagov/swap-nav-order-org-users
Swap order of usage and team members in navigation when organisation users are looking at a service
2020-02-11 11:21:14 +00:00
Chris Hill-Scott
8a4bf1d07e Make test more robust
Now tests:
- that the user doesn’t have the usage menu item when they’re not a
  member of the organisation (i.e. the counterfactual)
- that the user still gets a 403 when they try to view the usage page if
  they’re not a member of the organisation
2020-02-11 11:11:18 +00:00
Rebecca Law
94c9886a58 Merge pull request #3288 from alphagov/delete-template-dialog
Delete template dialog
2020-02-06 10:58:43 +00:00
Rebecca Law
b242467d77 Change the content for the delete template confirmation dialog.
As per https://www.pivotaltracker.com/story/show/170796514 we want to make the delete template confirmation dialog box more consistent and clear.
The API has been updated with a new endpoint that only returns the last-used date, this date is more accurate since it goes to the ft_notification_status table, if the notification table is empty.
2020-02-06 10:16:00 +00:00
Leo Hemsted
636a702d19 Merge pull request #3286 from alphagov/remove-api-keys
cleanup
2020-02-05 10:11:47 +00:00
Pea M. Tyczynska
b5723a1aef Merge pull request #3285 from alphagov/uploads-fix-letter-link
Fix bug where job url type was constructed for letter on uploads page
2020-02-04 16:26:49 +00:00
Rebecca Law
143564c7f0 Update message seen when deleting a template. 2020-02-04 16:00:51 +00:00
Leo Hemsted
5b868ff268 remove api keys from codebase
these are just used for tests so don't need to look like real api keys.
2020-02-04 14:44:19 +00:00
Pea Tyczynska
46292949cd Fix bug where job url type was constructed for letter on uploads page 2020-02-04 14:19:07 +00:00
Rebecca Law
8a19d9496a Check if user is authenticated before signing out, this will prevent a 500 if the user is an AnonymousUser.
I ended up creating a new test user and logged_in_client, which isn't really great. But I tried adding a current_session_id to the active user in the test, but that broke all other tests.
I tried setting current_session_id in all the users being tested but that didn't work either. I'd like to come back to fixing the tests and reducing the number of conftest methods in another PR. For now this fixes the bug.
2020-02-04 12:16:58 +00:00
Chris Hill-Scott
cceb731596 Rename test to be a more explicit about what it’s testing
It’s not just that they’re an org user, it’s that they’re also a service user. And the usage page is the special case.
2020-02-03 16:28:47 +00:00
Chris Hill-Scott
b7b9e9747b Add test for org user who is also a service user
Org users should always be able to see the usage page, even if they
don’t have the `manage_service` permission for the service.
2020-02-03 16:05:46 +00:00
Rebecca Law
0e1ee504ac - Add unit test for when case when the cookie doesn't match the db.
- Move code into User.signout method to further encapsulate the code.
2020-02-03 15:08:55 +00:00
Rebecca Law
937c9f2adc Ensure that the session is logged out server side, not just client side.
Anytime a user clicks "sign out" we should be signing them out server side as well. This can be accomplished by setting the Users.current_session_id = null.
I found that the method User.logged_in_elsewhere doesn't need to check if the current_session_id is None. The current_session_ids in the cookie and db (redis or postgres) then the user should be forced to log in again.
2020-02-03 12:24:02 +00:00
Chris Hill-Scott
a35931a33a Swap order of usage and team members for org users
Org users, when looking at the page for their org, see:
> Usage
> Team members

When they click into a service it switches to:
> Team members
> Usage

This is jarring. It should stay consistent. I think it that _Usage_ then
_Team members_ is the natural way of ordering the navigation at the
organisation level, so let’s follow that through to the service level.

This does mean that if someone is a member of both an organisation and a
service that the nav will jump (because it’ll switch to the existing,
service-level order of _Team members_ then _Usage_) but it’s going to
jump anyway because you get all the extra navigation items when you’re a
member of a service.
2020-02-03 11:39:58 +00:00
Leo Hemsted
01ba256ef9 bump utils to fix datetime formatting jinja bug 2020-01-28 10:32:21 +00:00
Leo Hemsted
4e1fcfbff1 handle invalid upload errors correctly
previously it assumed that invalid_pages would always exist, however it
might be `None` if the error isn't on a specific page. Errors on
specific pages include a page not being A4 or content being outside the
boundary. Errors not on specific pages include the file not being a pdf,
or containing too many pages
2020-01-27 15:11:37 +00:00
Chris Hill-Scott
d29f23bfc8 Add left hand navigation
Due to the way the navigation dictionaries are built this mean being
less smart about the view method for the guidance pages.
2020-01-24 16:25:32 +00:00
Chris Hill-Scott
da2bc29b40 Merge pull request #3263 from alphagov/fix-new-jobs-showing-as-deleted
Use time to determine why notifications don’t exist
2020-01-24 15:27:29 +00:00
Pea M. Tyczynska
ba6b412bca Merge pull request #3268 from alphagov/proper-form-for-letter-branding
Parametrise branding request flow so it serves both email and letter branding
2020-01-23 16:50:41 +00:00
Pea Tyczynska
a578ec23a3 Redirect to template after succesful branding request
if user entered branding request flow from a template.
2020-01-23 16:35:15 +00:00
Pea M. Tyczynska
fdff9d3b83 Ensure gov.uk branding only available for emails and not for letters
Also align and statements
2020-01-23 16:34:58 +00:00
Chris Hill-Scott
3b108e8c93 Add comment clarifying timings in test case 2020-01-23 16:32:08 +00:00
Leo Hemsted
461ba32f4e Merge pull request #3274 from alphagov/one-more-thing
fix one more place where senders weren't sanitised
2020-01-23 15:38:45 +00:00
Tom Byers
d68403f7dc Merge pull request #3272 from alphagov/stop-removing-ga-cookies
Stop removing GA cookies
2020-01-23 11:32:42 +00:00
Leo Hemsted
f3fa6a67e1 fix one more place where senders weren't sanitised
make sure everything is using the `nl2br` formatter that properly wraps
it in markdown to keep everything sanitised nicely. Also write a couple
of tests
2020-01-22 17:22:01 +00:00
Chris Hill-Scott
8e5d11c70e Add a route to serve guidance pages
Rather than hard coding the page titles, let’s just accept anythin
 that’s a real template in the guidance folder – will make it easier for
 Karl to edit and create pages.
2020-01-22 14:06:14 +00:00
Tom Byers
cfdc83a336 Update tests 2020-01-22 12:26:55 +00:00
Tom Byers
174c10c7ff Clear old cookies to be based on consent
We have been clearing all the Google Analytics
cookies on each page request.

It is now possible for a user to consent to having
Google Analytics cookies so this should have been
checking for that before deleting them.

This makes that change, with tests for those
scenarios.
2020-01-22 12:14:23 +00:00
Tom Byers
98e48e68f9 Change the URL JSDOM uses for the current page
https://jestjs.io/docs/en/configuration#testurl-string

Affects all DOM APIs that return information about
the URL, for example window.location.

Why:

We now have tests for setting/deleting cookies.
Tough-cookie, the library JSDOM uses for cookie
handling cookies doesn't allow setting cookies
with `domain=localhost`. This is correct by
RFC6265, the standard it follows, as domains must
have 2 or more `.`s in them.

The only way to set a cookie on `localhost` is to
leave out the `domain` attribute.

The code we are testing sets and deletes cookies
set on specific domains so using `localhost` is
out.

We also cannot just set/delete cookies on the
domains used as cookies are required to match the
domain of the current page.

The solution we are left with is to set the
current page to one from production and make sure
each cookie is set relative to that domain.

Note: this introduces `testURL` in isolation to be
sure it doesn't break any existing tests.
2020-01-22 11:08:29 +00:00
Pea Tyczynska
5a32177982 Delete old letter branding request page 2020-01-21 16:47:42 +00:00
Pea Tyczynska
02cb6c9c38 Create a letter branding request flow to match email branding request
Test if service settings links to branding request page for letters

Parametrize all branding tests so they also work for letter branding
2020-01-21 16:47:14 +00:00
Chris Hill-Scott
291734b0c4 Merge branch 'master' into fix-new-jobs-showing-as-deleted 2020-01-21 14:24:40 +00:00
Chris Hill-Scott
d27d400f53 Test the boundary conditions
Since date math can be hard it’s good to test as close to the boundary
as possible, which hopefully catches stuff like timezone related bugs.
2020-01-21 14:15:48 +00:00
Chris Hill-Scott
f5ced76e63 Don’t mock job processing in the future
It could hide bugs or make the tests harder to understand later on if
what they’re testing is an impossible scenario.
2020-01-21 14:09:54 +00:00
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