Commit Graph

225 Commits

Author SHA1 Message Date
Jonathan Bobel
67c8bef7aa Trying to change govukFieldset but I keep getting testing errors 2023-08-31 14:57:45 -04:00
Jonathan Bobel
2e16d8d31b Updates after merging black 2023-08-28 12:12:21 -04:00
Jonathan Bobel
8ab550a22f Radio buttons and list edits 2023-08-25 15:31:44 -04:00
Jonathan Bobel
8b3807da3c Removing the govuk-body class 2023-08-25 11:49:13 -04:00
Jonathan Bobel
a388178e2a Removing or changing more govuk styles 2023-08-25 10:40:56 -04:00
Jonathan Bobel
966e929d47 Got the tests to work 2023-08-23 11:24:35 -04:00
Jonathan Bobel
a4fc40bcba Renamed components folder, put failing tests back in to get some assistance with those 2023-08-22 12:40:53 -04:00
Jonathan Bobel
51fde90f79 A few clean-up items in the Platform Admin section 2023-08-18 11:30:30 -04:00
Jonathan Bobel
a574fc7b3a Working through the Platform Admin section 2023-08-17 15:13:26 -04:00
Jonathan Bobel
d66ff27bae Merge branch 'main' of https://github.com/GSA/notifications-admin into 686-remove-uk-styles
# Conflicts:
#	app/assets/stylesheets/main.scss
#	app/templates/views/find-users/user-information.html
#	app/templates/views/two-factor-webauthn.html
#	app/templates/views/user-profile/manage-security-key.html
#	app/templates/views/user-profile/security-keys.html
#	gulpfile.js
2023-08-15 13:29:39 -04:00
Jonathan Bobel
6b22c347da Got the tests to pass, so doing a commit 2023-08-15 13:22:39 -04:00
Carlo Costino
9e609efa1c Remove webauthn hooks
This changeset removes webauthn from the Notify.gov admin app.  We are not using webauthn at all in our implementation and will be looking at an entirely different authentication system in the near future.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2023-08-14 16:59:38 -04:00
Jonathan Bobel
1be305d045 Reworking checkboxes to adhere to USWDS styling 2023-08-14 10:35:11 -04:00
Jonathan Bobel
348e29fb40 - Removed links to the gov uk stylesheets
- Deleted /stylesheets folder
- Removed sass build from gulpfile
- Changed gov links to usa links
- Changed other govuk styles, like breadcrumbs
- Changed name of uk_components file to us_components
- Fixed a few tests that broke on account of the changes
2023-08-08 16:19:17 -04:00
Jonathan Bobel
bbc03d2ddb Deleting instead of commenting out 2023-07-14 10:39:12 -04:00
Jonathan Bobel
f11746324d Changing white space to try to kick this test off again 2023-07-13 12:54:40 -04:00
Jonathan Bobel
e2ba5e5bb7 Commenting out this test 2023-07-13 10:46:15 -04:00
Jonathan Bobel
1da906279f Removed links to the sticky javascript, but didn't remove altogether 2023-07-12 15:43:21 -04:00
Jonathan Bobel
f266084ddb Test passed, good time to commit 2023-06-16 14:55:24 -04:00
Steven Reilly
da623c87d6 Add Google Tag Manager for analytics (#541) 2023-06-12 13:52:38 -04:00
Jonathan Bobel
e0d2d74067 Update dashboard and template flow (#514)
* Updated header and footer
* Moved files around and updated gulpfile to correct the build process when it goes to production
* Updated fonts
* Adjusted grid templating
* Adding images to assets
* Updated account pages, dashboard, and pages in message sending flow
* Updated the styling for the landing pages in the account section once logged in
2023-06-08 13:12:00 -04:00
Steven Reilly
454b778582 Cookie streamlining (#493)
* remove cookie banner
* remove form from cookies.html
* move cookie content to privacy page
2023-05-03 15:33:27 -04:00
Andrew Shumway
575c2b7d75 Notify 473: add code coverage for jest (#488) 2023-05-02 16:38:28 -04:00
stvnrlly
b6bc02eb6b us → u.s. 2022-12-06 11:03:47 -05:00
stvnrlly
c8486ea015 midday → noon 2022-11-28 16:57:49 -05:00
Ryan Ahearn
e335487b9e Address PR feedback 2022-10-27 18:16:24 +00:00
Ryan Ahearn
bb2d57b27b Update tests to use most recent jest and supporting libraries 2022-10-27 11:12:39 -04:00
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
Chris Hill-Scott
6f856fdece Make terminology around visually hidden prefix clearer and more consistent
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2022-05-10 10:33:27 +01:00
Chris Hill-Scott
e82970d490 Remove whitespace around API key in JS templates
We removed whitespace in the HTML of the copy to clipboard component
in https://github.com/alphagov/notifications-admin/pull/4236/files

When the Javascript on the page loads it re-renders the component,
using HTML which is embedded in the .js file.

This means we also need to apply the same change to the .js file
to remove any extraneous whitespace.
2022-05-09 12:38:18 +01:00
Tom Byers
8521d1e45f Add assertions against stray classes
In previous iterations of the classPersister, we
found issues with the implementation meant classes
it should have added back to elements were also
added to other elements. This adds tests for this
scenario to ensure it doesn't happen again.

Also includes changes to fix a linting error with
the JS which complained about a function being
defined in a loop while referencing variables in
the outer scope.
2022-02-18 12:07:41 +00:00
Tom Byers
3a86bd1685 Change internals of classesPersister
The assumption that the classes you want to
persist will always have parity with the elements
that have those classes, at that point, won't
always be true.

Because of that, this changes the way elements
with those classes are stored, to be in a map
between classes and the elements with them (at
that point).

Also includes an extra test for a scenario where
more than one updating component is in the page
with classes that need to persist through updates.
2022-02-16 15:59:29 +00:00
Tom Byers
41ee340b45 Rewrite updateContent tests 2022-02-16 11:25:50 +00:00
Tom Byers
e310ff3469 Quick fixes for updateContent tests
To address issues in these comments:
- https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804641078
- https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804642005
2022-02-11 16:36:49 +00:00
Tom Byers
51594e7d46 Add test for changes to component HTML on start
The updateContent JS was changed in this commit so
the replacement of the original HTML (with GOVUK
modules data-attributes) was moved into the start
method rather than being a slightly odd side
effect of the render function diffing:

476ed1593c

This adds a test to make it more clear this
happens, as requested in this comment:

https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804689618
2022-02-11 15:10:23 +00:00
Tom Byers
3fa2650ffa Make updateContent persist specified classNames
Wrap the code that updates the HTML with changes
from the server with code that stores and
re-applies specified classes.

This is to allow other JS to add classes which
change the visual state of the HTML without them
being considered by the code that diffs our
in-page HTML against that from the server.

They are called classesToPersist because this
should make the visual state they create persist
between updates.

Includes the addition of tests for updateContent
that cover the addition/deletion of elements so we
can write a test for classNames persisting through
updates. The existing tests only cover updates
that change the content of elements. Just adding
the test for these changes to those would simulate
a scenario that doesn't exist in the app. Writing
extra tests for the kind of updates these changes
act on keeps them in line with the app code.
2022-02-09 12:24:59 +00:00
Tom Byers
77f7d1453c Replace domdiff library with morphdom
We added domdiff to replace the DiffDOM library
here:

87f54d1e88

DiffDOM had updated its code to be written to the
ECMAScript 6 (ES6) standard and so needed extra
work to work with the older browsers in our
support matrix. This was recorded as an issue
here:

https://www.pivotaltracker.com/n/projects/1443052/stories/165380360

Domdiff didn't work (see below for more details)
so this replaces it with the morphdom library.
Morphdom supports the same browsers as us and is
relied on by a range of large open source
projects:

https://github.com/patrick-steele-idem/morphdom#what-projects-are-using-morphdom

It was tricky to find alternatives to DiffDOM so
if we have to source alternatives in future, other
options could be:
- https://github.com/choojs/nanomorph
- https://diffhtml.org/index.html (using its
  outerHTML method)

Why domdiff didn't work

Turns out that domdiff was replacing the page HTML
with the HTML from the AJAX response every time,
not just when they differed. This isn't a bug.
Domdiff is bare bones enough that it compares old
DOM nodes to new DOM nodes with ===. With our
code, this always results to false because our new
nodes are made from HTML strings from AJAX
response so are never the same node as the old
one.
2022-01-27 11:37:53 +00:00
Chris Hill-Scott
edd2a04c7a Make autofocus work on all form elements which ask for it
In 674c27a693 we updated the autofocus
Javascript to be compatible with GOV.UK Frontend textboxes, which have
the `data-module` attribute set on the `input` element, rather than on
a wrapper element.

However we still have some `<textarea>`s and `<input>`s which haven’t
moved to GOV.UK Frontend and therefore aren’t getting picked up by the
Javascript which is supposed to focus them.

This commit makes the Javascript work with both kinds of textbox, which
is needed until we move entirely to GOV.UK Frontend.
2021-11-04 16:26:12 +00:00
Tom Byers
2b91d1d524 Fix mis-spelling of aria-describedby
This is currently spelt incorrectly though it
seemed to work nonetheless. Can only assume this
is a common error, for this attribute or all
attribute names, so browsers work it out.

This makes the spelling match the spec:

https://www.w3.org/TR/wai-aria/#aria-describedby
2021-10-19 11:09:37 +01:00
Tom Byers
37ae04f67e Make test comments explain use of require better
Based on comments on the pull request associated
with this work:

https://github.com/alphagov/notifications-admin/pull/4023#discussion_r711156154
2021-09-22 12:05:48 +01:00
Tom Byers
55287e944d Update updateContent tests to reflect its use
The way we're using the updateContent.js code is
slightly different to expected and to the
scenarios in our tests. This changes the
tests to match that use.

The expected behaviour was for updates to a
module's HTML to happen to the HTML inside of the
div[data-module=update-content] element.

So with initial HTML of:

<div data-module="update-content" data-key="one">
  <div class="ajax-block-container">
    Existing content
  </div>
</div>

...should be updated to be:

<div data-module="update-content" data-key="one">
  <div class="ajax-block-container">
    New content
  </div>
</div>

Instead the HTML returned by the AJAX requests
replaced the div[data-module=update-content]
element.

So with initial HTML of:

<div data-module="update-content" ..>
  <div class="ajax-block-container">
    Existing content
  </div>
</div>

...will be updated to be:

<div class="ajax-block-container">
  New content
</div>

This doesn't seem to create any noticable changes
to the visual interface so, I think, went
unnoticed. The assumption I am making, of this
being unintended, is based on the fact that the
div[data-module=update-content] element has an
aria-live attribute, which authors would normally
want to stay in the page when updates happen.

Note: This commit doesn't try and fix the problem,
as the behaviour still largely works and the lack
of aria-live actually seems to be a positive
thing, meaning non-visual users aren't told of
every update but can discover it themselves if
needed.
2021-09-22 12:05:47 +01:00
Tom Byers
87f54d1e88 Replace diffDOM library with domdiff
A while ago diffDOM moved its code to use ES6
modules and started using various language
features specific to ES6. These two things
happened independently btw.

The result of this is that the version of diffDOM
suitable for our build pipeline, structured as an
immediately invoked function evocation (IIFE),
now requires polyfills of some ES6 features to
work in the older browsers we support, like IE11.

It's also worth noting that in the move to ES6
the maintainers of diffDOM have adopted a process
whereby users who need to support older browsers
now have to add polyfill code for any ES6 features
they choose to use.

This commmit proposes a move to the domdiff
library instead because:
- it runs on all javascript runtimes with no
  polyfills
- it is 2KB instead of diffDOM's 25KB

Domdiff takes a different approach to diffDOM, in
that it compares existing nodes and new nodes and
replaces the existing ones with the new ones if
there are differences. By contrast, diffDOM will
make in-place changes to nodes if there are enough
similarities. In other words, in most situations,
diffDOM won't change the node in $component
whereas domdiff will.

Because of this, I've had to change the
updateContent.js code to cache the data-key
attribute's value so we don't lose access to it by
overwrite the $component variable with a different
jQuery selection.
2021-09-22 12:05:47 +01:00
Leo Hemsted
a96bfdb16e remove server-side error messages for webauthn
since we are hard-coding a generic error message on the front-end, we
have no need to do anything on the back end. This is also nice as it
standardises the two flows to behave more like each other (rather than
previously where one would `flash` an error message and the other would
return CBOR for the js to decode).

Note that the register flow returns 400 while the auth flow returns 403.
The js for both just checks `response.ok` so will handle both. The JS
completely discards any body returned if the status isn't 200 now.
2021-09-15 11:43:41 +01:00
Leo Hemsted
2c55f4d0ce hard-code html error message for errorBanner
turns out that we're only using errorBanner with a static message, and
it's also full of rich html content. This means that it's probably
better to put it in the html templates with other content, rather than
hidden away in js files if we can help it.

Since there are two places, had to dupe the error message but i think
that's fine as i don't anticipate this error message being used in
significantly more places.

making it a string is a bit gross and means we don't get nice syntax
highlighting on it, but as it needs to be passed in to a jinja macro
that's the way it has to go unfortunately.
2021-09-14 18:43:27 +01:00
Leo Hemsted
0b27d7e0a9 show error message in banner rather than an alert
the banner is a nicer user experience, and consistent with how we
display errors elsewhere in notify. For now pass through the error
message from JS, but we'll probably want to change that since the erorr
messages themselves are often a bit cryptic and unhelpful
2021-09-14 18:43:26 +01:00
Leo Hemsted
c96a1dc0b7 add new error banner module for showing users js errors
this ensures it's reusable by other components, and easier to unit test
by isolating the separate concerns

note: this is not in Modules since that's designed for classes that are
then bound to an element in the DOM as indicated by a data-module
attribute. This will just live at the window.GOVUK level since we want
there to only ever be one `.banner-dangerous` warning.
2021-09-14 18:43:25 +01:00
Leo Hemsted
85f6881a56 rename api key component to copy_to_clipboard
does what it says on the tin, and is also consistent with prior art:
https://components.publishing.service.gov.uk/component-guide/copy_to_clipboard
2021-09-08 10:18:17 +01:00
Ben Thorner
a2fb92ab74 Remove redundant semicolons in ES6 tests 2021-06-10 14:48:18 +01:00
Ben Thorner
1bb49e5456 Remove redundant spies after assertions
We only need to assert on the URL for the subsequent POST back to
the server, at which point we can call the test "done()". This is
a technique we use in the following tests as well, so we don't need
to comment about it here.
2021-06-10 14:47:58 +01:00
Ben Thorner
2d98bf6c5d Restore all mocks after each test
This is easier than re-assigning the mock functions manually, as
we're reusing Jest's in-built behaviour. Because all the mocks
are restored, we need to move the ones we had in the beforeAll
block into the beforeEach block.

Note: "require('./support/teardown.js')" also resets all Jest
mocks, but "require" only runs once, so we can't use it in a
beforeEach block [1]. We could do a "jest.resetModules()" to fix
that, which seems worse on the whole. I think there's a broader
discussion here about whether we could / should have a global
reset of Jest mocks after each test - I quickly tried this and
it causes some existing tests to fail :-|.

[1]: https://stackoverflow.com/questions/48989643/how-to-reset-module-imported-between-tests
2021-06-10 14:43:30 +01:00