feat(sqlite): refactor orders schema + dashboard period filter
Replace import_orders (insert-per-run) with orders table (one row per order, upsert on conflict). Eliminates dedup CTE on every dashboard query and prevents unbounded row growth at 4-500 orders/sync. Key changes: - orders table: PK order_number, upsert via ON CONFLICT DO UPDATE; COALESCE preserves id_comanda once set; times_skipped auto-increments - sync_run_orders: lightweight junction (sync_run_id, order_number) replaces sync_run_id column on orders - order_items: PK changed to (order_number, sku), INSERT OR IGNORE - Auto-migration in init_sqlite(): import_orders → orders on first boot, old table renamed to import_orders_bak - /api/dashboard/orders: period_days param (3/7/30/0=all, default 7) - Dashboard: period selector buttons in orders card header - start.sh: stop existing process on port 5003 before restart; remove --reload (broken on WSL2 /mnt/e/) - Add invoice_service, E2E Playwright tests, Oracle package updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
52
api/tests/e2e/test_order_detail.py
Normal file
52
api/tests/e2e/test_order_detail.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""E2E: Order detail modal structure and inline mapping."""
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
|
||||
def test_order_detail_modal_has_roa_ids(page: Page, app_url: str):
|
||||
"""R9: Verify order detail modal contains all ROA ID labels."""
|
||||
page.goto(f"{app_url}/logs")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
modal = page.locator("#orderDetailModal")
|
||||
expect(modal).to_be_attached()
|
||||
|
||||
modal_html = modal.inner_html()
|
||||
assert "ID Comanda ROA" in modal_html, "Missing 'ID Comanda ROA' label in order detail modal"
|
||||
assert "ID Partener" in modal_html, "Missing 'ID Partener' label in order detail modal"
|
||||
assert "ID Adr. Facturare" in modal_html, "Missing 'ID Adr. Facturare' label in order detail modal"
|
||||
assert "ID Adr. Livrare" in modal_html, "Missing 'ID Adr. Livrare' label in order detail modal"
|
||||
|
||||
|
||||
def test_order_detail_items_table_columns(page: Page, app_url: str):
|
||||
"""R9: Verify items table has all required columns."""
|
||||
page.goto(f"{app_url}/logs")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
headers = page.locator("#orderDetailModal thead th")
|
||||
texts = headers.all_text_contents()
|
||||
|
||||
required_columns = ["SKU", "Produs", "Cant.", "Pret", "TVA", "CODMAT", "Status", "Actiune"]
|
||||
for col in required_columns:
|
||||
assert col in texts, f"Column '{col}' missing from order detail items table. Found: {texts}"
|
||||
|
||||
|
||||
def test_quick_map_from_order_detail(page: Page, app_url: str):
|
||||
"""R9+R11: Verify quick map modal is reachable from order detail context."""
|
||||
page.goto(f"{app_url}/logs")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
modal = page.locator("#quickMapModal")
|
||||
expect(modal).to_be_attached()
|
||||
|
||||
expect(page.locator("#qmCodmatLines")).to_be_attached()
|
||||
expect(page.locator("#qmPctWarning")).to_be_attached()
|
||||
|
||||
|
||||
def test_dashboard_navigates_to_logs(page: Page, app_url: str):
|
||||
"""Verify the sidebar on the dashboard contains a link to the logs page."""
|
||||
page.goto(f"{app_url}/")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
logs_link = page.locator("a[href='/logs']")
|
||||
expect(logs_link).to_be_visible()
|
||||
Reference in New Issue
Block a user