Skip to content

Commit

Permalink
Add changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jym77 committed Jan 20, 2025
1 parent 53026ef commit 85cb9ac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-numbers-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-test-utils": minor
---

**Added:** `Logging` now includes error messages about problems that happens during deserialization or upload of results.
5 changes: 5 additions & 0 deletions .changeset/tidy-buses-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-test-utils": minor
---

**Added:** `Logging` now accepts a severity (default to `"log"`) and `Logging#print` respects it.
61 changes: 30 additions & 31 deletions packages/alfa-test-utils/src/report/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,38 @@ export namespace Logging {
pageReportUrl?: Result<string, string> | string,
options?: Options
): Logging {
const logs = // Retrieve or deserialize the page
// Retrieve or deserialize the page
// We may waste a bit of time deserializing a page we won't need (if URL
// and title are provided), but this streamlines error handling.

(Page.isPage(audit.page) ? Ok.of(audit.page) : Page.from(audit.page)).map(
(page) => {
const title =
options?.pageTitle ??
Query.getElementDescendants(page.document)
.filter(Element.isElement)
.find(Element.hasName("title"))
.map((title) => title.textContent())
.getOr(Defaults.Title);
const pageTitle =
typeof title === "string"
? title
: title !== undefined
? title(page)
: title;

const filteredAggregates = Array.sortWith(
(Audit.isAudit(audit)
? audit.resultAggregates.toArray()
: audit.resultAggregates
).filter(([_, { failed }]) => failed > 0),
([uria], [urib]) => uria.localeCompare(urib)
).map(([url, aggregate]): [string, { failed: number }] => [
url.split("/").pop() ?? "",
aggregate,
]);
return fromAggregate(filteredAggregates, pageTitle, pageReportUrl);
}
);
const logs = (
Page.isPage(audit.page) ? Ok.of(audit.page) : Page.from(audit.page)
).map((page) => {
const title =
options?.pageTitle ??
Query.getElementDescendants(page.document)
.filter(Element.isElement)
.find(Element.hasName("title"))
.map((title) => title.textContent())
.getOr(Defaults.Title);
const pageTitle =
typeof title === "string"
? title
: title !== undefined
? title(page)
: title;

const filteredAggregates = Array.sortWith(
(Audit.isAudit(audit)
? audit.resultAggregates.toArray()
: audit.resultAggregates
).filter(([_, { failed }]) => failed > 0),
([uria], [urib]) => uria.localeCompare(urib)
).map(([url, aggregate]): [string, { failed: number }] => [
url.split("/").pop() ?? "",
aggregate,
]);
return fromAggregate(filteredAggregates, pageTitle, pageReportUrl);
});

return logs.getOrElse(() =>
Logging.of(
Expand Down

0 comments on commit 85cb9ac

Please sign in to comment.