Skip to content

Commit f1c10ea

Browse files
authored
Fix keychain storybook (#1387)
1 parent f96a7de commit f1c10ea

File tree

39 files changed

+111
-117
lines changed

39 files changed

+111
-117
lines changed

Dockerfile.storybook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/playwright:v1.49.1
1+
FROM mcr.microsoft.com/playwright:v1.50.1
22

33
# Set environment variables
44
ENV CI=true \

packages/keychain/.storybook/mock.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { constants } from "starknet";
2-
import { getChainName } from "@cartridge/utils";
1+
import { constants, RpcProvider } from "starknet";
32
import Controller from "@cartridge/controller";
43
import { SessionPolicies } from "@cartridge/presets";
54
import { Parameters } from "@storybook/react";
@@ -20,35 +19,40 @@ export interface StoryParameters extends Parameters {
2019
}
2120

2221
export function useMockedConnection({
23-
chainId = constants.StarknetChainId.SN_SEPOLIA,
22+
chainId = constants.StarknetChainId.SN_MAIN,
2423
context = {
2524
type: "connect",
2625
origin: "http://localhost:3002",
2726
policies: [],
2827
resolve: () => {},
2928
reject: () => {},
3029
} as ConnectCtx,
30+
controller,
3131
...rest
3232
}: StoryParameters["connection"] = {}): ConnectionContextValue {
33-
const chainName = getChainName(chainId);
34-
3533
return {
3634
context,
35+
controller: {
36+
address: () =>
37+
"0x0000000000000000000000000000000000000000000000000000000000000000",
38+
username: () => "user",
39+
chainId: () => chainId,
40+
provider: new RpcProvider({
41+
nodeUrl: "https://api.cartridge.gg/x/starknet/sepolia",
42+
}),
43+
...controller,
44+
},
3745
origin: "http://localhost:3002",
38-
rpcUrl: "http://api.cartridge.gg/x/sepolia",
39-
chainId,
40-
chainName,
46+
rpcUrl: "http://api.cartridge.gg/x/starknet/mainnet",
4147
policies: {},
4248
theme: { defaultTheme, verified: true },
4349
hasPrefundRequest: false,
44-
error: undefined,
4550
setContext: () => {},
4651
setController: () => {},
4752
closeModal: () => {},
4853
openModal: () => {},
4954
logout: () => {},
5055
openSettings: () => {},
51-
controller: {},
5256
upgrade: {},
5357
...rest,
5458
};

packages/keychain/.storybook/provider.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ControllerThemeContext,
1313
VerifiableControllerTheme,
1414
} from "../src/context/theme";
15+
import { TokensProvider } from "../src/components/provider/tokens";
1516

1617
export function Provider({
1718
children,
@@ -38,9 +39,11 @@ export function Provider({
3839
>
3940
<QueryClientProvider client={queryClient}>
4041
<ConnectionContext.Provider value={connection}>
41-
<ControllerThemeProvider theme={connection.theme}>
42-
<BrowserRouter>{children}</BrowserRouter>
43-
</ControllerThemeProvider>
42+
<TokensProvider>
43+
<ControllerThemeProvider theme={connection.theme}>
44+
<BrowserRouter>{children}</BrowserRouter>
45+
</ControllerThemeProvider>
46+
</TokensProvider>
4447
</ConnectionContext.Provider>
4548
</QueryClientProvider>
4649
</StarknetConfig>

packages/keychain/.storybook/test-runner.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TestRunnerConfig } from "@storybook/test-runner";
1+
import { TestRunnerConfig, waitForPageReady } from "@storybook/test-runner";
22
import { toMatchImageSnapshot } from "jest-image-snapshot";
33
import path from "path";
44

@@ -22,10 +22,7 @@ const config: TestRunnerConfig = {
2222
},
2323
async postVisit(page, context) {
2424
// Wait for the page to be ready before taking a screenshot
25-
await page.waitForSelector("#storybook-root", {
26-
state: "visible",
27-
timeout: 45000,
28-
});
25+
await waitForPageReady(page);
2926

3027
// Wait for any animations to complete
3128
await page.waitForTimeout(1000);
-694 Bytes
Loading
-777 Bytes
Loading
-747 Bytes
Loading
-863 Bytes
Loading
-813 Bytes
Loading
-936 Bytes
Loading

0 commit comments

Comments
 (0)