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

feat: implement new parameters api, make cli --help work and notify user on page errors that occured while processing stories for Steps #73

Open
wants to merge 12 commits into
base: storybook7
Choose a base branch
from

Conversation

Hotell
Copy link

@Hotell Hotell commented Feb 17, 2025

Fixes:

false positives about Steps presence and execution

fixes false positives regarding story missing Steps definition.

Previously .steps property was always set on story because of logical error.

With this fix .step will exist on processed story only IFF a story really defines Steps

proper --help output

image

Features:

new API for defining Steps

This API should be used going forward as it supports various use-cases and Storybook version beyond v8

Before:

import {StoryWright, Steps} from 'storywright';
import {Button} from 'ui'

export default {
  component: Button,
  decorators: [ 
    (Story)=>{
       return <StoryWright steps={new Steps().snapshot('default').end()}>{ Story() }</StoryWright>
    }
  ]
}

After:

import {Steps, type StoryParameter} from 'storywright';
import {Button} from 'ui'

export default {
  component: Button,
  parameters: {
   storyWright: { 
       steps: new Steps().snapshot('default').end()
   }
  } satisfies StoryParameter
}

new CLI flag --bailOnStoriesError

💡 This is very useful for CI/CD pipelines to fail if there are any issues with stories or SW and Storybook stories fetching pipeline.

fails SW process in 2 places if enables:

1. errors occurred while processing stories -> it will exit process immediately.

image

2. errors occurred during creating snapshots images per story

image

new notification about issues that occurred while processing stories for Steps

previously these issues were consumed within page evaluation which consumer never received

image

improved Steps execution logging

Before:

image

After:

image

Related Issues

@Hotell Hotell changed the title Feat/improve cli args feat: notify user on page errors that occured while processing stories for Steps Feb 17, 2025
@@ -100,19 +111,23 @@ export class StoryWrightProcessor {
itemsForBatch.map(async (story: object) => {
const id: string = story["id"];
const tags: string = story["tags"];
if(tags && tags.includes("no-screenshot")){
console.log(`StoryId: ${id} has tag no-screenshot hence skipping.`);
if (tags && tags.includes("no-screenshot")) {
Copy link
Author

Choose a reason for hiding this comment

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

outcome of running prettier -w

@@ -65,7 +76,7 @@ export class StoryWrightProcessor {
} = require(storiesJsonPath);
stories = Object.values(rawStoriesObject.stories ?? {});
console.log(`${stories.length} stories found`);
console.warn('NOTE: stories Steps will not be processed')
console.warn("NOTE: stories Steps will not be processed");
Copy link
Author

Choose a reason for hiding this comment

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

outcome of running prettier -w

// regex test to check if exclude pattern is present in ssNamePrefix
let regex = new RegExp(excludePattern);
if(regex.test(ssNamePrefix)){
console.log(`Skipping story ${ssNamePrefix} as it matches exclude pattern ${excludePattern}`);
if (regex.test(ssNamePrefix)) {
Copy link
Author

Choose a reason for hiding this comment

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

outcome of running prettier -w

@@ -26,7 +36,6 @@ const args = argv
type: "string",
})
.option("browsers", {
alias: "browsers",
Copy link
Author

Choose a reason for hiding this comment

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

these were clashing with actual args preventing proper --help output

@Hotell Hotell marked this pull request as ready for review February 17, 2025 17:23
@Hotell Hotell changed the title feat: notify user on page errors that occured while processing stories for Steps feat: implement new parameters api, make cli --help work and notify user on page errors that occured while processing stories for Steps Feb 18, 2025
let steps = findSteps(res);
if (steps !== "undefined" && steps !== null) {
const steps = findSteps(res);
if (steps !== undefined && steps !== null) {
Copy link
Author

Choose a reason for hiding this comment

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

this fixes false positives regarding story missing Steps definition. this was previously always setting steps property. with this fix .step will exist on processed story only IFF a story really defines Steps

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.

1 participant