Files
site/WESP_REL/tests/test_feed_consumption_ui_contract.py
T
2026-07-17 12:57:18 +03:00

42 lines
1.6 KiB
Python

"""UI-контракт /feed_consumption."""
from __future__ import annotations
import unittest
from tests.helpers.zootech_test_helpers import STATIC
class FeedConsumptionUiContractTests(unittest.TestCase):
def setUp(self) -> None:
self.html = (STATIC / "consumption.html").read_text(encoding="utf-8")
def test_fetches_sklad_api(self) -> None:
self.assertIn("fetch('/api/sklad'", self.html)
def test_feed_accounting_modal_script(self) -> None:
self.assertIn("feed-accounting-modal.js", self.html)
self.assertIn("faSaveAllBtn", self.html)
self.assertIn('data-tab="requisites"', self.html)
self.assertIn('data-tab="signatures"', self.html)
self.assertIn('data-tab="export"', self.html)
self.assertNotIn("save_faSigZootech", self.html)
def test_consumption_export_buttons(self) -> None:
self.assertNotIn('id="exportConsumptionXlsx"', self.html)
self.assertNotIn('id="exportConsumptionPdf"', self.html)
self.assertIn('id="faExportConsumptionXlsx"', self.html)
self.assertIn('id="faExportConsumptionPdf"', self.html)
def test_notify_sanitizes_technical_messages(self) -> None:
notify_js = (STATIC / "js" / "wesp-zootech-notify.js").read_text(encoding="utf-8")
self.assertIn("userFacingMessage", notify_js)
self.assertIn("isTechnicalMessage", notify_js)
modal_js = (STATIC / "js" / "feed-accounting-modal.js").read_text(encoding="utf-8")
self.assertNotIn("err.message", modal_js)
self.assertNotIn("r.status", modal_js)
if __name__ == "__main__":
unittest.main()