Skip to content

Commit

Permalink
"this looks slightly promising" 🤞
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Feb 14, 2024
1 parent 869f44d commit 6cc11ac
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export function composeStory<TRenderer extends Renderer = Renderer, TArgs extend
: undefined,
}
);
console.log('LOG: I am globalizing globals 🌎');
globalThis.__STORYBOOK_TESTSTUFF = {
...globalThis.__STORYBOOK_TESTSTUFF,
[storyName]: {
load: composedStory.load,
play: composedStory.play,
},
};

return composedStory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ import stories from './Button.portable';
test('renders primary button', async ({ mount }) => {
const component = await mount(<stories.CSF3Primary />);
await expect(component).toContainText('Decorator')
// const element = await component.evaluate((element) => {
// // You can interact with the element directly here
// return element; // This returns the DOM element to Playwright's context
// });

// console.log({bla: stories.CSF3InputFieldFilled })
// await stories.CSF3InputFieldFilled.play({ canvasElement: element as HTMLElement });
// expect(button).toContainText('Hello world')
// const buttonElement = screen.getByText(/Hello world/i);
// expect(buttonElement).not.toBeNull();
});

test.only('apply story loaders', async ({ mount, page }) => {


// await stories.LoaderStory.load();
await mount(<stories.CSF3InputFieldFilled />);
// console.log({loaderStory: globalThis.__STORYBOOK_TESTSTUFF })
await page.evaluate(async() => {
console.log('LOG: stuff', { __STORYBOOK_TESTSTUFF: globalThis.__STORYBOOK_TESTSTUFF})
const story = globalThis.__STORYBOOK_TESTSTUFF['CSF3InputFieldFilled']
console.log({story})
await story.play({ canvasElement: document.body });
})
});

// test('reuses args from composed story', ({ mount }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { composeStories } from '@storybook/react';
import * as stories from './Button.stories';

export default composeStories(stories);
export default composeStories(stories);
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ export const LoaderStory: CSF3Story<{ spyFn: (val: string) => string }> = {
play: async () => {
expect(spyFn).toHaveBeenCalledWith('foo');
},
};
};

0 comments on commit 6cc11ac

Please sign in to comment.