diff --git a/src/pages/__tests__/LandingPage.holdingsTradeSequence.integration.test.tsx b/src/pages/__tests__/LandingPage.holdingsTradeSequence.integration.test.tsx
index 58e42c9..7706be4 100644
--- a/src/pages/__tests__/LandingPage.holdingsTradeSequence.integration.test.tsx
+++ b/src/pages/__tests__/LandingPage.holdingsTradeSequence.integration.test.tsx
@@ -25,6 +25,7 @@
import type { ComponentProps, ReactNode } from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import LandingPage from '@/pages/LandingPage';
import { courseService, type Course } from '@/services/course.service';
@@ -212,9 +213,11 @@ describe('LandingPage holdings entry count after buy/sell sequence', () => {
mockGetCourses.mockResolvedValue(twoCreators);
render(
-
-
-
+
+
+
+
+
);
await waitFor(() => expect(mockGetCourses).toHaveBeenCalledTimes(1));
diff --git a/src/pages/__tests__/LandingPage.searchAndSort.integration.test.tsx b/src/pages/__tests__/LandingPage.searchAndSort.integration.test.tsx
index 01ffcf3..c4786af 100644
--- a/src/pages/__tests__/LandingPage.searchAndSort.integration.test.tsx
+++ b/src/pages/__tests__/LandingPage.searchAndSort.integration.test.tsx
@@ -10,6 +10,7 @@
import type { ComponentProps, ReactNode } from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter, useLocation } from 'react-router';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import LandingPage from '@/pages/LandingPage';
import {
@@ -159,12 +160,18 @@ describe('LandingPage search and sort coexistence integration (#594)', () => {
});
});
+ function makeQueryClient() {
+ return new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ }
+
it('coexists search and sort params in URL and passes both in single API request', async () => {
render(
-
-
-
-
+
+
+
+
+
+
);
// Initial load fetch
diff --git a/src/pages/__tests__/holderCountCacheInvalidation.test.tsx b/src/pages/__tests__/holderCountCacheInvalidation.test.tsx
index d9ee754..0ac7782 100644
--- a/src/pages/__tests__/holderCountCacheInvalidation.test.tsx
+++ b/src/pages/__tests__/holderCountCacheInvalidation.test.tsx
@@ -77,7 +77,8 @@ describe('FeaturedCreatorAudienceChip — holder count cache invalidation', () =
beforeEach(() => {
queryClient = makeFreshQueryClient();
- mockFetchHolderCount = vi.fn<(id: string) => Promise>();
+ mockFetchHolderCount = vi.fn<(id: string) => Promise>()
+ .mockResolvedValue(null);
});
afterEach(() => {
@@ -141,11 +142,11 @@ describe('FeaturedCreatorAudienceChip — holder count cache invalidation', () =
{ wrapper: createWrapper(localClient) },
);
- // Trigger invalidation but do not await refetch resolution
- await act(async () => {
- await localClient.invalidateQueries({
- queryKey: ['creator', CREATOR_ID, 'holderCount'],
- });
+ // Trigger invalidation without awaiting — the refetch never resolves
+ // so awaiting would hang the test. We only verify the stale value
+ // stays visible while the refetch is in-flight.
+ localClient.invalidateQueries({
+ queryKey: ['creator', CREATOR_ID, 'holderCount'],
});
// Old value must still be visible (stale-while-revalidate)
@@ -179,10 +180,6 @@ describe('FeaturedCreatorAudienceChip — holder count cache invalidation', () =
localClient.setQueryData(['creator', CREATOR_ID, 'holderCount'], initialCount);
- const reloadSpy = vi
- .spyOn(window.location, 'reload')
- .mockImplementation(() => { /* noop */ });
-
const { unmount } = render(
{
};
const price = computeBondingCurvePrice(20, params);
// price = 5_000_000 * (1 + 0.005 * 20) = 5_000_000 * 1.1 = 5_500_000
- expect(price).toBe(5_500_000);
+ expect(price).toBeCloseTo(5_500_000);
});
it('throws error for negative supply', () => {
@@ -106,7 +106,8 @@ describe('bonding curve utilities', () => {
describe('computeBuyCost', () => {
it('calculates cost for single key at base price', () => {
const cost = computeBuyCost(0, 1, defaultParams);
- expect(cost).toBe(10_000_000); // Base price for first key
+ // avg price between supply 0 and 1: (10_000_000 + 10_100_000) / 2 = 10_050_000
+ expect(cost).toBeCloseTo(10_050_000);
});
it('calculates cost for multiple keys', () => {
@@ -225,16 +226,16 @@ describe('bonding curve utilities', () => {
}
// Verify specific values
- expect(prices[0]).toBe(10_000_000); // Supply 0
- expect(prices[5]).toBe(10_500_000); // Supply 50
- expect(prices[10]).toBe(11_000_000); // Supply 100
+ expect(prices[0]).toBeCloseTo(10_000_000); // Supply 0
+ expect(prices[5]).toBeCloseTo(15_000_000); // Supply 50 (10M * (1 + 0.01*50))
+ expect(prices[10]).toBeCloseTo(20_000_000); // Supply 100 (10M * (1 + 0.01*100))
});
it('handles large supply values', () => {
const largeSupply = 10000;
const price = computeBondingCurvePrice(largeSupply, defaultParams);
// price = 10_000_000 * (1 + 0.01 * 10000) = 10_000_000 * 101 = 1_010_000_000
- expect(price).toBe(1_010_000_000);
+ expect(price).toBeCloseTo(1_010_000_000);
});
});
});