Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
a4bf806
migrate vitest to v4
nguyenduy Dec 9, 2025
276916f
Merge branch 'main' into 245-upgrade-vitest-to-4x-and-fix-all-related…
nguyenduy Dec 10, 2025
dabe9ef
fix mock types
nguyenduy Dec 10, 2025
fd63a69
refactor(tests): restructure mocks and improve clarity in otel-builde…
nguyenduy Dec 10, 2025
7e0a5bd
attempt to fix error on pipeline
nguyenduy Dec 10, 2025
92e796b
fix mocks for stories
nguyenduy Dec 10, 2025
3f51579
attempt to fix "EMFILE: too many open files on pipeline"
nguyenduy Dec 11, 2025
6630071
remove unnecessary configs
nguyenduy Dec 11, 2025
65c0cd3
attempt to fix "EMFILE: too many open files on pipeline"
nguyenduy Dec 11, 2025
0c3af3b
fix exports to see if it resolve pipeline error EMFILE: too many open…
nguyenduy Dec 11, 2025
d2566ec
Merge remote-tracking branch 'origin/main' into 245-upgrade-vitest-to…
nguyenduy Dec 11, 2025
95c575a
attempt to fix error EMFILE: too many open files: increase the open f…
nguyenduy Dec 11, 2025
4f2dae9
increase to 10000 to see if it fixes the error
nguyenduy Dec 11, 2025
18d25ef
increase ulimit to 100000
nguyenduy Dec 11, 2025
24aa5cf
reduce open file limit from 100000 to 20000 in build pipeline
nguyenduy Dec 11, 2025
dbf8e6f
add comment to explain new configs after vitest 4 upgrade
nguyenduy Dec 11, 2025
c02e0ba
Merge remote-tracking branch 'origin/main' into 245-upgrade-vitest-to…
nguyenduy Dec 11, 2025
41858e7
fix: update import paths from .js to .tsx for UI components
nguyenduy Dec 12, 2025
8e9442f
fix: increase open file limit from 20000 to 25000 in build pipeline
nguyenduy Dec 12, 2025
cd4060b
fix: increase open file limit from 25000 to 30000 in build pipeline
nguyenduy Dec 12, 2025
8bb22e8
remove CI flag to see if it fixes pipeline error
nguyenduy Dec 12, 2025
342c5f0
fix: increase open file limit to 40000 and enable thread pooling in S…
nguyenduy Dec 12, 2025
06d1426
attempt to fix EMFILE error: increase open file limit from 40000 to …
nguyenduy Dec 13, 2025
f56096f
fix EMFILE: remove thread pooling option from Storybook test configur…
nguyenduy Dec 13, 2025
014b940
adjust testing configurations to improve stability and performance
nguyenduy Dec 13, 2025
207cd1e
increase concurrency for affected package coverage tests to reduce fi…
nguyenduy Dec 13, 2025
702505f
fix: adjust test coverage command and exclude build artifacts to redu…
nguyenduy Dec 15, 2025
119c019
remove unrelated comment+optimize test configuration to reduce EMFILE…
nguyenduy Dec 15, 2025
772c5d4
feat: enhance Storybook Vitest configuration with dynamic alias resol…
nguyenduy Dec 15, 2025
58c6546
fix: update Storybook Vitest config to dynamically resolve workspace …
nguyenduy Dec 15, 2025
56be73c
fix: increase file descriptor limit and update Storybook Vitest confi…
nguyenduy Dec 15, 2025
fe4cb83
fix: upgrade Vitest configuration to use UserConfig type and enhance …
nguyenduy Dec 15, 2025
f81f27f
fix EMFILE error: update Storybook Vitest configuration to use a cust…
nguyenduy Dec 15, 2025
3042bb6
refactor: remove unused workspace package aliasing logic from Storybo…
nguyenduy Dec 15, 2025
774f3f8
fix EMFILE error: increase soft limit for open file descriptors in bu…
nguyenduy Dec 15, 2025
42b5874
fix: update open file limit setting
nguyenduy Dec 15, 2025
21f5dcd
fix: lower open file limit to 70000 in build pipeline script
nguyenduy Dec 15, 2025
2ec41b5
fix: lower open file limit from 70000 to 65000 in build pipeline script
nguyenduy Dec 15, 2025
fc0b3a3
fix: update Storybook Vitest config to resolve workspace packages dur…
nguyenduy Dec 15, 2025
20b6b22
fix: ensure workspace packages do not override a single shared Vitest…
nguyenduy Dec 16, 2025
e06ccd2
fix: remove '@vitest/ui' from catalog to streamline Vitest dependencies
nguyenduy Dec 16, 2025
438ef58
remove ulimit setting for open file limit in build pipeline script
nguyenduy Dec 16, 2025
50dbea8
fix: streamline mock implementations in tests for better clarity and …
nguyenduy Dec 16, 2025
0bdf156
fix: update test exclusion patterns for improved file handling during…
nguyenduy Dec 16, 2025
a542669
fix: update handler type definitions in event bus tests for improved …
nguyenduy Dec 16, 2025
f6dfe6b
fix: update mock data structure for 'myListingsAll' in ProfilePage st…
nguyenduy Dec 16, 2025
8a87f48
fix: update event handler implementations to ensure proper promise re…
nguyenduy Dec 16, 2025
6577afd
revert the version for typescript in ui-core to have it consistent
nguyenduy Dec 16, 2025
92a9db2
fix: simplify handler registration in InProcEventBus tests
nguyenduy Dec 16, 2025
2079498
fix: improve type definition for handler function in event tests
nguyenduy Dec 16, 2025
7835b1d
fix: remove deprecated '@vitest/browser' dependency from package.json…
nguyenduy Dec 16, 2025
fda7ee7
format file
nguyenduy Dec 16, 2025
a825b60
remove unused "this"
nguyenduy Dec 16, 2025
2c4bdea
remove extra spaces
nguyenduy Dec 16, 2025
35b21ef
split test coverage for node and storybook
nguyenduy Dec 17, 2025
ed96651
fix splitting node and ui tests
nguyenduy Dec 17, 2025
f95f728
refactor: simplify mock exporter classes and improve type definitions…
nguyenduy Dec 18, 2025
a03278c
fix: refine CI detection and adjust watch mode behavior for improved …
nguyenduy Dec 18, 2025
cf36d97
fix: update test exclusion patterns to include default config exclusions
nguyenduy Dec 18, 2025
eec121b
Merge branch 'main' into 245-upgrade-vitest-to-4x-and-fix-all-related…
nguyenduy Dec 18, 2025
47bb72c
fix storybook vulnerability
nguyenduy Dec 18, 2025
c906f9d
fix: add CI variable documentation in storybook configuration
nguyenduy Dec 18, 2025
8f4f5c6
Merge remote-tracking branch 'origin/main' into 245-upgrade-vitest-to…
nguyenduy Jan 6, 2026
a5935b6
refactor mock creation function to reduce biome-ignore comments
nguyenduy Jan 6, 2026
aa537a4
refactor makeNewableMock into a package to reduce duplication
nguyenduy Jan 6, 2026
79b56e4
remove unused dependencies
nguyenduy Jan 6, 2026
cfe5b6c
remove unused devDeps
nguyenduy Jan 6, 2026
498945a
update lock file after removing unused devDeps
nguyenduy Jan 6, 2026
ae5bb18
add test coverage for test-utils package
nguyenduy Jan 6, 2026
36fa368
update to include test coverage for index file
nguyenduy Jan 6, 2026
286e378
Merge remote-tracking branch 'origin/main' into 245-upgrade-vitest-to…
nguyenduy Jan 6, 2026
93b0a06
unify vite version across packages
nguyenduy Jan 6, 2026
9211bc7
unify @types/node version
nguyenduy Jan 6, 2026
4cf0f3d
feat(tests): add coverage script to test-utils package
nguyenduy Jan 6, 2026
80d2aa8
refactor(tests): update mongo-unit-of-work tests to use mocks and sim…
nguyenduy Jan 7, 2026
a50b4ea
refactor(tests): enhance mongo-unit-of-work tests by simplifying doma…
nguyenduy Jan 7, 2026
53f3161
clean up
nguyenduy Jan 7, 2026
0a310f1
update implementation for test coverage of ui and node packages
nguyenduy Jan 7, 2026
992e1bb
remove affected flag to check if tests run successfully
nguyenduy Jan 7, 2026
3c43ca8
revert affected flag to original after checking tests are running fine
nguyenduy Jan 7, 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
6 changes: 3 additions & 3 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"@testing-library/react": "^16.1.0",
"@types/react": "^19.1.11",
"@types/react-dom": "^19.1.6",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/coverage-v8": "catalog:",
"jsdom": "^26.1.0",
"typescript": "~5.6.2",
"vitest": "^3.2.4"
"typescript": "^5.8.3",
"vitest": "catalog:"
},
"browserslist": {
"production": [
Expand Down
9 changes: 4 additions & 5 deletions apps/ui-sharethrift/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:coverage:ui": "vitest run --coverage",
"test:watch": "vitest"
},
"dependencies": {
Expand Down Expand Up @@ -47,17 +47,16 @@
"@types/react": "^19.1.9",
"@types/react-dom": "^19.1.7",
"@vitejs/plugin-react": "^4.7.0",
"@vitest/browser": "3.2.4",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/coverage-v8": "catalog:",
"eslint": "^9.30.1",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.3.0",
"storybook": "catalog:",
"typescript": "~5.8.3",
"typescript-eslint": "^8.35.1",
"vite": "^7.1.2",
"vitest": "^3.2.4"
"vite": "catalog:",
"vitest": "catalog:"
},
"license": "MIT"
}
2 changes: 1 addition & 1 deletion apps/ui-sharethrift/src/App.container.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const mockAuthenticatedNotCompletedOnboarding = {
},
result: {
data: {
currentUser: {
currentUserAndCreateIfNotExists: {
__typename: 'PersonalUser' as const,
id: 'user-456',
userType: 'personal-user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {
HomeAccountProfileViewContainerCurrentUserDocument,
HomeAccountProfileViewContainerUserListingsDocument,
UseUserIsAdminDocument,
type ItemListing,
type PersonalUser,
} from '../../../../../../generated.tsx';
Expand Down Expand Up @@ -86,6 +87,19 @@ const mockTwoListings: ItemListing[] = [
},
];

const userIsAdminMockRequest = (userId: string) => {
return {
request: {
query: UseUserIsAdminDocument,
},
result: {
data: {
currentUser: {id: userId, userIsAdmin: false },
},
},
};
};

const meta: Meta<typeof HomeRoutes> = {
title: 'Pages/Account/Profile',
component: HomeRoutes,
Expand Down Expand Up @@ -113,21 +127,28 @@ export const DefaultView: Story = {
},
result: {
data: {
currentPersonalUserAndCreateIfNotExists: mockUserSarah,
currentUser: mockUserSarah,
},
},
},

{
request: {
query: HomeAccountProfileViewContainerUserListingsDocument,
variables: { page: 1, pageSize: 100 },
},
result: {
data: {
itemListings: mockTwoListings,
myListingsAll: {
items: mockTwoListings,
total: 2,
page: 1,
pageSize: 100,
},
},
},
},
userIsAdminMockRequest(mockUserSarah.id),
],
},
},
Expand All @@ -143,20 +164,22 @@ export const NoListings: Story = {
},
result: {
data: {
currentPersonalUserAndCreateIfNotExists: mockUserAlex,
currentUser: mockUserAlex,
},
},
},
{
request: {
query: HomeAccountProfileViewContainerUserListingsDocument,
variables: { page: 1, pageSize: 100 },
},
result: {
data: {
itemListings: [],
myListingsAll: { items: [], total: 0, page: 1, pageSize: 100 },
},
},
},
userIsAdminMockRequest(mockUserAlex.id),
],
},
},
Expand Down
8 changes: 7 additions & 1 deletion build-pipeline/core/monorepo-build-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ stages:
targetType: 'inline'
script: |
set -euo pipefail
echo "Open file limit (ulimit -n): $(ulimit -n)"
export NODE_OPTIONS=--max_old_space_size=16384
export PLAYWRIGHT_BROWSERS_PATH="$(PLAYWRIGHT_BROWSERS_PATH)"

Expand All @@ -238,10 +239,15 @@ stages:
pnpm audit --audit-level=high --prod

# Use Turbo's built-in --affected flag for accurate change detection
# Split coverage collection: Node tests first, then Storybook tests separately
# to reduce race conditions and memory pressure in CI
if [ "$(Build.Reason)" = "PullRequest" ] || [ "$(Build.SourceBranch)" != "refs/heads/main" ]; then
echo "Testing affected packages only (PR/branch build)..."
export TURBO_SCM_BASE="origin/$(System.PullRequest.TargetBranch)"
pnpm run test:coverage --affected
echo "Running Node unit tests with coverage..."
pnpm run test:coverage:node --affected
echo "Running Storybook/Playwright tests with coverage..."
pnpm run test:coverage:ui --affected
pnpm run merge-lcov-reports
else
echo "Testing all packages (main branch build)..."
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"start-emulator:payment-server": "pnpm run start --workspace=@cellix/mock-payment-server",
"start-emulator:messaging-server": "pnpm run start --workspace=@sthrift/mock-messaging-server",
"test:all": "turbo run test:all",
"test:coverage": "turbo run test:coverage",
"test:coverage": "turbo run test:coverage:ui && turbo run test:coverage:node",
"test:coverage:node": "turbo run test:coverage:node",
"test:coverage:ui": "turbo run test:coverage:ui",
"test:coverage:merge": "pnpm run test:coverage && pnpm run merge-lcov-reports",
"merge-lcov-reports": "node build-pipeline/scripts/merge-coverage.js",
"test:integration": "turbo run test:integration",
Expand Down Expand Up @@ -56,7 +58,7 @@
}
},
"devDependencies": {
"@amiceli/vitest-cucumber": "^5.1.2",
"@amiceli/vitest-cucumber": "^6.1.0",
"@biomejs/biome": "2.0.0",
"@graphql-codegen/cli": "^5.0.7",
"@graphql-codegen/introspection": "^4.0.3",
Expand All @@ -68,7 +70,8 @@
"@playwright/test": "^1.55.1",
"@sonar/scan": "^4.3.0",
"@types/node": "^24.7.2",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/browser-playwright": "catalog:",
"@vitest/coverage-v8": "catalog:",
"azurite": "^3.35.0",
"concurrently": "^9.1.2",
"cpx2": "^3.0.2",
Expand All @@ -79,7 +82,7 @@
"tsx": "^4.20.3",
"turbo": "^2.5.8",
"typescript": "^5.8.3",
"vite": "^7.0.4",
"vitest": "^3.2.4"
"vite": "catalog:",
"vitest": "catalog:"
}
}
2 changes: 1 addition & 1 deletion packages/cellix/domain-seedwork/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "tsc --build",
"watch": "tsc --watch",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:coverage:node": "vitest run --coverage",
"test:watch": "vitest",
"lint": "biome lint",
"clean": "rimraf dist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const feature = await loadFeature(
class TestEvent extends DomainEventBase {}

test.for(feature, ({ Scenario }) => {
let handlerFn: ReturnType<typeof vi.fn>;
let handlerFn: (event: TestEvent) => void;
let handler: HandleEventImpl<TestEvent>;
let event: TestEvent;

Expand All @@ -40,7 +40,7 @@ test.for(feature, ({ Scenario }) => {
event = new TestEvent('agg-2');
});
When('I register the function using the static register method', () => {
handler = HandleEventImpl.register<TestEvent>(handlerFn) as HandleEventImpl<TestEvent>;
handler = HandleEventImpl.register<TestEvent>(handlerFn as (event: TestEvent) => void) as HandleEventImpl<TestEvent>;
});
Then('I should get a handler that calls the function when handling an event', () => {
handler.handle(event);
Expand All @@ -59,8 +59,8 @@ test.for(feature, ({ Scenario }) => {
Given('multiple handlers for a domain event', () => {
handlerFn1 = vi.fn();
handlerFn2 = vi.fn();
handler1 = new HandleEventImpl<TestEvent>(handlerFn1);
handler2 = new HandleEventImpl<TestEvent>(handlerFn2);
handler1 = new HandleEventImpl<TestEvent>(handlerFn1 as (event: TestEvent) => void);
handler2 = new HandleEventImpl<TestEvent>(handlerFn2 as (event: TestEvent) => void);
event = new TestEvent('agg-3');
});
When('I register them all using registerAll', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cellix/event-bus-seedwork-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "tsc --build",
"watch": "tsc --watch",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:coverage:node": "vitest run --coverage",
"test:watch": "vitest",
"lint": "biome lint",
"clean": "rimraf dist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class TestEventA extends DomainSeedwork.CustomDomainEventImpl<{ testA: string }>
class TestEventB extends DomainSeedwork.CustomDomainEventImpl<{ testB: string }> {}

test.for(feature, ({ Scenario, BeforeEachScenario }) => {
let handler: ReturnType<typeof vi.fn>;
let handler1: ReturnType<typeof vi.fn>;
let handler2: ReturnType<typeof vi.fn>;
let handlerA: ReturnType<typeof vi.fn>;
let handlerB: ReturnType<typeof vi.fn>;
let handler: (payload: { test: string }) => Promise<void>;
let handler1: (payload: { test: string }) => Promise<void>;
let handler2: (payload: { test: string }) => Promise<void>;
let handlerA: (payload: { testA: string }) => Promise<void>;
let handlerB: (payload: { testB: string }) => Promise<void>;
let error: unknown;

// Reset the singleton's subscribers for isolation before each scenario
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class EventA extends DomainSeedwork.CustomDomainEventImpl<{ a: string }> {}
class EventB extends DomainSeedwork.CustomDomainEventImpl<{ b: string }> {}

test.for(feature, ({ Scenario, Background, BeforeEachScenario }) => {
let handler: ReturnType<typeof vi.fn>;
let handler1: ReturnType<typeof vi.fn>;
let handler2: ReturnType<typeof vi.fn>;
let handlerA: ReturnType<typeof vi.fn>;
let handlerB: ReturnType<typeof vi.fn>;
let handler: (payload: { test: string }) => Promise<void>;
let handler1: (payload: { test: string }) => Promise<void>;
let handler2: (payload: { test: string }) => Promise<void>;
let handlerA: (payload: { a: string }) => Promise<void>;
let handlerB: (payload: { b: string }) => Promise<void>;

BeforeEachScenario(() => {
handler = vi.fn().mockResolvedValue(undefined);
Expand Down Expand Up @@ -135,8 +135,8 @@ test.for(feature, ({ Scenario, Background, BeforeEachScenario }) => {
// handlerA, handlerB, EventA, EventB are already defined
});
When('each handler is registered for a different event', () => {
NodeEventBusInstance.register(EventA, handlerA);
NodeEventBusInstance.register(EventB, handlerB);
NodeEventBusInstance.register(EventA, handlerA as (payload: { a: string }) => Promise<void>);
NodeEventBusInstance.register(EventB, handlerB as (payload: { b: string }) => Promise<void>);
});
And('each event is dispatched', async () => {
await NodeEventBusInstance.dispatch(EventA, { a: 'A' });
Expand Down Expand Up @@ -287,8 +287,14 @@ test.for(feature, ({ Scenario, Background, BeforeEachScenario }) => {
let callOrder: string[];
Given('multiple handlers for the same event class', () => {
callOrder = [];
handler1 = vi.fn(() => callOrder.push('handler1'));
handler2 = vi.fn(() => callOrder.push('handler2'));
handler1 = vi.fn(() => {
callOrder.push('handler1');
return Promise.resolve();
});
handler2 = vi.fn(() => {
callOrder.push('handler2');
return Promise.resolve();
});
});
When('all handlers are registered', () => {
NodeEventBusInstance.register(TestEvent, handler1);
Expand Down Expand Up @@ -341,7 +347,7 @@ test.for(feature, ({ Scenario, Background, BeforeEachScenario }) => {
Scenario('Dispatch does not wait for handler completion', ({ Given, When, And, Then }) => {
let handlerStarted = false;
let handlerCompleted = false;
let asyncHandler: ReturnType<typeof vi.fn>;
let asyncHandler: (payload: { test: string }) => Promise<void>;
Given('a handler for an event that is asynchronous', () => {
asyncHandler = vi.fn(async () => {
handlerStarted = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/cellix/mongoose-seedwork/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "tsc --build",
"watch": "tsc --watch",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:coverage:node": "vitest run --coverage",
"test:integration": "vitest run integration.test.ts",
"test:unit": "vitest run --exclude tests/integration/**/*.test.ts",
"test:watch": "vitest",
Expand Down
Loading