Commit 9db394ab authored by tom's avatar tom

clean up

parent 26d0abd6
......@@ -15,7 +15,6 @@ import theme from 'theme';
type Props = {
children: React.ReactNode;
withSocket?: boolean;
withWeb3?: boolean;
appContext?: {
pageProps: PageProps;
};
......@@ -28,7 +27,30 @@ const defaultAppContext = {
},
};
const TestApp = ({ children, withSocket, withWeb3, appContext = defaultAppContext }: Props) => {
// >>> Web3 stuff
const provider = new providers.JsonRpcProvider(
'http://localhost:8545',
{
name: 'POA',
chainId: 99,
},
);
const connector = new MockConnector({
chains: [ mainnet ],
options: {
signer: provider.getSigner(),
},
});
const wagmiClient = createClient({
autoConnect: true,
connectors: [ connector ],
provider,
});
// <<<<
const TestApp = ({ children, withSocket, appContext = defaultAppContext }: Props) => {
const [ queryClient ] = React.useState(() => new QueryClient({
defaultOptions: {
queries: {
......@@ -38,46 +60,14 @@ const TestApp = ({ children, withSocket, withWeb3, appContext = defaultAppContex
},
}));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [ wagmiClient ] = React.useState<any>(() => {
if (!withWeb3) {
return;
}
const provider = new providers.JsonRpcProvider(
'http://localhost:8545',
{
name: 'POA',
chainId: 99,
},
);
const connector = new MockConnector({
chains: [ mainnet ],
options: {
signer: provider.getSigner(),
},
});
return createClient({
autoConnect: true,
connectors: [ connector ],
provider,
});
});
const content = wagmiClient ? (
<WagmiConfig client={ wagmiClient }>
{ children }
</WagmiConfig>
) : children;
return (
<ChakraProvider theme={ theme }>
<QueryClientProvider client={ queryClient }>
<SocketProvider url={ withSocket ? `ws://localhost:${ PORT }` : undefined }>
<AppContextProvider { ...appContext }>
{ content }
<WagmiConfig client={ wagmiClient }>
{ children }
</WagmiConfig>
</AppContextProvider>
</SocketProvider>
</QueryClientProvider>
......
// running this test together with other causing JS memory leak
// I was not able to figure out the exact reason, so for now it is skipped
import { test, expect } from '@playwright/experimental-ct-react';
import React from 'react';
......
......@@ -27,7 +27,7 @@ test('base view +@mobile +@dark-mode', async({ mount, page }) => {
}));
const component = await mount(
<TestApp withWeb3>
<TestApp>
<ContractRead/>
</TestApp>,
{ hooksConfig },
......@@ -56,7 +56,7 @@ test('error result', async({ mount, page }) => {
}));
const component = await mount(
<TestApp withWeb3>
<TestApp>
<ContractRead/>
</TestApp>,
{ hooksConfig },
......
......@@ -22,7 +22,7 @@ test('base view +@mobile', async({ mount, page }) => {
}));
const component = await mount(
<TestApp withWeb3>
<TestApp>
<ContractWrite/>
</TestApp>,
{ hooksConfig },
......
......@@ -7096,7 +7096,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
fast-glob@^3.2.12, fast-glob@^3.2.9:
fast-glob@^3.2.9:
version "3.2.12"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80"
integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==
......@@ -11028,13 +11028,6 @@ valtio@1.8.2:
proxy-compare "2.4.0"
use-sync-external-store "1.2.0"
vite-plugin-dynamic-import@^1.2.6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.2.6.tgz#0e4ff699d4e97cdff3ccf9e979957167bc22654b"
integrity sha512-HeO5GsQfsiGfFDLhFOUZeqjM4Y8Xk5ctfRfkw5qLszZT5+N37mMbwqp8TqYxXZ4dd0EBnQ9Zg4Pr5mR2eE9hBA==
dependencies:
fast-glob "^3.2.12"
vite-plugin-svgr@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/vite-plugin-svgr/-/vite-plugin-svgr-2.2.2.tgz#c5c9cb573bf455bb079550531847ddc5d2e122af"
......@@ -11043,11 +11036,6 @@ vite-plugin-svgr@^2.2.2:
"@rollup/pluginutils" "^5.0.0"
"@svgr/core" "^6.4.0"
vite-plugin-utils@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/vite-plugin-utils/-/vite-plugin-utils-0.4.0.tgz#8f08acb4501efbee53156bcf63ad40da205a826a"
integrity sha512-UZ9hkvRtKXIvQdjozVhUvD+/f2LOoEw3VbJBCWOvchKlzmjGrNULc4ZA/gfpedtjxjxq2tO6WBhrwtoevLnIWg==
vite-tsconfig-paths@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/vite-tsconfig-paths/-/vite-tsconfig-paths-3.5.2.tgz#fd3232f93c426311d7e0d581187d8b63fff55fbc"
......
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