"""Phase 4 exit: a feature with a prototype image has a pinned thread; an implementation shows one feature shipped and one behind. Driven through the views.""" from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse from intent.comments.models import CommentThread, ThreadKind from intent.features.models import Feature P = {"org_slug": "catbriar", "project_slug": "intent"} PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 64 def test_prototype_pin_and_implementation_status(client, open_project, editor, outsider): client.force_login(editor) for title in ("Checkout", "Receipts"): client.post(reverse("features:create", kwargs=P), {"title": title, "note": ""}) checkout, receipts = Feature.objects.order_by("number") # A prototype image on the feature. client.post( reverse("files:add", kwargs={**P, "feature_key": checkout.key}), { "kind": "prototype", "upload": SimpleUploadedFile("checkout.png", PNG), "note": "First mockup", }, ) file = checkout.files.get() # Someone pins a comment to a point on it. client.force_login(outsider) client.post( reverse( "files:thread_create", kwargs={**P, "feature_key": checkout.key, "file_id": file.pk} ), {"body": "Pay button is hard to find", "across": "80", "down": "90"}, ) pin = CommentThread.objects.get(kind=ThreadKind.IMAGE) file_page = client.get( reverse("files:detail", kwargs={**P, "feature_key": checkout.key, "file_id": file.pk}) ).content.decode() assert 'behind (now 2)" in receipts_row assert "Shipped: 2" in page and "Behind the current revision: 1" in page