Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# storybook
/storybook-static
18 changes: 18 additions & 0 deletions ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { StorybookConfig } from '@storybook/nextjs-vite';

const config: StorybookConfig = {
stories: [
"../src/**/*.mdx",
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
],
addons: [
"@chromatic-com/storybook",
"@storybook/addon-vitest",
"@storybook/addon-a11y",
"@storybook/addon-docs",
"@storybook/addon-onboarding"
],
framework: "@storybook/nextjs-vite",
staticDirs: ["../public"],
};
export default config;
67 changes: 67 additions & 0 deletions ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { Preview } from '@storybook/nextjs-vite'
import { worker } from '../src/mocks/browser'
import React, { ReactNode } from 'react'
import '../src/app/globals.css'
import { AgentsContext } from '../src/components/AgentsProvider'
import type { AgentsContextType } from '../src/components/AgentsProvider'
import type { Agent } from '../src/types'

const mockContextValue: AgentsContextType = {
agents: [],
models: [],
loading: false,
error: "",
tools: [],
refreshAgents: async () => {},
refreshModels: async () => {},
refreshTools: async () => {},
createNewAgent: async () => ({ message: "mock", data: {} as Agent }),
updateAgent: async () => ({ message: "mock", data: {} as Agent }),
getAgent: async () => null,
validateAgentData: () => ({}),
};

interface MockAgentsProviderProps {
children: ReactNode;
value?: Partial<AgentsContextType>;
}

function MockAgentsProvider({ children, value }: MockAgentsProviderProps) {
return (
<AgentsContext.Provider value={{ ...mockContextValue, ...value }}>
{children}
</AgentsContext.Provider>
);
}

const preview: Preview = {
beforeAll: async () => {
await worker.start({ onUnhandledRequest: 'bypass' });
},
parameters: {
nextjs: {
appDirectory: true,
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
a11y: {
test: 'todo'
}
},
decorators: [
(Story) => {
document.documentElement.classList.add('dark');
return (
<MockAgentsProvider>
<Story />
</MockAgentsProvider>
);
},
],
};

export default preview;
7 changes: 7 additions & 0 deletions ui/.storybook/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
import { setProjectAnnotations } from '@storybook/nextjs-vite';
import * as projectAnnotations from './preview';

// This is an important step to apply the right configuration when testing your stories.
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
6 changes: 6 additions & 0 deletions ui/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import storybook from "eslint-plugin-storybook";

import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";
Expand Down Expand Up @@ -26,7 +29,10 @@ const eslintConfig = defineConfig([
"out/**",
"build/**",
"next-env.d.ts",
"storybook-static/**",
"public/mockServiceWorker.js",
]),
...storybook.configs["flat/recommended"],
]);

export default eslintConfig;
Loading
Loading