LaunchPadLab / lp-components

Our Components
http://lp-components.herokuapp.com
MIT License
5 stars 1 forks source link

Hotfix: button variant story #630

Closed chawes13 closed 5 months ago

chawes13 commented 6 months ago

Resolves #629

QA Steps

Author Checklist

chawes13 commented 5 months ago

@JoseWhite Got a few minutes to review this PR this week? Would love to get it in soon, thanks!

JoseWhite commented 5 months ago

Loaded the app locally and it renders correctly 👍 I was thinking if it would make sense to add a jest spec for it, something like the snippet below to the button.test.js file.:

test('Button variant: small renders correctly', () => {
  render(
    <Button type="button" style={{ variant: 'small' }} >
    Submit
  </Button>
  )
  const button = screen.getByRole('button')

  expect(button).toBeVisible()
})

I looked into testing storybook stories and found this jest add-on for storybook, it allows seeing test results in the storybook itself, perhaps it could make it easier to catch/prevent issues like this in the future.

chawes13 commented 5 months ago

Loaded the app locally and it renders correctly 👍 I was thinking if it would make sense to add a jest spec for it, something like the snippet below to the button.test.js file.:

test('Button variant: small renders correctly', () => {
  render(
    <Button type="button" style={{ variant: 'small' }} >
    Submit
  </Button>
  )
  const button = screen.getByRole('button')

  expect(button).toBeVisible()
})

I looked into testing storybook stories and found this jest add-on for storybook, it allows seeing test results in the storybook itself, perhaps it could make it easier to catch/prevent issues like this in the future.

We have a test for this! https://github.com/LaunchPadLab/lp-components/blob/bd1d293618fbe44fa07187863d9d28e2e1cc7f1a/test/forms/buttons/button.test.js#L89-L94

The jest add-on is interesting, thanks for sharing! I'm not sold on the value of including it – it wouldn't have prevented this issue here where the story was using an older syntax than the component/tests.