Распоряжения Хозяина 08.09.2026: на странице входа добавить полосу о том, что сайт ещё в разработке (не заменяя страницу), а внизу чата — адрес info@infosmeta.ru. Полоса стоит над посадочной частью и уходит вместе с экраном входа; адрес живёт вне ленты сообщений, поэтому не стирается при создании нового диалога. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RuEU1u9Rz24zmoy9TuvWc2
124 lines
6.4 KiB
Python
124 lines
6.4 KiB
Python
"""Полоса «Сайт ещё в разработке» глазами браузера.
|
||
|
||
Гоняем настоящий static/chat.html через стенд tests/ui_smoke_harness.py: важно не только
|
||
наличие полосы в исходнике, но и то, что она не сломала раскладку экрана входа.
|
||
|
||
Red-green: написано ДО правки static/chat.html.
|
||
"""
|
||
|
||
import os
|
||
import sys
|
||
|
||
import pytest
|
||
|
||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
if ROOT not in sys.path:
|
||
sys.path.insert(0, ROOT)
|
||
|
||
pytest.importorskip("playwright.sync_api", reason="playwright не установлен")
|
||
|
||
import ui_smoke_harness # noqa: E402
|
||
# Стенд и запуск браузера общие с проверками восстановления доступа — второй копии не нужно.
|
||
from test_password_reset_ui import _launch, browser, site # noqa: E402,F401
|
||
|
||
|
||
@pytest.fixture()
|
||
def page(browser, site):
|
||
ctx = browser.new_context(viewport={"width": 1280, "height": 900})
|
||
pg = ctx.new_page()
|
||
pg.set_default_timeout(5000)
|
||
pg.goto(site)
|
||
pg.wait_for_selector("#login-form")
|
||
yield pg
|
||
ctx.close()
|
||
|
||
|
||
def _box(page, selector):
|
||
return page.locator(selector).bounding_box()
|
||
|
||
|
||
def test_banner_visible_on_wide_screen(page):
|
||
"""Полоса одна, видна и целиком помещается в окно.
|
||
Порча: спрятать полосу или удалить её → проверка упадёт."""
|
||
assert page.locator("#dev-banner").count() == 1
|
||
assert page.is_visible("#dev-banner")
|
||
b = _box(page, "#dev-banner")
|
||
assert b["y"] >= 0 and b["y"] + b["height"] <= 900
|
||
assert "в разработке" in page.inner_text("#dev-banner").lower()
|
||
|
||
|
||
def test_banner_spans_top_above_landing(page):
|
||
"""Полоса тянется во всю ширину и стоит НАД посадочной частью.
|
||
Порча: убрать flex-direction: column у экрана входа → полоса станет узким столбцом сбоку."""
|
||
b = _box(page, "#dev-banner")
|
||
land = _box(page, ".landing")
|
||
assert b["width"] >= 0.95 * 1280, f"полоса шириной {b['width']}"
|
||
assert b["y"] + b["height"] <= land["y"] + 1, "полоса не над посадочной частью"
|
||
|
||
|
||
def test_form_stays_beside_hero_on_wide_screen(page):
|
||
"""Форма входа осталась справа от рассказа о сервисе и целиком в окне — «не менять всю
|
||
страницу на баннер». Порча: перенос строк у .landing или толстые отступы у полосы →
|
||
форма уедет вниз или за нижний край."""
|
||
form = _box(page, "#login-form")
|
||
hero = _box(page, ".landing-hero")
|
||
assert form["x"] >= hero["x"] + hero["width"] - 1, "форма съехала под рассказ о сервисе"
|
||
assert form["y"] < hero["y"] + hero["height"]
|
||
assert form["y"] + form["height"] <= 900
|
||
|
||
|
||
def test_banner_visible_on_phone_no_sideways_scroll(browser, site):
|
||
"""На телефоне полоса видна сразу, страница не уезжает вбок и экран не прокручен к форме.
|
||
Порча: white-space: nowrap → появится боковая прокрутка."""
|
||
ctx = browser.new_context(viewport={"width": 360, "height": 740})
|
||
pg = ctx.new_page()
|
||
pg.set_default_timeout(5000)
|
||
pg.goto(site)
|
||
pg.wait_for_selector("#login-form")
|
||
b = _box(pg, "#dev-banner")
|
||
over = pg.evaluate(
|
||
"document.documentElement.scrollWidth - document.documentElement.clientWidth")
|
||
top = pg.evaluate("document.getElementById('login-screen').scrollTop")
|
||
hit = pg.evaluate(
|
||
"([x, y]) => { const e = document.elementFromPoint(x, y);"
|
||
" return e && e.closest('#dev-banner') !== null; }",
|
||
[180, b["y"] + b["height"] / 2])
|
||
ctx.close()
|
||
assert b["y"] >= 0 and b["y"] + b["height"] <= 740, "полоса не видна на телефоне"
|
||
assert over <= 1, f"страница шире экрана на {over} точек"
|
||
assert top == 0, "экран прокручен к форме, полосу человек не увидит"
|
||
assert hit, "полосу что-то перекрывает"
|
||
|
||
|
||
def test_banner_readable_in_dark_theme(browser, site):
|
||
"""В тёмной теме текст полосы того же цвета, что заголовок рядом, а фон и рамка меняются
|
||
вместе с темой. Порча: задать цвет числом → в тёмной теме он останется светлым."""
|
||
ctx = browser.new_context(viewport={"width": 1280, "height": 900})
|
||
pg = ctx.new_page()
|
||
pg.set_default_timeout(5000)
|
||
pg.goto(site)
|
||
pg.wait_for_selector("#dev-banner")
|
||
light_bg = pg.evaluate("getComputedStyle(document.getElementById('dev-banner')).backgroundColor")
|
||
light_border = pg.evaluate(
|
||
"getComputedStyle(document.getElementById('dev-banner')).borderBottomColor")
|
||
pg.evaluate("document.documentElement.setAttribute('data-theme','dark')")
|
||
dark_bg = pg.evaluate("getComputedStyle(document.getElementById('dev-banner')).backgroundColor")
|
||
dark_border = pg.evaluate(
|
||
"getComputedStyle(document.getElementById('dev-banner')).borderBottomColor")
|
||
color = pg.evaluate("getComputedStyle(document.getElementById('dev-banner')).color")
|
||
h1 = pg.evaluate("getComputedStyle(document.querySelector('.landing-hero h1')).color")
|
||
ctx.close()
|
||
assert color == h1, f"текст полосы {color}, а заголовок {h1}"
|
||
assert dark_bg != light_bg and dark_border != light_border, "фон полосы не меняется с темой"
|
||
|
||
|
||
def test_login_still_works_and_banner_leaves_with_the_screen(page):
|
||
"""Вход работает, а после входа полоса уходит вместе с экраном входа — в чате её нет.
|
||
Порча: вынести полосу на уровень страницы → останется висеть над чатом."""
|
||
assert page.locator("#dev-banner").count() == 1
|
||
page.fill("#login-user", "kto@x.ru")
|
||
page.fill("#login-pass", "parol1")
|
||
page.click("#login-form button[type=submit]")
|
||
page.wait_for_selector("#chat-screen", state="visible")
|
||
assert not page.is_visible("#dev-banner")
|