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

test, upcoming: [M3-7134, M3-7314] - Add integration test for AGLB Edit Certificate flow and improve form validation #9880

Merged
merged 8 commits into from
Nov 7, 2023

Conversation

mjac0bs
Copy link
Contributor

@mjac0bs mjac0bs commented Nov 6, 2023

Description 📝

This PR does two things, because fixing the validation was necessary for writing a complete integration test that confirmed all input errors were handled gracefully.

  1. Add Cypress integration tests to confirm the UI flow for AGLB certification editing works as expected.
  2. Provide form validation to prevent a user from being able to edit a certificate and provide a blank label.

Changes 🔄

Integration tests in load-balancer-certificates.spec.ts test the following:

  • User can edit certificates from the AGLB certificate page (route: /loadbalancers/:id/certificates)
  • Certificates page updates to reflect edited certificates
  • Cloud Manager handles user input errors (e.g. empty or invalid fields/selections) gracefully
  • Cloud Manager handles server errors (e.g. HTTP 500 responses from the API) gracefully

In the Cloud Manager UI:

  • A validation error ("Label must not be empty.") is provided when a user attempts to submit the Edit Certificate drawer with a blank label field.

Preview 📷

Before After
Screen.Recording.2023-11-06.at.3.12.03.PM.mov
Screen.Recording.2023-11-06.at.3.10.57.PM.mov

Screenshot 2023-11-06 at 2 39 18 PM

How to test 🧪

Prerequisites

(How to setup test environment)

  • Checkout this PR.
  • Make sure the aglb feature flag is on and turn mocks on.

Reproduction steps

(How to reproduce the issue, if applicable)

  • Checkout develop.
  • Go to http://localhost:3000/loadbalancers/0/certificates.
  • Use the action menu (...) to select the Edit action and open the Edit Certificate drawer.
  • Clear the pre-populated label field.
  • Submit the form.
  • Observe there is no validation error and in the request payload, the blank label is submitted. (Due to the mocks, this isn't visible in the UI.)

Verification steps

(How to verify changes)

  • On this branch, go to http://localhost:3000/loadbalancers/0/certificates.
  • Use the action menu (...) to select the Edit action and open the Edit Certificate drawer.
  • Clear the pre-populated label field.
  • Submit the form.
  • Observe there is a validation error Label must not be empty and the form will not submit until a label is provided.

Also confirm the following validation still works as expected by checking the request payload:

  • When editing a TLS certificate:
    • A user can edit just the form label, and the form will submit. The certificate will be excluded from the payload since it has not changed.
    • A user can edit just the key, and the form will submit. The existing certificate will be included in the payload, since updating a key requires a cert.
    • A user cannot edit just the cert and will see a validation error on Private Key. This is invalid because updating a cert requires a key, and API does not return the key for security.
    • A user can edit both the cert and the key, and the form will submit. Both the edited cert and edited key will be in the payload.

Confirm the integration test passes:

yarn cy:run -s "cypress/e2e/core/loadBalancers/load-balancer-certificates.spec.ts"

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@mjac0bs mjac0bs added the ACLB Relating to the Akamai Cloud Load Balancer label Nov 6, 2023
@mjac0bs mjac0bs self-assigned this Nov 6, 2023
{!certificate ? (
<Notice variant="error">Error loading certificate.</Notice>
) : (
<form onSubmit={formik.handleSubmit}>
{errorMap.none && <Notice text={errorMap.none} variant="error" />}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow an extra error notice had slipped in originally -- cleaned this up here.

Comment on lines +75 to +76
validateOnBlur: !error,
validateOnChange: !error,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following suit with what we did in another edit drawer even though this doesn't look as nice, it seems better than have disappearing errors if a user were to clear the label and update the cert, but not provide a key (see PR description video).

@mjac0bs mjac0bs marked this pull request as ready for review November 6, 2023 23:29
@mjac0bs mjac0bs requested a review from a team as a code owner November 6, 2023 23:29
@mjac0bs mjac0bs requested review from dwiley-akamai, coliu-akamai, bnussman-akamai and cliu-akamai and removed request for a team November 6, 2023 23:29
Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

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

Changes look great! Thanks for all of the tests too 🧪

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

Looks good! Confirmed everything listed, just had one small comment below.

(Edit: not sure why GitHub isn't showing the rest of my comment, so I'll just put the checks here above the video
Confirmed that all tests pass! ✅
Confirmed that error appears! ✅
Confirmed previous validation: ✅

  • ✅ A user can edit just the form label, and the form will submit. The certificate will be excluded from the payload since it has not changed.
  • ✅ A user can edit just the key, and the form will submit. The existing certificate will be included in the payload, since updating a key requires a cert.
  • ✅ A user cannot edit just the cert and will see a validation error on Private Key. This is invalid because updating a cert requires a key, and API does not return the key for security.
  • ✅ A user can edit both the cert and the key, and the form will submit. Both the edited cert and edited key will be in the payload.)

Could we add a scroll to error, especially for the forms that have the Private Key field?

Screen.Recording.2023-11-07.at.10.45.36.AM.mov

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Integration test passes ✅

"Label must not be empty" validation error when attempting to submit an edited cert with no label ✅

Edit just the form label, and the form will submit. The certificate will be excluded from the payload since it has not changed. ✅

Edit just the key, and the form will submit. The existing certificate will be included in the payload, since updating a key requires a cert. ✅

Cannot edit just the cert. See a validation error on Private Key. ✅

Can edit both the cert and the key, and the form will submit. Both the edited cert and edited key are in the payload. ✅

@mjac0bs
Copy link
Contributor Author

mjac0bs commented Nov 7, 2023

Could we add a scroll to error, especially for the forms that have the Private Key field?

@coliu-akamai Good call out for smaller screens!

I implemented scroll-into-view for the Edit drawer in 423e64c.

Screen.Recording.2023-11-07.at.3.00.23.PM.mov

Since we'd want the same behavior in the Create drawer, so I made the change there too. (Also noticed that the Create drawer is not an expanded width, which is a bad UX when the user pastes long certs, so I adjusted in 7624cec. Not very evident in the screencap because I squished my viewport to get the drawer to scroll.)

Screen.Recording.2023-11-07.at.3.01.04.PM.mov

@mjac0bs mjac0bs added Approved Multiple approvals and ready to merge! and removed Ready for Review labels Nov 7, 2023
Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

awesome, thanks Mariah! 🎉

@mjac0bs mjac0bs merged commit 2a863b5 into linode:develop Nov 7, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACLB Relating to the Akamai Cloud Load Balancer Approved Multiple approvals and ready to merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants