Skip to content

Commit

Permalink
fix(C.SC.2.2): add AGID unreachable check
Browse files Browse the repository at this point in the history
  • Loading branch information
tensor5 committed May 31, 2024
1 parent 36b121f commit 590c279
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CheerioAPI } from "cheerio";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import lighthouse from "lighthouse";

import { getAllPageHTML, loadPageData, urlExists } from "../../utils/utils";
import { auditDictionary } from "../../storage/auditDictionary";

Expand Down Expand Up @@ -78,6 +79,7 @@ class LoadAudit extends Audit {
];

const $: CheerioAPI = await loadPageData(url);

const accessibilityDeclarationElement = $("footer").find(
'[data-element="accessibility-link"]'
);
Expand Down
11 changes: 6 additions & 5 deletions src/audits/school/accessibilityDeclarationIsPresentAudit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const Audit = lighthouse.Audit;
const auditId = "school-legislation-accessibility-declaration-is-present";
const auditData = auditDictionary[auditId];

const greenResult = auditData.greenResult;
const redResult = auditData.redResult;

class LoadAudit extends Audit {
static get meta() {
return {
Expand Down Expand Up @@ -72,7 +69,7 @@ class LoadAudit extends Audit {

const items = [
{
result: redResult,
result: auditData.redResult,
link_name: "",
link_destination: "",
existing_page: "No",
Expand All @@ -98,6 +95,10 @@ class LoadAudit extends Audit {
) {
const href = elementObj.href;
const checkUrl = await urlExists(url, href);

if (checkUrl.exception)
throw new Error("Possibile errore del server AGID, verificare.");

if (!checkUrl.result) {
return {
score: 0,
Expand Down Expand Up @@ -137,7 +138,7 @@ class LoadAudit extends Audit {
items[0].wcag = "Sì";
}

items[0].result = greenResult;
items[0].result = auditData.greenResult;
score = 1;
}

Expand Down

0 comments on commit 590c279

Please sign in to comment.