Commit 10a208e2 authored by tom's avatar tom

enable Web3 only for certain tests

parent 3b51fe06
...@@ -36,6 +36,7 @@ const wagmiClient = createClient({ ...@@ -36,6 +36,7 @@ const wagmiClient = createClient({
type Props = { type Props = {
children: React.ReactNode; children: React.ReactNode;
withSocket?: boolean; withSocket?: boolean;
withWeb3?: boolean;
appContext?: { appContext?: {
pageProps: PageProps; pageProps: PageProps;
}; };
...@@ -48,7 +49,7 @@ const defaultAppContext = { ...@@ -48,7 +49,7 @@ const defaultAppContext = {
}, },
}; };
const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props) => { const TestApp = ({ children, withSocket, withWeb3, appContext = defaultAppContext }: Props) => {
const [ queryClient ] = React.useState(() => new QueryClient({ const [ queryClient ] = React.useState(() => new QueryClient({
defaultOptions: { defaultOptions: {
queries: { queries: {
...@@ -58,14 +59,18 @@ const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props ...@@ -58,14 +59,18 @@ const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props
}, },
})); }));
const content = withWeb3 ? (
<WagmiConfig client={ wagmiClient }>
{ children }
</WagmiConfig>
) : children;
return ( return (
<ChakraProvider theme={ theme }> <ChakraProvider theme={ theme }>
<QueryClientProvider client={ queryClient }> <QueryClientProvider client={ queryClient }>
<SocketProvider url={ withSocket ? `ws://localhost:${ PORT }` : undefined }> <SocketProvider url={ withSocket ? `ws://localhost:${ PORT }` : undefined }>
<AppContextProvider { ...appContext }> <AppContextProvider { ...appContext }>
<WagmiConfig client={ wagmiClient }> { content }
{ children }
</WagmiConfig>
</AppContextProvider> </AppContextProvider>
</SocketProvider> </SocketProvider>
</QueryClientProvider> </QueryClientProvider>
......
...@@ -16,7 +16,7 @@ const hooksConfig = { ...@@ -16,7 +16,7 @@ const hooksConfig = {
}, },
}; };
test.skip('base view +@mobile +@dark-mode', async({ mount, page }) => { test('base view +@mobile +@dark-mode', async({ mount, page }) => {
await page.route(CONTRACT_READ_METHODS_API_URL, (route) => route.fulfill({ await page.route(CONTRACT_READ_METHODS_API_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify(contractMethodsMock.read), body: JSON.stringify(contractMethodsMock.read),
...@@ -27,7 +27,7 @@ test.skip('base view +@mobile +@dark-mode', async({ mount, page }) => { ...@@ -27,7 +27,7 @@ test.skip('base view +@mobile +@dark-mode', async({ mount, page }) => {
})); }));
const component = await mount( const component = await mount(
<TestApp> <TestApp withWeb3>
<ContractRead/> <ContractRead/>
</TestApp>, </TestApp>,
{ hooksConfig }, { hooksConfig },
...@@ -45,7 +45,7 @@ test.skip('base view +@mobile +@dark-mode', async({ mount, page }) => { ...@@ -45,7 +45,7 @@ test.skip('base view +@mobile +@dark-mode', async({ mount, page }) => {
await expect(component).toHaveScreenshot(); await expect(component).toHaveScreenshot();
}); });
test.skip('error result', async({ mount, page }) => { test('error result', async({ mount, page }) => {
await page.route(CONTRACT_READ_METHODS_API_URL, (route) => route.fulfill({ await page.route(CONTRACT_READ_METHODS_API_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify(contractMethodsMock.read), body: JSON.stringify(contractMethodsMock.read),
...@@ -56,7 +56,7 @@ test.skip('error result', async({ mount, page }) => { ...@@ -56,7 +56,7 @@ test.skip('error result', async({ mount, page }) => {
})); }));
const component = await mount( const component = await mount(
<TestApp> <TestApp withWeb3>
<ContractRead/> <ContractRead/>
</TestApp>, </TestApp>,
{ hooksConfig }, { hooksConfig },
......
...@@ -15,14 +15,14 @@ const hooksConfig = { ...@@ -15,14 +15,14 @@ const hooksConfig = {
}, },
}; };
test.skip('base view +@mobile', async({ mount, page }) => { test('base view +@mobile', async({ mount, page }) => {
await page.route(CONTRACT_READ_METHODS_API_URL, (route) => route.fulfill({ await page.route(CONTRACT_READ_METHODS_API_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify(contractMethodsMock.write), body: JSON.stringify(contractMethodsMock.write),
})); }));
const component = await mount( const component = await mount(
<TestApp> <TestApp withWeb3>
<ContractWrite/> <ContractWrite/>
</TestApp>, </TestApp>,
{ hooksConfig }, { hooksConfig },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment