From bf3a0149a8ef3cfbc8bc993a8e817baacb0496b9 Mon Sep 17 00:00:00 2001 From: ThibaudAv Date: Fri, 11 Dec 2020 00:12:37 +0100 Subject: [PATCH] feat(angular): remove internal storybook properties in storyshot Generates snapshots that will change less if the internal stroybook properties change --- .../src/frameworks/angular/renderTree.ts | 3 +- .../addon-actions.stories.storyshot | 20 ++---------- .../addon-background.stories.storyshot | 16 ++-------- .../addon-controls.stories.storyshot | 20 ++---------- .../addon-docs.stories.storyshot | 16 ++-------- .../addon-jest.stories.storyshot | 8 +---- .../addon-knobs.stories.storyshot | 32 ++----------------- .../addon-links.stories.storyshot | 10 +----- .../app.component.stories.storyshot | 8 +---- .../__snapshots__/core.stories.storyshot | 10 +----- .../custom-ng-content.stories.storyshot | 6 +--- .../custom-pipes.stories.storyshot | 18 ++--------- .../custom-providers.stories.storyshot | 18 ++--------- .../custom-styles.stories.storyshot | 16 ++-------- .../__snapshots__/index.stories.storyshot | 32 +++++++------------ .../metadata-combined.stories.storyshot | 14 ++------ .../metadata-individual.stories.storyshot | 13 ++------ .../metadata-shared.stories.storyshot | 13 ++------ .../ngrx-store.stories.storyshot | 14 ++------ .../di.component.stories.storyshot | 18 ++--------- .../enums.component.stories.storyshot | 14 +------- .../styled.component.stories.storyshot | 8 +---- .../custom-cva-component.stories.storyshot | 10 +----- .../doc-button.stories.storyshot | 10 +----- .../doc-directive.stories.storyshot | 6 +--- .../doc-injectable.stories.storyshot | 6 +--- .../__snapshots__/doc-pipe.stories.storyshot | 6 +--- .../angular-cli/src/stories/index.stories.ts | 2 +- .../inheritance.stories.storyshot | 19 ++--------- .../12009-unknown-component.stories.storyshot | 9 +----- .../module-context-forRoot.stories.storyshot | 31 ++---------------- .../module-context.stories.storyshot | 31 ++---------------- .../__snapshots__/on-push.stories.storyshot | 10 +----- 33 files changed, 64 insertions(+), 403 deletions(-) diff --git a/addons/storyshots/storyshots-core/src/frameworks/angular/renderTree.ts b/addons/storyshots/storyshots-core/src/frameworks/angular/renderTree.ts index ce691422170d..350f8a2dfb0b 100644 --- a/addons/storyshots/storyshots-core/src/frameworks/angular/renderTree.ts +++ b/addons/storyshots/storyshots-core/src/frameworks/angular/renderTree.ts @@ -36,7 +36,8 @@ function getRenderedTree(story: any) { const tree = TestBed.createComponent(moduleMeta.bootstrap[0] as any); tree.detectChanges(); - return tree; + // Empty componentInstance remove attributes of the internal main component () in snapshot + return { ...tree, componentInstance: {} }; }); } diff --git a/examples/angular-cli/src/stories/__snapshots__/addon-actions.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/addon-actions.stories.storyshot index 1020c50af8df..95a2444fbec8 100644 --- a/examples/angular-cli/src/stories/__snapshots__/addon-actions.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/addon-actions.stories.storyshot @@ -1,15 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Addon/Actions Action and method 1`] = ` - + + +
+ + + + + +
+ +

This is a template

+ <img src=x onerror="alert('XSS Attack')" > `; diff --git a/examples/angular-cli/src/stories/__snapshots__/addon-links.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/addon-links.stories.storyshot index 402511054b38..12978b2c037d 100644 --- a/examples/angular-cli/src/stories/__snapshots__/addon-links.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/addon-links.stories.storyshot @@ -1,15 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Addon/Links button with link to another story 1`] = ` - + +
+ + @@ -20,14 +13,7 @@ exports[`Storyshots Custom/Pipes Simple 1`] = ` `; exports[`Storyshots Custom/Pipes With Knobs 1`] = ` - + diff --git a/examples/angular-cli/src/stories/__snapshots__/custom-providers.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/custom-providers.stories.storyshot index d2c829686260..a45b8b33b460 100644 --- a/examples/angular-cli/src/stories/__snapshots__/custom-providers.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/custom-providers.stories.storyshot @@ -1,14 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Custom/Providers Simple 1`] = ` - + @@ -23,14 +16,7 @@ exports[`Storyshots Custom/Providers Simple 1`] = ` `; exports[`Storyshots Custom/Providers With knobs 1`] = ` - + diff --git a/examples/angular-cli/src/stories/__snapshots__/custom-styles.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/custom-styles.stories.storyshot index b2fe77a84685..f4e5e6c31afb 100644 --- a/examples/angular-cli/src/stories/__snapshots__/custom-styles.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/custom-styles.stories.storyshot @@ -1,13 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Custom/Style Default 1`] = ` - + + + 😀 😎 👍 💯 + + `; exports[`Storyshots Button with text 1`] = ` - + + diff --git a/examples/angular-cli/src/stories/__snapshots__/metadata-combined.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/metadata-combined.stories.storyshot index a6f5f2322e46..8571a016fce2 100644 --- a/examples/angular-cli/src/stories/__snapshots__/metadata-combined.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/metadata-combined.stories.storyshot @@ -1,12 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Metadata/Combined Combined 1 1`] = ` - + @@ -30,12 +25,7 @@ exports[`Storyshots Metadata/Combined Combined 1 1`] = ` `; exports[`Storyshots Metadata/Combined Combined 2 1`] = ` - + diff --git a/examples/angular-cli/src/stories/__snapshots__/metadata-individual.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/metadata-individual.stories.storyshot index a1ce8e3e747d..95e85e4edb7c 100644 --- a/examples/angular-cli/src/stories/__snapshots__/metadata-individual.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/metadata-individual.stories.storyshot @@ -1,12 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Metadata/Individual Individual 1 1`] = ` - + @@ -30,11 +25,7 @@ exports[`Storyshots Metadata/Individual Individual 1 1`] = ` `; exports[`Storyshots Metadata/Individual Individual 2 1`] = ` - +

Provider Name diff --git a/examples/angular-cli/src/stories/__snapshots__/metadata-shared.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/metadata-shared.stories.storyshot index 66fbb0048e05..53966c5d46c9 100644 --- a/examples/angular-cli/src/stories/__snapshots__/metadata-shared.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/metadata-shared.stories.storyshot @@ -1,12 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Metadata/Shared Shared 1 1`] = ` - + @@ -30,11 +25,7 @@ exports[`Storyshots Metadata/Shared Shared 1 1`] = ` `; exports[`Storyshots Metadata/Shared Shared 2 1`] = ` - +

Provider Name diff --git a/examples/angular-cli/src/stories/__snapshots__/ngrx-store.stories.storyshot b/examples/angular-cli/src/stories/__snapshots__/ngrx-store.stories.storyshot index cbe590085038..1b96b0cca699 100644 --- a/examples/angular-cli/src/stories/__snapshots__/ngrx-store.stories.storyshot +++ b/examples/angular-cli/src/stories/__snapshots__/ngrx-store.stories.storyshot @@ -1,13 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots ngrx/Store With component 1`] = ` - +
Store is injected @@ -17,11 +11,7 @@ exports[`Storyshots ngrx/Store With component 1`] = ` `; exports[`Storyshots ngrx/Store With template 1`] = ` - +
Store is injected diff --git a/examples/angular-cli/src/stories/component-with-di/__snapshots__/di.component.stories.storyshot b/examples/angular-cli/src/stories/component-with-di/__snapshots__/di.component.stories.storyshot index a522d5e171c6..a83094cc4215 100644 --- a/examples/angular-cli/src/stories/component-with-di/__snapshots__/di.component.stories.storyshot +++ b/examples/angular-cli/src/stories/component-with-di/__snapshots__/di.component.stories.storyshot @@ -1,14 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Custom/Dependencies inputs and inject dependencies 1`] = ` - + @@ -37,14 +30,7 @@ exports[`Storyshots Custom/Dependencies inputs and inject dependencies 1`] = ` `; exports[`Storyshots Custom/Dependencies inputs and inject dependencies with knobs 1`] = ` - + diff --git a/examples/angular-cli/src/stories/component-with-enums/__snapshots__/enums.component.stories.storyshot b/examples/angular-cli/src/stories/component-with-enums/__snapshots__/enums.component.stories.storyshot index 3c9c8b97518a..50b6eba8c1a5 100644 --- a/examples/angular-cli/src/stories/component-with-enums/__snapshots__/enums.component.stories.storyshot +++ b/examples/angular-cli/src/stories/component-with-enums/__snapshots__/enums.component.stories.storyshot @@ -1,19 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Enum Types Basic 1`] = ` - + +

+

diff --git a/examples/angular-cli/src/stories/doc-button/__snapshots__/doc-button.stories.storyshot b/examples/angular-cli/src/stories/doc-button/__snapshots__/doc-button.stories.storyshot index 718e9b8c422c..505d50ad46d3 100644 --- a/examples/angular-cli/src/stories/doc-button/__snapshots__/doc-button.stories.storyshot +++ b/examples/angular-cli/src/stories/doc-button/__snapshots__/doc-button.stories.storyshot @@ -1,15 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots DocButton Basic 1`] = ` - + +
+

DocInjectable diff --git a/examples/angular-cli/src/stories/doc-pipe/__snapshots__/doc-pipe.stories.storyshot b/examples/angular-cli/src/stories/doc-pipe/__snapshots__/doc-pipe.stories.storyshot index e2373b3f6320..0bc6d2644bb9 100644 --- a/examples/angular-cli/src/stories/doc-pipe/__snapshots__/doc-pipe.stories.storyshot +++ b/examples/angular-cli/src/stories/doc-pipe/__snapshots__/doc-pipe.stories.storyshot @@ -1,11 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots DocPipe Basic 1`] = ` - +

DOCPIPE diff --git a/examples/angular-cli/src/stories/index.stories.ts b/examples/angular-cli/src/stories/index.stories.ts index 44f29c327388..b589620f732f 100644 --- a/examples/angular-cli/src/stories/index.stories.ts +++ b/examples/angular-cli/src/stories/index.stories.ts @@ -34,7 +34,7 @@ storiesOf('Button', module) }, })) .add('with some emoji', () => ({ - template: ``, + template: ``, props: { text: '😀 😎 👍 💯', onClick: () => {}, diff --git a/examples/angular-cli/src/stories/inheritance/__snapshots__/inheritance.stories.storyshot b/examples/angular-cli/src/stories/inheritance/__snapshots__/inheritance.stories.storyshot index 0919386d15b0..8740c437353f 100644 --- a/examples/angular-cli/src/stories/inheritance/__snapshots__/inheritance.stories.storyshot +++ b/examples/angular-cli/src/stories/inheritance/__snapshots__/inheritance.stories.storyshot @@ -1,14 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Custom/Inheritance base button 1`] = ` - + @@ -20,15 +13,7 @@ exports[`Storyshots Custom/Inheritance base button 1`] = ` `; exports[`Storyshots Custom/Inheritance icon button 1`] = ` - + diff --git a/examples/angular-cli/src/stories/issues/__snapshots__/12009-unknown-component.stories.storyshot b/examples/angular-cli/src/stories/issues/__snapshots__/12009-unknown-component.stories.storyshot index 11c3dba67f2c..93360d7b090b 100644 --- a/examples/angular-cli/src/stories/issues/__snapshots__/12009-unknown-component.stories.storyshot +++ b/examples/angular-cli/src/stories/issues/__snapshots__/12009-unknown-component.stories.storyshot @@ -1,14 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Addon/Issues/12009 unknown component Basic 1`] = ` - + + + + diff --git a/examples/angular-cli/src/stories/module-context/__snapshots__/module-context.stories.storyshot b/examples/angular-cli/src/stories/module-context/__snapshots__/module-context.stories.storyshot index f573bde23efb..41fece0acca8 100644 --- a/examples/angular-cli/src/stories/module-context/__snapshots__/module-context.stories.storyshot +++ b/examples/angular-cli/src/stories/module-context/__snapshots__/module-context.stories.storyshot @@ -1,15 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Custom/Feature Module as Context Component with default providers 1`] = ` - + + + diff --git a/examples/angular-cli/src/stories/on-push/__snapshots__/on-push.stories.storyshot b/examples/angular-cli/src/stories/on-push/__snapshots__/on-push.stories.storyshot index 460622860011..91c119ff7473 100644 --- a/examples/angular-cli/src/stories/on-push/__snapshots__/on-push.stories.storyshot +++ b/examples/angular-cli/src/stories/on-push/__snapshots__/on-push.stories.storyshot @@ -1,15 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots Core/OnPush Class-specified component with OnPush and Knobs 1`] = ` - +