-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mutation demo to Storybook (#113)
- Loading branch information
Showing
41 changed files
with
2,389 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=VT323&display=swap" | ||
rel="stylesheet" | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { within, expect, waitFor } from "@storybook/test"; | ||
import { | ||
ApolloApp as ApolloEcommerceApp, | ||
ApolloAppWithDefer as AppWithDefer, | ||
} from "./components/apollo-client/EcommerceExample.js"; | ||
import { ApolloApp as ApolloWNBAApp } from "./components/apollo-client/WNBAExample.js"; | ||
import { ecommerceHandler } from "../../src/__tests__/mocks/handlers.js"; | ||
import { createHandler } from "../../src/handlers.js"; | ||
import wnbaTypeDefs from "../stories/schemas/wnba.graphql"; | ||
|
||
const meta = { | ||
title: "Example/Apollo Client", | ||
component: ApolloEcommerceApp, | ||
parameters: { | ||
layout: "centered", | ||
msw: { | ||
handlers: { | ||
graphql: ecommerceHandler, | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof ApolloEcommerceApp>; | ||
|
||
export default meta; | ||
|
||
export const EcommerceApp: StoryObj<typeof ApolloEcommerceApp> = { | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
await expect( | ||
canvas.getByRole("heading", { name: /loading/i }), | ||
).toHaveTextContent("Loading..."); | ||
await waitFor( | ||
() => | ||
expect( | ||
canvas.getByRole("heading", { name: /customers/i }), | ||
).toHaveTextContent("Customers also purchased"), | ||
{ timeout: 2000 }, | ||
); | ||
await waitFor( | ||
() => expect(canvas.getByText(/beanie/i)).toBeInTheDocument(), | ||
{ timeout: 2000 }, | ||
); | ||
}, | ||
}; | ||
|
||
export const EcommerceAppWithDefer = () => <AppWithDefer />; | ||
|
||
export const WNBAApp = () => <ApolloWNBAApp />; | ||
|
||
const teams = [ | ||
{ | ||
id: "1", | ||
name: "New York Liberty", | ||
}, | ||
{ | ||
id: "2", | ||
name: "Las Vegas Aces", | ||
}, | ||
]; | ||
|
||
WNBAApp.parameters = { | ||
msw: { | ||
handlers: { | ||
graphql: createHandler({ | ||
typeDefs: wnbaTypeDefs, | ||
resolvers: { | ||
Mutation: { | ||
setCurrentTeam: (_p, { team }) => teams.find((t) => t.id === team), | ||
}, | ||
Query: { | ||
team: () => ({ | ||
id: "1", | ||
name: "New York Liberty", | ||
}), | ||
teams: () => teams, | ||
}, | ||
}, | ||
}), | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Atlanta from "./logos/AtlantaDream.svg?react"; | ||
import Chicago from "./logos/ChicagoSky.svg?react"; | ||
import Connecticut from "./logos/ConnecticutSun.svg?react"; | ||
import Dallas from "./logos/DallasWings.svg?react"; | ||
import Indiana from "./logos/IndianaFever.svg?react"; | ||
import LasVegas from "./logos/LasVegasAces.svg?react"; | ||
import LosAngeles from "./logos/LosAngelesSparks.svg?react"; | ||
import Minnesota from "./logos/MinnesotaLynx.svg?react"; | ||
import NewYork from "./logos/NewYorkLiberty.svg?react"; | ||
import Phoenix from "./logos/PhoenixMercury.svg?react"; | ||
import Seattle from "./logos/SeattleStorm.svg?react"; | ||
import Washington from "./logos/WashingtonMystics.svg?react"; | ||
|
||
// indexed by team ID | ||
const logos = [ | ||
, | ||
NewYork, | ||
LasVegas, | ||
LosAngeles, | ||
Atlanta, | ||
Chicago, | ||
Connecticut, | ||
Indiana, | ||
Washington, | ||
Dallas, | ||
Minnesota, | ||
Phoenix, | ||
Seattle, | ||
]; | ||
|
||
export function TeamLogo({ team }: { team: string }) { | ||
const Logo = logos[parseInt(team)] || (() => "Error: no logo found"); | ||
return <Logo className="h-40 w-40 m-0" />; | ||
} |
File renamed without changes.
Oops, something went wrong.
01cb66e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report (95%)