Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
fe034cb
refactor: update play functions in Storybook stories to remove async …
nguyenduy Jan 8, 2026
a73559a
refactor: consolidate duplicated mock token helpers into shared utili…
nguyenduy Jan 8, 2026
091a7ec
partial fix: reorganize visual stories+hide functional test stories
nguyenduy Jan 9, 2026
4e60379
partial fix 2: reorganize visual stories+hide functional test stories
nguyenduy Jan 9, 2026
ce05554
refactor: simplify dependency array in useEffect hooks for RequireAut…
nguyenduy Jan 9, 2026
5624011
refactor: update Storybook stories to use data-testid for Sign Up button
nguyenduy Jan 12, 2026
de96a09
hide stories containing functional tests only
nguyenduy Jan 12, 2026
0e2a817
hide functional testing stories+reorganize UI story
nguyenduy Jan 12, 2026
7f130e7
remove unnecessary files
nguyenduy Jan 13, 2026
c5eefff
refactor: consolidate story sorting options in Storybook preview conf…
nguyenduy Jan 13, 2026
419c9d6
fix stories for pages to include the header
nguyenduy Jan 13, 2026
9a6aa26
fix storybook styling
nguyenduy Jan 13, 2026
f514595
remove default padding in Storybook preview
nguyenduy Jan 13, 2026
f1d4e50
refactor: add comment to clarify removal of default padding in Storyb…
nguyenduy Jan 13, 2026
ae37f04
make Story creation consistent for payment-page
nguyenduy Jan 13, 2026
3bb868b
fix story name to have it sorted properly
nguyenduy Jan 13, 2026
5070d00
fix missing header for my reservation stories
nguyenduy Jan 13, 2026
84a9119
make functional testing story hidden
nguyenduy Jan 13, 2026
ed94d36
update story creation to use StoryObj for consistency
nguyenduy Jan 13, 2026
4424d8c
hide story for incomplete Edit Listing component
nguyenduy Jan 13, 2026
1dfa8b1
switch to HomeRoutes to minimize component rendered for sign up stories
nguyenduy Jan 13, 2026
e91799d
fix mock data for Messages page story
nguyenduy Jan 13, 2026
8914efe
organize stories order
nguyenduy Jan 13, 2026
123707d
make story creation consistent for Messages page
nguyenduy Jan 14, 2026
53f7d32
organize and fix stories for Profile and Settings pages
nguyenduy Jan 14, 2026
25b6df1
organize+fix stories for admin dashboard
nguyenduy Jan 16, 2026
6fa0418
fix mock data for Message story
nguyenduy Jan 16, 2026
f3c855c
organize story for Settings functional story
nguyenduy Jan 16, 2026
6bdd78f
Merge remote-tracking branch 'origin/main' into 321-consolidate-dupli…
nguyenduy Jan 20, 2026
12e4025
remove irrelevant story
nguyenduy Jan 20, 2026
a1df91d
remove unnecessary "Loading" story
nguyenduy Jan 20, 2026
56b36b8
fix layout+mock data
nguyenduy Jan 20, 2026
f09d821
update page names
nguyenduy Jan 20, 2026
db16eaf
hide stories for functional testing stories
nguyenduy Jan 20, 2026
5918873
hide all functional testing stories+wip of fixing storybook errors
nguyenduy Jan 21, 2026
bf60478
remove duplicate tags option
nguyenduy Jan 21, 2026
3e25c9d
update+remove broken tests
nguyenduy Jan 21, 2026
579d768
fix test coverage script
nguyenduy Jan 21, 2026
a1f6f5a
Refactor Storybook tags for clarity and consistency across components
nguyenduy Jan 27, 2026
a351b2b
Merge remote-tracking branch 'origin/main' into 321-consolidate-dupli…
nguyenduy Jan 27, 2026
9be8574
hide functional testing stories
nguyenduy Jan 28, 2026
ac0efb9
re-organize stories
nguyenduy Jan 28, 2026
d4d0fe7
fix mock data
nguyenduy Jan 28, 2026
98c14a8
fix mock value for userType
nguyenduy Jan 28, 2026
35964bb
fix: replace deprecated bodyStyle by styles for padding in ListingBan…
nguyenduy Jan 28, 2026
fbd5aca
refactor: remove unused mockEnvironment export from storybook-decorators
nguyenduy Jan 28, 2026
3b45672
reuse shared mock for userIsAdmin query
nguyenduy Jan 28, 2026
3d9f4d4
fix compatibility of antd 5 and react 19 for storybook
nguyenduy Jan 28, 2026
74f191e
Merge branch 'main' into 321-consolidate-duplicated-generatemocktoken…
nguyenduy Jan 29, 2026
ae426ab
add test coverage for storybook-decorators component
nguyenduy Jan 30, 2026
cc3c9c1
add tests for login-selection to increase coverage
nguyenduy Jan 30, 2026
70c7cbb
only exclude coverage for stories files in test-utils
nguyenduy Jan 30, 2026
2833943
add more tests to increase test coverage
nguyenduy Jan 30, 2026
8ecea4d
add more tests to increase coverage
nguyenduy Jan 30, 2026
8a984c6
hide functional testing stories+update story names for consistency
nguyenduy Feb 4, 2026
b6d9c44
Merge remote-tracking branch 'origin/main' into 321-consolidate-dupli…
nguyenduy Feb 4, 2026
8fd6cd8
update @apollo/server to fix vulnerability
nguyenduy Feb 5, 2026
cbec70a
consolidate duplicated user admin mock into shared utility for improv…
nguyenduy Feb 5, 2026
8cf7693
add tests for withMockRouter and withMockUserId decorators to enhance…
nguyenduy Feb 5, 2026
a2c5fc2
refactor: consolidate and clean up login selection stories, removing …
nguyenduy Feb 5, 2026
56e4050
refactor: remove redundant validation tests for email and password in…
nguyenduy Feb 5, 2026
308a0d3
refactor: remove SubmitWithEnterKey story to streamline login selecti…
nguyenduy Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
12 changes: 0 additions & 12 deletions apps/ui-sharethrift/.storybook/preview.js

This file was deleted.

29 changes: 29 additions & 0 deletions apps/ui-sharethrift/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { Preview } from '@storybook/react-vite';
import "@sthrift/ui-components/src/styles/theme.css";
import '../src/index.css';
import '../src/App.css'
import '@ant-design/v5-patch-for-react-19';

const preview: Preview = {
parameters: {
Expand All @@ -11,7 +15,32 @@ const preview: Preview = {
a11y: {
test: 'todo',
},
options: {
storySort: {
order: [
'Pages',
['Home - Unauthenticated',
'Login',
'Signup', ['Select Account Type', 'Account Setup', 'Profile Setup', 'Terms', 'Payment'],
'Home - Authenticated',
'My Listings',
'My Reservations',
'Messages',
'Account', ['Profile', 'Settings']],
'Components',
'Containers'
],
},
},
},
};

// Remove Storybook's default 1rem padding from .sb-show-main.sb-main-padded
const style = document.createElement("style");
style.innerHTML = `
.sb-show-main.sb-main-padded {
padding: 0 !important;
}
`;
document.head.appendChild(style);
export default preview;
203 changes: 175 additions & 28 deletions apps/ui-sharethrift/src/App.container.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,77 @@ import { AppContainer } from './App.container.tsx';
import {
withMockApolloClient,
withMockRouter,
MockUnauthWrapper,
} from './test-utils/storybook-decorators.tsx';
import { AppContainerCurrentUserDocument } from './generated.tsx';
import {
AppContainerCurrentUserDocument,
ListingsPageContainerGetListingsDocument,
SelectAccountTypeContainerAccountPlansDocument,
SelectAccountTypeCurrentPersonalUserAndCreateIfNotExistsDocument,
} from './generated.tsx';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { MockUnauthWrapper } from './test-utils/storybook-mock-auth-wrappers.tsx';
import { userIsAdminMockRequest } from './test-utils/storybook-helpers.ts';

const mockListings = [
{
__typename: 'ItemListing',
id: '1',
title: 'Projector',
description: 'High-quality projector for home and office use',
category: 'Tools & Equipment',
location: 'Toronto, ON',
state: 'Active',
images: ['/assets/item-images/projector.png'],
sharingPeriodStart: '2025-01-01',
sharingPeriodEnd: '2025-12-31',
createdAt: '2025-01-01T00:00:00Z',
updatedAt: '2025-01-01T00:00:00Z',
schemaVersion: '1.0',
version: '1.0',
reports: 0,
sharingHistory: [],
},
{
__typename: 'ItemListing',
id: '2',
title: 'Umbrella',
description: 'Umbrella in excellent condition',
category: 'Accessories',
location: 'Vancouver, BC',
state: 'Active',
images: ['/assets/item-images/umbrella.png'],
sharingPeriodStart: '2025-02-01',
sharingPeriodEnd: '2025-06-30',
createdAt: '2025-01-15T00:00:00Z',
updatedAt: '2025-01-15T00:00:00Z',
schemaVersion: '1.0',
version: '1.0',
reports: 0,
sharingHistory: [],
},
];

const buildListingsMock = (listings = mockListings) => ({
request: { query: ListingsPageContainerGetListingsDocument },
result: { data: { itemListings: listings } },
});

const meta: Meta<typeof AppContainer> = {
title: 'App/AppContainer',
component: AppContainer,
parameters: {
layout: 'fullscreen',
},
tags: ['!dev'], // functional testing story, not rendered in sidebar - https://storybook.js.org/docs/writing-stories/tags
};

export default meta;
type Story = StoryObj<typeof meta>;

// Mock for authenticated user who has completed onboarding
const mockAuthenticatedCompletedOnboarding = {
request: {
query: AppContainerCurrentUserDocument,
variables: {},
},
result: {
data: {
currentUser: {
__typename: 'PersonalUser' as const,
id: 'user-123',
userType: 'personal-user',
hasCompletedOnboarding: true,
},
},
},
};

// Mock for authenticated user who hasn't completed onboarding
const mockAuthenticatedNotCompletedOnboarding = {
// Helper to build a current-user mock
const buildCurrentUserMock = (
opts: { id?: string; hasCompletedOnboarding?: boolean } = {},
) => ({
request: {
query: AppContainerCurrentUserDocument,
variables: {},
Expand All @@ -47,19 +82,33 @@ const mockAuthenticatedNotCompletedOnboarding = {
data: {
currentUserAndCreateIfNotExists: {
__typename: 'PersonalUser' as const,
id: 'user-456',
id: opts.id ?? 'user-123',
userType: 'personal-user',
hasCompletedOnboarding: false,
hasCompletedOnboarding: opts.hasCompletedOnboarding ?? true,
},
},
},
};
});

// Reusable canned responses
const mockAuthenticatedCompletedOnboarding = buildCurrentUserMock({
id: 'user-123',
hasCompletedOnboarding: true,
});
const mockAuthenticatedNotCompletedOnboarding = buildCurrentUserMock({
id: 'user-456',
hasCompletedOnboarding: false,
});

export const AuthenticatedCompletedOnboarding: Story = {
decorators: [withMockApolloClient, withMockRouter('/')],
parameters: {
apolloClient: {
mocks: [mockAuthenticatedCompletedOnboarding],
mocks: [
mockAuthenticatedCompletedOnboarding,
buildListingsMock(),
userIsAdminMockRequest('user-123', false),
],
},
},
};
Expand All @@ -68,7 +117,105 @@ export const AuthenticatedNotCompletedOnboarding: Story = {
decorators: [withMockApolloClient, withMockRouter('/')],
parameters: {
apolloClient: {
mocks: [mockAuthenticatedNotCompletedOnboarding],
mocks: [
mockAuthenticatedNotCompletedOnboarding,
{
request: {
query:
SelectAccountTypeCurrentPersonalUserAndCreateIfNotExistsDocument,
},
result: {
data: {
currentPersonalUserAndCreateIfNotExists: {
id: 'user-456',
account: {
accountType: 'personal-user',
},
},
},
},
},
buildListingsMock(),
userIsAdminMockRequest('user-456', false),
{
request: { query: SelectAccountTypeContainerAccountPlansDocument },
result: {
data: {
accountPlans: [
{
name: 'non-verified-personal',
description: 'Non-Verified Personal',
billingPeriodLength: 0,
billingPeriodUnit: 'month',
billingAmount: 0,
currency: 'USD',
setupFee: 0,
feature: {
activeReservations: 0,
bookmarks: 3,
itemsToShare: 15,
friends: 5,
__typename: 'AccountPlanFeature',
},
status: null,
cybersourcePlanId: null,
id: '607f1f77bcf86cd799439001',
schemaVersion: '1.0.0',
createdAt: '2023-05-02T10:00:00.000Z',
updatedAt: '2023-05-02T10:00:00.000Z',
__typename: 'AccountPlan',
},
{
name: 'verified-personal',
description: 'Verified Personal',
billingPeriodLength: 0,
billingPeriodUnit: 'month',
billingAmount: 0,
currency: 'USD',
setupFee: 0,
feature: {
activeReservations: 10,
bookmarks: 10,
itemsToShare: 30,
friends: 10,
__typename: 'AccountPlanFeature',
},
status: null,
cybersourcePlanId: null,
id: '607f1f77bcf86cd799439002',
schemaVersion: '1.0.0',
createdAt: '2023-05-02T10:00:00.000Z',
updatedAt: '2023-05-02T10:00:00.000Z',
__typename: 'AccountPlan',
},
{
name: 'verified-personal-plus',
description: 'Verified Personal Plus',
billingPeriodLength: 12,
billingPeriodUnit: 'month',
billingAmount: 4.99,
currency: 'USD',
setupFee: 0,
feature: {
activeReservations: 30,
bookmarks: 30,
itemsToShare: 50,
friends: 30,
__typename: 'AccountPlanFeature',
},
status: 'active',
cybersourcePlanId: 'cybersource_plan_001',
id: '607f1f77bcf86cd799439000',
schemaVersion: '1.0.0',
createdAt: '2023-05-02T10:00:00.000Z',
updatedAt: '2023-05-02T10:00:00.000Z',
__typename: 'AccountPlan',
},
],
},
},
},
],
},
},
};
Expand All @@ -88,7 +235,7 @@ export const Unauthenticated: Story = {
],
parameters: {
apolloClient: {
mocks: [],
mocks: [buildListingsMock(), userIsAdminMockRequest('user-456', false)],
},
},
};
57 changes: 3 additions & 54 deletions apps/ui-sharethrift/src/App.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,8 @@
import type { Meta, StoryObj } from '@storybook/react';
import { expect } from 'storybook/test';
import { MemoryRouter } from 'react-router-dom';
import { AuthProvider } from 'react-oidc-context';
import { MockedProvider } from '@apollo/client/testing/react';
import { App } from './App.tsx';

const mockEnv = {
VITE_FUNCTION_ENDPOINT: 'https://mock-functions.example.com',
VITE_BLOB_STORAGE_CONFIG_URL: 'https://mock-storage.example.com',
VITE_B2C_AUTHORITY: 'https://mock-authority.example.com',
VITE_B2C_CLIENTID: 'mock-client-id',
NODE_ENV: 'development',
};

const mockStorage = {
getItem: (key: string) => {
if (key.includes('oidc.user')) {
return JSON.stringify({
access_token: '',
profile: { sub: 'test-user' },
});
}
return null;
},
setItem: (_key: string, _value: string) => Promise.resolve(),
removeItem: (_key: string) => Promise.resolve(),
clear: () => Promise.resolve(),
key: () => null,
length: 0,
set: (_key: string, _value: unknown) => Promise.resolve(),
get: (_key: string) => Promise.resolve(null),
remove: (_key: string) => Promise.resolve(null),
getAllKeys: () => Promise.resolve([]),
};

Object.defineProperty(globalThis, 'sessionStorage', { value: mockStorage, writable: true });
Object.defineProperty(globalThis, 'localStorage', { value: mockStorage, writable: true });

Object.defineProperty(import.meta, 'env', {
value: mockEnv,
writable: true,
});
import { withAuthDecorator } from './test-utils/storybook-decorators.tsx';

const meta: Meta<typeof App> = {
title: 'App/Main Application',
Expand All @@ -49,6 +11,7 @@ const meta: Meta<typeof App> = {
hasCompletedOnboarding: false,
isAuthenticated: false,
},
tags: ['!dev'], // functional testing story, not rendered in sidebar - https://storybook.js.org/docs/writing-stories/tags
parameters: {
layout: 'fullscreen',
docs: {
Expand All @@ -58,21 +21,7 @@ const meta: Meta<typeof App> = {
},
},
},
decorators: [
(Story) => (
<MockedProvider mocks={[]}>
<AuthProvider
authority={mockEnv.VITE_B2C_AUTHORITY}
client_id={mockEnv.VITE_B2C_CLIENTID}
redirect_uri={globalThis.location.origin}
post_logout_redirect_uri={globalThis.location.origin}
userStore={mockStorage}
>
<Story />
</AuthProvider>
</MockedProvider>
),
],
decorators: [withAuthDecorator],
} satisfies Meta<typeof App>;

export default meta;
Expand Down
Loading
Loading