Add full test suite with unit, integration, and E2E smoke tests.
Introduce test.bat orchestrating Go/Vitest/Playwright phases, expand coverage across server, agent, and dashboard, and document in tests/README.md.
This commit is contained in:
26
server/web/src/api/auth.test.ts
Normal file
26
server/web/src/api/auth.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @vitest-environment happy-dom
|
||||
*/
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { authHeaders, clearStoredAuth, getStoredAuth, setStoredAuth } from '../api/auth';
|
||||
|
||||
describe('auth session helpers', () => {
|
||||
beforeEach(() => {
|
||||
sessionStorage.clear();
|
||||
});
|
||||
|
||||
it('stores and retrieves basic token', () => {
|
||||
setStoredAuth('drjones', 'secret');
|
||||
expect(getStoredAuth()).toBe(btoa('drjones:secret'));
|
||||
});
|
||||
|
||||
it('builds Authorization header when logged in', () => {
|
||||
setStoredAuth('user', 'pass');
|
||||
expect(authHeaders()).toEqual({ Authorization: `Basic ${btoa('user:pass')}` });
|
||||
});
|
||||
|
||||
it('returns empty headers when logged out', () => {
|
||||
clearStoredAuth();
|
||||
expect(authHeaders()).toEqual({});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user