diff --git a/src/components/SidebarBottom.stories.tsx b/src/components/SidebarBottom.stories.tsx new file mode 100644 index 00000000..4141a6c8 --- /dev/null +++ b/src/components/SidebarBottom.stories.tsx @@ -0,0 +1,40 @@ +import { action } from "@storybook/addon-actions"; + +import { ADDON_ID } from "../constants"; +import { SidebarBottomBase } from "./SidebarBottom"; + +export default { + component: SidebarBottomBase, + args: { + api: { experimental_setFilter: action("experimental_setFilter"), emit: action("emit") }, + }, +}; + +export const Changes = { + args: { + status: { + one: { [ADDON_ID]: { status: "warn" } }, + two: { [ADDON_ID]: { status: "warn" } }, + }, + }, +}; + +export const Errors = { + args: { + status: { + one: { [ADDON_ID]: { status: "error" } }, + two: { [ADDON_ID]: { status: "error" } }, + }, + }, +}; + +export const Both = { + args: { + status: { + one: { [ADDON_ID]: { status: "warn" } }, + two: { [ADDON_ID]: { status: "warn" } }, + three: { [ADDON_ID]: { status: "error" } }, + four: { [ADDON_ID]: { status: "error" } }, + }, + }, +}; diff --git a/src/SidebarBottom.tsx b/src/components/SidebarBottom.tsx similarity index 84% rename from src/SidebarBottom.tsx rename to src/components/SidebarBottom.tsx index 8e1ecb66..c7eea8e9 100644 --- a/src/SidebarBottom.tsx +++ b/src/components/SidebarBottom.tsx @@ -1,10 +1,10 @@ -import { type API, useStorybookState } from "@storybook/manager-api"; +import { type API, type State, useStorybookState } from "@storybook/manager-api"; import { styled } from "@storybook/theming"; import type { API_FilterFunction } from "@storybook/types"; import React, { useCallback, useEffect } from "react"; -import { SidebarToggleButton } from "./components/SidebarToggleButton"; -import { ADDON_ID, ENABLE_FILTER } from "./constants"; +import { ADDON_ID, ENABLE_FILTER } from "../constants"; +import { SidebarToggleButton } from "./SidebarToggleButton"; const filterNone: API_FilterFunction = () => true; const filterWarn: API_FilterFunction = ({ status }) => status?.[ADDON_ID]?.status === "warn"; @@ -26,13 +26,13 @@ const Wrapper = styled.div({ interface SidebarBottomProps { api: API; + status: State["status"]; } -export const SidebarBottom = ({ api }: SidebarBottomProps) => { +export const SidebarBottomBase = ({ api, status }: SidebarBottomProps) => { const [showWarnings, setShowWarnings] = React.useState(false); const [showErrors, setShowErrors] = React.useState(false); - const { status } = useStorybookState(); const warnings = Object.values(status).filter((value) => value[ADDON_ID]?.status === "warn"); const errors = Object.values(status).filter((value) => value[ADDON_ID]?.status === "error"); const hasWarnings = warnings.length > 0; @@ -74,3 +74,8 @@ export const SidebarBottom = ({ api }: SidebarBottomProps) => { ); }; + +export const SidebarBottom = (props: Omit) => { + const { status } = useStorybookState(); + return ; +}; diff --git a/src/SidebarTop.tsx b/src/components/SidebarTop.tsx similarity index 94% rename from src/SidebarTop.tsx rename to src/components/SidebarTop.tsx index 2ca4c9f4..b64e723b 100644 --- a/src/SidebarTop.tsx +++ b/src/components/SidebarTop.tsx @@ -4,7 +4,6 @@ import { color } from "@storybook/theming"; import pluralize from "pluralize"; import React, { useCallback, useContext, useEffect, useRef } from "react"; -import { SidebarTopButton } from "./components/SidebarTopButton"; import { ADDON_ID, CONFIG_INFO, @@ -13,13 +12,14 @@ import { IS_OUTDATED, LOCAL_BUILD_PROGRESS, PANEL_ID, -} from "./constants"; -import { ConfigInfoPayload, LocalBuildProgress } from "./types"; -import { useAccessToken } from "./utils/graphQLClient"; -import { TelemetryContext } from "./utils/TelemetryContext"; -import { useBuildEvents } from "./utils/useBuildEvents"; -import { useProjectId } from "./utils/useProjectId"; -import { useSharedState } from "./utils/useSharedState"; +} from "../constants"; +import { ConfigInfoPayload, LocalBuildProgress } from "../types"; +import { useAccessToken } from "../utils/graphQLClient"; +import { TelemetryContext } from "../utils/TelemetryContext"; +import { useBuildEvents } from "../utils/useBuildEvents"; +import { useProjectId } from "../utils/useProjectId"; +import { useSharedState } from "../utils/useSharedState"; +import { SidebarTopButton } from "./SidebarTopButton"; interface SidebarTopProps { api: API; diff --git a/src/manager.tsx b/src/manager.tsx index 78980477..d5fe8697 100644 --- a/src/manager.tsx +++ b/src/manager.tsx @@ -4,10 +4,10 @@ import { color } from "@storybook/theming"; import { Addon_TypesEnum } from "@storybook/types"; import React from "react"; +import { SidebarBottom } from "./components/SidebarBottom"; +import { SidebarTop } from "./components/SidebarTop"; import { ADDON_ID, PANEL_ID, SIDEBAR_BOTTOM_ID, SIDEBAR_TOP_ID } from "./constants"; import { Panel } from "./Panel"; -import { SidebarBottom } from "./SidebarBottom"; -import { SidebarTop } from "./SidebarTop"; let heartbeatTimeout: NodeJS.Timeout; const expectHeartbeat = (api: API) => { diff --git a/src/screens/VisualTests/VisualTests.stories.tsx b/src/screens/VisualTests/VisualTests.stories.tsx index baa1f452..27432d7d 100644 --- a/src/screens/VisualTests/VisualTests.stories.tsx +++ b/src/screens/VisualTests/VisualTests.stories.tsx @@ -3,15 +3,7 @@ import { VariablesOf } from "@graphql-typed-document-node/core"; import type { Meta, StoryObj } from "@storybook/react"; import { expect, fn } from "@storybook/test"; -import { - findByLabelText, - findByRole, - fireEvent, - screen, - userEvent, - waitFor, - within, -} from "@storybook/testing-library"; +import { findByLabelText, findByRole, fireEvent, waitFor } from "@storybook/testing-library"; import { delay, HttpResponse } from "msw"; import React from "react";