Skip to content

Commit 7c1601b

Browse files
authored
chore: Add internal SSR test stories to ssr-tests-v9 (microsoft#23852)
* chore: Add internal SSR test stories to ssr-tests-v9 Adds the capability to have internal SSR tests that will not appear as a part of the public documentation * Setup storybook * Update README.md * revert charting * fix build * fix build
1 parent ebfd9b6 commit 7c1601b

File tree

14 files changed

+90
-10
lines changed

14 files changed

+90
-10
lines changed

apps/ssr-tests-v9/.storybook/main.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const rootMain = require('../../../.storybook/main');
2+
3+
module.exports = /** @type {Omit<import('../../../.storybook/main'), 'typescript'|'babel'>} */ ({
4+
...rootMain,
5+
stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/index.stories.@(ts|tsx)'],
6+
addons: [...rootMain.addons],
7+
webpackFinal: (config, options) => {
8+
const localConfig = { ...rootMain.webpackFinal(config, options) };
9+
10+
// add your own webpack tweaks if needed
11+
12+
return localConfig;
13+
},
14+
});
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as rootPreview from '../../../.storybook/preview';
2+
3+
/** @type {typeof rootPreview.decorators} */
4+
export const decorators = [...rootPreview.decorators];
5+
6+
/** @type {typeof rootPreview.parameters} */
7+
export const parameters = { ...rootPreview.parameters };
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "",
5+
"allowJs": true,
6+
"checkJs": true,
7+
"types": ["static-assets", "environment", "storybook__addons"]
8+
},
9+
"include": ["../src/**/*.stories.ts", "../src/**/*.stories.tsx", "*.js"]
10+
}

apps/ssr-tests-v9/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"clean": "just-scripts clean",
1414
"code-style": "just-scripts code-style",
1515
"lint": "just-scripts lint",
16-
"test": "jest && ts-node --transpile-only ./src/test.ts",
16+
"storybook": "node ../../scripts/storybook/runner",
17+
"test:unit": "jest",
18+
"test:ssr": "ts-node --transpile-only ./src/test.ts",
19+
"test": "yarn test:unit && yarn test:ssr",
1720
"type-check": "tsc -b tsconfig.json"
1821
},
1922
"dependencies": {

apps/ssr-tests-v9/src/build.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async function build() {
2828
const generateStartTime = process.hrtime();
2929

3030
const rawStoriesGlobs = getVnextStories() as string[];
31+
rawStoriesGlobs.push(path.resolve(path.join(__dirname, './stories/**/index.stories.tsx')));
3132
const storiesGlobs = rawStoriesGlobs
3233
// TODO: Find a better way for this. Pass the path via params? 👇
3334
.map(pattern => path.resolve(__dirname, pattern));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from 'react';
2+
import { Button, MenuItem, Menu, MenuTrigger, MenuPopover, MenuList } from '@fluentui/react-components';
3+
4+
export const DefaultOpen = () => (
5+
<Menu defaultOpen>
6+
<MenuTrigger>
7+
<Button>Default open</Button>
8+
</MenuTrigger>
9+
10+
<MenuPopover>
11+
<MenuList>
12+
<MenuItem>Item</MenuItem>
13+
<MenuItem>Item</MenuItem>
14+
<MenuItem>Item</MenuItem>
15+
<MenuItem>Item</MenuItem>
16+
</MenuList>
17+
</MenuPopover>
18+
</Menu>
19+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { DefaultOpen } from './DefaultOpen.stories';
2+
3+
export default {
4+
title: 'Menu',
5+
};
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Internal stories for SSR tests
2+
3+
This project is not configured to host a storybook but contains
4+
storyfiles. The storyfiles in this folder are used for test cases that we do
5+
not want on the public docsite.
6+
7+
The project does not actually need to host a storybook, but the storybook
8+
setup is still applied for consistency with other projects.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as React from 'react';
2+
import { Button, Tooltip } from '@fluentui/react-components';
3+
4+
export const DefaultOpen = () => (
5+
<Tooltip relationship="description" visible content="Default open tooltip">
6+
<Button>Default open</Button>
7+
</Tooltip>
8+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { DefaultOpen } from './DefaultOpen.stories';
2+
3+
export default {
4+
title: 'Tooltip',
5+
};

apps/ssr-tests-v9/src/utils/generateEntryPoints.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ type GenerateEntryPointsConfig = {
1515
export async function generateEntryPoints(config: GenerateEntryPointsConfig): Promise<void> {
1616
const storiesFiles = config.storiesGlobs.map(pattern => glob.sync(pattern)).flatMap(pattern => pattern);
1717

18-
// TODO: Can removed after the issue will be solved https://github.com/microsoft/fluentui/issues/23393
19-
const indexStoriesFiles = storiesFiles.filter(filename =>
20-
fs.readFileSync(filename, { encoding: 'utf8' }).includes('export { Default } from'),
21-
);
18+
const indexStoriesFiles = storiesFiles.filter(filename => filename.includes('index.stories.ts'));
2219

2320
const distDir = path.dirname(config.cjsEntryPoint);
2421
const imports = (

apps/ssr-tests-v9/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
},
1919
{
2020
"path": "./tsconfig.spec.json"
21+
},
22+
{
23+
"path": "./.storybook/tsconfig.json"
2124
}
2225
]
2326
}

apps/ssr-tests-v9/tsconfig.stories.json

Whitespace-only changes.

packages/react-components/react-theme/src/stories/colors/ThemeShadows.stories.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ const ShadowBox: React.FunctionComponent<
1414
shadow: string;
1515
isBrand: boolean;
1616
}
17-
> = props => (
17+
> = ({ shadow, isBrand, ...rest }) => (
1818
<div
19-
{...props}
19+
{...rest}
2020
style={{
2121
display: 'flex',
2222
alignItems: 'center',
2323
justifyContent: 'center',
2424
flexDirection: 'column',
25-
boxShadow: props.shadow,
25+
boxShadow: shadow,
2626
minHeight: '2rem',
2727
fontFamily: 'monospace',
2828
fontSize: 10,
29-
...(props.isBrand && {
29+
...(isBrand && {
3030
backgroundColor: theme.light.colorBrandBackground,
3131
color: theme.light.colorNeutralForegroundOnBrand,
3232
}),
3333
}}
3434
>
35-
{props.shadow.split('),').map((line, index, arr) => {
35+
{shadow.split('),').map((line, index, arr) => {
3636
const value = index < arr.length - 1 ? line + ')' : line;
3737
return <div key={value}>{value}</div>;
3838
})}

0 commit comments

Comments
 (0)