Revise plain estimate answers from inline price zones

This commit is contained in:
anor
2026-12-02 23:21:25 +10:00
parent 2a3cdf8bd8
commit d908d183d5
8 changed files with 534 additions and 28 deletions
+53
View File
@@ -124,3 +124,56 @@ def test_saved_revision_reopens_inside_same_bubble(browser, site):
page.close()
assert state["bubbles"] == 1 and state["inside"]
assert "240" in state["text"] and "4 квартал 2026" in state["text"]
def test_plain_answer_zone_changes_inside_its_bubble(browser, site):
page = browser.new_page(viewport={"width": 390, "height": 844})
page.goto(site)
page.wait_for_timeout(500)
page.evaluate("""() => {
const oldFetch = window.fetch;
window.fetch = async (url, opts={}) => {
if (String(url).includes('/api/messages/30/basis')) {
if (opts.method === 'POST') return new Response(JSON.stringify({
answer:'Норма 10-08-002-02. Объём 100 шт. Ценовая зона: Хабаровский край (2 зона), 4 квартал 2026. Стоимость учтённой части: 280 ₽.'
}), {status:200,headers:{'Content-Type':'application/json'}});
return new Response(JSON.stringify({revision:'old-hash',zones:[
{zone_id:118,name:'Хабаровский край (1 зона)',periods:[{period_id:428,name:'4 квартал 2026'}]},
{zone_id:179,name:'Хабаровский край (2 зона)',periods:[{period_id:428,name:'4 квартал 2026'}]}
]}), {status:200,headers:{'Content-Type':'application/json'}});
}
return oldFetch(url,opts);
};
const answer = addMsg('ai','Норма ГЭСНм 10-08-002-02, объём работ = 100 шт.\\nВыберите ценовую зону:\\n1. Хабаровский край (1 зона)\\n2. Хабаровский край (2 зона)');
answer._messageId = 30;
bindFreeformBasis(answer);
}""")
page.locator(".inline-basis-trigger").first.click()
screenshot_dir = os.environ.get("INLINE_FREEFORM_SCREENSHOTS")
if screenshot_dir:
page.screenshot(path=str(Path(screenshot_dir) / "inline-freeform-picker.png"))
page.locator('select[aria-label="Ценовая зона"]').select_option("179")
page.locator('select[aria-label="Квартал цен"]').select_option("428")
page.locator(".inline-basis-apply").click()
page.locator(".msg-ai .ai-body", has_text="280 ₽").wait_for(timeout=10000)
assert page.locator("#messages .msg-ai").count() == 1
assert "Выберите ценовую зону" not in page.locator(".msg-ai").inner_text()
assert page.locator(".inline-basis-trigger").count() >= 1
assert page.evaluate("document.documentElement.scrollWidth <= window.innerWidth")
if screenshot_dir:
page.screenshot(path=str(Path(screenshot_dir) / "inline-freeform-updated.png"))
page.close()
def test_plain_zone_without_calculable_position_has_no_dead_selector(browser, site):
page = browser.new_page()
page.goto(site)
page.wait_for_timeout(500)
count = page.evaluate("""() => {
const answer = addMsg('ai','Выберите ценовую зону: Хабаровский край (1 зона).');
answer._messageId = 40;
bindFreeformBasis(answer);
return answer.querySelectorAll('.inline-basis-trigger').length;
}""")
page.close()
assert count == 0