test(api): add resetDb helper + per-test isolation (proof: sessions suite)
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { createApp } from '../src/app';
|
||||
import { db } from '../src/db/client';
|
||||
import { workSessions } from '../src/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { authToken, bearer, seedActivity } from './helpers';
|
||||
import { authToken, bearer, seedActivity, resetDb } from './helpers';
|
||||
|
||||
const json = { 'content-type': 'application/json' };
|
||||
|
||||
describe('session lifecycle', () => {
|
||||
beforeEach(resetDb);
|
||||
|
||||
it('401s start/stop/discard without a token', async () => {
|
||||
const app = createApp();
|
||||
|
||||
@@ -334,6 +336,8 @@ describe('session lifecycle', () => {
|
||||
});
|
||||
|
||||
describe('session reads', () => {
|
||||
beforeEach(resetDb);
|
||||
|
||||
it('401s GET /api/sessions and /api/sessions/active without a token', async () => {
|
||||
const app = createApp();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user