55 lines
3.4 KiB
TypeScript
55 lines
3.4 KiB
TypeScript
// PEP-274 (F-12, F-13): small things the test report found — every browser tab has its own
|
||
// title; the chat field on a phone keeps its hint whole and its buttons big enough to tap.
|
||
import assert from "node:assert/strict";
|
||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||
import { join, relative } from "node:path";
|
||
import { describe, test } from "node:test";
|
||
import { fileURLToPath } from "node:url";
|
||
|
||
const web = fileURLToPath(new URL("../../../apps/web/", import.meta.url));
|
||
const pages = (dir: string): string[] =>
|
||
readdirSync(dir).flatMap((name) => {
|
||
const full = join(dir, name);
|
||
if (statSync(full).isDirectory()) return name === "node_modules" ? [] : pages(full);
|
||
return name === "page.tsx" ? [full] : [];
|
||
});
|
||
|
||
describe("PEP-274: свой заголовок у каждой вкладки браузера", () => {
|
||
test("Страница без заголовка не проходит проверку: у каждой page.tsx есть generateMetadata или metadata", () => {
|
||
const all = pages(join(web, "app"));
|
||
assert.ok(all.length > 30, "pages found");
|
||
const missing = all.filter((f) => !/export (async function generateMetadata|const (metadata|generateMetadata)\b)/.test(readFileSync(f, "utf8"))).map((f) => relative(web, f));
|
||
assert.deepEqual(missing, [], `страницы без заголовка вкладки: ${missing.join(", ")}`);
|
||
});
|
||
|
||
test("Задача во вкладке и вкладка проекта: ключ и название / вкладка, затем FORGE", () => {
|
||
const title = readFileSync(join(web, "lib/title.ts"), "utf8");
|
||
assert.match(title, /join\(" · "\)/);
|
||
assert.match(title, /— \$\{productName\(t\.locale\)\}/);
|
||
assert.match(readFileSync(join(web, "app/(app)/t/[key]/page.tsx"), "utf8"), /taskTitle\(/);
|
||
assert.match(readFileSync(join(web, "app/(app)/p/[key]/page.tsx"), "utf8"), /projectTitle\(t, \(await params\)\.key, t\.text\(tab\.label\)\)/);
|
||
});
|
||
});
|
||
|
||
describe("PEP-274: поле ввода чата на телефоне", () => {
|
||
const page = readFileSync(join(web, "app/(app)/chats/[chat]/page.tsx"), "utf8");
|
||
test("Подсказка видна целиком: на узком экране поле на всю ширину и не ниже двух строк", () => {
|
||
assert.match(page, /data-chat-text/);
|
||
assert.match(page, /basis-full[^"]*\[field-sizing:content\][^"]*md:basis-0/);
|
||
assert.match(page, /min-h-\[4\.25rem\][^"]*md:min-h-9/);
|
||
});
|
||
test("Кнопки удобно нажимать: «Файл», «Голосом», «Отправить» — 44 px (h-11) на телефоне", () => {
|
||
assert.match(page, /<AttachField [^>]*touch/);
|
||
assert.match(page, /<Dictate [^>]*touch/);
|
||
assert.match(page, /className="[^"]*size-11[^"]*md:h-9[^"]*" data-chat-send/);
|
||
assert.match(readFileSync(join(web, "components/AttachField.tsx"), "utf8"), /touch && "h-11 min-w-11/);
|
||
assert.match(readFileSync(join(web, "components/DictateButton.tsx"), "utf8"), /touch && "h-11 min-w-11/);
|
||
});
|
||
test("Поле выросло — кнопка жалобы держится над его верхним краем", () => {
|
||
const fb = readFileSync(join(web, "components/FeedbackButton.tsx"), "utf8");
|
||
assert.match(fb, /querySelector\("\[data-chat-composer\]"\)/);
|
||
assert.match(fb, /style=\{lift != null \? \{ bottom: lift \}/);
|
||
assert.match(fb, /h-11 min-w-11/);
|
||
});
|
||
});
|