@storybook/svelte 9.0.0-beta.9 → 9.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/svelte",
3
- "version": "9.0.0-beta.9",
3
+ "version": "9.0.0-rc.1",
4
4
  "description": "Storybook Svelte renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -69,7 +69,7 @@
69
69
  "vite": "^6.2.5"
70
70
  },
71
71
  "peerDependencies": {
72
- "storybook": "^9.0.0-beta.9",
72
+ "storybook": "^9.0.0-rc.1",
73
73
  "svelte": "^5.0.0"
74
74
  },
75
75
  "engines": {
@@ -5,7 +5,7 @@ import {
5
5
  } from 'storybook/internal/core-events';
6
6
 
7
7
  import { addons } from 'storybook/preview-api';
8
- import { expect, userEvent, waitFor, within } from 'storybook/test';
8
+ import { expect, userEvent, waitFor } from 'storybook/test';
9
9
 
10
10
  import Button from './Button.svelte';
11
11
 
@@ -15,51 +15,53 @@ export default {
15
15
  };
16
16
 
17
17
  export const UpdatingArgs = {
18
- play: async ({ canvasElement, id, step }) => {
19
- const canvas = await within(canvasElement);
18
+ play: async ({ canvas, id, step }) => {
20
19
  const channel = addons.getChannel();
21
20
 
22
21
  await step('Reset story args', async () => {
23
22
  // Just to ensure the story is always in a clean state from the beginning, not really part of the test
24
- await channel.emit(RESET_STORY_ARGS, { storyId: id });
23
+ channel.emit(RESET_STORY_ARGS, { storyId: id });
25
24
  await new Promise((resolve) => {
26
25
  channel.once(STORY_RENDERED, resolve);
27
26
  });
28
- await expect(await canvas.getByRole('button')).toHaveTextContent('You clicked: 0');
27
+ await waitFor(async () => {
28
+ await expect(canvas.getByRole('button')).toHaveTextContent('You clicked: 0');
29
+ });
29
30
  });
30
31
 
31
- const button = await canvas.getByRole('button');
32
32
  await step('Change state', async () => {
33
- await userEvent.click(button);
34
-
33
+ await userEvent.click(canvas.getByRole('button'));
35
34
  await waitFor(async () => {
36
- await expect(button).toHaveTextContent('You clicked: 1');
35
+ await expect(canvas.getByRole('button')).toHaveTextContent('You clicked: 1');
37
36
  });
38
37
  });
39
38
 
40
39
  await step("Update story args with { text: 'Changed' }", async () => {
41
- await channel.emit(UPDATE_STORY_ARGS, { storyId: id, updatedArgs: { text: 'Changed' } });
40
+ channel.emit(UPDATE_STORY_ARGS, { storyId: id, updatedArgs: { text: 'Changed' } });
42
41
  await new Promise((resolve) => {
43
42
  channel.once(STORY_RENDERED, resolve);
44
43
  });
45
- await expect(button).toHaveTextContent('Changed: 1');
44
+ await waitFor(async () => {
45
+ await expect(canvas.getByRole('button')).toHaveTextContent('Changed: 1');
46
+ });
46
47
  });
47
48
  },
48
49
  };
49
50
 
50
51
  export const RemountOnResetStoryArgs = {
51
52
  play: async (playContext) => {
52
- const { canvas, id, step } = playContext;
53
53
  await UpdatingArgs.play(playContext);
54
54
 
55
55
  const channel = addons.getChannel();
56
+ const { canvas, id, step } = playContext;
56
57
 
57
58
  // expect that all state and args are reset after RESET_STORY_ARGS because Svelte needs to remount the component
58
59
  // most other renderers would have 'You clicked: 1' here because they don't remount the component
59
60
  // if this doesn't fully remount it would be 'undefined: 1' because undefined args are used as is in Svelte, and the state is kept
60
61
  await step('Reset story args', () => channel.emit(RESET_STORY_ARGS, { storyId: id }));
61
- await waitFor(async () =>
62
- expect(await canvas.getByRole('button')).toHaveTextContent('You clicked: 0')
63
- );
62
+
63
+ await waitFor(async () => {
64
+ await expect(canvas.getByRole('button')).toHaveTextContent('You clicked: 0');
65
+ });
64
66
  },
65
67
  };