Commit Graph

2671 Commits

Author SHA1 Message Date
Chris Hill-Scott
68c9147fec Merge pull request #3119 from alphagov/retire-old-static-content
Retire old static content pages
2019-09-23 13:19:01 +01:00
Chris Hill-Scott
bda2f41aac Merge pull request #3125 from alphagov/faster-tests
Create the app once per run, not once per test
2019-09-20 10:33:44 +01:00
Chris Hill-Scott
1a353d90eb Create the app once per run, not once per test
Turns out our tests spent a lot of time recreating the app for each test
case, which is quite intense.

This commit makes the fixture sessions level, so the app is only created
once per test session, not once per test function.

This cuts down the time taken to run the test suite to about 50 seconds.

It also makes the tests more parallelizable. Before this change going
from 4 to 8 processes made the tests slower. Now it cuts them down from
about 50 seconds to about 35 seconds[1]. So this commit also lets Pytest
choose the best number of processes to run, since on my machine it
chooses 8, which is the fastest.

Overall this means the

1. With a 2.2GHz quad-core Intel Core i7 processor on a 2015 MacBook Pro
2019-09-18 15:58:25 +01:00
Chris Hill-Scott
afcdedf598 Allow elaboration when ‘something else’ is chosen
Letting people input a bit of free text should reduce the amount of back
and forth we have to do over support tickets when setting up someone’s
branding.

If something else is the only option then we don’t show the radio button
at all and have just the free text input on the page (not behind a
progressive disclosure).
2019-09-16 11:18:22 +01:00
Chris Hill-Scott
6d0d10e8de Only show relevant choices of email branding
Users who work in local government can’t have GOV.UK branding on their
emails. And only those working for Companies House (for example) can
request the Companies House branding.

This commit adds:
- new choices of email branding, which offer the name of the branding,
  rather than the style
- logic to filter this list to only the applicable options, based on
  what we know about the user, service and organisation

This is a change from the previous approach which put the onus on users
to figure out the style of branding they wanted, when we might already
know that a lot of the options weren’t available to them, or would be
inconsistent with the branding of other services in their organisation.
2019-09-16 11:03:52 +01:00
Katie Smith
81da8e762d Update for new template preview sanitise response 2019-09-12 09:54:36 +01:00
Katie Smith
79053dec93 Allow uploaded letters to be sent if valid
Added a send button which only appears on the page if the query string
indicates that the PDF is valid. Before actually sending, we check that
the service has the right permissions and that the metadata for the
letter confirms the letter is valid (because the query string can be
changed).
2019-09-12 09:54:36 +01:00
Katie Smith
7368245c9a Show letter preview once file is uploaded
This shows the sanitised letter preview if the file had no validation
errors or the preview with the overlay if it failed validation.
2019-09-12 09:54:36 +01:00
Katie Smith
8a322b844b Sanitise uploaded letters and store in S3
This sanitises uploaded letters and stores the sanitised result in S3
with if it passes validation or the original PDF in S3 if validation
fails. A metadata value of 'status' is set to either 'valid' or
'invalid'.
2019-09-12 09:54:36 +01:00
Katie Smith
5fa9e071c7 Add check that PDF file can be opened and is not malformed
This checks that the PDF file is not malformed in some way (e.g. by
missing the EOF marker). We check this by trying to get the page count
of the letter which will be needed to display the preview of the letter.
2019-09-12 09:54:36 +01:00
Katie Smith
a103dbf801 Add max file size check when uploading a letter 2019-09-12 09:54:36 +01:00
Katie Smith
be6b5b922a Add virus scan stage when uploading a letter 2019-09-12 09:54:36 +01:00
Katie Smith
c577416866 Add letter upload form which redirects to blank preview page
Added a form to upload a single letter. Currently this only uses the
form to validate that a file is submitted and that the file is a PDF. If
either of these validations fail, the form will display an error.
Otherwise, we redirect to a new preview page which just has the filename
as the heading for now.
2019-09-12 09:54:36 +01:00
Chris Hill-Scott
8b8893ed1d Let NHS Trusts and CCGs choose own organisation
All we do via support is ask which organisation they work for and
manually assign their service to it. This commit makes that process self
service.

We think we have all the trusts and clinical commissioning groups
loaded into the database now.

This will make the go live process smoother for these teams.
2019-09-06 16:26:51 +01:00
Chris Hill-Scott
d37566a79b Merge pull request #3117 from alphagov/gp-self-define
Let GP surgeries create their own organisations before going live
2019-09-06 16:24:25 +01:00
Chris Hill-Scott
b67ea7f268 Retire old static content pages 2019-09-05 16:25:15 +01:00
Chris Hill-Scott
e0ab43f988 Let GPs nominate service name
Most GP practice services are named after the practice, which is the
organisation.

So rather than make people re-type the name of their organisation (and
potentially make a typo) let’s just let them say ‘yes, that’s the name
of my organisation’.
2019-09-05 15:01:12 +01:00
Chris Hill-Scott
daeefefeaa Let GP surgeries create their own organisations
We have a bunch of GP surgeries who want to go live. They don’t
automatically assigned to organisations. So this means a lot of back and
forth to get these organisations set up, and then the service has to
re-request to go live, and… it’s painful.

Instead, let’s let GPs create their own organisations, by confirming the
name of their organisation before going on to letting them accept the
agreement.
2019-09-05 15:01:12 +01:00
Chris Hill-Scott
d41effe8ce Allow GPs to click through to the agreement
We want GPs to be able to accept the agreement online. But at the moment
they don’t get automatically assigned to organisations. So we need to
let them enter the agreement accepting journey even if they don’t have
an organisation set up.
2019-09-05 14:46:02 +01:00
Tom Byers
45e61d6ba5 Fix description of time until re-enable clicks 2019-09-05 10:52:13 +01:00
Tom Byers
9967f29ca6 Add tests for preventing duplicate form submit 2019-09-05 10:52:13 +01:00
Tom Byers
3c1576dacf Add helper for mocking/stubbing form.submit
JSDOM doesn't implement the submit method on form
elements. It does have a submit method but this
just fires a 'not implemented' error.

We need to spy on form submissions fired by
clicking on the submit button but can't because
this event calls the submit method internally so
spying on `form.submit` doesn't work.

This adds a helper which spies on the internal
method that is actually called. When JSDOM
implements the submit method properly this should
be removed.
2019-09-05 10:52:13 +01:00
Leo Hemsted
0cf1251cad Merge pull request #3101 from alphagov/billing-for-all-services-report
Usage for all services
2019-09-02 16:38:23 +01:00
Chris Hill-Scott
13a98a73c1 Set free allowance for GP surgeries
This also tests that a user from an unknown organisation can pick any
of the available options and get the right allowance.
2019-08-29 17:47:14 +01:00
Tom Byers
68d533fa18 Merge pull request #3103 from alphagov/split-up-js-test-helpers
Split JS test helpers into separate files
2019-08-29 14:02:25 +01:00
Tom Byers
9d176d8d8d Merge pull request #3093 from alphagov/fix-aria-on-fullscreen-table
Change method of hiding extra table layer
2019-08-29 14:01:54 +01:00
Leo Hemsted
6412a4ab33 use a flash error message on the platform admin usage report
that makes more sense than attaching the error to a field

also fix tests and assert csv contents are correct
2019-08-29 10:49:38 +01:00
Chris Hill-Scott
38c2b32fa8 Add ‘GP’ as an organisation type
Although their allowances are the same as what we call `nhs_local` it
makes more sense to store them separately because:

- we already present them as two separate choices to the user
- we may want to handle them differently in the future, eg in terms of
  what branding choices are available to them

Once the API is updated we can start passing in this new value from
the admin app.
2019-08-28 15:36:09 +01:00
Tom Byers
baf8c1fddb Split helpers into separate files 2019-08-27 17:00:22 +01:00
Leo Hemsted
b69321bf7a rename logged_in_platform_admin_client to platform_admin_client
of course it's logged in, it's a platform admin

also, reduce use of the `client` fixture in test_platform_admin
(replace it with platform_admin_client)
2019-08-27 16:02:15 +01:00
Rebecca Law
464a74b329 fix codestyle 2019-08-23 17:18:05 +01:00
Rebecca Law
2fe5c4a96e New report on platform-admin/reports page to get the usage for all services. 2019-08-23 17:14:04 +01:00
karlchillmaid
0d7005094a Merge pull request #3099 from alphagov/update-receive-text-message-content
Update explanation of inbound SMS
2019-08-23 14:13:54 +01:00
Chris Hill-Scott
922a7fc9dc Fix tests 2019-08-23 13:52:41 +01:00
Tom Byers
78d6419f80 Add tests for window resizing 2019-08-22 15:21:33 +01:00
Tom Byers
fbc68b7bf2 Add tests for viewports < 769px wide
Elements should not stick unless the viewport is
768px wide or larger.
2019-08-22 15:21:33 +01:00
Tom Byers
6871dbcffe Add tests for when caret is underneath sticky
If focus moves to a textarea, we care more about
the caret being overlapped than the textarea.

This adds tests for the caret being overlapped on
load and as a result of it moving underneath the
sticky element from a keyboard event.
2019-08-22 15:21:33 +01:00
Tom Byers
fac116b835 Add tests for handling overlap of activeElement
If an element receives focus when underneath a
stick element, the window should scroll so the
focused element is revealed.

Includes some changes to the WindowMock API to
allow access to data from Jest spies.
2019-08-22 15:21:33 +01:00
Tom Byers
ab6e81a8a6 Add tests for 'shim'
A 'shim' element needs to be added to the page
when an element is made sticky to ensure the
vertical position of everything doesn't change.

When an element becomes sticky it is made
`position: fixed` which removes it from the layout
of the page. The 'shim' is an element added at the
same place in the page with the same dimensions,
so the layout isn't changed.
2019-08-22 15:21:33 +01:00
Tom Byers
381e745ec8 Make helper plug gap in JSDOM's DOM API
Errors fired from JSDOM showed it doesn't support
`window.scrollTo` (or `window.scroll` for that
matter).

This stubs it, to the extent that our use (jQuery
really) of it works.
2019-08-22 15:21:33 +01:00
Tom Byers
8a82d42bf7 Add tests for 'dialog' mode
'dialog' mode was introduced as part of this work:

https://github.com/alphagov/notifications-admin/pull/2682

It lets multiple elements sticky to the viewport
together so a set of UI can be present for a set
scrolling range. It's called a 'dialog' because
the behaviour is closest to that of a modal
dialog.
2019-08-22 15:21:31 +01:00
Tom Byers
85d54637fa Add tests for most scenarios 2019-08-22 15:16:45 +01:00
Tom Byers
9ef093cfda Add ScreenMock to helpers
Mocks DOM API calls for position and dimension of
elements and provides an API to allow access to
them.
2019-08-22 15:16:42 +01:00
Tom Byers
13c40a25d1 Changes to WindowMock helper
This includes the following fixes:

1. fix error in `WindowMock.setWidthTo`

   It was returning height, not width.

2. Fix for `WindowMock.reset`

   Changes to the scroll position need to go
   through the `scrollTo` method.

It also includes the following changes

1. Improve mocking of window scrollTop

   Increases the number of DOM API methods mocked
   to return the intended scrollTop value.

2. Change WindowMock.scrollBy to
   WindowMock.scrollTo

   Because you're not scrolling by an amount,
   you're scrolling to a position.

3. Give WindowMock getters for position/dimension

   It's useful to be able to get the
   position/dimension of the window in tests when
   you're resizing and scrolling it as part of the
   test.

4. Assign WindowMock spies on instantiation

   Assigning them whenever a dimension is set doesn't
   make sense. You're just setting a value, not
   changing how that value is accessed.
2019-08-22 15:12:43 +01:00
Tom Byers
93c3c4705f Merge pull request #3085 from alphagov/add-js-tests-for-api-key
Add js tests for api key
2019-08-21 10:10:21 +01:00
Tom Byers
3c50c3cd01 Merge pull request #3086 from alphagov/add-js-tests-for-colour-preview
Add tests for colour preview
2019-08-20 13:53:32 +01:00
Tom Byers
1edea76a50 Merge pull request #3087 from alphagov/add-js-tests-for-error-tracking
Add tests for error tracking module
2019-08-20 13:53:01 +01:00
Tom Byers
ddd8da0163 Add test for controlling height between states
The button shouldn't change its vertical position
when the state changes. The text confirming the
copy is just one line so setting height for both
based on the API key, which can run to 2 lines
makes sense.

Explained in this PR:

https://github.com/alphagov/notifications-admin/pull/2428
2019-08-20 13:49:09 +01:00
Tom Byers
cc70759a19 Add tests for API key module 2019-08-20 13:49:09 +01:00
Tom Byers
0e7b529fbc Add mock helpers for Range and Selection
To add the text from an element to the clipboard
you need to:
1. get the current Selection
1. create a Range from the contents of the element
2. clear any existing Ranges from the Selection
   and add the new Range to the selection
3. execute the 'copy' command

To track calls to all the DOM APIs involved in
this we need mocks for Range and Selection.

Range:

https://developer.mozilla.org/en-US/docs/Web/API/Range

Selection:

https://developer.mozilla.org/en-US/docs/Web/API/Selection

Also includes a base class to help building out
Web API interface mocks.
2019-08-20 13:49:09 +01:00