mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
Two root causes broke the vitest unit suite (6 suites failing → 29/29 green): 1. @growthbook/growthbook-react was intentionally removed from package.json in the registry-cleanup commit (888ef29) and is unused anywhere in the app, but the shared test render helpers (vitest/lib.tsx, playwright/TestApp.tsx) still wrapped children in a dead <GrowthBookProvider>. Vite failed to resolve the missing module, killing 5 suites that use the helper. Fix: remove the dead import + wrapper (the provider held no growthbook instance and no feature flags are consumed — it was a no-op). Do not re-add a deleted dependency. 2. tests/e2e/live-explorers.spec.ts is a Playwright live-infra E2E spec (imports @playwright/test, hits live explorer URLs). It matched the vitest include glob **/*.spec.ts and crashed the run. Fix: exclude **/tests/e2e/** from vitest — those run under the Playwright runner (pnpm test:pw*), not the unit suite. Also normalized pre-existing over-indentation in TestApp.tsx return block. Before: 6 failed / 24 passed suites. After: 29/29 suites, 267/267 tests green. Co-authored-by: Hanzo Dev <[email protected]>
93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import React from 'react';
|
|
import { http } from 'viem';
|
|
import { WagmiProvider, createConfig } from 'wagmi';
|
|
import { mainnet } from 'wagmi/chains';
|
|
import { mock } from 'wagmi/connectors';
|
|
|
|
import type { Props as PageProps } from 'nextjs/getServerSideProps/handlers';
|
|
|
|
import config from 'configs/app';
|
|
import { AppContextProvider } from 'lib/contexts/app';
|
|
import { MarketplaceContext } from 'lib/contexts/marketplace';
|
|
import { RewardsContextProvider } from 'lib/contexts/rewards';
|
|
import { SettingsContextProvider } from 'lib/contexts/settings';
|
|
import { SocketProvider } from 'lib/socket/context';
|
|
import { currentChain } from 'lib/web3/chains';
|
|
|
|
import { port as socketPort } from './utils/socket';
|
|
|
|
export type Props = {
|
|
children: React.ReactNode;
|
|
withSocket?: boolean;
|
|
withWalletClient?: boolean;
|
|
appContext?: {
|
|
pageProps: PageProps;
|
|
};
|
|
marketplaceContext?: {
|
|
isAutoConnectDisabled: boolean;
|
|
setIsAutoConnectDisabled: (isAutoConnectDisabled: boolean) => void;
|
|
};
|
|
};
|
|
|
|
const defaultAppContext = {
|
|
pageProps: {
|
|
cookies: '',
|
|
referrer: '',
|
|
query: {},
|
|
adBannerProvider: 'slise' as const,
|
|
apiData: null,
|
|
uuid: '123',
|
|
},
|
|
};
|
|
|
|
const defaultMarketplaceContext = {
|
|
isAutoConnectDisabled: false,
|
|
setIsAutoConnectDisabled: () => {},
|
|
};
|
|
|
|
const wagmiConfig = createConfig({
|
|
chains: [ currentChain ?? mainnet ],
|
|
connectors: [
|
|
mock({
|
|
accounts: [
|
|
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
],
|
|
}),
|
|
],
|
|
transports: {
|
|
[currentChain?.id ?? mainnet.id]: http(),
|
|
},
|
|
});
|
|
|
|
const TestApp = ({ children, withSocket, appContext = defaultAppContext, marketplaceContext = defaultMarketplaceContext }: Props) => {
|
|
const [ queryClient ] = React.useState(() => new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
refetchOnWindowFocus: false,
|
|
retry: 0,
|
|
},
|
|
},
|
|
}));
|
|
|
|
return (
|
|
<QueryClientProvider client={ queryClient }>
|
|
<SocketProvider url={ withSocket ? `ws://${ config.app.host }:${ socketPort }` : undefined }>
|
|
<AppContextProvider { ...appContext }>
|
|
<MarketplaceContext.Provider value={ marketplaceContext }>
|
|
<SettingsContextProvider>
|
|
<WagmiProvider config={ wagmiConfig! }>
|
|
<RewardsContextProvider>
|
|
{ children }
|
|
</RewardsContextProvider>
|
|
</WagmiProvider>
|
|
</SettingsContextProvider>
|
|
</MarketplaceContext.Provider>
|
|
</AppContextProvider>
|
|
</SocketProvider>
|
|
</QueryClientProvider>
|
|
);
|
|
};
|
|
|
|
export default TestApp;
|