Files
liqa/test/auth.controller.spec.ts
T
ars9 9a9ccbfe37 feat(scenario): run logs, lint/format tooling, CONTRIBUTING
- add ScenarioRunLogEntity to persist step script output to DB
- stepLogger dual-writes to NestJS logger and DB (fire-and-forget)
- add GET /scenarios/:id/run/:runId returning run, stepRuns and logs
- add POST /scenarios/:id/run/:runId/wait (polls until terminal state)
- 9 new integration tests for the two endpoints (136 total)
- add eslint with typescript-eslint and eslint-config-prettier
- add npm scripts: format, lint, lint:fix
- resolve all lint errors across src and test (no any types)
- add CONTRIBUTING.md covering dev workflow
2026-04-08 18:10:42 +03:00

62 lines
2.1 KiB
TypeScript

import { INestApplication } from "@nestjs/common";
import request from "supertest";
import { buildTestApp } from "./app.harness";
/**
* Auth controller integration tests.
*
* The login endpoint requires a live browser + real key files, so it is not
* exercised here (those belong to e2e tests with real credentials).
* We cover the parts that can be tested without external dependencies.
*/
describe("AuthController", () => {
let app: INestApplication;
beforeAll(async () => {
app = await buildTestApp();
});
afterAll(async () => {
await app.close();
});
// ── GET /keys ──────────────────────────────────────────────────────────────
describe("GET /keys", () => {
it("returns 200 with a keys array", async () => {
const res = await request(app.getHttpServer()).get("/keys").expect(200);
expect(res.body).toHaveProperty("keys");
expect(Array.isArray(res.body.keys)).toBe(true);
});
});
// ── POST /login ────────────────────────────────────────────────────────────
describe("POST /login", () => {
it("returns 400 when body is empty", async () => {
await request(app.getHttpServer()).post("/login").send({}).expect(400);
});
it("returns 400 when key is missing", async () => {
await request(app.getHttpServer())
.post("/login")
.send({ environmentName: "test-env" })
.expect(400);
});
it("returns 400 when environmentName is missing", async () => {
await request(app.getHttpServer())
.post("/login")
.send({ key: "some-key" })
.expect(400);
});
it("returns 400 when key file does not exist", async () => {
await request(app.getHttpServer())
.post("/login")
.send({ key: "nonexistent-key", environmentName: "test-env" })
.expect(404); // NotFoundException for missing environment
});
});
});