Commit Graph

76 Commits

Author SHA1 Message Date
Tom Byers
c1b8fb7531 Replace all visually-hidden classes
These have been replaced:

https://design-system.service.gov.uk/get-started/updating-your-code/#helper-class-names
2019-11-27 14:15:32 +00:00
Tom Byers
e09d510ab8 Revert "Replace govuk template with govuk frontend components - rewrite" 2019-11-26 12:14:09 +00:00
Tom Byers
2bd7ce8cf6 Replace all visually-hidden classes
These have been replaced:

https://design-system.service.gov.uk/get-started/updating-your-code/#helper-class-names
2019-11-25 11:43:30 +00:00
Tom Byers
e02f94f238 Revert "Replace govuk template with govuk frontend components" 2019-11-25 10:37:35 +00:00
Tom Byers
c3b2d3c521 Replace all visually-hidden classes
These have been replaced:

https://design-system.service.gov.uk/get-started/updating-your-code/#helper-class-names
2019-11-22 17:45:45 +00:00
Tom Byers
059fb66fae Merge pull request #3173 from alphagov/dependabot/npm_and_yarn/jquery-3.4.1
Bump jquery from 1.12.4 to 3.4.1
2019-11-11 14:23:06 +00:00
Tom Byers
47781cc929 Change treatment of space character in URLs
jQuery changed it from using '+' to '%20' between
versions 1 and 3. This updates the test to match.
2019-11-11 12:08:21 +00:00
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
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
Tom Byers
d516c85279 Merge pull request #3105 from alphagov/add-js-tests-for-live-search
Add js tests for live search
2019-10-23 15:37:32 +01:00
Tom Byers
2a7f464df7 Merge pull request #3106 from alphagov/add-js-tests-for-preview-pane
Add js tests for preview pane
2019-10-23 15:22:23 +01:00
Tom Byers
d7b99c733d Merge pull request #3110 from alphagov/add-js-tests-for-update-content
Add JS tests for update content
2019-10-23 15:12:55 +01:00
Tom Byers
605f027c61 Add tests for highlight tags module 2019-10-03 07:59:19 +01:00
Tom Byers
2b3bfc109a Add tests for live-search module 2019-10-03 07:57:47 +01:00
Tom Byers
125243addc Add tests for preview pane JS 2019-10-03 07:56:58 +01:00
Tom Byers
a67d1901c0 Add mock for window.location 2019-10-03 07:56:57 +01:00
Tom Byers
2fdf8161d2 Fix radios helpers
They were using a 'name' property which wasn't
being set in the data. Radios share the same name
attribute so they can get it from the parent
group.

Also includes fixes for tests where the original
API is used.
2019-10-03 07:56:57 +01:00
Tom Byers
5df4864743 Add note about advanceTimersByTime units 2019-10-03 07:56:22 +01:00
Tom Byers
c241d1eb5e Add tests for updateContent module 2019-10-03 07:56:22 +01:00
Tom Byers
bbb1ca33e9 Add utility helper for making form data sendable
Useful for assertions where the data you're
comparing is already in this format.
2019-10-03 07:56:22 +01:00
Tom Byers
0543dca23d Improve description of cancel link tests 2019-10-01 14:19:06 +01:00
Tom Byers
b6b1e7682b Rename the 'clear selection' link
In response to the sensible comments here:

https://github.com/alphagov/notifications-admin/pull/3053#discussion_r329957545
2019-10-01 14:10:22 +01:00
Tom Byers
8b9c8f2f95 Fix typo in comment 2019-10-01 08:26:08 +01:00
Tom Byers
5bd1e4bb7e Move template list fixture function into helpers
This will be needed in other tests so should be
made into a helper.
2019-10-01 08:26:08 +01:00
Tom Byers
f495288034 Add tests for integration with sticky JS 2019-10-01 08:26:08 +01:00
Tom Byers
60389d7087 Add tests for templateFolderForm JS interactions 2019-10-01 08:26:08 +01:00
Tom Byers
a93a7172e2 Merge pull request #3092 from alphagov/add-js-tests-for-file-upload
Add tests for fileUpload module
2019-09-30 11:08:31 +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
Tom Byers
4529f637b5 Add tests for fileUpload module 2019-09-05 09:37:53 +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
Tom Byers
baf8c1fddb Split helpers into separate files 2019-08-27 17:00:22 +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