Skip to content

Commit 1e1b129

Browse files
committed
fix: passing tests
just required changing how it looks for sessions also cleanup
1 parent fef3614 commit 1e1b129

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

examples/demo-app/tests/create-account.spec.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,12 @@ test("Create session and verify it appears in auth-server sessions list", async
497497
await popup.getByTestId("connect").click();
498498
await page.waitForTimeout(2000);
499499
await expect(page.getByText("Disconnect")).toBeVisible();
500-
console.log("✓ Account created");
500+
501+
// Capture the account address from the page
502+
const demoPageContent = await page.textContent("body");
503+
const accountMatch = demoPageContent?.match(/0x[a-fA-F0-9]{40}/);
504+
const demoAccountAddress = accountMatch ? accountMatch[0] : "unknown";
505+
console.log(`✓ Account created: ${demoAccountAddress}`);
501506

502507
// Step 2: Create session
503508
console.log("\nStep 2: Creating session...");
@@ -576,20 +581,45 @@ test("Create session and verify it appears in auth-server sessions list", async
576581
// Navigate to sessions page
577582
await authPage.goto("http://localhost:3002/dashboard/sessions");
578583
await authPage.waitForLoadState("domcontentloaded");
579-
await authPage.waitForTimeout(3000);
584+
585+
// Listen for console logs from the sessions page
586+
authPage.on("console", (msg) => {
587+
if (msg.text().includes("[sessions.vue]")) {
588+
console.log(` Auth-server: ${msg.text()}`);
589+
}
590+
});
591+
580592
console.log("✓ Navigated to sessions page");
593+
console.log(` Demo account (created session): ${demoAccountAddress}`);
581594

582595
// Verify sessions page content
583596
const header = authPage.locator("header").getByText("Sessions");
584597
await expect(header).toBeVisible();
585598
console.log("✓ Sessions page loaded");
586599

600+
// Wait for sessions data to load - look for either session rows or the table/list container
601+
// The sessions are loaded via WASM asynchronously, so we need to wait
602+
try {
603+
// Wait for the sessions list container or session rows to appear
604+
await authPage.waitForSelector("table tbody tr, [role='list'] > div, [data-testid*='session']", {
605+
timeout: 15000,
606+
state: "attached",
607+
});
608+
console.log("✓ Sessions data container loaded");
609+
} catch (e) {
610+
console.log("⚠ No sessions container appeared within 15s", e);
611+
}
612+
613+
// Additional wait to ensure console logs are captured
614+
await authPage.waitForTimeout(2000);
615+
587616
// Log page content for debugging
588617
const pageContent = await authPage.locator("main").textContent();
589618
console.log(`Page content: ${pageContent?.substring(0, 500)}`);
590619

591620
// Verify at least one session is displayed
592-
const sessionRows = authPage.locator("[data-testid*='session']");
621+
// The session rows use class="session-row" in the SessionRow component
622+
const sessionRows = authPage.locator(".session-row");
593623
const sessionCount = await sessionRows.count();
594624
console.log(`Found ${sessionCount} session row(s)`);
595625

packages/auth-server/pages/dashboard/sessions.vue

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,8 @@
44
<template #default>
55
Sessions
66
</template>
7-
<template #aside>
8-
<!-- <transition v-bind="TransitionOpacity">
9-
<ZkButton
10-
v-if="sessions?.length"
11-
type="danger"
12-
>
13-
<template #prefix>
14-
<HandRaisedIcon
15-
class="h-5 w-5 mr-1"
16-
aria-hidden="true"
17-
/>
18-
</template>
19-
<span class="leading-tight">End all sessions</span>
20-
</ZkButton>
21-
</transition> -->
22-
</template>
237
</layout-header>
248

25-
<CommonAlert
26-
v-if="sessions?.length"
27-
class="mb-4"
28-
>
29-
<template #icon>
30-
<InformationCircleIcon aria-hidden="true" />
31-
</template>
32-
<template #default>
33-
<p class="text-sm">
34-
ZKsync SSO is still under development. The displayed spending amounts may not always be accurate.
35-
</p>
36-
</template>
37-
</CommonAlert>
38-
399
<CommonAlert
4010
v-if="sessionsFetchError"
4111
class="mb-4"
@@ -85,7 +55,7 @@
8555
import { InformationCircleIcon } from "@heroicons/vue/20/solid";
8656
import type { Address, Hex } from "viem";
8757
import { listActiveSessions } from "zksync-sso-4337";
88-
import { LimitType, type SessionConfig } from "zksync-sso-4337/client";
58+
import { LimitType, type SessionSpec } from "zksync-sso-4337/client";
8959
9060
const { defaultChain } = useClientStore();
9161
const { address } = storeToRefs(useAccountStore());
@@ -127,7 +97,7 @@ interface WasmSessionSpec {
12797
}
12898
12999
// Helper to convert WASM session spec format to proper TypeScript types
130-
const convertSessionSpec = (wasmSpec: WasmSessionSpec): SessionConfig => {
100+
const convertSessionSpec = (wasmSpec: WasmSessionSpec): SessionSpec => {
131101
const convertLimit = (limit: WasmUsageLimit) => {
132102
// Map string limitType to enum value
133103
let limitType: LimitType;
@@ -178,13 +148,16 @@ const {
178148
// Get RPC URL from the chain configuration
179149
const rpcUrl = defaultChain.rpcUrls.default.http[0];
180150
151+
if (address.value === null) {
152+
throw new Error("Account address is null");
153+
}
181154
// Use the new listActiveSessions function from the SDK
182155
const { sessions: activeSessions } = await listActiveSessions({
183156
account: address.value,
184157
rpcUrl,
185158
contracts: {
186159
sessionValidator: contracts.sessionValidator,
187-
entryPoint: "0x0000000071727De22E5E9d8BAf0edAc6f37da032", // Standard EntryPoint v0.8
160+
entryPoint: contracts.entryPoint || "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
188161
accountFactory: contracts.factory,
189162
webauthnValidator: contracts.webauthnValidator,
190163
eoaValidator: contracts.eoaValidator,

0 commit comments

Comments
 (0)