push
This commit is contained in:
45
tests/test_dashboard.py
Normal file
45
tests/test_dashboard.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.company import Company
|
||||
from app.models.invoice import Invoice, InvoiceStatus, InvoiceType
|
||||
|
||||
|
||||
def test_dashboard_recent_invoices_uses_10_items_per_page(auth_client, app):
|
||||
with app.app_context():
|
||||
company = Company.query.first()
|
||||
now = datetime.utcnow()
|
||||
for index in range(12):
|
||||
invoice = Invoice(
|
||||
company_id=company.id,
|
||||
ksef_number=f'KSEF-DASH-{index}',
|
||||
invoice_number=f'FV/DASH/{index}',
|
||||
contractor_name=f'Kontrahent {index}',
|
||||
issue_date=date(2026, 3, 12) - timedelta(days=index),
|
||||
received_date=date(2026, 3, 12) - timedelta(days=index),
|
||||
net_amount=100 + index,
|
||||
vat_amount=23,
|
||||
gross_amount=123 + index,
|
||||
invoice_type=InvoiceType.PURCHASE,
|
||||
status=InvoiceStatus.NEW,
|
||||
source='ksef',
|
||||
created_at=now - timedelta(minutes=index),
|
||||
)
|
||||
db.session.add(invoice)
|
||||
db.session.commit()
|
||||
|
||||
response_page_1 = auth_client.get('/')
|
||||
assert response_page_1.status_code == 200
|
||||
assert response_page_1.data.count(b'btn btn-outline-primary">Szczeg') == 10
|
||||
assert b'FV/DASH/0' in response_page_1.data
|
||||
assert b'FV/DASH/9' in response_page_1.data
|
||||
assert b'FV/DASH/10' not in response_page_1.data
|
||||
assert b'FV/DASH/11' not in response_page_1.data
|
||||
assert b'dashboard_page=2' in response_page_1.data
|
||||
|
||||
response_page_2 = auth_client.get('/?dashboard_page=2')
|
||||
assert response_page_2.status_code == 200
|
||||
assert response_page_2.data.count(b'btn btn-outline-primary">Szczeg') == 2
|
||||
assert b'FV/DASH/10' in response_page_2.data
|
||||
assert b'FV/DASH/11' in response_page_2.data
|
||||
assert b'FV/DASH/9' not in response_page_2.data
|
||||
Reference in New Issue
Block a user