fix: verify stored sessions from a Reddit page

This commit is contained in:
jjbrunton committed 2026-08-08 20:22:45 +01:00
1 parent 8df2d648dd
commit 5623100e93
2 files changed
+26 -1

No files matched your search

+9
View File
@@ -42,7 +42,11 @@ describe('BrowserClient', () => {
json: async () => ({ kind: 't2', data: { name: 'bot-account', id: 'abc123' } }),
});
vi.stubGlobal('fetch', fetchMock);
let pageUrl = 'about:blank';
const goto = vi.fn(async (url: string) => { pageUrl = url; });
const page = {
url: () => pageUrl,
goto,
evaluate: async (pageFunction: () => Promise<string | null>) => pageFunction(),
} as unknown as Page;
const context = { pages: () => [page] } as unknown as BrowserContext;
@@ -54,6 +58,11 @@ describe('BrowserClient', () => {
username: 'bot-account',
accountId: 't2_abc123',
});
expect(goto).toHaveBeenCalledTimes(1);
expect(goto).toHaveBeenCalledWith('https://www.reddit.com', {
waitUntil: 'domcontentloaded',
timeout: 30000,
});
expect(fetchMock).toHaveBeenCalledWith(
'https://www.reddit.com/api/me.json',
{ credentials: 'include' },