|
| 1 | +# path: policylens/tests/test_ops_queue.py |
| 2 | +""" |
| 3 | +UI tests for ops queue. |
| 4 | +""" |
| 5 | + |
| 6 | +from __future__ import annotations |
| 7 | + |
| 8 | +from datetime import timedelta |
| 9 | + |
| 10 | +import pytest |
| 11 | +from django.contrib.auth import get_user_model |
| 12 | +from django.urls import reverse |
| 13 | +from django.utils import timezone |
| 14 | + |
| 15 | +from policylens.apps.claims.models import Claim, SlaClock |
| 16 | +from tests.factories import PolicyFactory |
| 17 | + |
| 18 | +User = get_user_model() |
| 19 | + |
| 20 | + |
| 21 | +@pytest.mark.django_db |
| 22 | +def test_ops_queue_empty_state(client): |
| 23 | + """Queue should render empty state when no open claims exist.""" |
| 24 | + user = User.objects.create_user(username="ops_user2", password="password123") |
| 25 | + client.force_login(user) |
| 26 | + |
| 27 | + url = reverse("ops:queue") |
| 28 | + resp = client.get(url) |
| 29 | + assert resp.status_code == 200 |
| 30 | + html = resp.content.decode("utf-8") |
| 31 | + assert "No claims to review" in html |
| 32 | + |
| 33 | + |
| 34 | +@pytest.mark.django_db |
| 35 | +def test_ops_queue_filter_priority(client): |
| 36 | + """Priority filter should reduce results.""" |
| 37 | + user = User.objects.create_user(username="ops_user3", password="password123") |
| 38 | + client.force_login(user) |
| 39 | + |
| 40 | + policy = PolicyFactory() |
| 41 | + c1 = Claim.objects.create( |
| 42 | + policy=policy, |
| 43 | + claim_type=Claim.Type.CLAIM, |
| 44 | + priority=Claim.Priority.HIGH, |
| 45 | + summary="H", |
| 46 | + created_by="x", |
| 47 | + status=Claim.Status.NEW, |
| 48 | + ) |
| 49 | + c2 = Claim.objects.create( |
| 50 | + policy=policy, |
| 51 | + claim_type=Claim.Type.CLAIM, |
| 52 | + priority=Claim.Priority.LOW, |
| 53 | + summary="L", |
| 54 | + created_by="x", |
| 55 | + status=Claim.Status.NEW, |
| 56 | + ) |
| 57 | + |
| 58 | + SlaClock.objects.create( |
| 59 | + claim=c1, started_at=c1.created_at, due_at=timezone.now() + timedelta(days=1) |
| 60 | + ) |
| 61 | + SlaClock.objects.create( |
| 62 | + claim=c2, started_at=c2.created_at, due_at=timezone.now() + timedelta(days=1) |
| 63 | + ) |
| 64 | + |
| 65 | + url = reverse("ops:queue") |
| 66 | + resp = client.get(url, data={"priority": "HIGH"}) |
| 67 | + assert resp.status_code == 200 |
| 68 | + html = resp.content.decode("utf-8") |
| 69 | + assert f"#{c1.id}" in html |
| 70 | + assert f"#{c2.id}" not in html |
0 commit comments