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

feat: frontend expiring certification warnings and sign-in prevention #205

Merged
merged 9 commits into from
Jan 7, 2025

Conversation

mathcolo
Copy link
Collaborator

@mathcolo mathcolo commented Dec 20, 2024

Asana Task: 📐 Implement Warnings for Expiring Certifications

image image image image

Checklist

  • https://github.com/mbta/terraform_modules/pull/58
  • Tests:
    • (x) Has tests
    • ( ) Doesn't need tests
    • ( ) Tests deferred (with justification)
  • Product/Design sign off:
    • (x) Okayed the plan for the feature (e.g. the design files, or the Asana task)
    • ( ) Reviewed the feature as implemented (e.g. on dev-green, or saw screenshots)
    • ( ) No review needed

@mathcolo mathcolo force-pushed the pim-load-certifications-frontend branch from f2d8c5e to 614450e Compare January 2, 2025 20:38
@mathcolo mathcolo added the deploy-to-sandbox deploy this PR to sandbox label Jan 2, 2025
@mathcolo mathcolo marked this pull request as ready for review January 2, 2025 23:23
@mathcolo mathcolo requested a review from a team as a code owner January 2, 2025 23:23
Copy link
Member

@skyqrose skyqrose left a comment

Choose a reason for hiding this comment

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

There was some talk about whether we should warn on someone not having any certifications in the database. I don't remember the resolution of that discussion. Should anything like that be incorporated into this feature?

js/hooks/useCertifications.ts Outdated Show resolved Hide resolved
js/models/certification.ts Outdated Show resolved Hide resolved
js/components/operatorSignIn/attestation.tsx Outdated Show resolved Hide resolved
js/test/components/operatorSignIn/attestation.test.tsx Outdated Show resolved Hide resolved
@@ -216,4 +227,42 @@ describe("Attestation", () => {
expect(onComplete).not.toHaveBeenCalled();
jest.useRealTimers();
});

describe("expiry", () => {
Copy link
Member

Choose a reason for hiding this comment

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

attestation.test.tsx now has a test for the expired case. But does it need a test that it shows the about to expire warning? I see that the details of that situation are asserted in expiry.test.tsx, but I'm thinking about a test that proves that CertificationBoxes is called.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The assertion on 243

expect(view.getByText("Expired card")).toBeInTheDocument();

is checking text that only appears in a certificate box, so it's guaranteeing it implicitly 👍

return (
<WarningParagraph
className={className([
"border-0 light:bg-opacity-40 dark:bg-opacity-30 dark:text-white",
Copy link
Member

Choose a reason for hiding this comment

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

refactoring suggestion: This is the only use of WarningParagraph, and these styles don't need to be controlled dynamically, so should they be part of WarningParagraph instead of passed in as an argument?

And should the background color be controlled by passing in "warning" or "error" instead of by giving an extraClassName?

Or, alternatively, WarningParagraph is just 2 divs and some styles, and it's not used anywhere else, so maybe it should be inlined here instead of abstracted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Inlined 👍 yeah, I honestly don't know why I made this separate in glides (which I copypastaed over here!)

js/components/operatorSignIn/expiry.tsx Outdated Show resolved Hide resolved
js/components/operatorSignIn/expiry.tsx Outdated Show resolved Hide resolved
js/components/operatorSignIn/expiry.tsx Outdated Show resolved Hide resolved
Copy link
Member

@skyqrose skyqrose left a comment

Choose a reason for hiding this comment

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

A couple comments, but no re-review needed after.

Comment on lines 57 to 59
"mb-4 mt-2 flex flex-row rounded border-0 px-3 py-2",
mode === "warning" && "bg-[#FFDE9E]",
mode === "error" && "bg-[#FF919A]",
Copy link
Member

Choose a reason for hiding this comment

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

A previous version (when there was the WarningParagraph component) had some extra classes. light:bg-opacity-40 dark:bg-opacity-30 dark:text-white. Did you mean to remove those in f54a721 ? (Also, I don't think border-0 is needed anymore, since no border should be the default.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, all intentional 👍 we don't have light/dark mode and the colors are exact. thanks for catching border-0!

# expires: "2025-01-24"
# }
# ]
# })
Copy link
Member

Choose a reason for hiding this comment

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

Left some dead code / test data in here.

@mathcolo mathcolo merged commit 5dfb5c9 into main Jan 7, 2025
5 checks passed
@mathcolo mathcolo deleted the pim-load-certifications-frontend branch January 7, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-to-sandbox deploy this PR to sandbox
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants