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

fix: can create new plans with test plan unchecked #370

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

pwnage101
Copy link
Contributor

@pwnage101 pwnage101 commented Dec 8, 2023

Somehow we let a regression slip through manual QA testing and unit testing which prevented non-test plans from being created. The provisioning tool would POST to create a subsidy, but failed to supply a default_internal_only request parameter, which is required. This change adds a default value for formData.internalOnly on context initialization to prevent the field from ever being empty.

ENT-8107

testing done

  1. create a new plan without checking the Test Plan checkbox.
  2. create a new plan, checking the Test Plan checkbox.
  3. edit an existing plan, unchecking the Test Plan checkbox and saving.
  4. edit an existing plan, checking the Test Plan checkbox and saving.

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (439e611) 88.07% compared to head (cdaa47a) 88.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #370      +/-   ##
==========================================
- Coverage   88.07%   88.07%   -0.01%     
==========================================
  Files         161      161              
  Lines        3364     3362       -2     
  Branches      828      827       -1     
==========================================
- Hits         2963     2961       -2     
  Misses        397      397              
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pwnage101 pwnage101 marked this pull request as ready for review December 11, 2023 06:41
Comment on lines +23 to +24
// `internalOnly` backs the "Test plan" checkbox. A true value means the plan will not be customer facing.
internalOnly: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line fixes the bug.

Comment on lines -14 to +16
let submittedFormInternalOnly;
if (isEditMode) {
submittedFormInternalOnly = formData.internalOnly;
}
const [value, setValue] = useState(submittedFormInternalOnly || false);
// formData.internalOnly is always defined, whether it's hydrated from an API call (isEditMode = true) or not
// (isEditMode = false) in which case ProvisioningContextProvider supplies a default.
const [value, setValue] = useState(formData.internalOnly || false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we can assume that formData.internalOnly is always defined, we can kill the if-condition.

Copy link
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏽 Great job

@pwnage101 pwnage101 merged commit 1541f15 into master Dec 11, 2023
5 checks passed
@pwnage101 pwnage101 deleted the pwnage101/ENT-8107 branch December 11, 2023 17:59
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