32 lines
1.6 KiB
TypeScript
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);
|
|
});
|
|
});
|