peppa/bench/tasks/01-landing/checks/check.mjs
2026-11-17 02:09:17 +05:00

68 lines
2.3 KiB
JavaScript
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.

// BENCH-HIDDEN — скрытые проверки задачи 1 (лендинг). Агент их не видит.
import { assertText, page } from "../../../lib/check-kit.mjs";
export default [
{
name: "заглушка заменена сайтом кофейни",
async run(t) {
const html = await page(t, "/");
t.assert.ok(!html.includes("Продукт создаётся"), "на главной всё ещё заглушка");
assertText(html, "Зерно");
assertText(html, "Кофе, который обжариваем сами");
},
},
{
name: "название вкладки",
async run(t) {
const html = await page(t, "/");
const title = html.match(/<title>([^<]*)<\/title>/i)?.[1] ?? "";
t.assert.match(title.replace(/&mdash;|—|–|-/g, "—"), /Зерно\s*—\s*кофейня/i, `title: «${title}»`);
},
},
{
name: "три причины прийти",
async run(t) {
const html = await page(t, "/");
assertText(html, "обжар");
assertText(html, "десерт");
assertText(html, "розетк");
},
},
{
name: "меню с ценами",
async run(t) {
const html = await page(t, "/");
for (const [item, price] of [["эспрессо", "900"], ["капучино", "1300"], ["раф", "1600"]]) {
assertText(html, item);
assertText(html, price, `${item} — ${price}`);
}
},
},
{
name: "адрес и часы работы",
async run(t) {
const html = await page(t, "/");
assertText(html, "Панфилова, 98");
assertText(html, "8:00");
assertText(html, "22:00");
},
},
{
name: "кнопка «Позвонить» набирает номер",
async run(t) {
const html = await page(t, "/");
const link = html.match(/<a\b[^>]*href=["']tel:([^"']+)["'][^>]*>([\s\S]*?)<\/a>/i);
t.assert.ok(link, "нет ссылки tel:");
t.assert.equal(link[1].replace(/[^\d+]/g, ""), "+77011234567");
t.assert.match(link[2], /Позвонить/);
},
},
{
name: "страница для телефона",
async run(t) {
const html = await page(t, "/");
t.assert.match(html, /<meta[^>]+name=["']viewport["'][^>]*width=device-width/i);
},
},
];