diff --git a/components/collector/src/source_collectors/axe_core/violations.py b/components/collector/src/source_collectors/axe_core/violations.py index c52d4ebe85..c32082f063 100644 --- a/components/collector/src/source_collectors/axe_core/violations.py +++ b/components/collector/src/source_collectors/axe_core/violations.py @@ -79,7 +79,7 @@ def __parse_violations(self, violations: dict[str, list[dict[str, list]]], url: """Parse the violations.""" entity_attributes = [] for result_type, violations_by_result_type in violations.items(): - for violation in violations_by_result_type: + for violation in violations_by_result_type or []: entity_attributes.extend(self.__parse_violation(violation, result_type, url)) return entity_attributes diff --git a/components/collector/tests/source_collectors/axe_core/test_violations.py b/components/collector/tests/source_collectors/axe_core/test_violations.py index a7bbe08e0c..e7c00777c1 100644 --- a/components/collector/tests/source_collectors/axe_core/test_violations.py +++ b/components/collector/tests/source_collectors/axe_core/test_violations.py @@ -94,11 +94,17 @@ async def test_nr_of_issues(self): self.assert_measurement(response, value="2", entities=self.expected_entities) async def test_no_issues(self): - """Test zero issues.""" + """Test zero issues, with an empty violations list.""" self.json["violations"] = [] response = await self.collect(get_request_json_return_value=self.json) self.assert_measurement(response, value="0", entities=[]) + async def test_no_violations_key(self): + """Test zero issues, without a violations list.""" + del self.json["violations"] + response = await self.collect(get_request_json_return_value=self.json) + self.assert_measurement(response, value="0", entities=[]) + async def test_filter_by_impact(self): """Test that violations can be filtered by impact level.""" self.set_source_parameter("impact", ["serious", "critical"]) diff --git a/docs/src/changelog.md b/docs/src/changelog.md index 18c9122d5b..38207ec312 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -17,6 +17,7 @@ If your currently installed *Quality-time* version is not the latest version, pl ### Fixed - When measuring test cases with Visual Studio TRX as source, search all test category items for test case ids, instead of cutting the search short after the first match. Fixes [#10460](https://github.com/ICTU/quality-time/issues/10460). +- Correctly parse empty Axe-core JSON report. Fixes [#10487](https://github.com/ICTU/quality-time/issues/10487). ## v5.20.0 - 2024-12-05