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

chore: conditional verification routing #2598

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

shon-button
Copy link
Contributor

@shon-button shon-button commented Dec 16, 2024

Addresses 405

🚀 Impact:

  • Implements conditional routing from Compliance Summary Form button Continue to either Verification or Final Review

🔬 Local Testing:

  1. From terminal command, start the api server:
cd bc_obps
make reset_db
make run
  1. From terminal command, start the app development server:
cd bciers && yarn dev-all

Test Registration Purpose = "OBPS Regulated Operation"

  1. Navigate to http://localhost:3000
  2. Click button "Log in with Business BCeID"
  3. Navigate to http://localhost:3000/reporting/reports
  4. On row Operation 3, click button Start
    Expected Results
  • Review operation information page displays
  • Field Registration Purpose = "OBPS Regulated Operation"
    image
  1. Complete the report pages until http://localhost:3000/reporting/reports/3/compliance-summary
    Expected Results
  • Compliance Summary page displays
  • Page has button Continue
    image
  1. Click button Continue
    Expected Results
  • Verification page displays because Operation 3/Registration Purpose = "OBPS Regulated Operation"
    image

Test Registration Purpose = "Electricity Import Operation"

  1. Navigate to http://localhost:3000/reporting/reports
  2. On row Operation 14, click button Start
    Expected Results
  • Review operation information page displays
  • Field Registration Purpose = "Electricity Import Operation"
  1. Complete the report pages so that total emissions attributable < 25,000 TCo2
  2. From http://localhost:3000/reporting/reports/14/compliance-summary click button Continue
    Expected Results
  • Final page displays because Operation 14/Registration Purpose != ("OBPS Regulated Operation":"Opt-in"; "New Entrant") AND total emissions attributable < 25,000 TCo2
    image

Optional: Test Registration Purpose = "Electricity Import Operation" total emissions attributable >=25,000 TCo2

  1. Navigate to http://localhost:3000/reporting/reports
  2. On row Operation 14, click button Start
  3. Complete the report pages so total emissions attributable >=25,000 TCo2
  4. From http://localhost:3000/reporting/reports/14/compliance-summary click button Continue
    Expected Results
  • Verification page displays because Operation 14/ total emissions attributable >=25,000 TCo2
    image

@shon-button shon-button force-pushed the chore/405-verification-conditions branch 13 times, most recently from eda1257 to a4b1611 Compare December 17, 2024 16:41
Copy link
Contributor

@pbastia pbastia left a comment

Choose a reason for hiding this comment

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

Amazing work as usual! I'll open a tech debt card for the one comment left

Comment on lines +25 to +40
let needsVerification = false;
//🔍 Check if registration purpose is OBPS Regulated Operation, Opt-in or New Entrants
const registrationPurpose = (await getRegistrationPurpose(version_id))
?.registration_purpose;
needsVerification = regulatedOperationPurposes.includes(
registrationPurpose as RegistrationPurposes,
);
if (
needsVerification === false &&
registrationPurpose === RegistrationPurposes.REPORTING_OPERATION
) {
//🔍 Check if the registration purpose is Reporting Operation AND their total emissions attributable for reporting threshold is = or > than 25,000 TCo2
const attributableEmissionThreshold = 25000000;
const attributableEmissions = await getAttributableEmissions(version_id);
needsVerification = attributableEmissions >= attributableEmissionThreshold;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should do this on the API side, otherwise technically an individual with malicious intentions might bypass it on the client.
It'll also allow us to refactor that logic for other forms under a service of some sorts, like a follow up to bcgov/cas-reporting#445 and bcgov/cas-reporting#450

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pbastia

For your consideration, as this component is a server side component; perhaps, it is as safe from mal-intent as an API ?

@shon-button shon-button force-pushed the chore/405-verification-conditions branch from e9c2d59 to 58d4f6c Compare December 17, 2024 16:59
chore: prettier

chore: update vitest

chore: prettier

chore: prettier

chore: prettier

chore: prettier
@shon-button shon-button force-pushed the chore/405-verification-conditions branch from 58d4f6c to 195b0b3 Compare December 17, 2024 18:26
chore: prettier

chore: prettier

chore: cleanup

chore: bump next.js to pass yarn audit

chore: cleanup
@shon-button shon-button force-pushed the chore/405-verification-conditions branch from 8ff64d5 to 95a8c6f Compare December 17, 2024 18:39
@shon-button shon-button merged commit 3527909 into develop Dec 17, 2024
41 of 42 checks passed
@shon-button shon-button deleted the chore/405-verification-conditions branch December 18, 2024 14:23
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.

2 participants