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

[AN-247] Edit method functionality #5175

Open
wants to merge 39 commits into
base: dev
Choose a base branch
from
Open

[AN-247] Edit method functionality #5175

wants to merge 39 commits into from

Conversation

salonishah11
Copy link
Contributor

@salonishah11 salonishah11 commented Nov 19, 2024

Jira Ticket: https://broadworkbench.atlassian.net/browse/AN-247

Summary of changes:

What

Adds "Edit method" functionality

Why

FC UI migration

TODO

  • fix tests
  • add unit tests

Testing strategy

  • manual testing
  • unit tests

Action menu
Screenshot 2024-11-19 at 6 27 52 PM

Edit modal
Screenshot 2024-11-19 at 6 29 15 PM

Comment on lines -81 to -85
allConfigs: async () => {
const res = await fetchAgora(`methods/${namespace}/${name}/configurations`, _.merge(authOpts(), { signal }));
return res.json();
},

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 wasn't used anywhere so I removed it.

@salonishah11
Copy link
Contributor Author

Sonarcloud reported one below issue. I am not sure how strict we want to enforce it because reducing the number of arguments would entail creating a new type for passing arguments. Plus Terra UI does have other functions with more than allowed 7 arguments. But I would like to reviewers opinion on this.

Async method 'createNewSnapshot' has too many parameters (9). Maximum allowed is 7.

@salonishah11 salonishah11 marked this pull request as ready for review November 22, 2024 19:29
@sam-schu sam-schu self-requested a review November 22, 2024 20:17
@sam-schu
Copy link
Contributor

@salonishah11 Regarding the SonarCloud issue, I have no problem with this function's having 9 arguments. All of its arguments are necessary for making the Ajax request, and if the caller had to construct the payload object themselves at the call site so that it could be passed as one argument to the provider function, that would defeat part of the purpose of the provider abstraction layer.

Copy link
Contributor

@sam-schu sam-schu left a comment

Choose a reason for hiding this comment

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

The design looks great!

// Act
await act(async () => {
render(
<EditWorkflowModal
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also check that the title and snapshot ID are rendered, and non-empty defaults for the synopsis and snapshot comment?

Copy link
Contributor Author

@salonishah11 salonishah11 Nov 26, 2024

Choose a reason for hiding this comment

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

I have added the check for title, snapshot ID and non-empty synopsis.

Your comment made me realize that snapshot comment in any action (create new method, clone method or edit method) doesn't have a default value because

  • it doesn't make sense for previous snapshot's comment to be automatically applied to new snapshot
  • makes user deliberately write new comment if they want to
  • replicates FC UI's current behavior

Hence I have removed defaultSnapshotComment from props and associated files, tests.

src/workflows/methods/modals/EditWorkflowModal.test.tsx Outdated Show resolved Hide resolved
expect(screen.getByRole('textbox', { name: 'Snapshot comment' })).toHaveDisplayValue('');
});

it('successfully creates a new snapshot with inputted information', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It wouldn't hurt to add a test that makes sure that by default redactPreviousSnapshot is set to false in the provider function call, given the consequences if it were always true regardless of whether the checkbox was checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I have added that test.

@lucymcnatt lucymcnatt self-requested a review November 26, 2024 16:09
Copy link

sonarcloud bot commented Nov 26, 2024

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