Commit Graph

140 Commits

Author SHA1 Message Date
Tom Byers
2f18e4b2f0 Update test helper that generates checkboxes
It was using GOVUK Elements HTML and we have since
moved to GOVUK Frontend.
2020-09-18 11:50:32 +01:00
Tom Byers
3719479356 Add tests for live-search announcements 2020-09-17 14:38:40 +01:00
Tom Byers
b4d985e071 Rewrite test descriptions
They originals didn't explain what the tests do.

We could test the contents of the range but that
would be testing the Range API, rather than our
use of it.

The tests test how we use that API for these
scenarios so their descriptions should say this.
2020-09-15 17:07:01 +01:00
Tom Byers
956f5d4c3e Make copy to clipboard work with prefixes
The prefix was being included in the selection
copied.
2020-09-15 17:04:03 +01:00
Tom Byers
d446a91a8e Merge pull request #3591 from alphagov/fix-copy-to-clipboard
Fix copy to clipboard
2020-08-28 10:58:36 +01:00
Chris Hill-Scott
674c27a693 Fix the autofocus component
Since moving textboxes to GOV.UK Frontend we’ve started putting the
data attribute on the `input` element itself, not a wrapper around it.

This commit updates the Javascript accordingly.
2020-08-27 08:50:28 +01:00
Tom Byers
c3e32b7f95 Fix JS tests 2020-08-25 16:03:01 +01:00
Pea M. Tyczynska
9b69d16963 Merge pull request #3554 from alphagov/convert-single-line-textboxes-to-govuk-frontend
Convert single line textboxes to govuk frontend
2020-08-18 11:29:44 +01:00
Pea Tyczynska
36c1ffa7be New template button takes user to new template page
for all services that only allow sending one type of notifications
2020-08-14 17:15:45 +01:00
Pea Tyczynska
1d2a73a1a4 Update TemplateAndFoldersSelectionForm fields
Changes its StringFields to GovukTextInputFields.

Includes changes to templates that use this form
and associated tests.
2020-08-12 10:34:51 +01:00
Pea Tyczynska
ad3b391e46 Convert ListEntry component to use new fields
ListEntry component uses FieldList field to group
textboxes. Textboxes can be text inputs, email fields
or international phone number fields. This converts
all field-lists to use:

- GovukTextInputField
- GovukEmailField
- InternationalPhoneNumber

Affects these forms:
- OrganisationDomainsForm
- GuestList

Also changes to related Javascript:

Update list-entry JS tests to match new HTML

Updates the HTML the JS operates on in the test
(a fixture representing the HTML in the page on
load) to match the new GOVUK Frontend we are
generating.

Make list-entry JS work with GOVUK Frontend HTML

The existing list-entry JS did a few things that
clashed with how the new HTML works:
- added a 'input-' prefix to the id attributes
  of all text-inputs
- did not make its name and id attributes values
  match

The new HTML has id and name attributes that
match so these changes remove the prefix for id
attributes and makes them match the name
attribute.

To understand these changes, it is useful to
know how the values for id and name attributes are
generated:
1. the id attribute for the component element is
   stored
2. the 'list-entry-' prefix is removed and the
   remainder is used to generate ids

For example, if the component's id is
'list-entry-domains', the id will be 'domains-1',
where the text-input is the first one.

This also adds some logic to the HoganJS template
to make the value attribute optional, so it is
only added if it has a non-null value. This
matches the behaviour of the text-input component
used in the new list-entry component.

Also change whitelist references to guestlist in tests
- we forgot to do it earlier, when we moved from calling this
feature whitelist to calling it guestlist.
2020-08-12 10:34:51 +01:00
Tom Byers
a3e661830d Convert text inputs on ServiceUpdateEmailBranding
Includes changes to templates that use this form
and associated tests.
2020-08-12 10:22:20 +01:00
Tom Byers
a74501f1d8 Merge pull request #3535 from alphagov/try-introducing-govuk-checkboxes-again
Try introducing govuk checkboxes again
2020-08-04 14:39:54 +01:00
Tom Byers
e3753ae623 Fix issues in tests from new fields 2020-07-24 11:34:02 +01:00
Tom Byers
e62fc846c7 Add test for scrollToRevealElement method 2020-07-17 11:57:19 +01:00
Tom Byers
741ab9288f Add tests for 'data-show-now-as-default' on/off 2020-07-17 08:28:59 +01:00
Tom Byers
b5360c14cc Lowercase value of 'show-now-as-default'
To match the boolean value in JavaScript.
2020-07-17 08:28:59 +01:00
Tom Byers
e45bbcf99e Fix comparison of original categories with new
These tests make sure the sub-categories shown
when a category is selected are right but the
comparison looked for a direct match between the
labels for both types.

This looks for the category label in the
sub-category label instead, ie.

'Today at' in 'Today at 1pm'.

...instead of

'Today at' === 'Today at 1pm', which will always
fail.
2020-07-17 08:28:59 +01:00
Tom Byers
909f2d4678 Fix numbering on hours in radioSelect test 2020-07-17 08:28:59 +01:00
Tom Byers
636cb6825b Fix use of querySelector in radioSelect tests 2020-07-17 08:28:58 +01:00
Chris Hill-Scott
83156bd16e Let users choose when to end a broadcast
Different emergencies will need broadcasts to last for a variable amount
of time. We give users some control over this by letting them stop a
broadcast early. But we should also let them set a maximum broadcast
time, for:
- when the duration of the danger is known
- when the broadcast has been live long enough to alert everyone who
  needs to know about it

This code re-uses the pattern for scheduling jobs, which has some
constraints that are probably OK for now:
- end time is limited to an hour
- longest duration is 3 whole days (eg if you start broadcasting Friday
  you have the choice of Saturday, Sunday and all of Monday, up to
  midnight)
2020-07-17 08:23:10 +01:00
Tom Byers
dfcddb757e Revert "Re-introduce govuk checkboxes" 2020-07-15 13:41:34 +01:00
Tom Byers
05088037d2 Fix issues in tests from new fields 2020-07-14 10:41:09 +01:00
Tom Byers
f0f461f5c9 Revert "Change checkboxes to GOVUK frontend" 2020-05-14 16:59:34 +01:00
Tom Byers
c9420418b3 Fix issues in tests from new fields 2020-05-13 17:37:44 +01:00
Chris Hill-Scott
8da16468ff Delay the initial AJAX call by 2 seconds
At the moment the first AJAX call is triggered as soon as the page
loads. We then look at its response time to work out how long to wait
until making the next call.

This isn’t great because:
- stuff is unlikely to have changed straight away, so it’s a waste of a
  call
- while the DOM is being updated it seems to introduce a delay in
  clicks on links, which is either more pronounced or more noticeable
  when it’s happening straight away, making the UI feel less snappy

I chose a value of 2 seconds as a rough proxy for the minimum time we’d
expect to see a notification go from created to delivered. Median
time-to-delivered was 2.9 seconds when we analysed it for
https://github.com/alphagov/notifications-admin/pull/2974#discussion_r286101286
2020-04-16 13:21:24 +01:00
Chris Hill-Scott
a2929ad748 Delay AJAX calls if the server is slow to respond
By default our AJAX calls were 2 seconds. Then they were 5 seconds
because someone reckoned 2 seconds was putting too much load on the
system. Then we made them 10 seconds while we were having an incident.
Then we made them 20 seconds for the heaviest pages, but back to 5
seconds or 2 seconds for the rest of the pages.

This is not a good situation because:
- it slows all services down equally, no  matter how much traffic they
  have, or which features they have  switched on
- it slows everything down by the same amount, no matter how much load
  the platform is under
- the values are set based on our worst performance, until we manually
  remember to switch them back
- we spend time during incidents deploying changes to slow down the
  dashboard refresh time because it’s a nothing-to-lose change that
  might relieve some symptoms, when we could be spending time digging
  into the underlying cause

This pull request makes the Javascript smarter about how long it waits
until it makes another AJAX call. It bases the delay on how long the
server takes to respond (as a proxy for how much load the server is
under).

It’s based on the square root of the response time, so is more sensitive
to slow downs early on, and less sensitive to slow downs later on. This
helps us give a more pronounced difference in delay between an AJAX call
that is fast (for example the page for a single notification) and one
that is slow (for example a dashboard for a service with lots of
traffic).

*Some examples of what this would mean for various pages*

Page | Response time | Wait until next AJAX call
---|---|---
Check a reply to address | 130ms | 1,850ms
Brand new service dashboard | 229ms | 2,783ms
HM Passport Office dashboard | 634ms | 5,294ms
NHS Coronavirus Service dashboard | 779ms | 5,977ms
_Example of the kind of slowness we’ve seen during an incident_ | 6,000ms | 18,364ms
GOV.UK email dashboard | `HTTP 504` | 😬
2020-04-09 12:05:18 +01:00
Katie Smith
a85f7fa2c1 Replace the .column-... classes in _grids.scss
We had 7 classes in _grids.scss named `.column-...` which were being
used to give a certain column width. These worked by using `@include
grid column()`, which is now deprecated.

`.column-whole` and `.column-three-quarters` can be removed and replaced
with `govuk-grid-column-full` and `govuk-grid-column-three-quarters`
respectively. The other column classes don't have a direct replacment in
GOV.UK Frontend. To get round this, we overwrite the `$govuk-grid-width`
SASS map in `extensions.scss` to add in extra widths, then use this with
the `govuk-grid-column` mixin to create new classes in for our custom
widths in `_grids.scss`
2020-03-06 11:11:41 +00:00
Katie Smith
bf949044bc Replace column-two-thirds with govuk-grid-column-two-thirds 2020-03-06 11:11:41 +00:00
Katie Smith
076d99c9dc Replace column-full with govuk-grid-column-full 2020-03-06 11:11:41 +00:00
Katie Smith
b9b9a138f9 Replace grid-row with govuk-grid-row
Replaced all instances of `grid-row` in the HTML and JavaScript with
`govuk-grid-row`, which is the new GOV.UK Frontend class.
2020-03-06 11:11:41 +00:00
Leo Hemsted
1558d05be7 ensure highlighting div size always matches the relevant textarea 2020-03-05 16:38:26 +00:00
Tom Byers
efa892423a Fix issues raised on pull request
Includes:
- make 'remove team member' link, on edit member
  permissions page, destructive
- convert missed links on /features pages
- convert missed links on /using-notify/guidance and sub pages
- give links in browse-lists back their size and
  weight (needed for lists of live and trial
  services on Platform Admin)
- give links on Platform Admin inbound numbers
  page back their size and weight
- update links in JS tests
2020-02-25 10:52:03 +00:00
Tom Byers
5b306dde4d Revert "Convert all links to govuk frontend" 2020-02-24 11:56:38 +00:00
Tom Byers
97172cca30 Merge branch 'master' into convert-all-links-to-govuk-frontend 2020-02-24 10:12:58 +00:00
Tom Byers
8a98c73b08 Make analytics send the same title for all pages
Sets it on the tracker which means this value gets
sent for each:
- pageview
- event

See: https://developers.google.com/analytics/devguides/collection/analyticsjs/pages

We can only test that this has been set on the
tracker, not how that effects what is sent to GA,
in the JS tests.

This change has been tested in-browser with the
Chrome Analytics Debugger. This revealed the
contents of what is in the beacon sent to GA and
allowed confirmation the title was being set
correctly.

See: https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna/related
2020-02-20 11:46:19 +00:00
Tom Byers
5459dd8c13 Fix issues raised on pull request
Includes:
- make 'remove team member' link, on edit member
  permissions page, destructive
- convert missed links on /features pages
- convert missed links on /using-notify/guidance and sub pages
- give links in browse-lists back their size and
  weight (needed for lists of live and trial
  services on Platform Admin)
- give links on Platform Admin inbound numbers
  page back their size and weight
- update links in JS tests
2020-02-20 09:19:06 +00:00
Katie Smith
e53a97423b Update radio-select to use govuk-frontend buttons 2020-02-17 08:05:05 +00:00
Katie Smith
0d0b71af63 Update buttons on api key pages to govuk-frontend buttons 2020-02-17 08:05:05 +00:00
Katie Smith
e53c5e17b3 Update file upload component to use govuk-frontend buttons 2020-02-17 08:05:05 +00:00
Katie Smith
2cbfaf1b6f Update the buttons on template folder form 2020-02-17 08:05:05 +00:00
Katie Smith
583a925e89 Add buttons for list entries
As part of updating the stylesheet, moved `.button-secondary` to the
global stylesheet, since this is not related to list entries but instead
affects all buttons with that class (this class wlil be removed once all
the buttons are using the new macro).
2020-02-17 08:05:05 +00:00
Katie Smith
4e42fa6f5d Update buttons for collapsible checkboxes
We use collapsible checkboxes when setting which folders team members
can see (on the manage folder page and on the edit team member page).
2020-02-17 08:05:05 +00:00
Katie Smith
ba8ac41953 Update Javascript tests
This only updates the JavaScript tests where we don't need to make changes to
the actual JavaScript too.
2020-02-17 08:05:05 +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
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
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
Tom Byers
62f1c5a88e Fix associated test 2020-01-20 10:05:15 +00:00