diff --git a/src/feditest/cli/utils.py b/src/feditest/cli/utils.py index b25360f..a0093c4 100644 --- a/src/feditest/cli/utils.py +++ b/src/feditest/cli/utils.py @@ -110,7 +110,7 @@ def create_session_template_from_tests(args: Namespace) -> TestPlanSession: for constellation_role_name in constellation_role_names: constellation_roles[constellation_role_name] = None - session = TestPlanSession(TestPlanConstellation(constellation_roles), test_plan_specs) + session = TestPlanSession(TestPlanConstellation(constellation_roles), test_plan_specs, args.name) return session diff --git a/src/feditest/nodedrivers/mastodon/__init__.py b/src/feditest/nodedrivers/mastodon/__init__.py index f049fc8..734452d 100644 --- a/src/feditest/nodedrivers/mastodon/__init__.py +++ b/src/feditest/nodedrivers/mastodon/__init__.py @@ -354,7 +354,7 @@ def actor_has_received_object(self, object_uri: str) -> dict[str, Any]: response = find_first_in_array(elements, lambda s: s['uri'] == object_uri) if not response: # Home timeline second case: an announce/boost was created by an account we follow -- need to look for the original URI - if reblog_response := find_first_in_array(elements, lambda s: 'reblog' in s and s['reblog']['uri'] == object_uri) : + if reblog_response := find_first_in_array(elements, lambda s: 'reblog' in s and s['reblog'] and 'uri' in s['reblog'] and s['reblog']['uri'] == object_uri) : response = reblog_response['reblog'] if not response: # Check for it in notifications: mentions arrive here @@ -458,7 +458,7 @@ def _find_account_dict_by_other_actor_acct_uri(self, other_actor_acct_uri: str) raise ValueError(f'Unexpected type: { ret }') - def _find_note_dict_by_uri(self, uri: str) -> dict[str,Any]: + def _find_note_dict_by_uri(self, uri: str) -> dict[str,Any] | None: """ Find a the dict for a status, or None. """ @@ -470,6 +470,8 @@ def _find_note_dict_by_uri(self, uri: str) -> dict[str,Any]: results = self.http_get('/api/v2/search?' + urlencode(args)) ret = find_first_in_array(results.get('statuses'), lambda b: b['uri'] == uri) + if ret is None: + return None if isinstance(ret, dict): return cast(dict[str,Any], ret) raise ValueError(f'Unexpected type: { ret }') diff --git a/src/feditest/templates/default/partials/test_matrix/title.jinja2 b/src/feditest/templates/default/partials/test_matrix/title.jinja2 index f7a3be0..2386cb7 100644 --- a/src/feditest/templates/default/partials/test_matrix/title.jinja2 +++ b/src/feditest/templates/default/partials/test_matrix/title.jinja2 @@ -1,4 +1,4 @@
-

Feditest Report: {{ run.plan.name }}

+

Feditest Summary Report: {{ run.plan.name }}

{{ run.id }}

diff --git a/src/feditest/templates/default/partials/test_session/results.jinja2 b/src/feditest/templates/default/partials/test_session/results.jinja2 index 8f022e6..1e365be 100644 --- a/src/feditest/templates/default/partials/test_session/results.jinja2 +++ b/src/feditest/templates/default/partials/test_session/results.jinja2 @@ -7,7 +7,7 @@ {% if role_name in run_session.constellation.nodes %} {%- set session_node = run_session.constellation.nodes[role_name] %}
-
{{ role_name }}
+

{{ role_name }}

{{ local_name_with_tooltip(node.nodedriver) }}
{{ session_node.appdata['app'] }}
{{ session_node.appdata['app_version'] or '?'}}
@@ -45,8 +45,8 @@ {%- if test_meta.description %}
{{ test_meta.description}}
{%- endif %} -

Started {{ format_timestamp(run_test.started) }}, ended {{ format_timestamp(run_test.ended) }}

-{%- with result=run_test.worst_result %} +

Started {{ format_timestamp(run_test.started) }}, ended {{ format_timestamp(run_test.ended) }} (duration: {{ format_duration(run_test.ended - run_test.started) }})

+ {%- with result=run_test.worst_result %} {%- include "partials/test_session/testresult.jinja2" %} {%- endwith %} {%- for test_step_index, run_step in enumerate(run_test.run_steps or []) %} @@ -56,8 +56,7 @@ {%- if test_step_meta.description %}
{{ test_step_meta.description}}
{%- endif %} -

Started {{ format_timestamp(run_step.started) }}, ended {{ format_timestamp(run_step.ended) }}

- +

Started {{ format_timestamp(run_test.started) }}, ended {{ format_timestamp(run_test.ended) }} (duration: {{ format_duration(run_test.ended - run_test.started) }})

{%- with result=run_step.result, idmod='step' %} {%- include "partials/test_session/testresult.jinja2" %} {%- endwith %} diff --git a/src/feditest/templates/default/partials/test_session/testresult.jinja2 b/src/feditest/templates/default/partials/test_session/testresult.jinja2 index 87f2aa0..0272b5e 100644 --- a/src/feditest/templates/default/partials/test_session/testresult.jinja2 +++ b/src/feditest/templates/default/partials/test_session/testresult.jinja2 @@ -2,8 +2,10 @@
-
{{ result }}
+
{{ html_escape(result) }}
{%- else %} -
Passed
+
+
Passed
+
{%- endif %} diff --git a/src/feditest/templates/default/partials/test_session/title.jinja2 b/src/feditest/templates/default/partials/test_session/title.jinja2 index 79c566b..47f233e 100644 --- a/src/feditest/templates/default/partials/test_session/title.jinja2 +++ b/src/feditest/templates/default/partials/test_session/title.jinja2 @@ -1,5 +1,5 @@ {% set plan_session = run.plan.sessions[run_session.plan_session_index] %}
-

Feditest: {{ plan_session.name }}

-

{{ run.id }} [Test Matrix]

+

Feditest Session Report: {{ plan_session.name }}

+

{{ run.id }} [Summary]

\ No newline at end of file diff --git a/src/feditest/templates/default/static/feditest.css b/src/feditest/templates/default/static/feditest.css index 213e4c4..ec24139 100644 --- a/src/feditest/templates/default/static/feditest.css +++ b/src/feditest/templates/default/static/feditest.css @@ -63,7 +63,7 @@ footer { font-size: smaller; } -div.feditest.title { +div.title { text-align: center; } div.feditest span.prefix, @@ -131,11 +131,7 @@ div.feditest.session > h3::before { border-color: var(--pico-table-border-color); } -.feditest div.role > div.name { - font-weight: bold; -} - -.feditest div.role > div.name::before { +.feditest div.role > h3.name::before { content: "Role: "; } @@ -422,7 +418,6 @@ nav.matrix { nav.matrix ul { display: block; - font-size: 1.4rem; } div.feditest.mobile { diff --git a/src/feditest/testrun.py b/src/feditest/testrun.py index 2730c82..5d83307 100644 --- a/src/feditest/testrun.py +++ b/src/feditest/testrun.py @@ -407,7 +407,7 @@ class TestRun(HasStartEndResults): def __init__(self, plan: TestPlan, record_who: bool = False): super().__init__() self.plan = plan - self.id : str = 'feditest-run-' + datetime.now(timezone.utc).strftime("%Y-%m-%dT%H-%M-%S.%fZ") + self.id : str = 'feditest-run-' + datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S") self.platform : str = platform.platform() self.run_sessions : list[TestRunSession] = [] self.username : str | None = None diff --git a/src/feditest/testruntranscript.py b/src/feditest/testruntranscript.py index 6046c11..0699495 100644 --- a/src/feditest/testruntranscript.py +++ b/src/feditest/testruntranscript.py @@ -9,6 +9,7 @@ import traceback from abc import ABC, abstractmethod from datetime import datetime +import html from typing import IO, Iterator, Optional import jinja2 @@ -560,9 +561,10 @@ def session_file_path(plan_session): r"(\.|::)", r"\1", s ), local_name_with_tooltip=lambda n: f'{ n.split(".")[-1] }', - format_timestamp=lambda ts: ts.isoformat() if ts else "", + format_timestamp=lambda ts: ts.strftime("%Y:%m:%d-%H:%M:%S.%fZ") if ts else "", format_duration=lambda s: str(s), # makes it easier to change in the future - len=len + len=len, + html_escape=lambda s: html.escape(str(s)) ) try: