@aurelia/storybook 2.1.0 → 2.2.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/.github/workflows/ci.yml +61 -0
- package/.github/workflows/publish.yml +82 -0
- package/.github/workflows/storybook-preview.yml +62 -0
- package/CHANGELOG.md +5 -0
- package/README.md +180 -1
- package/__tests__/create-aurelia-app.test.ts +94 -0
- package/__tests__/preset.test.ts +32 -3
- package/__tests__/preview.test.ts +9 -131
- package/__tests__/render.test.ts +15 -26
- package/apps/hello-world/package-lock.json +404 -287
- package/apps/hello-world/package.json +10 -10
- package/apps/hello-world/src/components/notification-center.ts +2 -2
- package/apps/hello-world/src/components/stat-card.ts +12 -4
- package/apps/hello-world/src/components/weather-widget.ts +2 -1
- package/apps/hello-world/src/stories/feedback-form.stories.ts +15 -9
- package/apps/hello-world/src/stories/hello-world.stories.ts +20 -9
- package/apps/hello-world/src/stories/notification-center.stories.ts +17 -10
- package/apps/hello-world/src/stories/stat-card.stories.ts +23 -13
- package/apps/hello-world/src/stories/weather-widget.stories.ts +18 -13
- package/apps/hello-world-rsbuild/.storybook/main.ts +16 -0
- package/apps/hello-world-rsbuild/.storybook/preview.ts +1 -0
- package/apps/hello-world-rsbuild/.stylelintrc.json +5 -0
- package/apps/hello-world-rsbuild/README.md +28 -0
- package/apps/hello-world-rsbuild/eslint.config.mjs +25 -0
- package/apps/hello-world-rsbuild/favicon.ico +0 -0
- package/apps/hello-world-rsbuild/index.html +17 -0
- package/apps/hello-world-rsbuild/package-lock.json +11131 -0
- package/apps/hello-world-rsbuild/package.json +56 -0
- package/apps/hello-world-rsbuild/src/components/feedback-form.html +111 -0
- package/apps/hello-world-rsbuild/src/components/feedback-form.ts +45 -0
- package/apps/hello-world-rsbuild/src/components/notification-center.html +119 -0
- package/apps/hello-world-rsbuild/src/components/notification-center.ts +27 -0
- package/apps/hello-world-rsbuild/src/components/stat-card.html +107 -0
- package/apps/hello-world-rsbuild/src/components/stat-card.ts +41 -0
- package/apps/hello-world-rsbuild/src/components/weather-widget.html +89 -0
- package/apps/hello-world-rsbuild/src/components/weather-widget.ts +31 -0
- package/apps/hello-world-rsbuild/src/hello-world.html +48 -0
- package/apps/hello-world-rsbuild/src/hello-world.ts +17 -0
- package/apps/hello-world-rsbuild/src/main.ts +6 -0
- package/apps/hello-world-rsbuild/src/my-app.html +1 -0
- package/apps/hello-world-rsbuild/src/my-app.ts +3 -0
- package/apps/hello-world-rsbuild/src/resource.d.ts +15 -0
- package/apps/hello-world-rsbuild/src/services/weather-service.ts +15 -0
- package/apps/hello-world-rsbuild/src/stories/feedback-form.stories.ts +58 -0
- package/apps/hello-world-rsbuild/src/stories/hello-world.stories.ts +64 -0
- package/apps/hello-world-rsbuild/src/stories/notification-center.stories.ts +88 -0
- package/apps/hello-world-rsbuild/src/stories/stat-card.stories.ts +75 -0
- package/apps/hello-world-rsbuild/src/stories/weather-widget.stories.ts +62 -0
- package/apps/hello-world-rsbuild/test/my-app.spec.ts +15 -0
- package/apps/hello-world-rsbuild/test/setup.ts +29 -0
- package/apps/hello-world-rsbuild/tsconfig.json +19 -0
- package/apps/hello-world-rsbuild/tsconfig.vitest.json +11 -0
- package/apps/hello-world-rsbuild/vite.config.ts +17 -0
- package/apps/hello-world-rsbuild/vitest.config.ts +15 -0
- package/apps/hello-world-webpack/package-lock.json +239 -264
- package/apps/hello-world-webpack/package.json +8 -7
- package/apps/hello-world-webpack/src/components/notification-center.ts +2 -2
- package/apps/hello-world-webpack/src/components/stat-card.ts +12 -4
- package/apps/hello-world-webpack/src/components/weather-widget.ts +2 -1
- package/apps/hello-world-webpack/src/my-app.stories.ts +6 -4
- package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +15 -9
- package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +20 -9
- package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +17 -10
- package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +23 -13
- package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +18 -13
- package/dist/index.d.ts +25 -0
- package/dist/index.js +68 -14
- package/dist/index.js.map +1 -1
- package/dist/preset.d.ts +21 -0
- package/dist/preset.js +46 -2
- package/dist/preset.js.map +1 -1
- package/dist/preview/helpers.d.ts +2 -0
- package/dist/preview/helpers.js +6 -0
- package/dist/preview/helpers.js.map +1 -0
- package/dist/preview/render.d.ts +7 -0
- package/dist/preview/render.js +66 -15
- package/dist/preview/render.js.map +1 -1
- package/dist/preview/storybook-types-runtime.d.ts +1 -0
- package/dist/preview/storybook-types-runtime.js +5 -0
- package/dist/preview/storybook-types-runtime.js.map +1 -0
- package/dist/preview/storybook-types.d.ts +27 -0
- package/dist/preview/types-runtime.d.ts +1 -0
- package/dist/preview/types-runtime.js +5 -0
- package/dist/preview/types-runtime.js.map +1 -0
- package/dist/preview/types.d.ts +44 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +71 -16
- package/dist/preview.js.map +1 -1
- package/dist/webpack.d.ts +10 -0
- package/dist/webpack.js +19 -1
- package/dist/webpack.js.map +1 -1
- package/package.json +54 -9
- package/rollup.config.mjs +5 -3
- package/scripts/sync-versions.cjs +55 -0
- package/src/index.ts +11 -1
- package/src/preset.ts +32 -2
- package/src/preview/helpers.ts +7 -0
- package/src/preview/render.ts +98 -30
- package/src/preview/storybook-types-runtime.ts +2 -0
- package/src/preview/storybook-types.ts +34 -0
- package/src/preview/types-runtime.ts +2 -0
- package/src/preview/types.ts +57 -2
- package/src/preview.ts +11 -1
- package/src/webpack.ts +19 -0
- package/CONTINUITY.md +0 -22
- package/dist/preview/types.js +0 -2
- package/dist/preview/types.js.map +0 -1
- /package/{jest.config.js → jest.config.cjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Hello World</h1>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module '*.html' {
|
|
2
|
+
import { IContainer, PartialBindableDefinition } from 'aurelia';
|
|
3
|
+
export const name: string;
|
|
4
|
+
export const template: string;
|
|
5
|
+
export default template;
|
|
6
|
+
export const dependencies: string[];
|
|
7
|
+
export const containerless: boolean | undefined;
|
|
8
|
+
export const bindables: Record<string, PartialBindableDefinition>;
|
|
9
|
+
export const shadowOptions: { mode: 'open' | 'closed' } | undefined;
|
|
10
|
+
export function register(container: IContainer): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '*.css';
|
|
14
|
+
|
|
15
|
+
declare module '*.au';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DI } from 'aurelia';
|
|
2
|
+
|
|
3
|
+
export interface WeatherSummary {
|
|
4
|
+
location: string;
|
|
5
|
+
condition: string;
|
|
6
|
+
temperature: number;
|
|
7
|
+
high: number;
|
|
8
|
+
low: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface WeatherService {
|
|
12
|
+
getWeather(location: string): Promise<WeatherSummary>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const IWeatherService = DI.createInterface<WeatherService>('IWeatherService');
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineAureliaStory } from '@aurelia/storybook';
|
|
2
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
3
|
+
import { FeedbackForm } from '../components/feedback-form';
|
|
4
|
+
|
|
5
|
+
type FeedbackFormArgs = {
|
|
6
|
+
topics: string[];
|
|
7
|
+
submitting?: boolean;
|
|
8
|
+
onSubmit?: (payload: unknown) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Dashboard/FeedbackForm',
|
|
13
|
+
component: FeedbackForm,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: 'centered',
|
|
16
|
+
},
|
|
17
|
+
render: (args: FeedbackFormArgs) =>
|
|
18
|
+
defineAureliaStory({
|
|
19
|
+
template: `<feedback-form topics.bind="topics"
|
|
20
|
+
submitting.bind="submitting"
|
|
21
|
+
on-submit.bind="onSubmit"></feedback-form>`,
|
|
22
|
+
props: args,
|
|
23
|
+
components: [FeedbackForm],
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
|
|
29
|
+
export const DefaultForm = {
|
|
30
|
+
args: {
|
|
31
|
+
topics: ['Bug report', 'Feature request', 'General question'],
|
|
32
|
+
onSubmit: fn(),
|
|
33
|
+
submitting: false,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const SubmittingState = {
|
|
38
|
+
args: {
|
|
39
|
+
topics: ['Design review', 'Accessibility', 'Performance'],
|
|
40
|
+
submitting: true,
|
|
41
|
+
onSubmit: fn(),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const FillAndSubmit = {
|
|
46
|
+
args: {
|
|
47
|
+
topics: ['Beta feedback', 'Success story'],
|
|
48
|
+
onSubmit: fn(),
|
|
49
|
+
},
|
|
50
|
+
play: async ({ canvasElement }) => {
|
|
51
|
+
const canvas = within(canvasElement);
|
|
52
|
+
await userEvent.type(canvas.getByLabelText('Name'), 'Jordan');
|
|
53
|
+
await userEvent.type(canvas.getByLabelText('Email'), 'jordan@example.com');
|
|
54
|
+
await userEvent.selectOptions(canvas.getByLabelText('Topic'), 'Success story');
|
|
55
|
+
await userEvent.type(canvas.getByLabelText('Message'), 'The new timeline view is great');
|
|
56
|
+
await userEvent.click(canvas.getByRole('button', { name: /send feedback/i }));
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineAureliaStory } from '@aurelia/storybook';
|
|
2
|
+
import { HelloWorld } from '../hello-world';
|
|
3
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
|
|
5
|
+
type HelloWorldArgs = {
|
|
6
|
+
message?: string;
|
|
7
|
+
onIncrement?: () => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: 'Example/HelloWorld',
|
|
12
|
+
component: HelloWorld,
|
|
13
|
+
render: (args: HelloWorldArgs) =>
|
|
14
|
+
defineAureliaStory({
|
|
15
|
+
template: `<hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>`,
|
|
16
|
+
props: args,
|
|
17
|
+
}),
|
|
18
|
+
argTypes: {
|
|
19
|
+
message: { control: 'text' },
|
|
20
|
+
onIncrement: { action: 'increment' }
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
export const DefaultHelloWorld = {
|
|
27
|
+
args: {
|
|
28
|
+
message: 'Hello from Aurelia Storybook',
|
|
29
|
+
onIncrement: fn()
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const InteractiveHelloWorld = {
|
|
34
|
+
args: {
|
|
35
|
+
message: 'Try clicking the button!',
|
|
36
|
+
onIncrement: fn()
|
|
37
|
+
},
|
|
38
|
+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
39
|
+
const canvas = within(canvasElement);
|
|
40
|
+
const button = canvas.getByRole('button');
|
|
41
|
+
// Simulate three button clicks
|
|
42
|
+
await userEvent.click(button);
|
|
43
|
+
await userEvent.click(button);
|
|
44
|
+
await userEvent.click(button);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const NoArgs = {
|
|
49
|
+
render: () =>
|
|
50
|
+
defineAureliaStory({
|
|
51
|
+
template: `<hello-world></hello-world>`,
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const WithCustomTemplate = {
|
|
56
|
+
render: (args: HelloWorldArgs) =>
|
|
57
|
+
defineAureliaStory({
|
|
58
|
+
template: `<hello-world message.bind="message">Click me!</hello-world>`,
|
|
59
|
+
props: args,
|
|
60
|
+
}),
|
|
61
|
+
args: {
|
|
62
|
+
message: 'This is a custom message'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { defineAureliaStory } from '@aurelia/storybook';
|
|
2
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
3
|
+
import { NotificationCenter, NotificationItem } from '../components/notification-center';
|
|
4
|
+
|
|
5
|
+
type NotificationCenterArgs = {
|
|
6
|
+
notifications: NotificationItem[];
|
|
7
|
+
maxVisible?: number;
|
|
8
|
+
showTimestamp?: boolean;
|
|
9
|
+
onDismiss?: (item: NotificationItem) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const baseNotifications: NotificationItem[] = [
|
|
13
|
+
{
|
|
14
|
+
id: 1,
|
|
15
|
+
title: 'Build succeeded',
|
|
16
|
+
message: 'Main pipeline finished in 4m 12s.',
|
|
17
|
+
level: 'success',
|
|
18
|
+
timestamp: 'Today - 09:24',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 2,
|
|
22
|
+
title: 'New comment',
|
|
23
|
+
message: 'Samira replied to your review on PR #512.',
|
|
24
|
+
level: 'info',
|
|
25
|
+
timestamp: 'Today - 08:51',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 3,
|
|
29
|
+
title: 'Usage warning',
|
|
30
|
+
message: 'API quota is at 85% of the monthly allocation.',
|
|
31
|
+
level: 'warning',
|
|
32
|
+
timestamp: 'Yesterday - 17:05',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 4,
|
|
36
|
+
title: 'Error spike',
|
|
37
|
+
message: 'Synthetic tests detected an uptick in 500s.',
|
|
38
|
+
level: 'error',
|
|
39
|
+
timestamp: 'Yesterday - 15:33',
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const meta = {
|
|
44
|
+
title: 'Dashboard/NotificationCenter',
|
|
45
|
+
component: NotificationCenter,
|
|
46
|
+
render: (args: NotificationCenterArgs) =>
|
|
47
|
+
defineAureliaStory({
|
|
48
|
+
template: `<notification-center notifications.bind="notifications"
|
|
49
|
+
max-visible.bind="maxVisible"
|
|
50
|
+
on-dismiss.bind="onDismiss"
|
|
51
|
+
show-timestamp.bind="showTimestamp"></notification-center>`,
|
|
52
|
+
props: args,
|
|
53
|
+
components: [NotificationCenter],
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default meta;
|
|
58
|
+
|
|
59
|
+
export const DefaultNotifications = {
|
|
60
|
+
args: {
|
|
61
|
+
notifications: baseNotifications,
|
|
62
|
+
maxVisible: 3,
|
|
63
|
+
showTimestamp: true,
|
|
64
|
+
onDismiss: fn(),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const CompactList = {
|
|
69
|
+
args: {
|
|
70
|
+
notifications: baseNotifications.slice(0, 2),
|
|
71
|
+
maxVisible: 2,
|
|
72
|
+
onDismiss: fn(),
|
|
73
|
+
showTimestamp: false,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Interactions = {
|
|
78
|
+
args: {
|
|
79
|
+
notifications: baseNotifications,
|
|
80
|
+
maxVisible: 4,
|
|
81
|
+
onDismiss: fn(),
|
|
82
|
+
},
|
|
83
|
+
play: async ({ canvasElement }) => {
|
|
84
|
+
const canvas = within(canvasElement);
|
|
85
|
+
const dismissButtons = await canvas.findAllByRole('button', { name: /dismiss/i });
|
|
86
|
+
await userEvent.click(dismissButtons[0]);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineAureliaStory } from '@aurelia/storybook';
|
|
2
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
3
|
+
import { StatCard } from '../components/stat-card';
|
|
4
|
+
|
|
5
|
+
type StatCardArgs = {
|
|
6
|
+
title: string;
|
|
7
|
+
value: number | string;
|
|
8
|
+
unit?: string;
|
|
9
|
+
change?: number;
|
|
10
|
+
changeCopy?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
onRefresh?: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const meta = {
|
|
16
|
+
title: 'Dashboard/StatCard',
|
|
17
|
+
component: StatCard,
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'centered',
|
|
20
|
+
},
|
|
21
|
+
render: (args: StatCardArgs) =>
|
|
22
|
+
defineAureliaStory({
|
|
23
|
+
components: [StatCard],
|
|
24
|
+
template: `<stat-card title.bind="title"
|
|
25
|
+
value.bind="value"
|
|
26
|
+
unit.bind="unit"
|
|
27
|
+
change.bind="change"
|
|
28
|
+
change-copy.bind="changeCopy"
|
|
29
|
+
description.bind="description"
|
|
30
|
+
on-refresh.bind="onRefresh"></stat-card>`,
|
|
31
|
+
props: args,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
|
|
37
|
+
export const DefaultCard = {
|
|
38
|
+
args: {
|
|
39
|
+
title: 'Active users',
|
|
40
|
+
value: 1284,
|
|
41
|
+
unit: '',
|
|
42
|
+
change: 12.5,
|
|
43
|
+
changeCopy: 'vs last week',
|
|
44
|
+
description: 'Rolling 7-day average of unique user sessions.',
|
|
45
|
+
onRefresh: fn(),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const NegativeTrend = {
|
|
50
|
+
args: {
|
|
51
|
+
title: 'NPS score',
|
|
52
|
+
value: 42,
|
|
53
|
+
change: -6.3,
|
|
54
|
+
changeCopy: 'vs previous survey',
|
|
55
|
+
description: 'Direct feedback collected from in-app survey responses.',
|
|
56
|
+
onRefresh: fn(),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const ManualRefreshDemo = {
|
|
61
|
+
args: {
|
|
62
|
+
title: 'Deploy success rate',
|
|
63
|
+
value: '99.2',
|
|
64
|
+
unit: '%',
|
|
65
|
+
change: 1.1,
|
|
66
|
+
changeCopy: 'vs last 24h',
|
|
67
|
+
description: 'Completed deploys without rollbacks.',
|
|
68
|
+
onRefresh: fn(),
|
|
69
|
+
},
|
|
70
|
+
play: async ({ canvasElement }) => {
|
|
71
|
+
const canvas = within(canvasElement);
|
|
72
|
+
const refreshButton = await canvas.findByRole('button', { name: /refresh metric/i });
|
|
73
|
+
await userEvent.click(refreshButton);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineAureliaStory } from '@aurelia/storybook';
|
|
2
|
+
import { Registration } from 'aurelia';
|
|
3
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
4
|
+
import { WeatherWidget } from '../components/weather-widget';
|
|
5
|
+
import { IWeatherService, WeatherService, WeatherSummary } from '../services/weather-service';
|
|
6
|
+
|
|
7
|
+
type WeatherWidgetArgs = {
|
|
8
|
+
location: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const mockService: WeatherService = {
|
|
12
|
+
async getWeather(location: string): Promise<WeatherSummary> {
|
|
13
|
+
const safeLocation = location ?? '';
|
|
14
|
+
return {
|
|
15
|
+
location: safeLocation,
|
|
16
|
+
condition: safeLocation.includes('Berlin') ? 'Cloudy' : 'Sunny',
|
|
17
|
+
temperature: safeLocation.includes('Berlin') ? 16 : 24,
|
|
18
|
+
high: safeLocation.includes('Berlin') ? 18 : 27,
|
|
19
|
+
low: safeLocation.includes('Berlin') ? 11 : 19,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const meta = {
|
|
25
|
+
title: 'Dashboard/WeatherWidget',
|
|
26
|
+
component: WeatherWidget,
|
|
27
|
+
parameters: {
|
|
28
|
+
layout: 'centered',
|
|
29
|
+
},
|
|
30
|
+
render: (args: WeatherWidgetArgs) =>
|
|
31
|
+
defineAureliaStory({
|
|
32
|
+
template: `<weather-widget location.bind="location"></weather-widget>`,
|
|
33
|
+
props: args,
|
|
34
|
+
components: [WeatherWidget],
|
|
35
|
+
items: [Registration.instance(IWeatherService, mockService)],
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default meta;
|
|
40
|
+
|
|
41
|
+
export const DefaultWeather = {
|
|
42
|
+
args: {
|
|
43
|
+
location: 'Seattle, WA',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const EuropeanCity = {
|
|
48
|
+
args: {
|
|
49
|
+
location: 'Berlin, Germany',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const RefreshInteraction = {
|
|
54
|
+
args: {
|
|
55
|
+
location: 'Lisbon, Portugal',
|
|
56
|
+
},
|
|
57
|
+
play: async ({ canvasElement }) => {
|
|
58
|
+
const canvas = within(canvasElement);
|
|
59
|
+
const refreshButton = await canvas.findByRole('button', { name: /refresh/i });
|
|
60
|
+
await userEvent.click(refreshButton);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
|
+
import { MyApp } from '../src/my-app';
|
|
3
|
+
import { createFixture } from '@aurelia/testing';
|
|
4
|
+
|
|
5
|
+
describe('my-app', () => {
|
|
6
|
+
it('should render message', async () => {
|
|
7
|
+
const { assertText } = await createFixture(
|
|
8
|
+
'<my-app></my-app>',
|
|
9
|
+
{},
|
|
10
|
+
[MyApp],
|
|
11
|
+
).started;
|
|
12
|
+
|
|
13
|
+
assertText('Hello World!', { compact: true });
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BrowserPlatform } from '@aurelia/platform-browser';
|
|
2
|
+
import { setPlatform, onFixtureCreated, type IFixture } from '@aurelia/testing';
|
|
3
|
+
import { beforeAll, afterEach } from 'vitest';
|
|
4
|
+
|
|
5
|
+
// Sets up the Aurelia environment for testing
|
|
6
|
+
function bootstrapTextEnv() {
|
|
7
|
+
const platform = new BrowserPlatform(window);
|
|
8
|
+
setPlatform(platform);
|
|
9
|
+
BrowserPlatform.set(globalThis, platform);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const fixtures: IFixture<object>[] = [];
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
bootstrapTextEnv();
|
|
15
|
+
onFixtureCreated(fixture => {
|
|
16
|
+
fixtures.push(fixture);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
fixtures.forEach(async f => {
|
|
22
|
+
try {
|
|
23
|
+
await f.stop(true);
|
|
24
|
+
} catch {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
fixtures.length = 0;
|
|
29
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "esnext",
|
|
4
|
+
"moduleResolution": "bundler",
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"target": "ES2017",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"importHelpers": true,
|
|
10
|
+
"sourceMap": true
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"src",
|
|
14
|
+
"aurelia-sfc-plugin.js"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"src/resource.d.ts"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import aurelia from '@aurelia/vite-plugin';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
server: {
|
|
6
|
+
open: !process.env.CI,
|
|
7
|
+
port: 9000,
|
|
8
|
+
},
|
|
9
|
+
esbuild: {
|
|
10
|
+
target: 'es2022'
|
|
11
|
+
},
|
|
12
|
+
plugins: [
|
|
13
|
+
aurelia({
|
|
14
|
+
useDev: true,
|
|
15
|
+
}),
|
|
16
|
+
],
|
|
17
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { mergeConfig, defineConfig } from "vitest/config";
|
|
3
|
+
import viteConfig from "./vite.config";
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(
|
|
6
|
+
viteConfig,
|
|
7
|
+
defineConfig({
|
|
8
|
+
test: {
|
|
9
|
+
environment: "jsdom",
|
|
10
|
+
watch: false,
|
|
11
|
+
root: fileURLToPath(new URL("./", import.meta.url)),
|
|
12
|
+
setupFiles: ["./test/setup.ts"]
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
);
|