Files
lincodex/frontend/src/widgets/invitation-preview/ui/invitation-preview.test.tsx
T

97 lines
3.8 KiB
TypeScript

import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import type { CandidateOrganizationCard, InvitationTerms } from "../../../shared/api/schemas";
import { InvitationPreview } from "./invitation-preview";
const card: CandidateOrganizationCard = {
id: "0199b4f2-7c1e-7d3a-9f00-aabbccddee01",
name: "Северный ветер",
description: "Платежная инфраструктура для малого бизнеса",
sphere: "Финтех",
contacts: { website: "https://north.example", email: null, phone: null, telegram: null },
verification_level: "e0",
};
const terms: InvitationTerms = {
role_title: "Middle Go-разработчик",
specialization: "backend",
grade: "middle",
offer_type: "full_time",
tasks: ["Развивать сервис выплат", "Перевести отчеты на события"],
team: "Пять бэкенд-разработчиков\nи QA-инженер",
tech_stack: ["Go", "PostgreSQL"],
work_formats: ["remote", "hybrid"],
location: "Москва",
communication_method: { channel: "video_call", details: "Созвон с тимлидом" },
salary: {
salary_from: 100000,
salary_to: 140000,
currency: "RUB",
period: "month",
tax_basis: "net",
},
package: {
bonus: { status: "provided", description: "Квартальная премия до 20%" },
equipment: { status: "provided", description: "Ноутбук и монитор" },
training: { status: "not_provided" },
health_insurance: { status: "not_provided" },
},
};
const text = (html: string) => html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ");
describe("invitation preview", () => {
it("shows the company card and every term as the candidate sees them", () => {
const html = renderToStaticMarkup(
<InvitationPreview
card={card}
terms={terms}
responsePeriodDays={7}
responseDeadlineAt={null}
/>,
);
const content = text(html);
for (const value of [
"Северный ветер",
"Платежная инфраструктура для малого бизнеса",
"Уровень E0",
"Middle Go-разработчик",
"Backend, Middle",
"Полная занятость",
"Развивать сервис выплат",
"Перевести отчеты на события",
"Go, PostgreSQL",
"Удаленно, Гибридно",
"Москва",
"Видеозвонок. Созвон с тимлидом",
"Квартальная премия до 20%",
"Ноутбук и монитор",
"7 дней с момента доставки",
]) {
expect(content).toContain(value);
}
expect(content).toMatch(/от 100\s000 ₽ до 140\s000 ₽ в месяц, после налога \(net\)/);
expect(html.match(/Не предусмотрено/g)).toHaveLength(2);
expect(html).toContain('data-package="training"');
expect(html).not.toContain("<time");
});
it("shows the server deadline of a sent invitation and a fallback without the card", () => {
const html = renderToStaticMarkup(
<InvitationPreview
card={null}
cardFallback={<p>Карточка недоступна</p>}
terms={{ ...terms, location: null, work_formats: ["remote"] }}
responsePeriodDays={7}
responseDeadlineAt="2026-10-16T10:00:00Z"
/>,
);
expect(html).toContain("Карточка недоступна");
expect(html).toContain('<time dateTime="2026-10-16T10:00:00Z">16 октября 2026');
expect(html).toContain("10:00 UTC</time>");
expect(text(html)).toContain("Не требуется: только удаленная работа");
});
});