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

Angular: Deprecate the story component attribute #13383

Merged
merged 23 commits into from
Dec 16, 2020

Conversation

ThibaudAV
Copy link
Contributor

@ThibaudAV ThibaudAV commented Dec 5, 2020

Issue: #8673

TODO :

  • Add MIGRATION.md info
  • change the current examples
  • check the doc

What I did

  • use same "angular preview render" in storyshots and in app/angular
  • fix some exemples
  • deprecate story component attribute
  • update all exemples

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

@ThibaudAV ThibaudAV changed the title feat(angular): depreciate the story component attribute Angular: depreciate the story component attribute Dec 5, 2020
@shilman shilman requested a review from a team December 5, 2020 13:29
@shilman shilman added angular maintenance User-facing maintenance tasks labels Dec 5, 2020
@ThibaudAV
Copy link
Contributor Author

@shilman I'm not sure what to put in MIGRATION.md 🤷‍♂️ Can I let you do it?

some comments :

  • It's a mess in angular-cli examples ^^
  • I did my best for the doc snippets. but I think it needs another look

@ThibaudAV ThibaudAV force-pushed the angular-parameters-component branch 4 times, most recently from 499b74e to a6a833a Compare December 8, 2020 22:41
@@ -7,35 +7,35 @@ import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/t
// eslint-disable-next-line import/no-extraneous-dependencies
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { addSerializer } from 'jest-specific-snapshot';
import { initModuleData } from './helpers';
import { RenderNgAppService } from '@storybook/angular/dist/client/preview/angular-beta/RenderNgAppService';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoids redefining the rendering like before.
if you have a (simple) idea to avoid the /dist/ tell me :)

@shilman shilman changed the title Angular: depreciate the story component attribute Angular: deprecate the story component attribute Dec 9, 2020
@shilman shilman changed the title Angular: deprecate the story component attribute Angular: Deprecate the story component attribute Dec 9, 2020
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

This is so awesome @ThibaudAV 💯 Thanks for pushing it forward.

I wrote a MIGRATION and added a couple comments to the PR including one change request.

Would be great to get more @storybookjs/angular eyes on it to critique from an Angular standpoint. From a CSF standpoint it looks like a big improvement to me. I also appreciate the example cleanup.

One more thing, can we leave around an "old-style" story as a test case, if there's not one already? Or create one?

@shilman shilman added this to the 6.2 core milestone Dec 9, 2020
@ThibaudAV ThibaudAV marked this pull request as ready for review December 9, 2020 17:03
@shilman
Copy link
Member

shilman commented Dec 10, 2020

@ThibaudAV I think we can sneak in a breaking change if that's necessary and force users to regenerate their snapshots. But I don't understand why that's needed and would certainly prefer to avoid it if it's not too much work.

@ThibaudAV
Copy link
Contributor Author

ThibaudAV commented Dec 11, 2020

@shilman
IMHO: I think it would be better to change the snapshots. Otherwise, there will be other problems

To generate the snapshot storyshot needs some information built by the "render".
Before there was a code duplication and so 2 versions of the render (one for addon/storyshot and one for storybook/angular)
This is problematic because the storyshot version does not benefit from the improvements and corrections of the main part (storybook/angular), for some time now
It also makes tests that do not reflect precisely the generated stories.

If we continue with the same code as before the new internal storybook functionality will not work with storyshot anymore. and this will make the storyshot completely legacy. :/

To prevent snapshots from changing due to internal storybook modifications🤞
My last commit removes from snapshots some internal properties that may change in the future.
And allows snapshots to contain mainly the story code.

What do you think about adding also a message in MIGRATION to inform that storyshot is improving to contain fewer internal storybook properties? And that it will be necessary to regenerate them 🙈 but it's for a good reason

I have a little talk with @gaetanmaisse who will surely be able to complete some information

I don't know if it's reassuring or not but when angular or angular-material changes minor version and you have test snapshot on your project it's not uncommon to have to regenerate them.

In any case, I thank you for accompanying me in these changes, it is very nice to have your opinion. 😌

@gaetanmaisse
Copy link
Member

I think the final result we have for story snapshots is a huge improvement because:

  • it now really matches what is rendered when running Storybook
  • all Storybook renderer specific properties aren't included in the snapshots anymore, so we can now update the renderer internal plumbing without causing any update of the snapshots 👌🏻

So the remaining question is: are we ok to ask SB users to update all their snapshots when updating to 6.2? Or must we wait for 7.0 to do any change in @storybook/addon-storyshot?

I would prefer to merge and release this in 6.2 as it's part of major improvements of SB for Angular 🤷🏻

Copy link
Member

@gaetanmaisse gaetanmaisse left a comment

Choose a reason for hiding this comment

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

The code LGTM, if we agree on making this land in 6.2 we have to add a section about snapshots update in MIGRATION.md

@shilman
Copy link
Member

shilman commented Dec 14, 2020

@ThibaudAV @gaetanmaisse thanks for getting this over the line. I've updated the MIGRATION instructions as I understand them:

We've updated the Angular storyshots format in 6.2, which is technically a breaking change. Apologies to semver purists: if you're using storyshots, you'll need to update your snapshots. The new format hides the implementation details of @storybook/angular so that we can evolve its renderer without breaking your snapshots in the future.

I'm OK with this compromise, but since this is a breaking change in a minor release I'm going to give the rest of the maintainers a day or two to chime in before merging.

MIGRATION.md Outdated Show resolved Hide resolved
shilman and others added 2 commits December 14, 2020 23:30
Co-authored-by: Manuel Meister <[email protected]>
@shilman shilman added the run e2e extended test suite Run the e2e extended test suite in CircleCI workflows label Dec 15, 2020
@@ -9,6 +9,8 @@ export {
raw,
} from './preview';

export { RenderNgAppService } from './preview/angular-beta/RenderNgAppService';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hadn't dared to export this service in the public index. ^^

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 this is the right way. However, we recently introduced ESM into the codebase and it broke things: #13013. If there's a less aggressive way to do it, I'm also open to that!

@@ -5,7 +5,7 @@ import { TestBed } from '@angular/core/testing';
// eslint-disable-next-line import/no-extraneous-dependencies
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
import { addSerializer } from 'jest-specific-snapshot';
import { RenderNgAppService } from '@storybook/angular';
import { RenderNgAppService } from '@storybook/angular/renderer';
Copy link
Member

Choose a reason for hiding this comment

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

@ThibaudAV trying this as something less aggressive 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but I can see that it doesn't seem simple 💪 . Tell me if you need help with this PR

@shilman
Copy link
Member

shilman commented Dec 16, 2020

@ThibaudAV I think this is ready to merge. WDYT?

@ThibaudAV
Copy link
Contributor Author

ThibaudAV commented Dec 16, 2020

@shilman 🤞 yes

@shilman shilman merged commit 518f8ec into storybookjs:next Dec 16, 2020
@shilman
Copy link
Member

shilman commented Jan 4, 2021

cc @mandarini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular maintenance User-facing maintenance tasks run e2e extended test suite Run the e2e extended test suite in CircleCI workflows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants