Files
Millaguie f11ea58c2c
CI/CD Pipeline / test (push) Successful in 26s
CI/CD Pipeline / build-and-push (push) Successful in 44s
Sternboard: free retro board, no signup (initial)
Servidor Fastify + Socket.IO + Drizzle/Postgres; front Vite+React (EN/ES, tema claro/oscuro).
Tableros por columnas con plantillas, notas privadas/públicas, agrupación, votos
configurables (multivoto), timer compartido con alarma, fases, action items,
export Markdown/JSON e import, autodestrucción, gestión de columnas.
Imagen única (front servido por el servidor) y CI que la construye y publica.
2026-06-16 10:27:33 +02:00

49 lines
1.6 KiB
TypeScript

import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { eq } from "drizzle-orm";
import { startTestServer, createBoard, join, type TestServer } from "./helpers.js";
import { runCleanup } from "../src/app.js";
import { db, schema } from "../src/db/index.js";
let server: TestServer;
beforeAll(async () => {
server = await startTestServer();
});
afterAll(async () => {
await server.close();
});
describe("Autodestrucción", () => {
it("borra boards caducados y avisa a la room", async () => {
const board = await createBoard(server.url, { ttlHours: 1 });
// forzamos expires_at al pasado
await db
.update(schema.boards)
.set({ expiresAt: new Date(Date.now() - 1000) })
.where(eq(schema.boards.id, board.boardId));
const alice = await join(server.url, board.boardId, "alice", "Alice");
const destroyed = new Promise<void>((resolve) =>
alice.socket.once("board:destroyed", () => resolve()),
);
const deleted = await runCleanup(server.io);
expect(deleted).toContain(board.boardId);
await destroyed; // la room recibió el aviso
// ya no existe en DB
const rows = await db.select().from(schema.boards).where(eq(schema.boards.id, board.boardId));
expect(rows).toHaveLength(0);
alice.socket.close();
});
it("no borra boards sin caducidad ni los aún vigentes", async () => {
const persistent = await createBoard(server.url, { ttlHours: null });
const future = await createBoard(server.url, { ttlHours: 24 });
const deleted = await runCleanup(server.io);
expect(deleted).not.toContain(persistent.boardId);
expect(deleted).not.toContain(future.boardId);
});
});