recruter/test/product-page.test.ts
Peppa b8eb888672
All checks were successful
peppa/lint lint: success за 0с
peppa/typecheck typecheck: success за 1с
peppa/test test: success за 0с
peppa/build build: success за 1с
ci / checks (pull_request) Successful in 15s
deploy / deploy (pull_request) Successful in 15s
RCT-2: старт без API_TOKEN, страница продукта, фиксированный pnpm в Dockerfile
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 10:49:55 +05:00

32 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { buildApp } from "../src/app.js";
import { openDb } from "../src/db.js";
const noToken = () => buildApp({ db: openDb(), apiToken: "" });
describe("product-page", () => {
it("Scenario: Открытие по ссылке", async () => {
const res = await noToken().inject({ method: "GET", url: "/" });
expect(res.statusCode).toBe(200);
expect(res.headers["content-type"]).toContain("text/html");
expect(res.body).toContain("Виртуальный рекрутер");
expect(res.body).not.toContain("full_name");
});
it("Scenario: Другой язык", async () => {
const res = await noToken().inject({ method: "GET", url: "/?lang=en" });
expect(res.body).toContain("Virtual Recruiter");
});
it("Scenario: язык из Accept-Language, чужой lang игнорируется", async () => {
const res = await noToken().inject({ method: "GET", url: "/?lang=<script>", headers: { "accept-language": "kk-KZ" } });
expect(res.body).toContain("Виртуалды рекрутер");
});
it("Scenario: Запуск без токена", async () => {
expect((await noToken().inject({ method: "GET", url: "/healthz" })).statusCode).toBe(200);
});
it("Scenario: Запрос к закрытой части без токена", async () => {
const a = noToken();
expect((await a.inject({ method: "GET", url: "/api/vacancies" })).statusCode).toBe(401);
expect((await a.inject({ method: "GET", url: "/api/vacancies", headers: { authorization: "Bearer " } })).statusCode).toBe(401);
});
});