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

Remove repo secrets from redux state, fetch on mount #4028

Merged
merged 3 commits into from
Jan 6, 2022

Conversation

absoludity
Copy link
Contributor

@absoludity absoludity commented Jan 5, 2022

Description of the change

Following on from #4027, this PR updates the AppRepoForm component so that it no longer receives a related secret as a prop (from the redux state?), but rather fetches the secret when mounting and uses the local component state.

Benefits

The new endpoint for fetching a secret for a repo's secret is used (rather than the k8s API), and it avoids the need to update the redux state when a repo is updated (since we always fetch the secret when loading the form). Also avoids storing all repo secrets in the redux state (and removes the related actions/reducers).

Possible drawbacks

Applicable issues

Additional information

As always, testing the combination of an async react hook (useEffect) turned out to be painful to realise, but got there after a lot of head scratching.

I still need to test this IRL locally before landing (once CI passes etc.)

Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

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

Great, happy to see we're getting rid of unexpected direct calls to the k8s API.
Certainly, we should explore the capabilities of the "testing library" when implementing future tests.

@@ -75,6 +75,7 @@
"devDependencies": {
"@formatjs/cli": "^4.7.0",
"@improbable-eng/grpc-web-fake-transport": "^0.15.0",
"@testing-library/react": "^12.1.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the testing library seems to be the first step towards getting rid of Enzyme: https://testing-library.com/docs/react-testing-library/migrate-from-enzyme :P

wrapper = mountWrapper(defaultStore, <AppRepoForm {...defaultProps} repo={repo} />);
});

await waitFor(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Way simpler than the tricky approach with jest.runAllTimers() we still have in some places.

Base automatically changed from 3922-app-repo-secrets-workaround to master January 5, 2022 23:08
Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
Signed-off-by: Michael Nelson <minelson@vmware.com>
@absoludity absoludity force-pushed the 3922-app-repo-secrets-workaround-2 branch from 772011e to ef86572 Compare January 5, 2022 23:41
@absoludity absoludity merged commit 30e945e into master Jan 6, 2022
@absoludity absoludity deleted the 3922-app-repo-secrets-workaround-2 branch January 6, 2022 00:12
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.

None yet

2 participants