Commit Graph

2634 Commits

Author SHA1 Message Date
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
Pea (Malgorzata Tyczynska)
551c4abee2 Merge pull request #3089 from alphagov/search-services-by-name
Find services by name or partial name
2019-08-16 11:53:07 +01:00
Pea Tyczynska
3844d050ff Simplify find users by email view - valdiation already done by form 2019-08-16 11:20:36 +01:00
Pea Tyczynska
c717e37c48 Test no input 2019-08-15 17:06:43 +01:00
Pea Tyczynska
035cb19568 Find services by name or partial name 2019-08-14 11:38:58 +01:00
Tom Byers
436367ce81 Add tests for error tracking module 2019-08-12 16:48:23 +01:00
Tom Byers
5bda6a062e Add tests for colour preview 2019-08-12 16:29:28 +01:00
Katie Smith
8a453890e6 Add 'Uploads' hub and navigation
The uploads hub is just a page with text for now - there are no actions
available on the page. It is linked to from a new 'Uploads' menu item on
the left of the page which is only visible if your service has the
`letter` and `upload_letters` permissions and if the current user has
permissions to send messages.
2019-08-09 08:50:48 +01:00
Tom Byers
551f7b91f4 Test and then fix focus when module state changes
Includes tests for this.
2019-08-07 10:23:09 +01:00
Tom Byers
c11c054323 Fix option selection for keyboard users
Keyboard users select a time slot by moving to the
radio for that slot, using the arrow keys, and
selecting it by pressing 'space' or 'enter', like
a `<select>`.

We allow this by listening for 'keydown' events
from the 'enter' or 'space' keys on time slot
radios that are checked.

Browsers fire 'click' events alongside the
'keydown' event meaning it's possible for the
code that makes the selection to be run twice.

We currently guard against this by checking for
the `pageX` property of the event object,
reasoning that a click event fired by a key press
won't have a cursor position.

Most browsers we support set it to `0` but it
isn't always the case:

https://dom-event-test.glitch.me/results.html

For those browsers, the `!event.pageX` condition
resolves correctly so this works. Safari and
versions of Internet Explorer before 11 however,
set it to a positive number.

In those browsers, moving the selection between
radios using the arrow keys fired a 'click' event
which, in Safari and IE<11, was treated as a
mouse/touch event and so confirmed the selection.
This made it impossible to select a later time.

These changes replace the 'click' event on time
slots with an artifical one that tracks
mouse/trackpad clicks by listening for a
'mousedown' followed by a 'mouseup' on a time
slot. This doesn't fire on key presses so avoids
the problem.
2019-08-07 10:23:09 +01:00
Tom Byers
5186402958 Add tests for different selection methods
Adds tests for selection by keyboard, involving
making a selection with the arrow keys and
confirming it with the space or enter keys.
2019-08-07 10:23:09 +01:00
Tom Byers
6854361375 Expand event helpers
Extends triggerEvent, allowing the creation of
different types of event, and to change the data
on its object. Also fakes the positional data
browsers add to the event object.

Also adds helpers for simulating:
- all the events for a mouse click
- the events invovled in moving the selection in a radio group
2019-08-07 10:23:09 +01:00
Tom Byers
25b2414cec Add tests for radioSelect module 2019-08-07 10:23:09 +01:00
Rebecca Law
026a01a090 Changing the labels on the sevice setting page.
We added `Upload letters` to the platform admin service settings, which makes is confusing when next to `Upload documents`.
Also `User auth type editting` is a confusing label

`User auth type editting` --> `Email authentication`
`Uploading documents` --> `Send file by email`
2019-08-06 16:57:40 +01:00
Katie Smith
0882c76476 Add upload letters permission to service settings page
The upload_letters permission can only be changed by Platform Admin
users. It works in a similar way to the inbound_sms nested permission
- you only see the row in the table if you have the 'letter' permission,
but the 'letter' and 'upload_letters' are still separate permissions and
changing one does not affect the other.
2019-08-05 13:51:31 +01:00
Katie Smith
e72540d3f9 Merge pull request #3065 from alphagov/rename-endpoint
Remove ft from method and url, it doesn't add any meaning.
2019-07-29 10:07:31 +01:00
Katie Smith
123b769771 Change code order for Redis delete decorator
Before, the delete decorator would delete the keys from Redis and then
we made the request to api to change the data. However, it is possible
that the cache could get re-populated in between these two things
happening, and so would cache outdated data.

This changes the order to send the api request first. We then always
delete the specified keys from Redis. Changing the order of the code in
the decorator changes the order in which the cache keys get deleted, so
the tests have been updated.
2019-07-26 16:29:50 +01:00
Katie Smith
dc1c73c647 Delete service cache when changing an organisation's sector
When we change an organisation's sector we now also change the sector of
all its services, so we need to delete those services from Redis.
2019-07-26 16:26:20 +01:00
karlchillmaid
92343aa45e Update change links and headings (#3064)
* Update Settings titles
* Update Change links on settings
* Update Team members Change link
* Update Settings pages headings
2019-07-25 11:52:13 +01:00
Rebecca Law
cc29764d43 Update unit test for the content changes. 2019-07-24 12:03:30 +01:00
Chris Hill-Scott
45ae5b1782 Merge pull request #3041 from alphagov/delete-letter-contact
Let users delete letter contact blocks
2019-07-24 10:47:48 +01:00
Katie Smith
9dc13f1d8e Add new report to show monthly notification stats for each service
This report will be used by the engagement team. There is a form to give
a start and end date for the report, and the form is then downloaded
as a CSV file when the form is submitted.
2019-07-23 11:32:28 +01:00
Pea (Malgorzata Tyczynska)
1bd5ff1dfc Merge pull request #3057 from alphagov/new_org_types_part_1
Introduce new org types
2019-07-22 15:56:31 +01:00
Rebecca Law
e0bcad77f5 Remove ft from method name and url, it doesn't add any meaning. 2019-07-22 14:34:15 +01:00
Chris Hill-Scott
06bb0e997e Merge pull request #3056 from alphagov/spellcheck-email
Set autocomplete and spellcheck attributes on email field
2019-07-22 12:09:14 +01:00
Chris Hill-Scott
44d5dc44d3 Allow deleting default letter contact blocks
It’s possible to delete default letter contact blocks because there is a
fallback – having a blank letter contact block. This is different to SMS
senders and reply to addresses.

For this to make sense it also means:
- adding the ‘blank’ letter contact block to the list of letter contact
  blocks
- having a way of setting the default back to being blank
2019-07-22 11:57:11 +01:00
Chris Hill-Scott
17bf06d04c Let users delete letter contact blocks
Because they can delete email reply to addresses and text message
senders.
2019-07-22 11:57:11 +01:00
Chris Hill-Scott
19fd89a2ee Fix tests 2019-07-19 16:20:27 +01:00
Pea Tyczynska
eae1ccf607 Refactor following review 2019-07-19 16:10:55 +01:00
Pea Tyczynska
c8ed608c9a Only show nhs radios if user has nhs domain email
Also split local NHS into two groups following designer advice
on readability.
2019-07-18 17:07:42 +01:00
Chris Hill-Scott
2e78981648 Merge pull request #3054 from alphagov/remove-old-agreement-pages
Remove the user-specific agreement pages
2019-07-17 13:07:39 +01:00
Chris Hill-Scott
92ea5894bb Add autocomplete attribute to password fields
This helps the browser autocomplete them with the right thing.

Value based on https://www.w3.org/TR/WCAG21/#input-purposes
2019-07-16 17:15:17 +01:00
Chris Hill-Scott
30eeaec154 Add autocomplete to email address on register form
GOV.UK Design System recommends:
> You should also set the autocomplete attribute to email. This lets
> browsers autofill the email address on a user’s behalf if they’ve
> entered it previously.

Only doing this on the register and sign in forms because it’s unlikely
to be helpful where a user is trying to enter someone else’s email
address.
2019-07-16 17:14:49 +01:00
Chris Hill-Scott
88242c31d1 Don’t spellcheck email addresses
The GOV.UK Design System recommends:
> setting the spellcheck attribute to false so that browsers do not
> spellcheck the email address
2019-07-16 17:14:49 +01:00
Pea Tyczynska
77d281f44f Introduce new org types 2019-07-16 17:00:26 +01:00
Katie Smith
b6ebbe6f67 Add organisation_type property to Service model
This will return the organisation_type of the service's organisation (if
there is one), or the organisation_type of the service if not.
2019-07-16 11:36:19 +01:00
Katie Smith
53214937a8 Stop allowing the service org type to be changed
The service organisation type will either be the same as the org type of
the service's organisation or will be set by a user when creating a new
service. This removes the ability to change it from the platform admin
settings table.
2019-07-16 11:36:19 +01:00