sdlc-hub/web/e2e/feed.spec.ts
2026-10-28 12:48:40 +04:00

47 lines
3.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, test } from "@playwright/test";
import { HUB_URL } from "../playwright.config.ts";
import { login, tokens } from "./hub.ts";
// журнал изменений засевается агентским маршрутом, как его шлёт агент v13 (#70); id записей уникальны на прогон
async function seedHistory() {
const run = Date.now();
const created = new Date(Date.now() - 10 * 60_000).toISOString();
const changes = [
{ history_id: `e2e-${run}-1`, seq: 0, key: "AURORA-9002", created, author: "Петров Пётр", field_id: "status",
field_name: "status", from: "1", from_string: "В работе", to: "2", to_string: "Готово" },
{ history_id: `e2e-${run}-2`, seq: 0, key: "AURORA-9002", created, author: "Петров Пётр", field_id: "assignee",
field_name: "assignee", from: null, from_string: null, to: "x".repeat(200), to_string: "Очень-длинное-имя-без-пробелов-".repeat(8) },
];
const r = await fetch(HUB_URL + "/agent/history", { method: "POST", headers: { Authorization: "Bearer " + tokens().agents.jira, "Content-Type": "application/json" }, body: JSON.stringify({ changes }) });
expect(r.ok).toBe(true);
}
test("лента: событие за сегодня, карточка окном поверх ленты, история в карточке", async ({ page }) => {
await seedHistory();
await login(page, "/app/feed?project=AWPCA");
const group = page.getByTestId("feed-group").filter({ has: page.getByRole("link", { name: "AURORA-9002", exact: true }) });
await expect(group.getByText("статус «В работе» → «Готово»").first()).toBeVisible();
const other = page.getByRole("checkbox", { name: "Прочие поля" });
await other.click(); // флажок управляемый: состояние приходит из адреса после навигации
await expect(other).toBeChecked();
await expect(page).toHaveURL(/kinds=status%2Cdescription%2Cdates%2Ccomment%2Cother|kinds=status,description,dates,comment,other/);
await expect(group.getByText(/исполнитель:/).first()).toBeVisible();
await group.getByRole("link", { name: "AURORA-9002", exact: true }).click();
const d = page.getByRole("dialog");
await expect(d.getByRole("heading", { name: "API свода" })).toBeVisible();
await expect(d.getByRole("heading", { name: /^История \(\d+\)$/ })).toBeVisible();
await expect(d.getByTestId("history").getByText("статус «В работе» → «Готово»").first()).toBeVisible();
await page.keyboard.press("Escape");
await expect(page.getByRole("dialog")).toHaveCount(0);
await expect(page.getByTestId("page-feed")).toBeVisible();
});
test("лента на 390 px: нет горизонтальной прокрутки при длинных значениях", async ({ page }) => {
await seedHistory();
await page.setViewportSize({ width: 390, height: 844 });
await login(page, "/app/feed?project=AWPCA&kinds=status,other");
await expect(page.getByTestId("feed-group").first()).toBeVisible();
const overflow = await page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth);
expect(overflow).toBeLessThanOrEqual(0);
});