Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/desktop/src/renderer/lib/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ describe("account status cache", () => {

unsubscribe();
});

it("coerces a null bridge response to the signed-out account shape", async () => {
const status = vi.fn(async () => null);
Object.defineProperty(globalThis.window, "ade", {
configurable: true,
writable: true,
value: {
account: { status },
} as unknown as typeof window.ade,
});

const { fetchAccountStatus, SIGNED_OUT_ACCOUNT } = await import("./account");

const normalized = await fetchAccountStatus({ force: true });

expect(normalized).toBe(SIGNED_OUT_ACCOUNT);
expect(normalized).toMatchObject({ signedIn: false, userId: null, email: null });
expect(status).toHaveBeenCalledOnce();
});
});

describe("account avatar presentation", () => {
Expand Down
5 changes: 3 additions & 2 deletions apps/desktop/src/renderer/lib/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export async function fetchAccountStatus(options?: { force?: boolean }): Promise
inFlight = api
.status()
.then((status) => {
if (serial === fetchSerial) emit(status);
return status;
const normalized = status ?? SIGNED_OUT_ACCOUNT;
if (serial === fetchSerial) emit(normalized);
return normalized;
})
.catch(() => cachedStatus?.value ?? SIGNED_OUT_ACCOUNT)
.finally(() => {
Expand Down
Loading
Loading