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

Core: Testing Module UI #29236

Merged
merged 43 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a43f27e
Testing Module UI
ghengeveld Sep 27, 2024
8af1122
Add Knip with initial custom config
webpro Sep 12, 2024
b05237c
Move script/config
webpro Sep 12, 2024
9e28a8b
Add knip job to circle ci
webpro Sep 22, 2024
0ae48df
Fix TS issues (use matcher pkg that we have types for)
webpro Sep 22, 2024
26f9219
remove handlebars
ndelangen Sep 25, 2024
8058192
fixes
ndelangen Sep 26, 2024
4381f77
Discard changes to .vscode/settings.json
ndelangen Sep 26, 2024
13fd6aa
ignore eslint warning of template file
ndelangen Sep 26, 2024
9aaf4a7
fix
ndelangen Sep 27, 2024
1e64fb3
make prettier a core optional peer dependency
JReinhold Sep 26, 2024
0cc7bb8
keep prettier/standalone
JReinhold Sep 26, 2024
c75dc6a
propagate prettier peer dependency to storybook package
JReinhold Sep 27, 2024
41093ec
update lock-file
JReinhold Sep 27, 2024
c2b75ba
Update CHANGELOG.md for v8.3.4 [skip ci]
storybook-bot Sep 28, 2024
5c82c12
Write changelog for 8.4.0-alpha.2 [skip ci]
storybook-bot Sep 28, 2024
491f595
Bump version from "8.4.0-alpha.1" to "8.4.0-alpha.2" [skip ci]
storybook-bot Sep 28, 2024
fc01f69
fix test run
yannbf Sep 30, 2024
11042e8
Testing Module functionality and stories
ghengeveld Sep 30, 2024
628e730
Upgrade es-toolkit to fix throttle
ghengeveld Sep 30, 2024
dc75e9a
Proper floating Testing Module style and behavior
ghengeveld Sep 30, 2024
641799c
Proper floating Testing Module style and behavior
ghengeveld Sep 30, 2024
31608b4
Also show collapse toggle on focus
ghengeveld Sep 30, 2024
8dd3585
Handle stopPropagation internally
ghengeveld Sep 30, 2024
13fa858
Show notifications in sidebar
ghengeveld Sep 30, 2024
c133e5a
Dark mode fixes
ghengeveld Sep 30, 2024
b19c824
Tweaks
ghengeveld Sep 30, 2024
ef23e3b
Merge branch 'unified-ui-testing' into testing-module-ui
ghengeveld Sep 30, 2024
c3bb1b2
Use actual registered test providers
ghengeveld Sep 30, 2024
21d01be
Handle empty list of test providers and fix story data
ghengeveld Sep 30, 2024
1815e21
Fix mocks
ghengeveld Oct 1, 2024
001abc4
update lockfile
yannbf Oct 1, 2024
e6d2872
Disable console.log
ghengeveld Oct 1, 2024
d64d8ce
Description is non-nullable
ghengeveld Oct 1, 2024
6986da3
Fix runAllTests action
ghengeveld Oct 1, 2024
ea4f8ef
Fix filter button colors
ghengeveld Oct 1, 2024
d9099d2
Hide Testing Module on mobile
ghengeveld Oct 1, 2024
0a96f01
Fix notification shadow on mobile
ghengeveld Oct 1, 2024
5702fb0
Extract to constant
ghengeveld Oct 1, 2024
dd965b8
Avoid shadow on top of scrollbar
ghengeveld Oct 1, 2024
543e0bb
Fix active state for filter toggles
ghengeveld Oct 1, 2024
0a6fc46
Avoid excessive shadow on stacked notifications
ghengeveld Oct 1, 2024
0c11df3
Merge branch 'unified-ui-testing' into testing-module-ui
ghengeveld Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"devDependencies": {
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"@testing-library/react": "^14.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@storybook/blocks": "workspace:*",
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion code/addons/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"upath": "^2.0.1"
},
"devDependencies": {
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-resize-detector": "^7.1.2",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/measure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"tiny-invariant": "^1.3.1"
},
"devDependencies": {
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion code/addons/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"@radix-ui/react-dialog": "^1.0.5",
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"@storybook/react": "workspace:*",
"framer-motion": "^11.0.3",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/outline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"dependencies": {
"@storybook/csf": "^0.1.11",
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"chalk": "^5.3.0"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions code/addons/test/src/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ addons.register(ADDON_ID, () => {
icon: <PointerHandIcon />,
title: 'Component tests',
description: () => 'Not yet run',
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
runnable: true,
watchable: true,
});
});
2 changes: 1 addition & 1 deletion code/addons/themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"ts-dedent": "^2.0.0"
},
"devDependencies": {
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"typescript": "^5.3.2"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/viewport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"devDependencies": {
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.3.2"
Expand Down
4 changes: 2 additions & 2 deletions code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
"@radix-ui/react-slot": "^1.0.2",
"@storybook/docs-mdx": "4.0.0-next.1",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.10",
"@storybook/icons": "^1.2.12",
"@tanstack/react-virtual": "^3.3.0",
"@testing-library/react": "^14.0.0",
"@types/compression": "^1.7.0",
Expand Down Expand Up @@ -360,7 +360,7 @@
"diff": "^5.2.0",
"downshift": "^9.0.4",
"ejs": "^3.1.10",
"es-toolkit": "^1.21.0",
"es-toolkit": "^1.22.0",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0",
"esbuild-plugin-alias": "^0.2.1",
"execa": "^8.0.1",
Expand Down
10 changes: 8 additions & 2 deletions code/core/src/manager/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export const Layout = ({ managerLayoutState, setManagerLayoutState, hasTab, ...s
viewMode={managerLayoutState.viewMode}
showPanel={showPanel}
>
<Notifications />
{showPages && <PagesContainer>{slots.slotPages}</PagesContainer>}
<Match path={/(^\/story|docs|onboarding\/|^\/$)/} startsWith={false}>
{({ match }) => <ContentContainer shown={!!match}>{slots.slotMain}</ContentContainer>}
Expand All @@ -170,7 +169,14 @@ export const Layout = ({ managerLayoutState, setManagerLayoutState, hasTab, ...s
</>
)}
{isMobile && (
<MobileNavigation menu={slots.slotSidebar} panel={slots.slotPanel} showPanel={showPanel} />
<>
<Notifications />
<MobileNavigation
menu={slots.slotSidebar}
panel={slots.slotPanel}
showPanel={showPanel}
/>
</>
)}
</LayoutContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const meta = {
</LocationProvider>
),
(Story) => (
<div style={{ width: '240px', margin: '1rem' }}>
<div style={{ width: '240px' }}>
<Story />
</div>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { type State } from '@storybook/core/manager-api';

import { transparentize } from 'polished';

import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants';

const slideIn = keyframes({
'0%': {
opacity: 0,
Expand All @@ -35,17 +37,21 @@ const Notification = styled.div<{ duration?: number }>(
({ theme }) => ({
position: 'relative',
display: 'flex',
padding: 15,
width: 280,
borderRadius: 4,
border: `1px solid ${theme.appBorderColor}`,
padding: '12px 6px 12px 12px',
borderRadius: theme.appBorderRadius + 1,
alignItems: 'center',

animation: `${slideIn} 500ms`,
background: theme.base === 'light' ? 'hsla(203, 50%, 20%, .97)' : 'hsla(203, 30%, 95%, .97)',
boxShadow: `0 2px 5px 0 rgba(0,0,0,0.05), 0 5px 15px 0 rgba(0,0,0,0.1)`,
boxShadow: `0 2px 5px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.1)`,
color: theme.color.inverseText,
textDecoration: 'none',
overflow: 'hidden',
zIndex: 1,
[MEDIA_DESKTOP_BREAKPOINT]: {
boxShadow: `0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app}`,
},
}),
({ duration, theme }) =>
duration && {
Expand Down Expand Up @@ -107,9 +113,8 @@ const NotificationTextWrapper = styled.div(({ theme }) => ({

const Headline = styled.div<{ hasIcon: boolean }>(({ theme, hasIcon }) => ({
height: '100%',
width: hasIcon ? 205 : 230,
alignItems: 'center',
whiteSpace: 'nowrap',
whiteSpace: 'balance',
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
overflow: 'hidden',
textOverflow: 'ellipsis',
fontSize: theme.typography.size.s1,
Expand All @@ -122,6 +127,7 @@ const SubHeadline = styled.div(({ theme }) => ({
fontSize: theme.typography.size.s1 - 1,
lineHeight: '14px',
marginTop: 2,
whiteSpace: 'balance',
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
}));

const ItemContent: FC<Pick<State['notifications'][0], 'icon' | 'content'>> = ({
Expand Down Expand Up @@ -154,6 +160,7 @@ const ItemContent: FC<Pick<State['notifications'][0], 'icon' | 'content'>> = ({
};

const DismissButtonWrapper = styled(IconButton)(({ theme }) => ({
width: 28,
alignSelf: 'center',
marginTop: 0,
color: theme.base === 'light' ? 'rgba(255,255,255,0.7)' : ' #999999',
Expand Down
39 changes: 19 additions & 20 deletions code/core/src/manager/components/notifications/NotificationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import type { FC } from 'react';
import React from 'react';

import { styled } from '@storybook/core/theming';
import type { CSSObject } from '@storybook/core/theming';

import type { State } from '@storybook/core/manager-api';

import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants';
import { useLayout } from '../layout/LayoutProvider';
import NotificationItem from './NotificationItem';

interface NotificationListProps {
Expand All @@ -18,8 +17,9 @@ export const NotificationList: FC<NotificationListProps> = ({
notifications,
clearNotification,
}) => {
const { isMobile } = useLayout();
return (
<List>
<List isMobile={isMobile}>
{notifications &&
notifications.map((notification) => (
<NotificationItem
Expand All @@ -32,21 +32,20 @@ export const NotificationList: FC<NotificationListProps> = ({
);
};

const List = styled.div<{ placement?: CSSObject }>({
zIndex: 200,
position: 'fixed',
left: 20,
bottom: 60,

[MEDIA_DESKTOP_BREAKPOINT]: {
bottom: 20,
},

'> * + *': {
marginTop: 10,
},

'&:empty': {
display: 'none',
const List = styled.div<{ isMobile?: boolean }>(
{
'> * + *': {
marginTop: 12,
},
'&:empty': {
display: 'none',
},
},
});
({ isMobile }) =>
isMobile && {
zIndex: 200,
position: 'fixed',
bottom: 40,
margin: 20,
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const managerContext: any = {
'api::getShortcutKeys'
),
getChannel: fn().mockName('api::getChannel'),
getElements: fn(() => ({})),
selectStory: fn().mockName('api::selectStory'),
experimental_setFilter: fn().mockName('api::experimental_setFilter'),
},
Expand Down
47 changes: 4 additions & 43 deletions code/core/src/manager/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React, { useEffect, useMemo, useState } from 'react';
import React, { useMemo } from 'react';

import { Button, ScrollArea, Spaced } from '@storybook/core/components';
import { styled } from '@storybook/core/theming';
import type { API_LoadedRefData, Addon_SidebarTopType } from '@storybook/core/types';

import {
TESTING_MODULE_RUN_ALL_REQUEST,
TESTING_MODULE_WATCH_MODE_REQUEST,
type TestingModuleRunAllRequestPayload,
type TestingModuleWatchModeRequestPayload,
} from '@storybook/core/core-events';
import { type State, useStorybookApi } from '@storybook/core/manager-api';

import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants';
import { useLayout } from '../layout/LayoutProvider';
import { Explorer } from './Explorer';
import type { HeadingProps } from './Heading';
import { Heading } from './Heading';
Expand Down Expand Up @@ -51,19 +50,6 @@ const Top = styled(Spaced)({
flex: 1,
});

const Bottom = styled.div(({ theme }) => ({
borderTop: `1px solid ${theme.appBorderColor}`,
padding: theme.layoutMargin / 2,
display: 'flex',
flexWrap: 'wrap',
gap: theme.layoutMargin / 2,
backgroundColor: theme.barBg,

'&:empty': {
display: 'none',
},
}));

const Swap = React.memo(function Swap({
children,
condition,
Expand Down Expand Up @@ -140,15 +126,7 @@ export const Sidebar = React.memo(function Sidebar({
const dataset = useCombination(index, indexError, previewInitialized, status, refs);
const isLoading = !index && !indexError;
const lastViewedProps = useLastViewed(selected);
const api = useStorybookApi();
const [watchMode, setWatchMode] = useState(false);

useEffect(() => {
api.emit(TESTING_MODULE_WATCH_MODE_REQUEST, {
providerId: TEST_PROVIDER_ID,
watchMode,
} as TestingModuleWatchModeRequestPayload);
}, [api, watchMode]);
const { isMobile } = useLayout();

return (
<Container className="container sidebar-container">
Expand Down Expand Up @@ -200,25 +178,8 @@ export const Sidebar = React.memo(function Sidebar({
)}
</Search>
</Top>
{isMobile || isLoading ? null : <SidebarBottom />}
</ScrollArea>
{isLoading ? null : (
<Bottom className="sb-bar">
<SidebarBottom />
<Button
onClick={() => {
api.emit(TESTING_MODULE_RUN_ALL_REQUEST, {
providerId: TEST_PROVIDER_ID,
} as TestingModuleRunAllRequestPayload);
}}
>
Run test for all Stories
</Button>
<label>
<input type="checkbox" checked={watchMode} onChange={() => setWatchMode(!watchMode)} />{' '}
Watch Mode
</label>
</Bottom>
)}
</Container>
);
});
Loading