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

Import demo components from @storybook/react #1303

Merged
merged 18 commits into from
Jun 22, 2017
Merged

Conversation

shilman
Copy link
Member

@shilman shilman commented Jun 17, 2017

Issue: #1266

What I did

Import demo components from @storybook/react instead of @storybook/components

We do this so we can have a uniform way to do this across frameworks
(e.g. RN, vue)

How to test

To make sure the deps work:

yarn bootstrap
cd examples/cra-kitchen-sink
yarn storybook

Does not test getstorybook, but I think we can assume that will work (but please review)

We do this so we can have a uniform way to do this across frameworks
(e.g. RN, vue)
@codecov
Copy link

codecov bot commented Jun 17, 2017

Codecov Report

Merging #1303 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1303      +/-   ##
==========================================
- Coverage   13.76%   13.76%   -0.01%     
==========================================
  Files         201      202       +1     
  Lines        4620     4621       +1     
  Branches      507      574      +67     
==========================================
  Hits          636      636              
+ Misses       3550     3493      -57     
- Partials      434      492      +58
Impacted Files Coverage Δ
app/react/src/demo/Button.js 0% <ø> (ø)
app/react/src/demo/Welcome.js 0% <ø> (ø)
...ts/stories/required_with_context/Button.stories.js 0% <0%> (ø) ⬆️
...s/stories/required_with_context/Welcome.stories.js 0% <0%> (ø) ⬆️
app/react/demo.js 0% <0%> (ø)
...dons/storyshots/stories/directly_required/index.js 0% <0%> (ø) ⬆️
app/react/src/client/preview/init.js 0% <0%> (ø) ⬆️
lib/ui/src/libs/key_events.js 23.25% <0%> (ø) ⬆️
app/react-native/src/preview/story_kind.js 0% <0%> (ø) ⬆️
app/react-native/src/bin/storybook-build.js 0% <0%> (ø) ⬆️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a27e21...c61e045. Read the comment docs.

@shilman shilman added the cleanup Minor cleanup style change that won't show up in release changelog label Jun 17, 2017
@shilman shilman requested a review from ndelangen June 17, 2017 13:17
usulpro
usulpro previously approved these changes Jun 17, 2017
Copy link
Member

@usulpro usulpro left a comment

Choose a reason for hiding this comment

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

works fine for me!

Copy link
Contributor

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

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

it works

@usulpro
Copy link
Member

usulpro commented Jun 17, 2017

still WIP? need to remove \lib\components\src\demo

@shilman
Copy link
Member Author

shilman commented Jun 17, 2017

Thanks @usulpro . I forgot to remove them earlier

@shilman
Copy link
Member Author

shilman commented Jun 17, 2017

@ndelangen @usulpro @alexandrebodin a test is failing but I don't have time to figure it out 😭

 FAIL  examples/test-cra/src/storyshots.test.js
 Test suite failed to run

Your test suite must contain at least one test.

Copy link
Contributor

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

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

We could create a demo.js in the root folder to reexport the components from dist ?

I don't like that user can access filles like this :(

Juste a preference no big deal for me ;)

@shilman
Copy link
Member Author

shilman commented Jun 17, 2017

Need to be offline for next four days. Would ❤️ if somebody could get this merged and shipped. @ndelangen @usulpro ?

@@ -3,7 +3,7 @@ import React from 'react';
import { storiesOf } from '@storybook/react'; // eslint-disable-line
import { action } from '@storybook/addon-actions'; // eslint-disable-line

import Button from '@storybook/components/dist/demo/Button';
import Button from '@storybook/react/dist/demo/Button';
Copy link
Member

Choose a reason for hiding this comment

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

investigated that test fails after this change
not sure what the reason, possible someone who more familiar with storyshots could help?

Copy link
Member

Choose a reason for hiding this comment

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

FYI these particular files are not tested by CI

Copy link
Member

@usulpro usulpro Jun 21, 2017

Choose a reason for hiding this comment

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

it fails at examples/test-cra/src/storyshots.test.js but after this change.
#2833 passed
#2836 failed

but possible it's more CI related issue then this PR?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why it sometimes passes to be honest, I would have thought it would consistently fail due to: #1303 (comment)

@ndelangen
Copy link
Member

Looks good to me, what's failing the build?

@tmeasday
Copy link
Member

tmeasday commented Jun 21, 2017

Cf. #1286 -- not sure this test passes on any branch with npm5.

In this case the issue is that storyshots and the app have different copies of @storybook/react because it is loaded over a symlink. So storyshots finds no stories.

We should make storyshots show a better error if it finds no stories -- #1330

@@ -28,7 +28,7 @@
"@storybook/addon-links": "^3.1.2",
"@storybook/addons": "^3.1.2",
"@storybook/channel-websocket": "^3.1.2",
"@storybook/components": "^3.0.0",
"@storybook/react": "^3.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

Not sure we should be doing this

Copy link
Member

Choose a reason for hiding this comment

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

Does RN use these components? AFAIK not (if so it should be changed in this PR).

@@ -3,7 +3,7 @@ import React from 'react';
import { storiesOf } from '@storybook/react'; // eslint-disable-line
import { action } from '@storybook/addon-actions'; // eslint-disable-line

import Button from '@storybook/components/dist/demo/Button';
import Button from '@storybook/react/dist/demo/Button';
Copy link
Member

Choose a reason for hiding this comment

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

FYI these particular files are not tested by CI

@shilman
Copy link
Member Author

shilman commented Jun 21, 2017

Update

Currently the build is broken because test-cra requires @storybook/addon-storyshots AND @storybook/react. At the same time @storybook/addon-storyshots requires @storybook/react.

When we run the test-cra tests, two versions of @storybook/react are getting loaded, and this leads to a test error “Your test suite must contain at least one test.”

If we remove @storybook/react from @storybook/addon-storyshots's package.json then the tests pass again.

However, we are using demo components from @storybook/react in @storybook/addon-storyshots, so this "fix" is a filthy hack.

This is a hack. Currently the build is broken because `test-cra`
requires `@storybook/addon-storyshots` AND `@storybook/react`, but
`@storybook/addon-storyshots` requires `@storybook/react`. Before this
change, two versions of `@storybook/react` are getting loaded, and this
leads to a test error “Your test suite must contain at least one test.”

After this “fix” the error goes away. However,
`@storybook/addon-storyshots` should have a dev- dependency on
`@storybook/react`, because it uses it for its examples. But it only
has a peer-dep for now.
@shilman
Copy link
Member Author

shilman commented Jun 21, 2017

Update again

I have fixed the build with an unfortunate hack. @storybook/addon-storyshots now only takes @storybook/react as a peer-dep, rather than as a dev dep.

This sucks, and is not technically correct, but it unbreaks the build. I am thinking about alternative approaches to this whole mess.

@shilman
Copy link
Member Author

shilman commented Jun 22, 2017

@alexandrebodin i missed your suggestion above about creating a demo.js file. it's a great suggestion and i've incorporated it into this PR

@shilman
Copy link
Member Author

shilman commented Jun 22, 2017

Triumph!

@tmeasday 's PR uses tarballs for test-cra. This is a better solution than my hack above, so we merged his solution in and backed my hack out. Merging.

In the words of @tmeasday :

we ended up not removing test-cra, but instead using a npm pack-based strategy to reproduce the old file:// local package behaviour so test-cra retains the "flat" node_modules structure without symlinks. In particular, this works around issues with Jest misbehaving with symlinks, and allows us to test storyshots

@shilman shilman merged commit 84f6770 into master Jun 22, 2017
@shilman shilman added maintenance User-facing maintenance tasks and removed in progress cleanup Minor cleanup style change that won't show up in release changelog labels Jun 22, 2017
@Hypnosphi Hypnosphi deleted the 1266-fix-components-deps branch August 17, 2017 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants