9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
24 lines
841 B
JavaScript
24 lines
841 B
JavaScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { getRegistry } from '@jackwener/opencli/registry';
|
|
import './whoami.js';
|
|
|
|
function makePage(authMe, status = 200) {
|
|
return {
|
|
goto: vi.fn().mockResolvedValue(undefined),
|
|
evaluate: vi.fn().mockResolvedValue(
|
|
status === 200 ? { kind: 'ok', rows: authMe } : { kind: 'auth', detail: `/auth/me ${status}` },
|
|
),
|
|
};
|
|
}
|
|
|
|
describe('slock whoami', () => {
|
|
const command = getRegistry().get('slock/whoami');
|
|
|
|
it('returns a normalized identity object from /auth/me on 200', async () => {
|
|
const page = makePage({ id: 'u1', name: 'Alice', email: 'a@b.c' });
|
|
const identity = await command.func(page, {});
|
|
expect(identity).toEqual({ logged_in: true, site: 'slock', id: 'u1', name: 'Alice', email: 'a@b.c' });
|
|
expect(page.goto).toHaveBeenCalled();
|
|
});
|
|
});
|