Skip to content

Commit 3863635

Browse files
authored
Merge pull request #29475 from storybookjs/version-non-patch-from-8.4.0-beta.2
Release: Prerelease 8.4.0-beta.3
2 parents 88c7787 + 59ca5a0 commit 3863635

File tree

4 files changed

+103
-96
lines changed

4 files changed

+103
-96
lines changed

CHANGELOG.prerelease.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 8.4.0-beta.3
2+
3+
- Addon Test: Only register testing module in Vite projects - [#29472](https://github.com/storybookjs/storybook/pull/29472), thanks @yannbf!
4+
15
## 8.4.0-beta.2
26

37
- Addon Test: Adjust file exports to be ESM/CJS compatible - [#29471](https://github.com/storybookjs/storybook/pull/29471), thanks @valentinpalkovic!

code/addons/test/src/manager.tsx

Lines changed: 96 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -80,104 +80,106 @@ const RelativeTime = ({ timestamp, testCount }: { timestamp: Date; testCount: nu
8080
};
8181

8282
addons.register(ADDON_ID, (api) => {
83-
const openAddonPanel = () => {
84-
api.setSelectedPanel(PANEL_ID);
85-
api.togglePanel(true);
86-
};
87-
88-
addons.add(TEST_PROVIDER_ID, {
89-
type: Addon_TypesEnum.experimental_TEST_PROVIDER,
90-
runnable: true,
91-
watchable: true,
92-
93-
name: 'Component tests',
94-
title: ({ crashed, failed }) =>
95-
crashed || failed ? 'Component tests failed' : 'Component tests',
96-
description: ({ failed, running, watching, progress, crashed, details }) => {
97-
const [isModalOpen, setIsModalOpen] = useState(false);
98-
99-
const errorMessage = details?.error?.message;
100-
101-
let message: string | React.ReactNode = 'Not run';
102-
103-
if (running) {
104-
message = progress
105-
? `Testing... ${progress.numPassedTests}/${progress.numTotalTests}`
106-
: 'Starting...';
107-
} else if (failed && !errorMessage) {
108-
message = 'Component tests failed';
109-
} else if (crashed || (failed && errorMessage)) {
110-
message = (
83+
if (globalThis.STORYBOOK_BUILDER?.includes('vite')) {
84+
const openAddonPanel = () => {
85+
api.setSelectedPanel(PANEL_ID);
86+
api.togglePanel(true);
87+
};
88+
89+
addons.add(TEST_PROVIDER_ID, {
90+
type: Addon_TypesEnum.experimental_TEST_PROVIDER,
91+
runnable: true,
92+
watchable: true,
93+
94+
name: 'Component tests',
95+
title: ({ crashed, failed }) =>
96+
crashed || failed ? 'Component tests failed' : 'Component tests',
97+
description: ({ failed, running, watching, progress, crashed, details }) => {
98+
const [isModalOpen, setIsModalOpen] = useState(false);
99+
100+
const errorMessage = details?.error?.message;
101+
102+
let message: string | React.ReactNode = 'Not run';
103+
104+
if (running) {
105+
message = progress
106+
? `Testing... ${progress.numPassedTests}/${progress.numTotalTests}`
107+
: 'Starting...';
108+
} else if (failed && !errorMessage) {
109+
message = 'Component tests failed';
110+
} else if (crashed || (failed && errorMessage)) {
111+
message = (
112+
<>
113+
<LinkComponent
114+
isButton
115+
onClick={() => {
116+
setIsModalOpen(true);
117+
}}
118+
>
119+
{details?.error?.name || 'View full error'}
120+
</LinkComponent>
121+
</>
122+
);
123+
} else if (progress?.finishedAt) {
124+
message = (
125+
<RelativeTime
126+
timestamp={new Date(progress.finishedAt)}
127+
testCount={progress.numTotalTests}
128+
/>
129+
);
130+
} else if (watching) {
131+
message = 'Watching for file changes';
132+
}
133+
134+
return (
111135
<>
112-
<LinkComponent
113-
isButton
114-
onClick={() => {
115-
setIsModalOpen(true);
136+
{message}
137+
<GlobalErrorModal
138+
error={errorMessage}
139+
open={isModalOpen}
140+
onClose={() => {
141+
setIsModalOpen(false);
116142
}}
117-
>
118-
{details?.error?.name || 'View full error'}
119-
</LinkComponent>
143+
onRerun={() => {
144+
setIsModalOpen(false);
145+
api
146+
.getChannel()
147+
.emit(TESTING_MODULE_RUN_ALL_REQUEST, { providerId: TEST_PROVIDER_ID });
148+
}}
149+
/>
120150
</>
121151
);
122-
} else if (progress?.finishedAt) {
123-
message = (
124-
<RelativeTime
125-
timestamp={new Date(progress.finishedAt)}
126-
testCount={progress.numTotalTests}
127-
/>
128-
);
129-
} else if (watching) {
130-
message = 'Watching for file changes';
131-
}
132-
133-
return (
134-
<>
135-
{message}
136-
<GlobalErrorModal
137-
error={errorMessage}
138-
open={isModalOpen}
139-
onClose={() => {
140-
setIsModalOpen(false);
141-
}}
142-
onRerun={() => {
143-
setIsModalOpen(false);
144-
api
145-
.getChannel()
146-
.emit(TESTING_MODULE_RUN_ALL_REQUEST, { providerId: TEST_PROVIDER_ID });
147-
}}
148-
/>
149-
</>
150-
);
151-
},
152-
153-
mapStatusUpdate: (state) =>
154-
Object.fromEntries(
155-
(state.details.testResults || []).flatMap((testResult) =>
156-
testResult.results
157-
.map(({ storyId, status, testRunId, ...rest }) => {
158-
if (storyId) {
159-
const statusObject: API_StatusObject = {
160-
title: 'Component tests',
161-
status: statusMap[status],
162-
description:
163-
'failureMessages' in rest && rest.failureMessages?.length
164-
? rest.failureMessages.join('\n')
165-
: '',
166-
data: {
167-
testRunId,
168-
},
169-
onClick: openAddonPanel,
170-
};
171-
return [storyId, statusObject];
172-
}
173-
})
174-
.filter(Boolean)
175-
)
176-
),
177-
} as Addon_TestProviderType<{
178-
testResults: TestResult[];
179-
error?: { message: string; name: string };
180-
}>);
152+
},
153+
154+
mapStatusUpdate: (state) =>
155+
Object.fromEntries(
156+
(state.details.testResults || []).flatMap((testResult) =>
157+
testResult.results
158+
.map(({ storyId, status, testRunId, ...rest }) => {
159+
if (storyId) {
160+
const statusObject: API_StatusObject = {
161+
title: 'Component tests',
162+
status: statusMap[status],
163+
description:
164+
'failureMessages' in rest && rest.failureMessages?.length
165+
? rest.failureMessages.join('\n')
166+
: '',
167+
data: {
168+
testRunId,
169+
},
170+
onClick: openAddonPanel,
171+
};
172+
return [storyId, statusObject];
173+
}
174+
})
175+
.filter(Boolean)
176+
)
177+
),
178+
} as Addon_TestProviderType<{
179+
testResults: TestResult[];
180+
error?: { message: string; name: string };
181+
}>);
182+
}
181183

182184
addons.add(PANEL_ID, {
183185
type: types.PANEL,

code/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,6 @@
293293
"Dependency Upgrades"
294294
]
295295
]
296-
}
296+
},
297+
"deferredNextVersion": "8.4.0-beta.3"
297298
}

docs/versions/next.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"8.4.0-beta.2","info":{"plain":"- Addon Test: Adjust file exports to be ESM/CJS compatible - [#29471](https://github.com/storybookjs/storybook/pull/29471), thanks @valentinpalkovic!\n- Core: Show tooltip on filter toggles to clarify their purpose - [#29447](https://github.com/storybookjs/storybook/pull/29447), thanks @ghengeveld!\n- Webpack: Fix export 'act' (imported as 'React4') was not found in 'react' errors in webpack - [#29235](https://github.com/storybookjs/storybook/pull/29235), thanks @kasperpeulen!"}}
1+
{"version":"8.4.0-beta.3","info":{"plain":"- Addon Test: Only register testing module in Vite projects - [#29472](https://github.com/storybookjs/storybook/pull/29472), thanks @yannbf!"}}

0 commit comments

Comments
 (0)