Skip to content

Conversation

@nguyenduy
Copy link
Contributor

@nguyenduy nguyenduy commented Jan 8, 2026

Summary by Sourcery

Extract shared Storybook authentication and environment mocking into reusable utilities and standardize their usage across UI stories.

Enhancements:

  • Introduce shared Storybook auth wrappers and environment/storage mocks to centralize test configuration.
  • Refine App container stories with richer mocked GraphQL data for listings, account setup, and admin state, improving story realism.
  • Update Storybook stories to rely on common decorators and utilities instead of in-file mocks, reducing duplication and tightening consistency across app, layout, and admin stories.

Tests:

  • Adjust numerous Storybook stories to use new shared auth and Apollo decorators while preserving existing behavior and interaction tests.

…where unnecessary

- Changed play functions in various Storybook stories from async to synchronous where applicable.
- Updated imports for MockAuthWrapper to a new file for better organization.
- Removed unused MockAuthWrapper and MockUnauthWrapper implementations from storybook-decorators.tsx for it mixes exporting constants and components
@nguyenduy nguyenduy requested a review from a team January 8, 2026 21:55
@nguyenduy nguyenduy linked an issue Jan 8, 2026 that may be closed by this pull request
4 tasks
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 8, 2026

Reviewer's Guide

Refactors Storybook test infrastructure by centralizing mock auth wrappers and environment/storage setup into shared utilities, adds reusable GraphQL mock builders for App stories, and updates many Storybook stories to use the new shared decorators and helpers while making minor consistency/typing tweaks to play functions and props.

Sequence diagram for AppContainer story with centralized GraphQL mocks

sequenceDiagram
    participant SB as StorybookRunner
    participant ST as AppContainerStory
    participant WMAC as withMockApolloClient
    participant AP as ApolloProvider
    participant AC as ApolloClient(MockLink)
    participant C as AppContainer

    SB->>ST: Load AuthenticatedCompletedOnboarding story
    ST->>WMAC: Apply decorator with mocks
    WMAC->>AP: Wrap Story with ApolloProvider
    AP->>AC: Initialize client with mocks

    SB->>C: Render AppContainer inside providers

    C->>AC: Query AppContainerCurrentUserDocument
    AC-->>C: Mock response from buildCurrentUserMock

    C->>AC: Query ListingsPageContainerGetListingsDocument
    AC-->>C: Mock response from buildListingsMock

    C->>AC: Query UseUserIsAdminDocument
    AC-->>C: Mock response from buildUseUserIsAdminMock

    C-->>SB: Render UI for authenticated user with listings
Loading

Class diagram for shared Storybook test utilities and helpers

classDiagram
    class StorybookDecorators {
        +withAuthDecorator(storyFn) JSXElement
        +withMockApolloClient(storyFn, mocks) JSXElement
        +withMockRouter(initialPath) Decorator
    }

    class StorybookMockAuthWrappers {
        +MockAuthWrapper~FC~
        +MockUnauthWrapper~FC~
    }

    class AppContainerStoriesHelpers {
        +buildCurrentUserMock(id, hasCompletedOnboarding) ApolloMock
        +buildListingsMock(listings) ApolloMock
        +buildUseUserIsAdminMock(isAdmin) ApolloMock
    }

    class ApolloMock {
        +request QueryRequest
        +result QueryResult
    }

    class QueryRequest {
        +query DocumentNode
        +variables any
    }

    class QueryResult {
        +data any
    }

    StorybookDecorators --> StorybookMockAuthWrappers : uses
    StorybookDecorators --> ApolloMock : configures
    AppContainerStoriesHelpers --> ApolloMock : builds
Loading

File-Level Changes

Change Details Files
Centralize mock auth wrappers into a dedicated shared utility and update stories to use it.
  • Extract MockAuthWrapper and MockUnauthWrapper into a new test-utils/storybook-mock-auth-wrappers module using createMockAuth/createMockUser and AuthContext.Provider
  • Remove auth wrappers from storybook-decorators and re-import them from the new shared mock-auth-wrappers module where needed
  • Update stories across layouts, shared components, and hooks to import MockAuthWrapper/MockUnauthWrapper from the new module instead of storybook-decorators
apps/ui-sharethrift/src/test-utils/storybook-mock-auth-wrappers.tsx
apps/ui-sharethrift/src/test-utils/storybook-decorators.tsx
apps/ui-sharethrift/src/components/layouts/home/components/create-listing/hooks/use-create-listing-navigation.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/stories/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
apps/ui-sharethrift/src/components/shared/stories/auth-redirect-user.stories.tsx
apps/ui-sharethrift/src/components/shared/stories/login-selection.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/stories/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
apps/ui-sharethrift/src/components/shared/stories/require-auth-admin.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
Create a shared auth/environment Storybook decorator and reuse it in App and Apollo connection stories instead of duplicating mock env and storage setup.
  • Add mockEnv and mockStorage objects and attach them to globalThis.sessionStorage, globalThis.localStorage, and import.meta.env in storybook-decorators
  • Introduce withAuthDecorator that wraps stories with MockedProvider and AuthProvider configured with mockEnv and mockStorage
  • Refactor ApolloConnection and App stories to import and use withAuthDecorator instead of defining their own mock env/storage and AuthProvider/MockedProvider setup
apps/ui-sharethrift/src/test-utils/storybook-decorators.tsx
apps/ui-sharethrift/src/components/shared/apollo-connection.stories.tsx
apps/ui-sharethrift/src/App.stories.tsx
Enhance App container stories with reusable GraphQL mocks for listings, current user, account plans, and admin checks.
  • Add mockListings data and helper builders buildListingsMock, buildUseUserIsAdminMock, and buildCurrentUserMock for constructing Apollo mocks
  • Update AuthenticatedCompletedOnboarding, AuthenticatedNotCompletedOnboarding, and Unauthenticated stories to use the new helpers and provide richer mocks for listings, account type, account plans, and admin status
  • Adjust imports to include the needed generated GraphQL documents and to use the new MockUnauthWrapper module
apps/ui-sharethrift/src/App.container.stories.tsx
Normalize Storybook play function signatures and minor typings/props adjustments across many stories for consistency.
  • Remove unnecessary async keywords where not needed and standardize spacing in play function declarations (e.g., play: ({ canvasElement }) => and play: async ({ canvasElement }) =>)
  • Tweak argument types for play functions where explicit typing is used (e.g., { canvasElement: HTMLElement }) without changing behavior
  • Make small prop/handler adjustments for type-safety or clarity, such as adding button type, ignoring unused parameters, and loosening callback signatures where appropriate
apps/ui-sharethrift/src/components/layouts/home/components/create-listing/create-listing.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/stories/all-listings-table.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-listings-table/admin-listings-table.view-listing.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/requests-table.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/stories/all-listings-card.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/components/profile-setup.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-users-table/admin-users-table.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/create-listing/hooks/use-file-limit.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/sharer-information/sharer-information.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-listings-table/admin-listings-table.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/components/account-setup.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/create-listing/hooks/use-create-listing-navigation.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/messages/stories/ConversationBoxContainer.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-listings-table/admin-listings-table.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-users-table/stories/admin-users-card.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/settings/pages/settings-view.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-reservations/stories/reservation-actions.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-listings-table/stories/admin-listings-table.status-tag.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-listings-table/stories/admin-listings-table.title-filter.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/profile/components/profile-view.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/view-listing.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-reservations/components/reservations-view-history.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-reservations/stories/reservation-state-utils.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/stories/HeroSection.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/components/select-account-type.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-users-table/admin-users-table.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/settings/components/settings-view.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/stories/requests-status-helpers.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-reservations/components/reservations-view-active.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/components/admin-users-table/admin-users.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/admin-dashboard/pages/admin-dashboard-main.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/account/settings/pages/Settings.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/category-filter.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/hero-section.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/components/listings-page.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/messages/pages/Conversation.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/pages/edit-listing.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/pages/my-listings.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/stories/my-listings-dashboard.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/my-reservations/stories/reservations-table.stories.tsx
apps/ui-sharethrift/src/components/layouts/home/stories/section-layout.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/components/select-account-type.container.stories.tsx
apps/ui-sharethrift/src/components/layouts/signup/stories/section-layout.stories.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#321 Create a shared generateMockToken helper in a test/story utilities location (e.g., apps/ui-sharethrift/src/test-utils/mockToken.ts) with the specified implementation. The diff does not add any new file or export named generateMockToken, nor does it create a mockToken.ts (or equivalent) helper in a shared test-utils location.
#321 Update all story files that previously defined a local generateMockToken to import and use the shared helper instead, removing local implementations. None of the modified story files show removal of a local generateMockToken function or an added import for generateMockToken from a shared utility. The changes focus on auth wrappers, Apollo mocks, and play function signatures.
#321 Eliminate duplicated generateMockToken implementations across the codebase so that no local copies remain. Because no shared generateMockToken helper is introduced and no local generateMockToken implementations are removed or changed, duplicated implementations (if present) are not addressed by this PR.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The Storybook env/storage mocking in storybook-decorators.tsx now mutates globalThis.sessionStorage, globalThis.localStorage, and import.meta.env at module load; consider moving these side effects into a dedicated Storybook setup (e.g., preview file) or behind a guard so simply importing the decorators in non-Storybook code doesn’t unexpectedly alter global state.
  • The mockStorage implementation is used both as window.localStorage/sessionStorage and as a userStore for AuthProvider, mixing sync (DOM Storage) and async (oidc userStore) style APIs; it may be worth clearly separating these concerns or adding comments to avoid accidental reuse of this object in a context that expects only one of the interfaces.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Storybook env/storage mocking in `storybook-decorators.tsx` now mutates `globalThis.sessionStorage`, `globalThis.localStorage`, and `import.meta.env` at module load; consider moving these side effects into a dedicated Storybook setup (e.g., preview file) or behind a guard so simply importing the decorators in non-Storybook code doesn’t unexpectedly alter global state.
- The `mockStorage` implementation is used both as `window.localStorage`/`sessionStorage` and as a `userStore` for `AuthProvider`, mixing sync (DOM Storage) and async (oidc userStore) style APIs; it may be worth clearly separating these concerns or adding comments to avoid accidental reuse of this object in a context that expects only one of the interfaces.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- Updated comments for Storybook tags to clarify that they are functional testing stories and not rendered in the sidebar.
- Adjusted the `withMockRouter` decorator to accept an `isAuthenticated` parameter for better control over authentication state in stories.
- Added a new story for the unauthenticated homepage to improve testing coverage for user flows.
- Made minor adjustments to the layout and structure of various story files for better organization and readability.
…cated-generatemocktoken-helper-into-shared-teststory-utility
@nguyenduy
Copy link
Contributor Author

@sourcery-ai dismiss

@nguyenduy
Copy link
Contributor Author

@sourcery-ai review

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 28, 2026

Sorry @nguyenduy, your pull request is larger than the review limit of 150000 diff characters

1 similar comment
@SourceryAI
Copy link

Sorry @nguyenduy, your pull request is larger than the review limit of 150000 diff characters

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes Storybook authentication/environment mocks and updates a wide set of stories to use shared utilities and a consistent “Pages / Components / Containers” taxonomy. It also refines several high-value app flows (home, onboarding, admin, messages) with richer Apollo mocks and tagging to distinguish functional “test” stories from UI docs.

Changes:

  • Introduces shared Storybook helpers: mock auth wrappers, a reusable userIsAdminMockRequest, global env/storage mocks, and an withAuthDecorator for OIDC/Apollo setup.
  • Standardizes Storybook metadata (titles, tags, decorators, routing) across login, signup, home, reservations, listings, messages, account, and admin areas, adding more realistic GraphQL mocks where needed.
  • Slightly adjusts production code paths around admin auth (RequireAuthAdmin), the home section layout, and login selection to better support the updated stories and interactions.

Reviewed changes

Copilot reviewed 103 out of 105 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test-utils/storybook-mock-auth-wrappers.tsx Adds reusable authenticated/unauthenticated AuthContext wrappers for stories, backed by createMockAuth/createMockUser.
src/test-utils/storybook-helpers.ts Adds userIsAdminMockRequest helper to generate consistent UseUserIsAdmin mocks.
src/test-utils/storybook-decorators.tsx Refactors decorators to use shared MockAuthWrapper, adds global env/storage mocks and withAuthDecorator for OIDC + Apollo.
src/contexts/applicant-id-context.stories.tsx Tags functional story with !dev to hide from sidebar.
src/components/shared/use-onboarding-redirect.stories.tsx Tags functional story with !dev.
src/components/shared/require-auth.stories.tsx Tags functional story with !dev.
src/components/shared/require-auth-admin.tsx Adjusts useEffect dependency arrays for signin and token-refresh logic.
src/components/shared/require-auth-admin.stories.tsx Switches to shared auth wrapper, centralizes admin mocks, and adds !dev test tags.
src/components/shared/payment/state-province-form-item.stories.tsx Retitles story under Components/Shared/Payment/....
src/components/shared/payment/payment-token-form-items.stories.tsx Retitles story under Components/Shared/Payment/....
src/components/shared/payment/payment-form.stories.tsx Retitles story under Components/Shared/Payment/....
src/components/shared/payment/country-form-item.stories.tsx Retitles story under Components/Shared/Payment/....
src/components/shared/payment/country-change-utils.stories.tsx Tags functional testing story with !dev.
src/components/shared/payment/billing-address-form-items.stories.tsx Retitles story under Components/Shared/Payment/....
src/components/shared/local-storage.stories.tsx Tags functional testing story with !dev.
src/components/shared/hooks/use-create-listing-navigation.stories.tsx Switches to shared auth wrapper, tags with !dev, and tweaks button/play signatures.
src/components/shared/handle-logout.stories.tsx Tags functional testing story with !dev.
src/components/shared/auth-redirect-user.stories.tsx Switches to shared auth wrapper and tags functional story with !dev.
src/components/shared/auth-redirect-admin.stories.tsx Tags functional testing story with !dev.
src/components/shared/auth-landing.stories.tsx Tags functional testing story with !dev.
src/components/shared/apollo-manual-merge-cache-fix.stories.tsx Tags functional testing story with !dev.
src/components/shared/apollo-connection.stories.tsx Replaces inline env/auth setup with withAuthDecorator and tags with !dev.
src/components/shared/apollo-client-links.stories.tsx Tags functional testing story with !dev.
src/components/layouts/signup/section-layout.stories.tsx Switches to shared auth wrapper and retitles layout story for signup.
src/components/layouts/signup/pages/terms-page.stories.tsx Uses SignupRoutes + router decorator for terms page entry.
src/components/layouts/signup/pages/select-account-type-page.stories.tsx Uses SignupRoutes and adds detailed Apollo mocks via page-level story.
src/components/layouts/signup/pages/profile-setup-page.stories.tsx Uses SignupRoutes with router decorator for profile-setup route.
src/components/layouts/signup/pages/payment-page.stories.tsx Uses SignupRoutes with router decorator and refines Story type alias.
src/components/layouts/signup/pages/account-setup-page.stories.tsx Uses SignupRoutes and simplified route (/account-setup).
src/components/layouts/signup/components/terms.container.stories.tsx Tags container story with !dev.
src/components/layouts/signup/components/terms-communication-preferences.stories.tsx Retitles story under Components/Signup/....
src/components/layouts/signup/components/select-account-type.stories.tsx Retitles story and simplifies play functions to sync.
src/components/layouts/signup/components/select-account-type.container.stories.tsx Tags container story with !dev and narrows some play functions.
src/components/layouts/signup/components/profile-setup.container.stories.tsx Tags container stories with !dev and simplifies play bodies.
src/components/layouts/signup/components/account-setup.container.stories.tsx Tags container stories with !dev and simplifies play bodies.
src/components/layouts/login/login-selection.tsx Adds data-testid="sign-up-button" to disambiguate Sign Up button in stories.
src/components/layouts/login/login-selection.stories.tsx Switches to unauth wrapper, retitles under unauth home, and updates interactions to use data-testid.
src/components/layouts/home/section-layout.tsx Minor cleanup of whitespace and useApolloClient import alignment.
src/components/layouts/home/section-layout.stories.tsx Switches to shared auth wrapper and retitles layout story.
src/components/layouts/home/pages/view-listing/view-listing.stories.tsx Retitles ViewListing component story under Components/Home/....
src/components/layouts/home/pages/view-listing/view-listing.container.stories.tsx Adds userType to currentUser mock, tags with !dev, and normalizes play behavior.
src/components/layouts/home/pages/view-listing/components/sharer-information/sharer-information.stories.tsx Normalizes play signatures and expectations to be simple truthiness checks.
src/components/layouts/home/pages/view-listing/components/sharer-information/sharer-information.container.stories.tsx Tags container story with !dev.
src/components/layouts/home/pages/view-listing/components/listing-information/listing-information.container.stories.tsx Tags container story with !dev.
src/components/layouts/home/pages/view-listing-page.stories.tsx Switches to HomeRoutes, enriches mocks (reservations, sharer info, admin status), and aligns currentUser ID.
src/components/layouts/home/pages/homepage-unauthenticated.stories.tsx Adds new unauthenticated home routes story with realistic listing mocks and unauthenticated router.
src/components/layouts/home/pages/create-listing/create-listing.stories.tsx Normalizes play functions (mostly interaction assertions).
src/components/layouts/home/pages/create-listing/create-listing.container.stories.tsx Tags container story with !dev.
src/components/layouts/home/pages/create-listing/components/create-listing-form.stories.tsx Retitles listing form story under Components/CreateListing/....
src/components/layouts/home/pages/create-listing-page.stories.tsx Switches to HomeRoutes and uses userIsAdminMockRequest for admin gating.
src/components/layouts/home/pages/Homepage.stories.tsx Refactors to StoryObj API, splits authenticated home under Pages/Home - Authenticated, and wires UseUserIsAdmin mocks.
src/components/layouts/home/my-reservations/utils/reservation-state-utils.stories.tsx Retitles utilities story and simplifies play functions.
src/components/layouts/home/my-reservations/pages/my-reservations.stories.tsx Switches to top-level App routes and adds admin + reservation mocks via userIsAdminMockRequest.
src/components/layouts/home/my-reservations/components/reservations-view.stories.tsx Retitles ReservationsView story under Components/Organisms/....
src/components/layouts/home/my-reservations/components/reservations-view-history.container.stories.tsx Tags container story with !dev and reflows long query names.
src/components/layouts/home/my-reservations/components/reservations-view-active.container.stories.tsx Fixes userType value, tags with !dev, and simplifies loading play assertions.
src/components/layouts/home/my-reservations/components/reservations-table.stories.tsx Retitles under Components/Organisms/... and normalizes async play.
src/components/layouts/home/my-reservations/components/reservations-grid.stories.tsx Retitles under Components/Organisms/....
src/components/layouts/home/my-reservations/components/reservation-card.stories.tsx Retitles under Components/Molecules/....
src/components/layouts/home/my-reservations/components/reservation-actions.stories.tsx Retitles under Components/Molecules/... and adds an eslint suppression for mock callback inspection.
src/components/layouts/home/my-listings/pages/my-listings.stories.tsx Switches to HomeRoutes, reworks mocks, and tags a file export test story with !dev.
src/components/layouts/home/my-listings/pages/edit-listing.stories.tsx Retitles edit listing page, updates Story type alias, and tags as temporarily hidden.
src/components/layouts/home/my-listings/components/status-tag-class.stories.tsx Retitles status-tag utility and tags as !dev.
src/components/layouts/home/my-listings/components/requests-table.tsx Safely changes image fallback from empty string to undefined for AntD Image.
src/components/layouts/home/my-listings/components/requests-table.stories.tsx Retitles requests table story under Components/My Listings/....
src/components/layouts/home/my-listings/components/requests-table.container.tsx Improves default/fallback labels for title, requester, period, and status during data mapping.
src/components/layouts/home/my-listings/components/requests-table.container.stories.tsx Tags container story with !dev, enriches pagination mocks, and updates expectations for new fallback text.
src/components/layouts/home/my-listings/components/requests-card.stories.tsx Retitles under Components/My Listings/....
src/components/layouts/home/my-listings/components/my-listings-dashboard.stories.tsx Retitles dashboard component and normalizes play.
src/components/layouts/home/my-listings/components/my-listings-dashboard.container.stories.tsx Tags container stories with !dev and expands empty-state mocks.
src/components/layouts/home/my-listings/components/all-listings-table.stories.tsx Retitles table story under Components/My Listings/... and normalizes many interaction plays.
src/components/layouts/home/my-listings/components/all-listings-table.container.stories.tsx Tags container story with !dev and simplifies loading play.
src/components/layouts/home/my-listings/components/all-listings-card.stories.tsx Retitles card story and normalizes multiple state-specific play functions.
src/components/layouts/home/my-listings/components/requests-status-helpers.stories.tsx Retitles helpers under Components/Layouts/... and tags as !dev.
src/components/layouts/home/messages/pages/MessagesPage.stories.tsx Modernizes to StoryObj, routes through HomeRoutes, and adds comprehensive mocks for current user, conversations, and admin status.
src/components/layouts/home/messages/pages/Conversation.stories.tsx Tags placeholder Conversation page story with !dev and simplifies play.
src/components/layouts/home/messages/components/listing-banner.tsx Switches AntD Card padding from bodyStyle to v5 styles.body API while keeping behavior.
src/components/layouts/home/messages/components/ConversationBoxContainer.stories.tsx Retitles under Components/Messages/..., tags as !dev, and normalizes play usage.
src/components/layouts/home/components/listings-page.container.stories.tsx Tags ListingsPage container stories with !dev and simplifies loading checks.
src/components/layouts/home/components/hero-section.container.stories.tsx Tags container stories with !dev and simplifies play.
src/components/layouts/home/components/category-filter.container.stories.tsx Tags container story with !dev and simplifies play.
src/components/layouts/home/components/HeroSection.stories.tsx Retitles under Components/Hero and refines interaction test with slightly cleaner textContent usage plus !dev tag on one story.
src/components/layouts/home/components/CategoryFilter.stories.tsx Retitles under Components/Listing/Category Filter.
src/components/layouts/home/admin-dashboard/pages/admin-dashboard-main.stories.tsx Tags admin dashboard main page file-export check with !dev.
src/components/layouts/home/admin-dashboard/pages/admin-dashboard-main.container.stories.tsx Routes through HomeRoutes, uses admin mocks via helper, and asserts heading presence.
src/components/layouts/home/admin-dashboard/components/admin-users-table/admin-users-table.container.stories.tsx Tags container stories with !dev and makes all play callbacks synchronous.
src/components/layouts/home/admin-dashboard/components/admin-users-table/admin-users-card.stories.tsx Retitles card story and normalizes play functions.
src/components/layouts/home/admin-dashboard/components/admin-listings-table/admin-listings-table.view-listing.stories.tsx Tags AdminViewListing container story with !dev.
src/components/layouts/home/admin-dashboard/components/admin-listings-table/admin-listings-table.utils.stories.tsx Tags format-date utility story with !dev and simplifies play.
src/components/layouts/home/admin-dashboard/components/admin-listings-table/admin-listings-table.title-filter.stories.tsx Retitles TitleFilter under Components/AdminListingsTable/... and normalizes tests.
src/components/layouts/home/admin-dashboard/components/admin-listings-table/admin-listings-table.status-tag.stories.tsx Retitles StatusTag under Components/AdminListingsTable/... and normalizes tests.
src/components/layouts/home/admin-dashboard/components/admin-listings-table/admin-listings-table.status-filter.stories.tsx Retitles StatusFilter under Components/AdminListingsTable/....
src/components/layouts/home/admin-dashboard/components/admin-listings-table/admin-listings-table.container.stories.tsx Tags AdminListings container stories with !dev and simplifies loading play.
src/components/layouts/home/account/settings/pages/settings-view.stories.tsx Normalizes play functions to sync while keeping assertions.
src/components/layouts/home/account/settings/pages/SettingsPage.stories.tsx Switches to HomeRoutes, adds richer currentUser mocks and userIsAdminMockRequest, but currently duplicates/overwrites parameters blocks.
src/components/layouts/home/account/settings/pages/Settings.stories.tsx Retitles file-export smoke test, tags with !dev, and slightly tweaks async play.
src/components/layouts/home/account/settings/components/settings-view.container.stories.tsx Tags container stories with !dev and simplifies loading / not-found plays.
src/components/layouts/home/account/profile/pages/ProfilePage.stories.tsx Refines PersonalUser mocks, moves userIsAdminMockRequest to shared helper, and adjusts list mocks.
src/components/layouts/home/account/profile/components/profile-view.stories.tsx Normalizes handlers and play declarations, avoids unused parameter in onListingClick.
src/App.tsx Moves LoginSelection import to layouts/login to match new structure.
src/App.stories.tsx Replaces inline OIDC/Apollo env mocking with withAuthDecorator and tags App story with !dev.
src/App.container.stories.tsx Adds richer mocks for listings, onboarding flows, and admin flag; defines helpers for user and listing mocks (note: bug in buildUseUserIsAdminMock as commented).
.storybook/preview.tsx Converts preview to TSX, imports global styles, configures story sorting order, and centralizes removal of Storybook main padding.
.storybook/preview.js Removes legacy JS-based preview in favor of the new TSX version.
.storybook/preview-head.html Left unchanged (included for context only).


const buildUseUserIsAdminMock = (isAdmin = false) => ({
request: { query: UseUserIsAdminDocument },
result: { data: { currentUser: { useUserIsAdmin: isAdmin } } },
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In buildUseUserIsAdminMock, the mocked response sets currentUser with a useUserIsAdmin field instead of userIsAdmin, which does not match the UseUserIsAdmin query shape and will never satisfy callers that read data.currentUser.userIsAdmin (e.g., the useUserIsAdmin hook). Please update this helper to return a currentUser object with a userIsAdmin field (and, ideally, the same __typename/id shape used elsewhere) so that these stories correctly exercise admin/non-admin behavior.

Suggested change
result: { data: { currentUser: { useUserIsAdmin: isAdmin } } },
result: {
data: {
currentUser: {
__typename: 'PersonalUser' as const,
id: 'user-123',
userIsAdmin: isAdmin,
},
},
},

Copilot uses AI. Check for mistakes.
Comment on lines 82 to 208
DefaultView.parameters = {
apolloClient: {
mocks: [
{
request: {
query: HomeAccountSettingsViewContainerCurrentUserDocument,
},
result: {
data: {
currentPersonalUserAndCreateIfNotExists: {
__typename: "PersonalUser",
id: "507f1f77bcf86cd799439099",
userType: "personal-user",
createdAt: "2024-08-01T00:00:00Z",
updatedAt: "2025-08-08T12:00:00Z",
account: {
__typename: "PersonalUserAccount",
accountType: "personal",
email: "patrick.g@example.com",
username: "patrick_g",
profile: {
__typename: "PersonalUserAccountProfile",
firstName: "Patrick",
lastName: "Garcia",
location: {
__typename: "PersonalUserAccountProfileLocation",
address1: "123 Main Street",
address2: "Apt 4B",
city: "Philadelphia",
state: "PA",
country: "United States",
zipCode: "19101",
},
billing: {
__typename: "PersonalUserAccountProfileBilling",
subscriptionId: "sub_123456789",
cybersourceCustomerId: "cust_abc123",
},
},
},
},
},
},
},
{
request: {
query: {
kind: "Document",
definitions: [
{
kind: "OperationDefinition",
operation: "query",
name: { kind: "Name", value: "useUserIsAdmin" },
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
name: { kind: "Name", value: "currentUser" },
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "InlineFragment",
typeCondition: {
kind: "NamedType",
name: { kind: "Name", value: "PersonalUser" },
},
selectionSet: {
kind: "SelectionSet",
selections: [
{ kind: "Field", name: { kind: "Name", value: "id" } },
{ kind: "Field", name: { kind: "Name", value: "userIsAdmin" } },
],
},
},
{
kind: "InlineFragment",
typeCondition: {
kind: "NamedType",
name: { kind: "Name", value: "AdminUser" },
},
selectionSet: {
kind: "SelectionSet",
selections: [
{ kind: "Field", name: { kind: "Name", value: "id" } },
{ kind: "Field", name: { kind: "Name", value: "userIsAdmin" } },
],
},
},
],
},
},
],
},
},
],
},
},
result: {
data: {
currentUser: {
__typename: "PersonalUser",
id: "507f1f77bcf86cd799439099",
userIsAdmin: false,
},
},
},
},
],
},
}; No newline at end of file
apolloClient: {
mocks: [
{
request: {
query: HomeAccountSettingsViewContainerCurrentUserDocument,
},
result: {
data: {
currentUser: {
__typename: 'PersonalUser',
id: '507f1f77bcf86cd799439099',
userType: 'personal-user',
createdAt: '2024-08-01T00:00:00Z',
updatedAt: '2025-08-08T12:00:00Z',
account: {
__typename: 'PersonalUserAccount',
accountType: 'personal',
email: 'patrick.g@example.com',
username: 'patrick_g',
profile: {
__typename: 'PersonalUserAccountProfile',
firstName: 'Patrick',
lastName: 'Garcia',
location: {
__typename: 'PersonalUserAccountProfileLocation',
address1: '123 Main Street',
address2: 'Apt 4B',
city: 'Philadelphia',
state: 'PA',
country: 'United States',
zipCode: '19101',
},
billing: {
__typename: 'PersonalUserAccountProfileBilling',
subscription: { subscriptionId: 'sub_123456789' },
cybersourceCustomerId: 'cust_abc123',
},
aboutMe:
'Enthusiastic thrift shopper and vintage lover. Always on the hunt for unique finds and sustainable fashion.',
},
},
},
},
},
},
{
request: {
query: {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'useUserIsAdmin' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'currentUser' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'InlineFragment',
typeCondition: {
kind: 'NamedType',
name: { kind: 'Name', value: 'PersonalUser' },
},
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'id' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'userIsAdmin' },
},
],
},
},
{
kind: 'InlineFragment',
typeCondition: {
kind: 'NamedType',
name: { kind: 'Name', value: 'AdminUser' },
},
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'id' },
},
{
kind: 'Field',
name: { kind: 'Name', value: 'userIsAdmin' },
},
],
},
},
],
},
},
],
},
},
],
},
},
result: {
data: {
currentUser: {
__typename: 'PersonalUser',
id: '507f1f77bcf86cd799439099',
userIsAdmin: false,
},
},
},
},
],
},
};
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultView defines Storybook parameters inline (lines 21–76) and then immediately overwrites them with a second DefaultView.parameters assignment (lines 83–208), which both duplicates the mocks and discards the new userIsAdminMockRequest helper you introduced. To avoid confusion and keep this story aligned with the shared helpers, please consolidate these into a single parameters definition (e.g., remove the lower block and keep the top one, or refactor both to use the common mock helpers).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate duplicated generateMockToken helper into shared test/story utility

3 participants