-
Notifications
You must be signed in to change notification settings - Fork 0
321 consolidate duplicated generatemocktoken helper into shared teststory utility #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
321 consolidate duplicated generatemocktoken helper into shared teststory utility #336
Conversation
…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
Reviewer's GuideRefactors 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 mockssequenceDiagram
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
Class diagram for shared Storybook test utilities and helpersclassDiagram
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
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey - I've left some high level feedback:
- The Storybook env/storage mocking in
storybook-decorators.tsxnow mutatesglobalThis.sessionStorage,globalThis.localStorage, andimport.meta.envat 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
mockStorageimplementation is used both aswindow.localStorage/sessionStorageand as auserStoreforAuthProvider, 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…cated-generatemocktoken-helper-into-shared-teststory-utility
...t/admin-dashboard/components/admin-listings-table/admin-listings-table.container.stories.tsx
Fixed
Show fixed
Hide fixed
- 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
|
@sourcery-ai dismiss |
|
@sourcery-ai review |
|
Sorry @nguyenduy, your pull request is larger than the review limit of 150000 diff characters |
1 similar comment
|
Sorry @nguyenduy, your pull request is larger than the review limit of 150000 diff characters |
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.
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 anwithAuthDecoratorfor 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 } } }, |
Copilot
AI
Jan 28, 2026
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.
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.
| result: { data: { currentUser: { useUserIsAdmin: isAdmin } } }, | |
| result: { | |
| data: { | |
| currentUser: { | |
| __typename: 'PersonalUser' as const, | |
| id: 'user-123', | |
| userIsAdmin: isAdmin, | |
| }, | |
| }, | |
| }, |
| 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, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }; |
Copilot
AI
Jan 28, 2026
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.
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).
Summary by Sourcery
Extract shared Storybook authentication and environment mocking into reusable utilities and standardize their usage across UI stories.
Enhancements:
Tests: