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(opentrons-ai-client): fix example buttons and clear text after submitting prompt #15299

Merged
merged 8 commits into from
May 31, 2024

Conversation

shlokamin
Copy link
Member

@shlokamin shlokamin commented May 31, 2024

Overview

closes AUTH-434 and AUTH-437

This PR fixes the example buttons and clears the input prompt text after clicking the submit button.

I also removed the unnecessary jotai state variable that was holding onto prompt button text because the prompt button can access the form directly. This allows us to get rid of an unnecessary useEffect which was just listening for changes to the state variable and setting form state with the updated state variable value.

Also, testing react-hook-form is a massive pain. sometimes we need to mock internals, and sometimes we want to test full integration. I introuced patterns for both in this PR. Though honestly I'm not even convinced we need react hook form. Ideally we can get rid of both that and jotai

Changelog

  • Clear prompt text after submitting
  • Enable same button to be pressed after initial press

Review requests

  • Check to see that the input prompt text clears after pressing the submit button
  • Check to see that you can press the same button twice after submitting

Risk assessment

Low

@shlokamin shlokamin marked this pull request as ready for review May 31, 2024 16:19
@shlokamin shlokamin requested a review from a team as a code owner May 31, 2024 16:19
@shlokamin shlokamin requested review from koji, y3rsh and Elyorcv May 31, 2024 16:19
@shlokamin shlokamin changed the title fix(opentrons-ai-client): fix example buttons fix(opentrons-ai-client): fix example buttons and clear text after submitting prompt May 31, 2024
const render = (props: React.ComponentProps<typeof PromptButton>) => {
return renderWithProviders(<PromptButton {...props} />)
}

let mockSetValue = vi.fn()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let mockSetValue = vi.fn()
const mockSetValue = vi.fn()

beforeEach(() => {
props = {
buttonText: 'Reagent Transfer',
}
mockSetValue = vi.fn()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mockSetValue = vi.fn()

Copy link
Contributor

@koji koji left a comment

Choose a reason for hiding this comment

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

lgtm!
thank you for fixing this!

@koji koji self-requested a review May 31, 2024 19:15
@shlokamin shlokamin merged commit 1a4c0c7 into edge May 31, 2024
8 checks passed
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