style(13-03): apply Prettier formatting across repo

Mechanical reformat — no logic changes. 398 files changed, 19125
insertions(+), 16457 deletions(-). Prettier 3.8.4 with .prettierrc
(singleQuote:true, semi:true, tabWidth:2, trailingComma:all,
printWidth:100). Isolated per D-13-08 for reviewability.
This commit is contained in:
Lucas Berger
2026-06-11 20:35:18 -04:00
parent 4bc0445173
commit 982438dc10
398 changed files with 19050 additions and 16382 deletions
+35 -38
View File
@@ -14,7 +14,7 @@
* directly and redirects to '/'.
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
// ---------------------------------------------------------------------------
// Shared mock: DB — avoids real DB connections across all tests in this file.
@@ -34,76 +34,73 @@ vi.mock('../../src/db/client.js', () => ({
}),
}),
},
}))
}));
// ---------------------------------------------------------------------------
// Track whether oidcAuthMiddleware was registered on the app.
// ---------------------------------------------------------------------------
const oidcMiddlewareSpy = vi.fn(
() => async (_c: unknown, next: () => Promise<void>) => next(),
)
const oidcMiddlewareSpy = vi.fn(() => async (_c: unknown, next: () => Promise<void>) => next());
vi.mock('@hono/oidc-auth', () => ({
oidcAuthMiddleware: () => oidcMiddlewareSpy(),
processOAuthCallback: () => async (c: { json: (v: unknown) => unknown }) =>
c.json({ ok: true }),
processOAuthCallback: () => async (c: { json: (v: unknown) => unknown }) => c.json({ ok: true }),
getAuth: vi.fn().mockResolvedValue(null),
}))
}));
// ---------------------------------------------------------------------------
// Env snapshot — restored after each test.
// ---------------------------------------------------------------------------
const originalNodeEnv = process.env.NODE_ENV
const originalBypassFlag = process.env.DEV_AUTH_BYPASS
const originalNodeEnv = process.env.NODE_ENV;
const originalBypassFlag = process.env.DEV_AUTH_BYPASS;
afterEach(() => {
process.env.NODE_ENV = originalNodeEnv
process.env.NODE_ENV = originalNodeEnv;
if (originalBypassFlag === undefined) {
delete process.env.DEV_AUTH_BYPASS
delete process.env.DEV_AUTH_BYPASS;
} else {
process.env.DEV_AUTH_BYPASS = originalBypassFlag
process.env.DEV_AUTH_BYPASS = originalBypassFlag;
}
vi.resetModules()
oidcMiddlewareSpy.mockClear()
})
vi.resetModules();
oidcMiddlewareSpy.mockClear();
});
// ---------------------------------------------------------------------------
describe('GET /api/login — dev-auth bypass (DEV_AUTH_BYPASS=true)', () => {
beforeEach(() => {
process.env.NODE_ENV = 'test'
process.env.DEV_AUTH_BYPASS = 'true'
})
process.env.NODE_ENV = 'test';
process.env.DEV_AUTH_BYPASS = 'true';
});
it('returns 302 with location "/" (bypass active, guard not mounted)', async () => {
const { app } = await import('../../src/index.js')
const { app } = await import('../../src/index.js');
const res = await app.request('/api/login')
expect(res.status).toBe(302)
expect(res.headers.get('location')).toBe('/')
})
const res = await app.request('/api/login');
expect(res.status).toBe(302);
expect(res.headers.get('location')).toBe('/');
});
it('does not invoke oidcAuthMiddleware when bypass is active', async () => {
const { app } = await import('../../src/index.js')
const { app } = await import('../../src/index.js');
await app.request('/api/login')
await app.request('/api/login');
expect(oidcMiddlewareSpy).not.toHaveBeenCalled()
})
})
expect(oidcMiddlewareSpy).not.toHaveBeenCalled();
});
});
describe('GET /api/login — OIDC path (no DEV_AUTH_BYPASS)', () => {
beforeEach(() => {
process.env.NODE_ENV = 'test'
delete process.env.DEV_AUTH_BYPASS
})
process.env.NODE_ENV = 'test';
delete process.env.DEV_AUTH_BYPASS;
});
it('returns 302 with location "/" when OIDC passthrough allows the request', async () => {
const { app } = await import('../../src/index.js')
const { app } = await import('../../src/index.js');
// oidcAuthMiddleware is mocked as a passthrough — request reaches the handler.
const res = await app.request('/api/login')
expect(res.status).toBe(302)
expect(res.headers.get('location')).toBe('/')
})
})
const res = await app.request('/api/login');
expect(res.status).toBe(302);
expect(res.headers.get('location')).toBe('/');
});
});