Projects under organizations with fixed URL name and feature ID prefix, three visibility levels, open contribution, per-project roles, settings and typed-confirmation delete. Hidden projects 404. Leaving an org drops its project roles. Project access rules live in intent/access.py alongside org access. Features numbered per project (INT-12) in a tree. Every change is a revision with a required note; history, old revisions, and side-by-side field and line diffs between any two. Cycles and superseded-without-replacement are rejected. Markdown renders safely with source-line attributes for Phase 3 line comments and headings shifted below the page h1. Server-side preview works without JS. Structural accessibility check runs on every page in tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
import pytest
|
|
from django.urls import reverse
|
|
|
|
from intent.features.services import create_feature, update_feature
|
|
from intent.orgs.services import invite
|
|
|
|
from .a11y import assert_accessible_html
|
|
|
|
|
|
@pytest.fixture
|
|
def populated(project, owner, make_user, org):
|
|
parent = create_feature(project, owner, title="Accounts", description="# Goal\n\nText\n")
|
|
child = create_feature(project, owner, title="Sign in", parent=parent)
|
|
update_feature(child, owner, note="Detail", description="Steps\n\n1. One\n2. Two\n")
|
|
invite(org, owner, email="new@example.com")
|
|
return child
|
|
|
|
|
|
def _pages(org, project, feature):
|
|
o, p, k = org.slug, project.slug, feature.key
|
|
pk = {"org_slug": o, "project_slug": p}
|
|
fk = {**pk, "feature_key": k}
|
|
return [
|
|
reverse("home"),
|
|
reverse("invites:list"),
|
|
reverse("account_email"),
|
|
reverse("orgs:detail", kwargs={"org_slug": o}),
|
|
reverse("orgs:members", kwargs={"org_slug": o}),
|
|
reverse("project_create", kwargs={"org_slug": o}),
|
|
reverse("projects:home", kwargs=pk),
|
|
reverse("projects:settings", kwargs=pk),
|
|
reverse("projects:delete", kwargs=pk),
|
|
reverse("projects:members", kwargs=pk),
|
|
reverse("features:list", kwargs=pk),
|
|
reverse("features:create", kwargs=pk),
|
|
reverse("features:detail", kwargs=fk),
|
|
reverse("features:edit", kwargs=fk),
|
|
reverse("features:history", kwargs=fk),
|
|
reverse("features:revision", kwargs={**fk, "revision": 1}),
|
|
reverse("features:compare", kwargs=fk),
|
|
]
|
|
|
|
|
|
def test_signed_in_pages(client, owner, org, project, populated):
|
|
client.force_login(owner)
|
|
for path in _pages(org, project, populated):
|
|
response = client.get(path)
|
|
assert response.status_code == 200, path
|
|
try:
|
|
assert_accessible_html(response.content.decode())
|
|
except AssertionError as exc:
|
|
raise AssertionError(f"{path}: {exc}") from None
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"html, problem",
|
|
[
|
|
("<html><body><h1>a</h1></body></html>", "no lang"),
|
|
('<html lang="en"><h2>a</h2></html>', "one <h1>"),
|
|
('<html lang="en"><h1>a</h1><h3>b</h3></html>', "skips"),
|
|
('<html lang="en"><h1 id="x">a</h1><p id="x"></p></html>', "duplicate ids"),
|
|
('<html lang="en"><h1>a</h1><input name="q"></html>', "without a label"),
|
|
('<html lang="en"><h1>a</h1><img src="x"></html>', "without alt"),
|
|
],
|
|
)
|
|
def test_checker_catches_problems(html, problem):
|
|
with pytest.raises(AssertionError, match=problem):
|
|
assert_accessible_html(html)
|
|
|
|
|
|
@pytest.mark.parametrize("name", ["account_login", "account_signup", "account_request_login_code"])
|
|
def test_signed_out_pages(client, db, name):
|
|
assert_accessible_html(client.get(reverse(name)).content.decode())
|