2026-10-27 07:10:27 -04:00
|
|
|
import itertools
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
from allauth.account.models import EmailAddress
|
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
|
|
|
|
|
|
from intent.orgs.models import OrgMembership, Role
|
|
|
|
|
from intent.orgs.services import create_org
|
2026-10-27 07:58:16 -04:00
|
|
|
from intent.projects.models import ProjectMembership, Visibility
|
|
|
|
|
from intent.projects.services import create_project
|
2026-10-27 07:10:27 -04:00
|
|
|
|
|
|
|
|
_counter = itertools.count()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def make_user(db):
|
|
|
|
|
def make(username=None, *, email=None, is_staff=False):
|
|
|
|
|
username = username or f"user{next(_counter)}"
|
|
|
|
|
email = email or f"{username}@example.com"
|
|
|
|
|
user = get_user_model().objects.create_user(
|
|
|
|
|
username=username, email=email, is_staff=is_staff
|
|
|
|
|
)
|
|
|
|
|
EmailAddress.objects.create(user=user, email=email, verified=True, primary=True)
|
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
|
return make
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def owner(make_user):
|
|
|
|
|
return make_user("olive")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def org(owner):
|
|
|
|
|
return create_org(slug="catbriar", name="Catbriar", owner=owner)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def collaborator(make_user, org):
|
|
|
|
|
user = make_user("cole")
|
|
|
|
|
OrgMembership.objects.create(org=org, user=user, role=Role.COLLABORATOR)
|
|
|
|
|
return user
|
2026-10-27 07:58:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def project(org, owner):
|
|
|
|
|
"""A private project created by the org owner, who is therefore its project owner too."""
|
|
|
|
|
return create_project(
|
|
|
|
|
org,
|
|
|
|
|
owner,
|
|
|
|
|
slug="intent",
|
|
|
|
|
name="Intent",
|
|
|
|
|
feature_prefix="INT",
|
|
|
|
|
visibility=Visibility.PRIVATE,
|
|
|
|
|
open_contribution=False,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def editor(make_user, org, project):
|
|
|
|
|
"""An org collaborator who is a collaborator on the project."""
|
|
|
|
|
user = make_user("eddie")
|
|
|
|
|
OrgMembership.objects.create(org=org, user=user)
|
|
|
|
|
ProjectMembership.objects.create(project=project, user=user)
|
|
|
|
|
return user
|
Add issues and comment threads (Phase 3)
Issues: per-project numbers, statuses (open, accepted, rejected,
withdrawn, duplicate), feature links, edits, and a timeline of comments
and events. From an issue, collaborators create or update a feature
with the revision tied to the issue and an option to accept it.
Comments: general and line-anchored threads on features, one
discussion thread per issue, edit history, tombstone deletes, resolve,
and promoting a feature thread to an issue. Line threads attach to
top-level Markdown blocks and go outdated only when the text changes.
HTMX swaps threads in place with focus management; every action also
works as a plain form post. Markdown headings are re-levelled so user
text never skips heading levels on the page.
The example flow from concept.md (steps 1-7) is covered end to end in
tests/test_example_flow.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:18:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def open_project(project):
|
|
|
|
|
"""The project, made public and open to contributions from any signed-in user."""
|
|
|
|
|
project.visibility = Visibility.PUBLIC
|
|
|
|
|
project.open_contribution = True
|
|
|
|
|
project.save()
|
|
|
|
|
return project
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def outsider(make_user):
|
|
|
|
|
"""A signed-in user with no role in the org."""
|
|
|
|
|
return make_user("uma")
|