chore: remove runtime artifacts from repository
This commit is contained in:
@@ -46,3 +46,7 @@ secrets.*
|
|||||||
*~
|
*~
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
_tmp_*.py
|
||||||
|
output/
|
||||||
|
storage/
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
|
|
||||||
p = Path("app/templates/agreements/detail.html")
|
|
||||||
t = p.read_text(encoding="utf-8")
|
|
||||||
|
|
||||||
old_badge = (
|
|
||||||
"{% if agreement.status == 'approved' %}"
|
|
||||||
'<span class="badge text-bg-success align-self-center">\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043e</span>'
|
|
||||||
"{% else %}"
|
|
||||||
'<span class="badge text-bg-secondary align-self-center">\u0427\u0435\u0440\u043d\u043e\u0432\u0438\u043a</span>'
|
|
||||||
)
|
|
||||||
new_badge = (
|
|
||||||
"{% if agreement.status == 'approved' %}"
|
|
||||||
'<span class="badge text-bg-success align-self-center">\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043e</span>'
|
|
||||||
'<button type="button" class="btn btn-outline-warning" data-bs-toggle="modal" '
|
|
||||||
'data-bs-target="#cancelAgreementModal">\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0414\u0421</button>'
|
|
||||||
"{% elif agreement.status == 'cancelled' %}"
|
|
||||||
'<span class="badge text-bg-danger align-self-center">\u041e\u0422\u041c\u0415\u041d\u0415\u041d\u041e</span>'
|
|
||||||
"{% else %}"
|
|
||||||
'<span class="badge text-bg-secondary align-self-center">\u0427\u0435\u0440\u043d\u043e\u0432\u0438\u043a</span>'
|
|
||||||
)
|
|
||||||
|
|
||||||
if old_badge in t:
|
|
||||||
t = t.replace(old_badge, new_badge)
|
|
||||||
print("badge replaced")
|
|
||||||
else:
|
|
||||||
print("badge NOT found")
|
|
||||||
|
|
||||||
# The file uses HTML entities for Russian text - find and replace using entity form
|
|
||||||
# Look for the actual bytes in file
|
|
||||||
old_ent = "{% if agreement.status == 'approved' %}"
|
|
||||||
idx = t.find(old_ent)
|
|
||||||
if idx >= 0:
|
|
||||||
# Find the closing {% endif %} after this
|
|
||||||
end = t.find("{% endif %}", idx)
|
|
||||||
end += len("{% endif %}")
|
|
||||||
old_block = t[idx:end]
|
|
||||||
print("OLD BLOCK:", repr(old_block[:200]))
|
|
||||||
new_block = (
|
|
||||||
"{% if agreement.status == 'approved' %}"
|
|
||||||
'<span class="badge text-bg-success align-self-center">\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043e</span>'
|
|
||||||
'<button type="button" class="btn btn-outline-warning" data-bs-toggle="modal" '
|
|
||||||
'data-bs-target="#cancelAgreementModal">\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0414\u0421</button>'
|
|
||||||
"{% elif agreement.status == 'cancelled' %}"
|
|
||||||
'<span class="badge text-bg-danger align-self-center">\u041e\u0422\u041c\u0415\u041d\u0415\u041d\u041e</span>'
|
|
||||||
"{% else %}"
|
|
||||||
'<span class="badge text-bg-secondary align-self-center">\u0427\u0435\u0440\u043d\u043e\u0432\u0438\u043a</span>'
|
|
||||||
'<button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" '
|
|
||||||
'data-bs-target="#deleteAgreementModal">\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0414\u0421</button>'
|
|
||||||
"{% endif %}"
|
|
||||||
)
|
|
||||||
t = t.replace(old_block, new_block)
|
|
||||||
print("badge block replaced")
|
|
||||||
|
|
||||||
old_modal = "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0414\u0421</button></form></div></div></div></div>"
|
|
||||||
cancel_modal = (
|
|
||||||
'<div class="modal fade" id="cancelAgreementModal" tabindex="-1">'
|
|
||||||
'<div class="modal-dialog"><div class="modal-content">'
|
|
||||||
'<div class="modal-header"><h2 class="modal-title fs-5">\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0414\u0421</h2>'
|
|
||||||
'<button type="button" class="btn-close" data-bs-dismiss="modal"></button></div>'
|
|
||||||
'<div class="modal-body"><p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u043c\u0435\u043d\u044b \u0414\u0421 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u043b\u0430\u043d\u0435. \u0418\u0441\u0442\u043e\u0440\u0438\u044f \u0414\u0421 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f.</p></div>'
|
|
||||||
'<div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">\u041d\u0430\u0437\u0430\u0434</button>'
|
|
||||||
'<form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/cancel">'
|
|
||||||
'<button class="btn btn-warning">\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u0414\u0421</button></form></div>'
|
|
||||||
"</div></div></div>" + old_modal
|
|
||||||
)
|
|
||||||
|
|
||||||
if old_modal in t:
|
|
||||||
t = t.replace(old_modal, cancel_modal)
|
|
||||||
print("modal replaced")
|
|
||||||
else:
|
|
||||||
print("modal NOT found")
|
|
||||||
|
|
||||||
p.write_text(t, encoding="utf-8")
|
|
||||||
print("done")
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
"""Browser smoke for DOC-B6 (temporary)."""
|
|
||||||
import pathlib
|
|
||||||
from datetime import date
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from playwright.sync_api import sync_playwright
|
|
||||||
|
|
||||||
from app.main import app
|
|
||||||
from app.database.database import SessionLocal
|
|
||||||
from app.models.boq import BoqDocument, WorkItem
|
|
||||||
from app.models.daily_report import DailyReport, DailyReportItem
|
|
||||||
from app.models.project import Project
|
|
||||||
from app.services.ks2_service import cancel_ks2, issue_ks2, save_draft as save_ks2_draft
|
|
||||||
from app.services.ks3_service import cancel_ks3, issue_ks3, save_draft as save_ks3_draft
|
|
||||||
|
|
||||||
BASE = "http://127.0.0.1:8026"
|
|
||||||
results = []
|
|
||||||
|
|
||||||
|
|
||||||
def ok(name, cond, detail=""):
|
|
||||||
results.append((name, bool(cond), detail))
|
|
||||||
print(("PASS" if cond else "FAIL"), name, detail)
|
|
||||||
|
|
||||||
|
|
||||||
db = SessionLocal()
|
|
||||||
p = Project(name="B6 smoke", status="active")
|
|
||||||
db.add(p)
|
|
||||||
db.flush()
|
|
||||||
doc = BoqDocument(project_id=p.id, name="BOQ")
|
|
||||||
db.add(doc)
|
|
||||||
db.flush()
|
|
||||||
wi = WorkItem(project_id=p.id, boq_document_id=doc.id, name="W", unit="шт",
|
|
||||||
quantity=Decimal("100"), unit_price=Decimal("10"), amount=Decimal("1000"))
|
|
||||||
db.add(wi)
|
|
||||||
db.flush()
|
|
||||||
dr = DailyReport(project_id=p.id, report_date=date(2026, 2, 1))
|
|
||||||
db.add(dr)
|
|
||||||
db.flush()
|
|
||||||
db.add(DailyReportItem(daily_report_id=dr.id, work_item_id=wi.id, completed_quantity=Decimal("50")))
|
|
||||||
db.commit()
|
|
||||||
pid, wi_id = p.id, wi.id
|
|
||||||
|
|
||||||
# Draft KS-2
|
|
||||||
draft2 = save_ks2_draft(db, pid, "K2-SM", date(2026, 3, 1), None,
|
|
||||||
[(wi_id, Decimal("10"))],
|
|
||||||
reporting_period_from=date(2026, 2, 1),
|
|
||||||
reporting_period_to=date(2026, 2, 28))
|
|
||||||
db.commit()
|
|
||||||
draft2_id = draft2.id
|
|
||||||
|
|
||||||
# Issued KS-2
|
|
||||||
ks2 = issue_ks2(db, pid, draft2_id)
|
|
||||||
ks2_id = ks2.id
|
|
||||||
|
|
||||||
# Issued KS-3
|
|
||||||
draft3 = save_ks3_draft(db, pid, "K3-SM", date(2026, 4, 1), None, [ks2_id],
|
|
||||||
reporting_period_from=date(2026, 2, 1),
|
|
||||||
reporting_period_to=date(2026, 2, 28))
|
|
||||||
db.commit()
|
|
||||||
ks3 = issue_ks3(db, pid, draft3.id)
|
|
||||||
ks3_id = ks3.id
|
|
||||||
|
|
||||||
# Cancelled KS-2 copy
|
|
||||||
draft2b = save_ks2_draft(db, pid, "K2-SM-C", date(2026, 3, 2), None,
|
|
||||||
[(wi_id, Decimal("5"))],
|
|
||||||
reporting_period_from=date(2026, 2, 1),
|
|
||||||
reporting_period_to=date(2026, 2, 28))
|
|
||||||
db.commit()
|
|
||||||
ks2c = issue_ks2(db, pid, draft2b.id)
|
|
||||||
cancel_ks2(db, pid, ks2c.id)
|
|
||||||
ks2c_id = ks2c.id
|
|
||||||
|
|
||||||
# Separate draft that stays draft
|
|
||||||
draft_only = save_ks2_draft(db, pid, "K2-SM-D", date(2026, 3, 3), None,
|
|
||||||
[(wi_id, Decimal("3"))],
|
|
||||||
reporting_period_from=date(2026, 2, 1),
|
|
||||||
reporting_period_to=date(2026, 2, 28))
|
|
||||||
db.commit()
|
|
||||||
draft_only_id = draft_only.id
|
|
||||||
|
|
||||||
db.close()
|
|
||||||
print("SEEDED", pid, "draft2", draft2_id, "ks2", ks2_id, "ks3", ks3_id, "ks2c", ks2c_id)
|
|
||||||
|
|
||||||
with sync_playwright() as pw:
|
|
||||||
b = pw.chromium.launch(headless=True)
|
|
||||||
ctx = b.new_context(accept_downloads=True, viewport={"width": 1280, "height": 900})
|
|
||||||
page = ctx.new_page()
|
|
||||||
|
|
||||||
# Draft KS-2: no official button
|
|
||||||
page.goto(f"{BASE}/projects/{pid}/ks2/{draft_only_id}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
ok("draft-ks2-no-btn", "Официальная форма" not in page.content())
|
|
||||||
|
|
||||||
# Issued KS-2: button present, download works
|
|
||||||
page.goto(f"{BASE}/projects/{pid}/ks2/{ks2_id}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
html = page.content()
|
|
||||||
ok("issued-ks2-btn", "Официальная форма" in html)
|
|
||||||
ok("issued-ks2-export-still-there", "Excel" in html and "Word" in html)
|
|
||||||
with page.expect_download() as dl:
|
|
||||||
page.locator("a", has_text="Официальная форма").click()
|
|
||||||
d = dl.value
|
|
||||||
fname = d.suggested_filename
|
|
||||||
ok("ks2-download-filename", "КС-2" in fname and fname.endswith(".xlsx"), fname)
|
|
||||||
pathlib.Path("output").mkdir(exist_ok=True)
|
|
||||||
d.save_as("output/smoke_b6_ks2.xlsx")
|
|
||||||
ok("ks2-download-size", pathlib.Path("output/smoke_b6_ks2.xlsx").stat().st_size > 100)
|
|
||||||
|
|
||||||
# Cancelled KS-2: button + СТОРНИРОВАН badge
|
|
||||||
page.goto(f"{BASE}/projects/{pid}/ks2/{ks2c_id}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
html = page.content()
|
|
||||||
ok("cancelled-ks2-btn", "Официальная форма" in html)
|
|
||||||
ok("cancelled-ks2-storno", "СТОРНИРОВАН" in html)
|
|
||||||
with page.expect_download() as dl:
|
|
||||||
page.locator("a", has_text="Официальная форма").click()
|
|
||||||
d = dl.value
|
|
||||||
ok("cancelled-ks2-download", d.suggested_filename.endswith(".xlsx"), d.suggested_filename)
|
|
||||||
|
|
||||||
# Issued KS-3: button + download
|
|
||||||
page.goto(f"{BASE}/projects/{pid}/ks3/{ks3_id}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
html = page.content()
|
|
||||||
ok("issued-ks3-btn", "Официальная форма" in html)
|
|
||||||
ok("issued-ks3-word-label", "Word" in html)
|
|
||||||
with page.expect_download() as dl:
|
|
||||||
page.locator("a", has_text="Официальная форма").click()
|
|
||||||
d = dl.value
|
|
||||||
ok("ks3-download-filename", "КС-3" in d.suggested_filename and d.suggested_filename.endswith(".docx"), d.suggested_filename)
|
|
||||||
d.save_as("output/smoke_b6_ks3.docx")
|
|
||||||
ok("ks3-download-size", pathlib.Path("output/smoke_b6_ks3.docx").stat().st_size > 100)
|
|
||||||
|
|
||||||
# Existing export still works
|
|
||||||
page.goto(f"{BASE}/projects/{pid}/ks2/{ks2_id}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
with page.expect_download() as dl:
|
|
||||||
page.locator("a", has_text="Excel").first.click()
|
|
||||||
ok("legacy-export-works", dl.value.suggested_filename.endswith(".xlsx"))
|
|
||||||
|
|
||||||
b.close()
|
|
||||||
|
|
||||||
print("\nSUMMARY", sum(1 for r in results if r[1]), "/", len(results))
|
|
||||||
for n, p, d in results:
|
|
||||||
if not p:
|
|
||||||
print("FAIL", n, d)
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
"""Browser smoke for task 029 (temporary)."""
|
|
||||||
from datetime import date
|
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from playwright.sync_api import sync_playwright
|
|
||||||
|
|
||||||
from app.main import app
|
|
||||||
from app.database.database import SessionLocal
|
|
||||||
from app.models.project import Project
|
|
||||||
from app.models.agreement import Agreement, AgreementItem
|
|
||||||
from app.models.boq import BoqDocument, System, WorkItem
|
|
||||||
|
|
||||||
BASE = "http://127.0.0.1:8029"
|
|
||||||
PID = 2
|
|
||||||
results = []
|
|
||||||
|
|
||||||
|
|
||||||
def ok(name, cond, detail=""):
|
|
||||||
results.append((name, bool(cond), detail))
|
|
||||||
print(("PASS" if cond else "FAIL"), name, detail)
|
|
||||||
|
|
||||||
|
|
||||||
db = SessionLocal()
|
|
||||||
p = db.query(Project).filter_by(id=PID).first()
|
|
||||||
doc = db.query(BoqDocument).filter_by(project_id=PID).first()
|
|
||||||
system = db.query(System).filter_by(project_id=PID).first()
|
|
||||||
wi = db.query(WorkItem).filter(
|
|
||||||
WorkItem.project_id == PID,
|
|
||||||
WorkItem.system_id.isnot(None),
|
|
||||||
WorkItem.quantity > 0,
|
|
||||||
).first()
|
|
||||||
assert p and doc and system and wi
|
|
||||||
sys_id, wi_id, doc_id = system.id, wi.id, doc.id
|
|
||||||
print("ctx", PID, doc_id, sys_id, wi_id)
|
|
||||||
db.close()
|
|
||||||
|
|
||||||
|
|
||||||
def make_draft(number):
|
|
||||||
import time
|
|
||||||
number = f"{number}-{int(time.time() * 1000) % 100000}"
|
|
||||||
db = SessionLocal()
|
|
||||||
a = Agreement(
|
|
||||||
project_id=PID, number=number, date=date(2026, 1, 1),
|
|
||||||
title=f"Smoke {number}", status="draft", boq_document_id=doc_id,
|
|
||||||
)
|
|
||||||
db.add(a)
|
|
||||||
db.commit()
|
|
||||||
aid = a.id
|
|
||||||
db.close()
|
|
||||||
return aid
|
|
||||||
|
|
||||||
|
|
||||||
with sync_playwright() as pw:
|
|
||||||
b = pw.chromium.launch(headless=True)
|
|
||||||
page = b.new_page(viewport={"width": 1280, "height": 900})
|
|
||||||
page.on("dialog", lambda d: d.accept())
|
|
||||||
|
|
||||||
# 2-5. Empty draft: button exists, delete works
|
|
||||||
aid = make_draft("SM-EMPTY")
|
|
||||||
page.goto(f"{BASE}/projects/{PID}/agreements/{aid}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
ok("empty-draft-btn", page.locator("button[data-bs-target='#deleteAgreementModal']").count() == 1)
|
|
||||||
ok("empty-draft-modal", "deleteAgreementModal" in page.content())
|
|
||||||
page.locator("button[data-bs-target='#deleteAgreementModal']").click()
|
|
||||||
page.wait_for_timeout(300)
|
|
||||||
page.locator("#deleteAgreementModal button.btn-danger").click()
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
ok("empty-deleted", "agreements" in page.url and "deleted=1" in page.url, page.url)
|
|
||||||
ok("empty-flash", "Черновик ДС удалён" in page.content())
|
|
||||||
db = SessionLocal()
|
|
||||||
ok("empty-gone", db.get(Agreement, aid) is None)
|
|
||||||
db.close()
|
|
||||||
|
|
||||||
# 6-8. Draft with existing item: base WorkItem preserved
|
|
||||||
aid = make_draft("SM-EXIST")
|
|
||||||
page.goto(f"{BASE}/projects/{PID}/agreements/{aid}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
page.fill("#existing-position-search", "")
|
|
||||||
page.wait_for_timeout(200)
|
|
||||||
# pick first autocomplete option
|
|
||||||
page.locator(".autocomplete-position").first.click()
|
|
||||||
page.locator("form[action$='/items/existing'] input[name=quantity_delta]").fill("3")
|
|
||||||
page.locator("button", has_text="Добавить позицию").click()
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
ok("existing-added", "Увеличение" in page.content() or "3" in page.content())
|
|
||||||
page.locator("button[data-bs-target='#deleteAgreementModal']").click()
|
|
||||||
page.wait_for_timeout(300)
|
|
||||||
page.locator("#deleteAgreementModal button.btn-danger").click()
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
db = SessionLocal()
|
|
||||||
ok("existing-agr-gone", db.get(Agreement, aid) is None)
|
|
||||||
ok("base-wi-kept", db.get(WorkItem, wi_id) is not None)
|
|
||||||
db.close()
|
|
||||||
|
|
||||||
# 9-11. Draft with new_position: orphan WorkItem removed
|
|
||||||
aid = make_draft("SM-NEW")
|
|
||||||
page.goto(f"{BASE}/projects/{PID}/agreements/{aid}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
page.locator("form[action$='/items/new'] input[name=name]").fill("Сирота 029")
|
|
||||||
page.locator("form[action$='/items/new'] input[name=quantity_delta]").fill("2")
|
|
||||||
page.locator("form[action$='/items/new'] input[name=unit_price]").fill("5")
|
|
||||||
page.select_option("form[action$='/items/new'] select[name=system_id]", str(sys_id))
|
|
||||||
page.wait_for_timeout(100)
|
|
||||||
page.select_option("form[action$='/items/new'] select[name=section_id]", str(wi.section_id or 0) if False else page.locator("form[action$='/items/new'] select[name=section_id] option").nth(1).get_attribute("value"))
|
|
||||||
page.locator("button", has_text="Добавить новую позицию").click()
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
ok("new-added", "Сирота 029" in page.content() or "Новая" in page.content())
|
|
||||||
db = SessionLocal()
|
|
||||||
orphan = db.query(WorkItem).filter_by(name="Сирота 029").first()
|
|
||||||
orphan_id = orphan.id if orphan else None
|
|
||||||
db.close()
|
|
||||||
ok("orphan-created", orphan_id is not None)
|
|
||||||
page.locator("button[data-bs-target='#deleteAgreementModal']").click()
|
|
||||||
page.wait_for_timeout(300)
|
|
||||||
page.locator("#deleteAgreementModal button.btn-danger").click()
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
db = SessionLocal()
|
|
||||||
ok("new-agr-gone", db.get(Agreement, aid) is None)
|
|
||||||
ok("orphan-wi-gone", orphan_id is None or db.get(WorkItem, orphan_id) is None)
|
|
||||||
db.close()
|
|
||||||
|
|
||||||
# 12-13. Approved cannot be deleted
|
|
||||||
db = SessionLocal()
|
|
||||||
a = Agreement(project_id=PID, number="SM-APPR", date=date(2026, 1, 1),
|
|
||||||
title="Approved smoke", status="approved", boq_document_id=doc_id)
|
|
||||||
db.add(a)
|
|
||||||
db.commit()
|
|
||||||
appr_id = a.id
|
|
||||||
db.close()
|
|
||||||
page.goto(f"{BASE}/projects/{PID}/agreements/{appr_id}")
|
|
||||||
page.wait_for_load_state("networkidle")
|
|
||||||
ok("approved-no-btn", page.locator("button[data-bs-target='#deleteAgreementModal']").count() == 0)
|
|
||||||
ok("approved-no-modal", "deleteAgreementModal" not in page.content())
|
|
||||||
# direct POST blocked
|
|
||||||
resp = page.request.post(f"{BASE}/projects/{PID}/agreements/{appr_id}/delete")
|
|
||||||
ok("approved-post-blocked", resp.status == 409, str(resp.status))
|
|
||||||
page.screenshot(path="output/playwright/029-approved-no-delete.png")
|
|
||||||
|
|
||||||
b.close()
|
|
||||||
|
|
||||||
print("\nSUMMARY", sum(1 for r in results if r[1]), "/", len(results))
|
|
||||||
for n, p, d in results:
|
|
||||||
if not p:
|
|
||||||
print("FAIL", n, d)
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user