Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit form contact details #462

Merged
merged 14 commits into from
Sep 16, 2024
Merged

Conversation

davidjamesstone
Copy link
Contributor

@davidjamesstone davidjamesstone commented Sep 10, 2024

image

image

image

image

Copy link
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ace work @davidjamesstone

Some minor comments, see what you think

designer/server/src/models/forms/contact.js Outdated Show resolved Hide resolved
const { slug } = params
const { token } = auth.credentials

const validation = yar.flash(sessionNames.validationFailure).at(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried how much we're sharing sessionNames.validationFailure

You could potentially submit a form in one form and see the errors in another (separate tab)

Should we keep the same name, but use a nested object keyed by route name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good point. Future improvement?

document.querySelector('#address')
)

expect(address?.value).toBe('[email protected]')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not a fan of coercing everything to HTMLInputElement, have you seen this?

Suggested change
expect(address?.value).toBe('[email protected]')
expect(address).toHaveValue('[email protected]')

Although, can we start switching to ByRole queries so we're testing labels + hints at the same time?

I've been following the $XXX syntax for queried elements that GOV.UK Frontend uses too:

Suggested change
expect(address?.value).toBe('[email protected]')
const $address = screen.getByRole('textbox', {
name: 'Email address',
description: 'XXX'
})
expect($address).toHaveValue('[email protected]')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved with 50f25b4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @davidjamesstone

What about the ByRole queries?

We're currently using field IDs but "role" queries also test if labels/hints etc are wired up too

designer/server/src/routes/forms/contact/phone.js Outdated Show resolved Hide resolved
designer/server/src/views/forms/overview.njk Outdated Show resolved Hide resolved
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7.8% Duplication on New Code (required ≤ 3%)
2 New Critical Issues (required ≤ 0)
3 New Major Issues (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@davidjamesstone davidjamesstone merged commit c414b38 into main Sep 16, 2024
7 of 9 checks passed
@davidjamesstone davidjamesstone deleted the feature/290019-support-details branch September 16, 2024 12:37
@colinrotherham
Copy link
Contributor

I'll add a fix to my code coverage PR, but there was a compiler error in this one:

> [email protected] lint:types
> tsc --build tsconfig.json

designer/server/src/routes/forms/create.js(326,3): error TS2322: Type '{ createForm: "createFormValidationFailure"; privacyNotice: "privacyNoticeValidationFailure"; contactEmail: "contactEmailValidationFailure"; contactPhone: "contactPhoneValidationFailure"; contactOnline: "contactOnlineValidationFailure"; }' is not assignable to type '"create" | "redirectTo" | "fileDownloadValidationFailure" | "successNotification" | "errorList" | "validationFailure" | undefined'.
designer/server/src/routes/forms/api.js(62,23): error TS2345: Argument of type '{ createForm: "createFormValidationFailure"; privacyNotice: "privacyNoticeValidationFailure"; contactEmail: "contactEmailValidationFailure"; contactPhone: "contactPhoneValidationFailure"; contactOnline: "contactOnlineValidationFailure"; }' is not assignable to parameter of type 'string'.

@colinrotherham
Copy link
Contributor

Fixed in commit range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants