Skip to content

Commit

Permalink
[skip ci] clean up and more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Oct 14, 2024
1 parent a3f9cc1 commit db115fe
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/contexts/marketplace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type TMarketplaceContext = {
setIsAutoConnectDisabled: (isAutoConnectDisabled: boolean) => void;
}

const MarketplaceContext = createContext<TMarketplaceContext>({
export const MarketplaceContext = createContext<TMarketplaceContext>({
isAutoConnectDisabled: false,
setIsAutoConnectDisabled: () => {},
});
Expand Down
4 changes: 2 additions & 2 deletions nextjs/utils/fetchProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default function fetchFactory(
httpLogger.logger.info({
message: 'API fetch via Next.js proxy',
url,
headers,
init,
// headers,
// init,
});

const body = (() => {
Expand Down
24 changes: 18 additions & 6 deletions playwright/TestApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Props as PageProps } from 'nextjs/getServerSideProps';

import config from 'configs/app';
import { AppContextProvider } from 'lib/contexts/app';
import { MarketplaceContext } from 'lib/contexts/marketplace';
import { SocketProvider } from 'lib/socket/context';
import currentChain from 'lib/web3/currentChain';
import theme from 'theme/theme';
Expand All @@ -23,6 +24,10 @@ export type Props = {
appContext?: {
pageProps: PageProps;
};
marketplaceContext?: {
isAutoConnectDisabled: boolean;
setIsAutoConnectDisabled: (isAutoConnectDisabled: boolean) => void;
};
}

const defaultAppContext = {
Expand All @@ -35,6 +40,11 @@ const defaultAppContext = {
},
};

const defaultMarketplaceContext = {
isAutoConnectDisabled: false,
setIsAutoConnectDisabled: () => {},
};

const wagmiConfig = createConfig({
chains: [ currentChain ],
connectors: [
Expand All @@ -49,7 +59,7 @@ const wagmiConfig = createConfig({
},
});

const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props) => {
const TestApp = ({ children, withSocket, appContext = defaultAppContext, marketplaceContext = defaultMarketplaceContext }: Props) => {
const [ queryClient ] = React.useState(() => new QueryClient({
defaultOptions: {
queries: {
Expand All @@ -64,11 +74,13 @@ const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props
<QueryClientProvider client={ queryClient }>
<SocketProvider url={ withSocket ? `ws://${ config.app.host }:${ socketPort }` : undefined }>
<AppContextProvider { ...appContext }>
<GrowthBookProvider>
<WagmiProvider config={ wagmiConfig }>
{ children }
</WagmiProvider>
</GrowthBookProvider>
<MarketplaceContext.Provider value={ marketplaceContext }>
<GrowthBookProvider>
<WagmiProvider config={ wagmiConfig }>
{ children }
</WagmiProvider>
</GrowthBookProvider>
</MarketplaceContext.Provider>
</AppContextProvider>
</SocketProvider>
</QueryClientProvider>
Expand Down
1 change: 0 additions & 1 deletion ui/snippets/auth/screens/AuthModalScreenOtpCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const AuthModalScreenOtpCode = ({ email, onSuccess, isAuth }: Props) => {
description: 'Code has been sent to your email',
});
} catch (error) {
// TODO @tom2drum check cool down error
const apiError = getErrorObjPayload<{ message: string }>(error);

toast({
Expand Down
4 changes: 2 additions & 2 deletions ui/snippets/user/profile/UserProfileDesktop.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const test = base.extend<{ context: BrowserContext }>({

test('without address', async({ render, page, mockApiResponse }) => {
await mockApiResponse('user_info', profileMock.base);
await render(<UserProfileDesktop/>);
await render(<UserProfileDesktop/>, undefined, { marketplaceContext: { isAutoConnectDisabled: true, setIsAutoConnectDisabled: () => {} } });
await page.getByText(/tom/i).click();

await expect(page).toHaveScreenshot({
clip: { x: 0, y: 0, width: 300, height: 600 },
clip: { x: 0, y: 0, width: 300, height: 700 },
});
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit db115fe

Please sign in to comment.