Skip to content

refactor(site): Suport template version variables on template creation #6434

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

Merged
merged 10 commits into from
Mar 6, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma commented Mar 3, 2023

Screen Shot 2023-03-03 at 10 32 59

@BrunoQuaresma BrunoQuaresma requested review from mtojek and a team March 3, 2023 12:53
@BrunoQuaresma BrunoQuaresma self-assigned this Mar 3, 2023
@BrunoQuaresma BrunoQuaresma requested review from code-asher and removed request for a team March 3, 2023 12:53
@BrunoQuaresma
Copy link
Collaborator Author

Related to #5980

defaultValue?: string
}

export const VariableInput: FC<VariableInputProps> = ({
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this component be placed in components?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a good question. We should try to keep code close to where it is used, if this component starts to be used in other pages like the EditTemplatePage, we should move it to the components folder.

)}

{/* Variables */}
{variables && (
Copy link
Member

Choose a reason for hiding this comment

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

Do you plan to cover it with unit tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I plan to add tests for this.

Copy link
Member

Choose a reason for hiding this comment

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

👍 It would be awesome to include those in this PR, unless you have a different idea.

disabled={isSubmitting}
key={variable.name}
onChange={async (value) => {
await form.setFieldValue("user_variable_values." + index, {
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity: why async/await?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is from the Formik library and for some reason, they made this function async. I think it is strange as well.

Copy link
Member

Choose a reason for hiding this comment

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

TIL!

upload: TemplateUploadProps
starterTemplate?: TemplateExample
parameters?: ParameterSchema[]
variables?: TemplateVersionVariable[]
Copy link
Member

Choose a reason for hiding this comment

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

In this case, you're adjusting the CreateTemplateForm. It seems that it has a similar logic to "edit template variables", but I'm afraid that it will hard to unify both forms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! Because this form creates a template version + the template resource so it has some mixed values. I think this is a bit "nasty" too but Idk how to make it better or clear. 🤔 open to suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

This is a valid point, those forms are different indeed 👍

@BrunoQuaresma BrunoQuaresma requested a review from mtojek March 3, 2023 16:22
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Implementation seems 👍 , but I would feel safer if we add some unit tests here.

@BrunoQuaresma
Copy link
Collaborator Author

@mtojek definitely! I just sent it first because I would like to validate the flow first. Did you have time to QA it locally?

@BrunoQuaresma
Copy link
Collaborator Author

My thoughts about testing this. Unfortunately, testing all the flow like selecting a tar, uploading it, checking if there are any parameters or variable errors, showing the error and logs on the screen, etc is kinda complex. I'm wondering if we could add a storybook to check the different states like showing variables, parameters, errors, etc, and do an integration test on the form, to see if the correct data is being returned from it. I think this is simple and good enough to guarantee the flow is working as expected. If we have major issues, we can increase the coverage by doing a major integration or e2e test. Thoughts?

@mtojek
Copy link
Member

mtojek commented Mar 6, 2023

Yes, in this case, a storybook will be a low-hanging fruit. Alternatively, you could mock relevant backend API responses, and just "assume" that the uploaded .tar file is correct.

@BrunoQuaresma
Copy link
Collaborator Author

@mtojek Yes. I just don't think having them rn is valuable. IMO, the "buggy" part is the form and see if it is returning or not the correct values on submit.

@mtojek mtojek self-requested a review March 6, 2023 15:22
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

👍 Let's get this in. Thanks!

@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) March 6, 2023 18:29
@Kira-Pilot
Copy link
Member

If we have major issues, we can increase the coverage by doing a major integration or e2e test. Thoughts?

@BrunoQuaresma that sounds fine to me. If we can capture visual representations of data and errors in storybook and then use an integration test/tests to validate form submission, I think we'll be in a good spot.

@BrunoQuaresma BrunoQuaresma merged commit 136f23f into main Mar 6, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/refactor-template-create branch March 6, 2023 18:36
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.

3 participants