-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(core): catch type issues when configuring from external json #14101
base: main
Are you sure you want to change the base?
test(core): catch type issues when configuring from external json #14101
Conversation
// Ensures that all optional properties in mockAmplifyOutputs are defined | ||
const _amplifyOutputs: DeepRequired<AmplifyOutputs> = | ||
recreateObject(mockAmplifyOutputs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't quite get this - are we validating all possible fields are contained in the amplify_outputs.json file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep exactly, when a new optional key is added in AmplifyOutputs we want to make sure the mockAmplifyOutputs
used here is also updated to include this field. With this approach if amplify_outputs isn't updated this line would crib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. amplify_outputs.json will be updated manually? Is there any checks too that the manual update conforms to CLI JSON schema?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 we need to figure out a way to make sure our outputs.json conforms to CLI schema.Might be out of scope for this PR.
"require_symbols": true, | ||
"min_length": 6 | ||
}, | ||
"groups": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was previously
{
"ADMIN": { "precedence": 0 },
"USER": { "precedence": 1 }
},
{
"USER": { "precedence": 0 }
},
{
"TEST": { "precedence": 2 },
"USER": { "precedence": 1 },
"ADMIN": { "precedence": 0 }
}
since backend can only generate one userGroup as one item in the array atm, updated to this format.
One Major comment I have for this approach is this will only catch us from missing addition of optional properties in amplify_outputs. It does not catch the core issue on if the value we provide for these properties actually causes an issue or not. |
Description of changes
authentication_flow_type
type from string literal union to stringamplify_outputs.json
has all combinations defined, else throw type error (CI failure)Amplify.configure
(CI failure)Description of how you validated changes
linked ^
Checklist
yarn test
passesChecklist for repo maintainers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.