Skip to content

Commit

Permalink
feat(DashboardPage): add loading story
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed Jul 19, 2024
1 parent c7bd38b commit d3bb1a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions apps/studio/src/stories/Page/DashboardPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ type Story = StoryObj<typeof DashboardPage>
export const Default: Story = {
name: "Dashboard Page",
}

export const Loading: Story = {
parameters: {
msw: {
handlers: [meHandlers.me(), sitesHandlers.list.loading()],
},
},
}
11 changes: 9 additions & 2 deletions apps/studio/tests/msw/handlers/sites.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import type { DelayMode } from "msw"
import { delay } from "msw"

import { trpcMsw } from "../mockTrpc"

const siteListQuery = () => {
return trpcMsw.site.list.query(() => {
const siteListQuery = (wait?: DelayMode | number) => {
return trpcMsw.site.list.query(async () => {
if (wait !== undefined) {
await delay(wait)
}
return [
{
id: 1,
Expand All @@ -14,5 +20,6 @@ const siteListQuery = () => {
export const sitesHandlers = {
list: {
default: siteListQuery,
loading: () => siteListQuery("infinite"),
},
}

0 comments on commit d3bb1a3

Please sign in to comment.