refactor next push

This commit is contained in:
Mateusz Gruszczyński
2026-03-14 23:17:05 +01:00
parent a16798553e
commit 3a57f2f1d7
37 changed files with 4012 additions and 658 deletions

70
tests/test_refactor.py Normal file
View File

@@ -0,0 +1,70 @@
import unittest
from pathlib import Path
from shopping_app import app
class RefactorSmokeTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
app.config.update(TESTING=True)
cls.client = app.test_client()
def test_undefined_path_returns_not_500(self):
response = self.client.get('/undefined')
self.assertNotEqual(response.status_code, 500)
self.assertEqual(response.status_code, 404)
def test_login_page_renders(self):
response = self.client.get('/login')
self.assertEqual(response.status_code, 200)
html = response.get_data(as_text=True)
self.assertIn('name="password"', html)
self.assertIn('app_ui.js', html)
class TemplateContractTests(unittest.TestCase):
def test_main_template_uses_single_action_group_on_mobile(self):
main_html = Path('shopping_app/templates/main.html').read_text(encoding='utf-8')
self.assertIn('mobile-list-heading', main_html)
self.assertIn('list-main-title__link', main_html)
self.assertNotIn('d-flex d-sm-none" role="group"', main_html)
def test_list_templates_use_compact_mobile_action_layout(self):
list_html = Path('shopping_app/templates/list.html').read_text(encoding='utf-8')
shared_html = Path('shopping_app/templates/list_share.html').read_text(encoding='utf-8')
for html in (list_html, shared_html):
self.assertIn('shopping-item-row', html)
self.assertIn('shopping-item-actions', html)
self.assertIn('shopping-compact-input-group', html)
self.assertIn('shopping-item-head', html)
def test_css_contains_mobile_ux_overrides(self):
css = Path('shopping_app/static/css/style.css').read_text(encoding='utf-8')
self.assertIn('.shopping-item-actions', css)
self.assertIn('.shopping-compact-input-group', css)
self.assertIn('.ui-password-group > .ui-password-toggle', css)
self.assertIn('.hide-purchased-switch--minimal', css)
self.assertIn('.shopping-item-head', css)
self.assertIn('UX tweak 2026-03-14 c: hamburger with full labels', css)
if __name__ == '__main__':
unittest.main()
class NavbarContractTests(unittest.TestCase):
def test_base_template_uses_mobile_collapse_nav(self):
base_html = Path('shopping_app/templates/base.html').read_text(encoding='utf-8')
self.assertIn('navbar-toggler', base_html)
self.assertIn('appNavbarMenu', base_html)
def test_base_template_mobile_nav_has_full_labels(self):
base_html = Path('shopping_app/templates/base.html').read_text(encoding='utf-8')
self.assertIn('>📊 <span>Wydatki</span><', base_html)
self.assertIn('>🚪 <span>Wyloguj</span><', base_html)
def test_main_template_temp_toggle_is_integrated(self):
main_html = Path('shopping_app/templates/main.html').read_text(encoding='utf-8')
self.assertIn('create-list-temp-toggle', main_html)