Commit Graph

88 Commits

Author SHA1 Message Date
Tom Byers
1a97c6028c Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-20 10:04:56 +00:00
Tom Byers
b17140ac46 Fix test description 2020-01-20 10:03:47 +00:00
Tom Byers
8a0d0a15a8 Hide cookie banner if no-js
Decided in discussions with @quis and @yahoopete
that users without JS available cannot
accept/reject analytics cookies so the banner has
no use.
2020-01-20 10:03:47 +00:00
Tom Byers
9a0d522964 Add JS tests for analytics & cookies JS
Includes:
- tests for the analytics interface ported from
  GOVUK Frontend Toolkit
- tests for the cookie banner that appears on all
  pages except the cookies page
- tests for the cookies page JS
- tests for the hasConsentFor function
- adding a deleteCookie helper to remove
  cookies during tests
- polyfill for insertAdjacentText

The last one is because JSDOM doesn't support
insertAdjacentText but our target browsers
do. This polyfill also includes one for
insertAdjacentHTML.
2020-01-20 10:03:36 +00:00
Leo Hemsted
66db735e09 Revert "Merge pull request #3238 from alphagov/cookies-update"
This reverts commit eec4bec761, reversing
changes made to 64480e2fff.
2020-01-15 14:40:48 +00:00
Tom Byers
b86398ddda Fix associated test 2020-01-15 12:03:44 +00:00
Tom Byers
dce6a46df6 Make Google Analytics cookies expire in 1 year 2020-01-14 14:16:00 +00:00
Tom Byers
c18cb1e984 Default the cookie banner to be hidden
It should only be shown if JS is available and the
cookieMessage JS finds consent has not been set.
2020-01-14 12:11:40 +00:00
Tom Byers
b6e37a6ac8 Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-14 11:28:06 +00:00
Tom Byers
7d31431cef Fix test description 2020-01-08 17:48:37 +00:00
Tom Byers
f156fe2e95 Hide cookie banner if no-js
Decided in discussions with @quis and @yahoopete
that users without JS available cannot
accept/reject analytics cookies so the banner has
no use.
2020-01-08 10:23:52 +00:00
Tom Byers
900aa19bd3 Add JS tests for analytics & cookies JS
Includes:
- tests for the analytics interface ported from
  GOVUK Frontend Toolkit
- tests for the cookie banner that appears on all
  pages except the cookies page
- tests for the cookies page JS
- tests for the hasConsentFor function
- adding a deleteCookie helper to remove
  cookies during tests
- polyfill for insertAdjacentText

The last one is because JSDOM doesn't support
insertAdjacentText but our target browsers
do. This polyfill also includes one for
insertAdjacentHTML.
2020-01-06 13:38:34 +00:00
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