feat(matches): add the candidate match screen with expandable explanations
This commit is contained in:
1 parent
0b11021b16
commit
28337d84cb
50 files changed
+4834
-37
No files matched your search
@@ -0,0 +1,160 @@
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { MatchSearchModel } from "../../../entities/match";
|
||||
import {
|
||||
backendHandle,
|
||||
emptyMatchModelFixture,
|
||||
matchFixtureNeedId as needId,
|
||||
matchModelFixture,
|
||||
} from "../../../entities/match/testing";
|
||||
import { MatchList } from "./match-list";
|
||||
|
||||
const organizationId = "0199b4f2-7c1e-7d3a-9f00-aabbccddee01";
|
||||
|
||||
function render(
|
||||
result: MatchSearchModel,
|
||||
props: { stale?: boolean; needTitle?: string | null } = {},
|
||||
): string {
|
||||
return renderToString(
|
||||
<MemoryRouter>
|
||||
<MatchList
|
||||
accountId="0199b4f2-7c1e-7d3a-9f00-aabbccddee02"
|
||||
organizationId={organizationId}
|
||||
result={result}
|
||||
sentFilters={undefined}
|
||||
needTitle={props.needTitle ?? null}
|
||||
stale={props.stale ?? false}
|
||||
/>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("match list", () => {
|
||||
it("prints the three groups in the product order with their labels", () => {
|
||||
const html = render(matchModelFixture());
|
||||
const positions = ["Подтвержденные", "Близкие варианты", "Грейд не подтвержден"].map((label) =>
|
||||
html.indexOf(`>${label}</h3>`),
|
||||
);
|
||||
|
||||
expect(positions.every((position) => position > 0)).toBe(true);
|
||||
expect([...positions].sort((a, b) => a - b)).toEqual(positions);
|
||||
});
|
||||
|
||||
it("keeps the confirmed and the declared grade on separate lines", () => {
|
||||
const html = render(matchModelFixture());
|
||||
|
||||
expect(html).toContain("Подтвержденная категория");
|
||||
expect(html).toContain("Заявленный кандидатом грейд");
|
||||
expect(html).toContain("Грейд подтвержден: Middle");
|
||||
expect(html).toContain("Backend, Middle. Сильное подтверждение");
|
||||
});
|
||||
|
||||
it("offers a specialization switch when the result holds several specializations", () => {
|
||||
const html = render(matchModelFixture());
|
||||
|
||||
expect(html).toContain("Представление по специализациям");
|
||||
expect(html).toContain("Все специализации");
|
||||
expect(html).toContain("Сетевое администрирование");
|
||||
expect(html).toContain("Подтверждение не переносится");
|
||||
});
|
||||
|
||||
it("offers no switch for a single specialization", () => {
|
||||
const base = matchModelFixture();
|
||||
const single = {
|
||||
...base,
|
||||
cards: base.cards.filter((card) => card.specialization === "backend"),
|
||||
};
|
||||
|
||||
expect(render(single)).not.toContain("Представление по специализациям");
|
||||
});
|
||||
|
||||
it("links every entry to the invitation with the organization-scoped handle, also unconfirmed ones", () => {
|
||||
const html = render(matchModelFixture());
|
||||
const links = [...html.matchAll(/href="(\/employer\/invitations\?[^"]+)"/g)].map(
|
||||
(match) => new URL((match[1] ?? "").replaceAll("&", "&"), "http://x"),
|
||||
);
|
||||
|
||||
expect(links).toHaveLength(matchModelFixture().cards.length);
|
||||
const network = links.find(
|
||||
(url) => url.searchParams.get("specialization") === "network_engineer",
|
||||
);
|
||||
expect(network?.searchParams.get("candidate_handle")).toBe(backendHandle);
|
||||
expect(network?.searchParams.get("organization_id")).toBe(organizationId);
|
||||
expect(html).toContain("Пригласить кандидата");
|
||||
});
|
||||
|
||||
it("passes the need to the invitation link when the search was based on a need", () => {
|
||||
const model = matchModelFixture({
|
||||
source: { kind: "need", need_id: needId, requirements_version: 4 },
|
||||
});
|
||||
const html = render(model, { needTitle: "Платежный backend" });
|
||||
|
||||
expect(html).toContain(`need_id=${needId}`);
|
||||
expect(html).toContain("Платежный backend");
|
||||
expect(html).toContain("версия требований 4");
|
||||
});
|
||||
|
||||
it("shows no contact, no stable identifier and no failure reason", () => {
|
||||
const html = render(matchModelFixture());
|
||||
|
||||
expect(html).not.toMatch(/@|\+7|telegram|email/i);
|
||||
expect(html).not.toContain("candidate_id");
|
||||
expect(html).not.toContain("account");
|
||||
// Only the shortened alias is printed; the full handle goes into links only.
|
||||
expect(html).not.toContain(`>${backendHandle}<`);
|
||||
expect(html).not.toMatch(/провал|неудач/i);
|
||||
});
|
||||
|
||||
it("keeps the explanation and the card closed until the employer asks", () => {
|
||||
const html = render(matchModelFixture());
|
||||
|
||||
expect(html).not.toContain("Как получена позиция");
|
||||
expect(html).not.toContain("Карточка кандидата</h5>");
|
||||
expect(html).toContain('aria-expanded="false"');
|
||||
expect(html).toContain("Показать объяснение");
|
||||
expect(html).toContain("Открыть карточку");
|
||||
});
|
||||
|
||||
it("explains a partial output without a count", () => {
|
||||
const html = render(matchModelFixture({ truncated: true }));
|
||||
|
||||
expect(html).toContain("Показана часть выдачи; квота просмотров или предел группы");
|
||||
expect(render(matchModelFixture())).not.toContain("Показана часть выдачи");
|
||||
});
|
||||
|
||||
it("explains an empty result and keeps the filters in view", () => {
|
||||
const html = render(emptyMatchModelFixture());
|
||||
|
||||
expect(html).toContain("По этим условиям никого не нашли");
|
||||
expect(html).toContain("поиск не ослабляет их сам");
|
||||
expect(html).not.toContain("Подтвержденные</h3>");
|
||||
});
|
||||
|
||||
it("lists the filters of an empty result that the employer can change", () => {
|
||||
const model = emptyMatchModelFixture();
|
||||
const html = render({
|
||||
...model,
|
||||
source: {
|
||||
kind: "bank",
|
||||
filters: {
|
||||
specialization: "qa",
|
||||
confirmedGrade: "senior",
|
||||
confirmedCategory: null,
|
||||
confirmationStatus: null,
|
||||
declaredGrade: null,
|
||||
stack: ["kafka"],
|
||||
conditions: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(html).toContain("Подтвержденный грейд: Senior");
|
||||
expect(html).toContain("Технологии в карточке (нужны все): Kafka");
|
||||
});
|
||||
|
||||
it("warns that the form changed after the shown result", () => {
|
||||
expect(render(matchModelFixture(), { stale: true })).toContain("Условия поиска изменены");
|
||||
expect(render(matchModelFixture())).not.toContain("Условия поиска изменены");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user