Commit Graph

8706 Commits

Author SHA1 Message Date
Tom Byers
2b5ba5f438 Use screenMock helper in fullscreenTable test 2019-11-08 17:37:06 +00:00
Tom Byers
e65946680a Use screenMock helper in API key test
jQuery 3 checks for any styles before dimension so
a value typical of the browser defaults needs to
be provided when mocking them.

This helps the mocking of `$.height` by providing
a default style for `height`.
2019-11-08 17:37:06 +00:00
Tom Byers
3fba2c381d Make screenMock helper mock more DOM APIs
jQuery 3 also calls `.getClientRects` to get the
position and dimension of elements.
2019-11-08 17:37:06 +00:00
Tom Byers
56a2aab5f0 Mock out getClientRects for tests that need it
jQuery 3 calls `getClientRects` in the
`.innerHeight` code. Version 1 didn't.

This mocks out those calls to the same as
`getCoundingClientRect`.
2019-11-08 17:37:06 +00:00
Katie Smith
c3c224dcc8 Merge pull request #3178 from alphagov/show-recipient-address-for-uploads
Show recipient when about to send uploaded letter
2019-11-08 13:12:41 +00:00
Katie Smith
a542047581 Show recipient when about to send uploaded letter
The recipient of the letter now displays at the bottom of the page when
previewing a valid letter. The template preview `/precompiled/sanitise`
endpoint returns the address, but we format it to display on a single
line with commas between each line. We also need to convert the
recipient address to ASCII so that it can be stored as S3 metadata.
2019-11-08 10:17:11 +00:00
Chris Hill-Scott
bf981c308a Require return_to param in action_blocked
The `action_blocked` endpoint needed a variation of the URL without
a `template_id` parameter, because `None` is no longer a valid
`template_id` (because it’s not a UUID).

This change was made in 265931d21746918c4ddfc19c4ad3f8cb5683c1bf, which
also removed the `return_to` parameter, because the back link on the
`action blocked` page only ever goes to `add_new_template` if there’s
no `template_id` provided.

However this was conflating the two things, so I’ve wound it back a bit
so that:
- there’s still a new route, whose URL doesn’t include `template_id`
  as a parameter
- `return_to` is always required

I’ve also refactored the code a bit to move the looking up of the back
link from the Jinja into the view layer, so that the related code is in
one place and easier to reason about.
2019-11-07 17:55:35 +00:00
Chris Hill-Scott
545b485d86 Add URL converters for template and file types
Sometimes we manually check that a URL parameter is in a required set.
Sometimes we don’t bother.

This commit adds a URL converter to do this so that:
- we don’t have to re-write the same code every time
- it’s easier to apply this check to other endpoints

This means endpoints that previously allowed a `template_type` or
`message_type` of `None` now 404. So I’ve had to add new routes for
with URLs that don’t include such parameters.

So this…:
```
/services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications/sms.csv
/services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications/None.csv
```

…becomes:
```
/services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications/sms.csv
/services/128b91b6-2996-4107-bb65-51b7c24a728d/notifications.csv
```

This matches what we do for the HTML-responding equivalent (see
265931d217/app/main/views/jobs.py (L215-L216))
2019-11-07 13:48:09 +00:00
Chris Hill-Scott
ef335e7601 Require IDs to be UUIDs in URLS
We mostly rely on the API returning a 404 to generate 404s for trying
to get things with non-UUID IDs. This is fine, except our tests often
mock these API calls. So it could look like everything is working fine,
except the thing your passing in might never be a valid UUID, and thus
would 404 in a non-test environment.

So this commit:
1. uses the `uuid` URL converter everywhere there’s something that looks
   like an ID in a URL parameter
2.  adds a test which automates checking for 1.
2019-11-07 13:46:25 +00:00
Chris Hill-Scott
554a852e2d Don’t return UUID objects from the UUID convertor
Because it means you often have to cast to string in your application
code just to get your tests passing.

The method being monkey patched is originally defined here: b81aa0f18c/src/werkzeug/routing.py (L1272)
2019-11-07 13:46:24 +00:00
Pea (Malgorzata Tyczynska)
21a59598b2 Merge pull request #3170 from alphagov/show-users-why-their-precompiled-letter-failed-validation
Show users why their precompiled letter failed validation
2019-11-07 11:23:30 +00:00
Chris Hill-Scott
653926f636 Merge pull request #3149 from alphagov/resize-all-textbox-dem
Let textareas resize automatically without having to highlight placeholders
2019-11-07 11:13:06 +00:00
Pea Tyczynska
678e0bed81 Show users more detailed validation failed mesage on notification page
Show valdiation failed messages on letter notifications in red text,
not in the banner like we do on Uploads and Validation checker pages.
This is because it is a different step in the journey: the user
has already sent the notification and styling needs to be in line
with other places where user is checking the notification she already
has sent.
2019-11-07 11:10:27 +00:00
Chris Hill-Scott
b671ad239d Merge pull request #3166 from alphagov/usage-back-on-dashboard
Put usage summary back on the dashboard
2019-11-07 10:32:51 +00:00
Pea Tyczynska
f12dc823cb Show dynamic message when letter fails validation in validation checker - part 2 2019-11-06 14:26:16 +00:00
Pea Tyczynska
5e10ed23a1 Refactor uploads preview error banner to use a shared component
Also refactor a corresponding test to avoid asserting on the content
2019-11-06 14:26:14 +00:00
Pea Tyczynska
f2c7eb5c3e Tell user why validation failed on letter validation page - part 1 2019-11-06 12:21:18 +00:00
Pea Tyczynska
c843940b14 Test letter too long error banner using exisitng data-error-type attribute
This way we can avoid both creating an id attribute for testing
and testing by content.
2019-11-06 12:21:18 +00:00
David McDonald
4ca4cef1b3 Merge pull request #3144 from alphagov/choose-postage
Choose postage
2019-11-05 10:14:40 +00:00
Chris Hill-Scott
f5e906c00c Merge pull request #3174 from alphagov/update_get_started_page
Update Get started page
2019-11-04 16:13:02 +00:00
Chris Hill-Scott
889d601475 Put usage summary back on the dashboard
This reverts 1b1839ad30, which removed
the usage from the dashboard because it was causing performance
problems:

> **The yearly usage section on the dashboard page takes too log as a
> result services with large yearly stats are timing out.**
>
> As a short term fix we have taken the yearly stats off the dashboard.
>
> There is a plan to create permanent statistic tables to warehouse the
> data.

The long term fix (the fact tables) is now in place, so it should be OK
to bring this back.

This is part of a wider piece of work to refresh the dashboard page now
that jobs are moving to their own page.
2019-11-04 14:54:16 +00:00
Chris Hill-Scott
8782049548 Merge pull request #3165 from alphagov/letters-always-on-usage
Always show letters on the dashboard and usage page
2019-11-04 14:49:47 +00:00
Chris Hill-Scott
6c5255f30b Merge pull request #3167 from alphagov/hide-len-1-template-statistics
Don’t show template statistics on dashboard if only one template has been used
2019-11-04 14:45:33 +00:00
Rebecca Law
47a491af92 Merge pull request #3171 from alphagov/start-app-script-with-exec
Change how the bash script is started.
2019-11-04 10:53:35 +00:00
karlchillmaid
0950781a5b Fix links and heading 2019-11-04 10:25:27 +00:00
dependabot[bot]
f2b7c42f53 Bump jquery from 1.12.4 to 3.4.1
Bumps [jquery](https://github.com/jquery/jquery) from 1.12.4 to 3.4.1.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](https://github.com/jquery/jquery/compare/1.12.4...3.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-01 12:09:59 +00:00
Chris Hill-Scott
07475f23f3 Merge pull request #3172 from alphagov/flake8-bugbear
Do extra code style checks with flake8-bugbear
2019-11-01 12:07:55 +00:00
David McDonald
159d2ff6b2 Add form.validate_on_submit for sending uploaded letter
Decided it was better to call this then not. This does rely on
the file_id not being corrupted so the file_id passed
into `uploaded_letter_preview` is valid but am taking that risk
given it should only change if a user is changing the form html.
2019-11-01 10:56:34 +00:00
David McDonald
183c45d523 Assert radio buttons exist in form 2019-11-01 10:47:42 +00:00
David McDonald
36e5317da8 Use page_footer macro instead of manually writing HTML 2019-11-01 10:47:42 +00:00
David McDonald
4ddc82d148 Access request values from form object 2019-11-01 10:47:42 +00:00
David McDonald
11a271b6c5 Bump requirements to use 36.0.0 of utils 2019-11-01 10:47:42 +00:00
David McDonald
1c3095329b Change radio buttons to inline
Adds ability to have inline radio buttons using the fieldset.inline
functionality from gov.uk elements.

Then implements this for the radio buttons for choosing postage
class.

Also overrides the gov uk elements styling for the inline radio
buttons to place them slightly closer together as this looks
better.
2019-11-01 10:47:42 +00:00
David McDonald
2b8b4c25aa Send postage value to API when sending pre compiled letter 2019-11-01 10:47:42 +00:00
David McDonald
9ba1dbfffa Do not show postage stamp for letter preview 2019-11-01 10:47:42 +00:00
David McDonald
fdf74572b9 Add radio button and convert from to WTForm 2019-11-01 10:47:42 +00:00
Chris Hill-Scott
fcc84ac514 Do extra code style checks with flake8-bugbear
Flake8 Bugbear checks for some extra things that aren’t code style
errors, but are likely to introduce bugs or unexpected behaviour. A
good example is having mutable default function arguments, which get
shared between every call to the function and therefore mutating a value
in one place can unexpectedly cause it to change in another.

This commit enables all the extra warnings provided by Flake8 Bugbear,
except for the line length one (because we already lint for that
separately).

It disables:
- _B003: Assigning to os.environ_ because I don’t really understand this
- _B306: BaseException.message is removed in Python 3_ because I think
  our exceptions have a custom structure that means the `.message`
  attribute is still present
2019-11-01 10:43:01 +00:00
Chris Hill-Scott
9e781177fd Merge pull request #3148 from alphagov/add-get-started-page
Add a 'Get started' page
2019-11-01 10:36:47 +00:00
Chris Hill-Scott
6fa0f06f5d Enable autosizing for some textboxes
This commit makes textboxes auto-resize any time they might be used to
enter long passages of text which would otherwise make them scroll
internally.
2019-10-31 17:53:45 +00:00
Chris Hill-Scott
6c0e853db4 Rename module
HighlightTags was bad because:
- we haven’t called placeholders ‘tags’ for a long time
- it also does resizing of the `<textarea>`, not just highlighting the
  placeholders
2019-10-31 17:53:44 +00:00
Chris Hill-Scott
d0ce4d07a3 Autosize textboxes w/out highlighting placeholders
Scrolling within textareas on the page is a bit grim. Which is why we
don’t do it for the textboxes that people use to edit templates.

This commit will allow us to extend the auto-resizing of `<textarea>`s
to those which don’t need the highlighting of placeholders.

The code is still quite coupled to the placeholder highlighting code,
because both work by copying the content of the `<textarea>` into a
`<div>` that underlaps the textbox. This `<div>` is used for both
rendering the placeholder highlights, and calculating the natural height
of the content. So it would be hard/confusing to split the two bits of
code into separate modules.
2019-10-31 17:53:44 +00:00
Rebecca Law
d69de324ea Change how the bash script is started.
By adding `exec` to the entrypoint bash script for the application, we can trap an EXIT from the script and execute our custom `on_exit` method with checks if the application process is busy before terminating, waiting up to 10 seconds.

Written by:
@servingupaces
@tlwr
2019-10-31 16:38:17 +00:00
Chris Hill-Scott
e73ce0561d Merge branch 'master' into add-get-started-page 2019-10-31 10:54:11 +00:00
Chris Hill-Scott
239e3079d1 Fix import sort order 2019-10-31 10:53:45 +00:00
Chris Hill-Scott
4e026bc306 Make sure all sticky footer variants are aligned
The bottom margin should always be consistent. Height of footers doesn’t
have to be consistent. Items on the left and right should baseline
align.
2019-10-31 10:49:02 +00:00
Chris Hill-Scott
d298949a5a Style the page to look like the Pay one 2019-10-31 10:10:01 +00:00
Chris Hill-Scott
9b91132276 Test that static pages work w/out current_service
If you sign in, don’t choose a service then navigate to a state page
then it’s possible `current_service` won’t be set, in which case you
shouldn’t be generating URLs that need `current_service.id`.
2019-10-31 09:43:16 +00:00
karlchillmaid
fa72c35fce Update app/templates/views/get-started.html
Co-Authored-By: Chris Hill-Scott <me@quis.cc>
2019-10-31 08:40:25 +00:00
Chris Hill-Scott
0ac6a2c1ab Remove unused variable
We use different logic to decide whether to show/hide the template
statistics part of the dashboard now.
2019-10-30 11:12:58 +00:00
Chris Hill-Scott
c919c25bf8 Remove unreachable code
An `if` statement higher up the page means this code will never get run
now. We can simplify the template by removing it.
2019-10-30 11:12:26 +00:00