From ae7621fb544a459177293c3c74dc313481d19c1d Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Wed, 5 Jan 2022 17:08:17 -0800 Subject: [PATCH] fix(routers.trusted_user): fix missing submitter link on `/tu/{id}` Closes #235 Signed-off-by: Kevin Morris --- templates/partials/tu/proposal/details.html | 7 +++++-- test/test_trusted_user_routes.py | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/partials/tu/proposal/details.html b/templates/partials/tu/proposal/details.html index 3f15a6eb..fd84f093 100644 --- a/templates/partials/tu/proposal/details.html +++ b/templates/partials/tu/proposal/details.html @@ -22,12 +22,15 @@ {% set submitted = voteinfo.Submitted | dt | as_timezone(timezone) %} + {% set submitter = voteinfo.Submitter.Username %} + {% set submitter_uri = "/account/%s" | format(submitter) %} + {% set submitter = '%s' | format(submitter_uri, submitter) %} {% set end = voteinfo.End | dt | as_timezone(timezone) %} diff --git a/test/test_trusted_user_routes.py b/test/test_trusted_user_routes.py index ac7f82d5..96e2c704 100644 --- a/test/test_trusted_user_routes.py +++ b/test/test_trusted_user_routes.py @@ -3,6 +3,7 @@ import re from datetime import datetime from http import HTTPStatus from io import StringIO +from typing import Tuple import lxml.etree import pytest @@ -477,7 +478,8 @@ def test_tu_proposal_not_found(client, tu_user): assert response.status_code == int(HTTPStatus.NOT_FOUND) -def test_tu_running_proposal(client, proposal): +def test_tu_running_proposal(client: TestClient, + proposal: Tuple[User, User, TUVoteInfo]): tu_user, user, voteinfo = proposal # Initiate an authenticated GET request to /tu/{proposal_id}. @@ -502,8 +504,11 @@ def test_tu_running_proposal(client, proposal): submitted = details.xpath( './div[contains(@class, "submitted")]/text()')[0] - assert re.match(r'^Submitted: \d{4}-\d{2}-\d{2} \d{2}:\d{2} by .+$', + assert re.match(r'^Submitted: \d{4}-\d{2}-\d{2} \d{2}:\d{2} by$', submitted.strip()) is not None + submitter = details.xpath('./div[contains(@class, "submitted")]/a')[0] + assert submitter.text.strip() == tu_user.Username + assert submitter.attrib["href"] == f"/account/{tu_user.Username}" end = details.xpath('./div[contains(@class, "end")]')[0] end_label = end.xpath("./text()")[0]