feat(админка): оболочка v2 с пятью разделами
This commit is contained in:
@@ -162,6 +162,13 @@
|
||||
- CI: `py_compile *.py`, `bash -n scripts/*.sh`, `py_compile scripts/*.py`, весь `tests/`.
|
||||
- Тесты: `tests/test_requirements_split.py` — 3 passed.
|
||||
|
||||
## 4.17. P2.1a/b — оболочка v2
|
||||
|
||||
- `static/admin2/index.html`, `app.js`, `router.js`, `styles.css`, vendor Preact/htm; 5 разделов.
|
||||
- Абсолютные импорты `/static/admin2/...`; CSP без `unsafe-inline`; deep link `/admin/v2/customers` и F5.
|
||||
- Тесты: `tests/test_admin_v2_shell.py` — 3 passed (deep link, 5 разделов, отсутствие inline).
|
||||
- Backend-маршрут `/admin/v2` — P2.2, пока статика не подключена к main.
|
||||
|
||||
## 5. Следующий шаг
|
||||
|
||||
P0.0 design-gate → P0.1 backup/restore → P0.2 (release `feat/topup` отдельно, не в рамках выравнивания).
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
- P0.1 — прод-бэкап `2026-11-06_1632.gz` (2,7 МБ gz / 12 МБ), `integrity_check=ok`, users 24, messages 5397; `SMETA_USER/PASS` заданы (env-вход — реальный); индекс на копии 46 мс. Админка на копии открыта (`/admin` 200, users/stats/overview 200). Осталось: 5 вопросов владельца.
|
||||
- P0.2 — выравнивание сделано; pre-release `feat/topup` проверен: 155 тестов зелёные, отчёт `docs/ADMIN_V2_TOPUP_PRERELEASE.md`; **релиз не начинался** (нужен go/no-go и тест-магазин).
|
||||
- **P0.5 — готово:** спайк в `sandbox/admin-spike/`; Preact+htm: 8,7 КБ gzip, 106 строк, 37,2 мс; vanilla: 3,3 КБ, 116 строк, 34,5 мс; CSP 0 ошибок у обоих; решение — Preact+htm, fallback vanilla; ревью Зайкой 3 круга, последний без дефектов. `docs/ADMIN_V2_DECISIONS.md`.
|
||||
- **P2.1a/b — готово:** оболочка `/static/admin2/` (5 разделов, Preact+htm, абсолютные импорты), deep link + F5, CSP без inline, 3 теста; Зайка P2 (дубли путей/заголовков) исправлены.
|
||||
- **P1.8b — готово:** `requirements-dev.txt` (pytest+playwright) и `requirements-prod-test.txt` (pytest без браузера); прод `requirements.txt` не тронут; 3 теста.
|
||||
- **P1.10 — готово:** CI уже гоняет весь `tests/`; добавлена проверка синтаксиса `scripts/*.sh`/`scripts/*.py`.
|
||||
- **P1.8 — частично:** `predeploy.sh` (prod только с копией и pytest, realpath+inode, migrate→gate→pytest; dev — полный набор), `deploy.sh --no-pull/--check/ROLLBACK_TAG/ROLLBACK_FLOOR` с отказом ниже/вне пола и `pip install` после отката. 7 тестов; Зайка P1 (exit-код, фиктивный тест HEAD, пол) исправлены.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { h, render } from '/static/admin2/vendor/preact.module.js';
|
||||
import htm from '/static/admin2/vendor/htm.module.js';
|
||||
import { SECTIONS, sectionFromPath, hrefFor } from '/static/admin2/router.js';
|
||||
|
||||
const html = htm.bind(h);
|
||||
const TITLES = {
|
||||
today: ["Мой день", "Что требует внимания сегодня"],
|
||||
customers: ["Клиенты", "Кто платит, кто ушёл и кого надо вернуть"],
|
||||
money: ["Деньги", "Поступления, поток и обязательства"],
|
||||
work: ["Работа", "Очередь, прогоны и сбои"],
|
||||
system: ["Система", "Здоровье службы и настройки"],
|
||||
};
|
||||
const section = sectionFromPath(location.pathname);
|
||||
const [title, subtitle] = TITLES[section]
|
||||
|| [SECTIONS.find(([key]) => key === section)?.[1] || 'Раздел', ''];
|
||||
|
||||
const App = () => html`
|
||||
<div class="shell">
|
||||
<nav class="side" aria-label="Разделы">
|
||||
<a class="brand" href=${hrefFor('today')}>smeta<span>·</span>кокпит</a>
|
||||
${SECTIONS.map(([key, label, href]) => html`
|
||||
<a key=${key} href=${href} class=${'nav-link' + (key === section ? ' active' : '')}
|
||||
aria-current=${key === section ? 'page' : null}>${label}</a>`)}
|
||||
</nav>
|
||||
<main class="main">
|
||||
<header class="top"><div><h1>${title}</h1><p>${subtitle}</p></div></header>
|
||||
<section class="card" aria-labelledby="placeholder">
|
||||
<h2 id="placeholder">Раздел готовится</h2>
|
||||
<p>Оболочка v2. Данные и действия подключит следующий этап.</p>
|
||||
</section>
|
||||
</main>
|
||||
</div>`;
|
||||
|
||||
render(html`<${App} />`, document.getElementById('app'));
|
||||
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:">
|
||||
<title>Кокпит — smeta-web</title>
|
||||
<link rel="stylesheet" href="/static/admin2/styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/static/admin2/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
export const BASE = "/admin/v2";
|
||||
export const SECTIONS = [
|
||||
["today", "Мой день", BASE],
|
||||
["customers", "Клиенты", `${BASE}/customers`],
|
||||
["money", "Деньги", `${BASE}/money`],
|
||||
["work", "Работа", `${BASE}/work`],
|
||||
["system", "Система", `${BASE}/system`],
|
||||
];
|
||||
|
||||
export function sectionFromPath(pathname) {
|
||||
const clean = (pathname || "").replace(/\/+$/, "");
|
||||
if (clean === BASE || clean === `${BASE}/today`) return "today";
|
||||
const found = SECTIONS.find(([, , href]) => clean === href);
|
||||
return found ? found[0] : "today";
|
||||
}
|
||||
|
||||
export function hrefFor(section) {
|
||||
const found = SECTIONS.find(([key]) => key === section);
|
||||
return found ? found[2] : BASE;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
:root{--bg:#f5f6f8;--card:#fff;--ink:#1b2433;--muted:#667085;--line:#e3e7ee;--accent:#2457d6;--side:#111827}
|
||||
*{box-sizing:border-box}
|
||||
body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}
|
||||
.shell{display:flex;min-height:100vh}
|
||||
.side{width:220px;background:var(--side);color:#cfd6e4;padding:18px 12px;display:flex;flex-direction:column;gap:4px}
|
||||
.brand{color:#fff;text-decoration:none;font-weight:700;font-size:16px;padding:6px 10px 16px}
|
||||
.brand span{color:#7ea2ff}
|
||||
.nav-link{color:#cfd6e4;text-decoration:none;padding:9px 10px;border-radius:8px}
|
||||
.nav-link:hover{background:#1f2937;color:#fff}
|
||||
.nav-link.active{background:#2457d6;color:#fff}
|
||||
.main{flex:1;min-width:0;padding:22px 26px}
|
||||
.top h1{margin:0 0 4px;font-size:22px}
|
||||
.top p{margin:0 0 18px;color:var(--muted)}
|
||||
.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:18px;max-width:760px}
|
||||
.card h2{margin:0 0 6px;font-size:16px}
|
||||
.card p{margin:0;color:var(--muted)}
|
||||
@media (max-width:720px){.shell{flex-direction:column}.side{width:auto;flex-direction:row;flex-wrap:wrap;align-items:center}.brand{padding:4px 10px;width:100%}.main{padding:16px}}
|
||||
Vendored
+202
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
var n=function(t,s,r,e){var u;s[0]=0;for(var h=1;h<s.length;h++){var p=s[h++],a=s[h]?(s[0]|=p?1:2,r[s[h++]]):s[++h];3===p?e[0]=a:4===p?e[1]=Object.assign(e[1]||{},a):5===p?(e[1]=e[1]||{})[s[++h]]=a:6===p?e[1][s[++h]]+=a+"":p?(u=t.apply(a,n(t,a,r,["",null])),e.push(u),a[0]?s[0]|=2:(s[h-2]=0,s[h]=u)):e.push(a)}return e},t=new Map;export default function(s){var r=t.get(this);return r||(r=new Map,t.set(this,r)),(r=n(this,r.get(s)||(r.set(s,r=function(n){for(var t,s,r=1,e="",u="",h=[0],p=function(n){1===r&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?h.push(0,n,e):3===r&&(n||e)?(h.push(3,n,e),r=2):2===r&&"..."===e&&n?h.push(4,n,0):2===r&&e&&!n?h.push(5,0,!0,e):r>=5&&((e||!n&&5===r)&&(h.push(r,0,e,s),r=6),n&&(h.push(r,n,0,s),r=6)),e=""},a=0;a<n.length;a++){a&&(1===r&&p(),p(a));for(var l=0;l<n[a].length;l++)t=n[a][l],1===r?"<"===t?(p(),h=[h],r=3):e+=t:4===r?"--"===e&&">"===t?(r=1,e=""):e=t+e[0]:u?t===u?u="":e+=t:'"'===t||"'"===t?u=t:">"===t?(p(),r=1):r&&("="===t?(r=5,s=e,e=""):"/"===t&&(r<5||">"===n[a][l+1])?(p(),3===r&&(h=h[0]),r=h,(h=h[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(p(),r=2):e+=t),3===r&&"!--"===e&&(r=4,h=h[0])}return p(),h}(s)),r),arguments,[])).length>1?r:r[0]}
|
||||
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,84 @@
|
||||
"""Оболочка admin v2: 5 разделов, deep link, F5, CSP без inline."""
|
||||
import functools
|
||||
import http.server
|
||||
import os
|
||||
import socketserver
|
||||
import sys
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
pytest.importorskip("playwright.sync_api", reason="playwright не установлен")
|
||||
from test_admin_design_ui import browser # noqa: E402,F401
|
||||
|
||||
|
||||
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||
def __init__(self, *a, **kw):
|
||||
super().__init__(*a, directory=str(ROOT), **kw)
|
||||
|
||||
def do_GET(self):
|
||||
if self.path == "/admin/v2" or self.path.startswith("/admin/v2/"):
|
||||
return self._file(ROOT / "static" / "admin2" / "index.html")
|
||||
return super().do_GET()
|
||||
|
||||
def _file(self, path: Path):
|
||||
data = path.read_bytes()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
|
||||
def log_message(self, *a):
|
||||
return
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def site():
|
||||
class Quiet(socketserver.ThreadingTCPServer):
|
||||
allow_reuse_address = True
|
||||
daemon_threads = True
|
||||
|
||||
srv = Quiet(("127.0.0.1", 0), Handler)
|
||||
threading.Thread(target=srv.serve_forever, daemon=True).start()
|
||||
yield f"http://127.0.0.1:{srv.server_address[1]}"
|
||||
srv.shutdown()
|
||||
|
||||
|
||||
def test_deep_link_customers_and_f5(browser, site):
|
||||
page = browser.new_page()
|
||||
errors = []
|
||||
page.on("pageerror", lambda e: errors.append(str(e)))
|
||||
page.goto(site + "/admin/v2/customers")
|
||||
page.wait_for_selector("h1")
|
||||
assert page.locator("h1").inner_text() == "Клиенты"
|
||||
assert page.locator(".nav-link.active").inner_text() == "Клиенты"
|
||||
page.reload()
|
||||
page.wait_for_selector("h1")
|
||||
assert page.locator("h1").inner_text() == "Клиенты"
|
||||
assert errors == []
|
||||
page.close()
|
||||
|
||||
|
||||
def test_five_sections_navigate(browser, site):
|
||||
page = browser.new_page()
|
||||
page.goto(site + "/admin/v2")
|
||||
page.wait_for_selector("h1")
|
||||
assert page.locator("h1").inner_text() == "Мой день"
|
||||
assert page.locator(".nav-link").count() == 5
|
||||
page.click('a[href="/admin/v2/money"]')
|
||||
page.wait_for_selector("h1")
|
||||
assert page.locator("h1").inner_text() == "Деньги"
|
||||
assert page.url.endswith("/admin/v2/money")
|
||||
page.close()
|
||||
|
||||
|
||||
def test_shell_has_no_inline_or_unsafe_csp():
|
||||
html = (ROOT / "static" / "admin2" / "index.html").read_text(encoding="utf-8")
|
||||
assert "unsafe-inline" not in html
|
||||
assert "<script>" not in html
|
||||
assert "onclick=" not in (ROOT / "static" / "admin2" / "app.js").read_text(encoding="utf-8")
|
||||
Reference in New Issue
Block a user