Skip to content
24 changes: 23 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "equa11y",
"version": "2.1.4",
"version": "3.0.1",
"description": "",
"main": "index.ts",
"scripts": {
Expand Down Expand Up @@ -63,6 +63,7 @@
"inquirer": "^7.3.3",
"lodash": "^4.17.20",
"minimist": "^1.2.5",
"open": "^7.2.1",
"puppeteer": "^5.2.1",
"touch": "^3.1.0"
}
Expand Down
64 changes: 29 additions & 35 deletions src/dataParser.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { Result, NodeResult } from 'axe-core';
import { wcag } from './wcag';
import { manualCheckObj } from './manualCheckObj'
import { manualCheckObj } from './manualCheckObj';

export interface SpecificIssue {
recommendation?: string;
html?: string;
}

export interface IssueInfo {
dequeId?: string;
wcagCriteria?: string;
urlToWCAG?: string;
title?: string;
specificIssues?: SpecificIssue[];
impact?: Result['impact'];
dequeId?: string;
wcagCriteria?: string;
urlToWCAG?: string;
title?: string;
specificIssues?: SpecificIssue[];
impact?: Result['impact'];
}


export interface ParsedData {
minor?: IssueInfo[];
moderate?: IssueInfo[];
serious?: IssueInfo[];
critical?: IssueInfo[];
manualTest?: IssueInfo[];
nonEssential?: IssueInfo[];
minor?: IssueInfo[];
moderate?: IssueInfo[];
serious?: IssueInfo[];
critical?: IssueInfo[];
manualTest?: IssueInfo[];
nonEssential?: IssueInfo[];
}

export const dataParser = (dataToBeParsed: Result[]): ParsedData => {
// sort issues into common occurances i.e. { critical: [resultItem1, resultItem2], severe: [resultItem3]}
// instead of returning bind to constant
const data = dataToBeParsed.reduce((parsedData: ParsedData, curIssue: Result) => {
const data = dataToBeParsed.reduce((parsedData: ParsedData, curIssue: Result) => {
const specificIssuePopulator = (node: NodeResult): SpecificIssue => {
const parsedSpecificIssue: SpecificIssue = {}
const parsedSpecificIssue: SpecificIssue = {};
parsedSpecificIssue.recommendation = node.failureSummary;
parsedSpecificIssue.html = node.html;
return parsedSpecificIssue;
}
};

let wcagURLInfo: string;
let wcagCriteriaInfo: string;
// default values for no given wcag information
let wcagURLInfo = curIssue.helpUrl;
let wcagCriteriaInfo = 'n/a';
let foundFlag = false;

const wcagConnector = () => {
Expand All @@ -47,7 +47,6 @@ export const dataParser = (dataToBeParsed: Result[]): ParsedData => {
for (let j = 0; j < wcag.principles[i].guidelines.length; j += 1) {
for (let k = 0; k < wcag.principles[i].guidelines[j].successcriteria.length; k += 1) {
const location = wcag.principles[i].guidelines[j].successcriteria[k];

if (location.dq_id && location.dq_id.includes(id)) {
foundFlag = true;
wcagURLInfo = location.url;
Expand All @@ -59,22 +58,18 @@ export const dataParser = (dataToBeParsed: Result[]): ParsedData => {
}
if (foundFlag) break;
}
if (!foundFlag) {
wcagURLInfo = curIssue.helpUrl;
wcagCriteriaInfo = 'n/a';
}
}
};
const issuesPopulator = (): IssueInfo => {
const parsedIssue: IssueInfo = {};
wcagConnector();
parsedIssue.dequeId = curIssue.id;
parsedIssue.wcagCriteria = wcagCriteriaInfo; // wcag.principles[index].guidelines[0].successcriteria[0].num
parsedIssue.urlToWCAG = wcagURLInfo; // wcag.principles[index].guidelines[0].successcriteria[0].url
parsedIssue.title = curIssue.help;
parsedIssue.specificIssues = curIssue.nodes.map((node) => specificIssuePopulator(node));
parsedIssue.impact = curIssue.impact
parsedIssue.specificIssues = curIssue.nodes.map(node => specificIssuePopulator(node));
parsedIssue.impact = curIssue.impact;
return parsedIssue;
}
};

const parsedIssue = issuesPopulator();
if (curIssue.impact === null || curIssue.impact === undefined) {
Expand All @@ -88,17 +83,16 @@ export const dataParser = (dataToBeParsed: Result[]): ParsedData => {
return parsedData;
}, {});
// add manual test to object

data.manualTest = manualCheckObj;
// console.log(data)
return data
}

// return BAO
return data;
};

// return BAO

// critical: [
// {
// {
// dequeId: 'aria-required-attr',
// wcagCriteria: 'n/a',
// urlToWCAG: 'https://dequeuniversity.com/rules/axe/3.5/aria-required-attr?application=axe-puppeteer',
Expand Down Expand Up @@ -126,7 +120,7 @@ export const dataParser = (dataToBeParsed: Result[]): ParsedData => {
// specificIssues: [Array],
// impact: 'moderate'
// },
//
//
// ],
// manualTest: [
// {
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { prompts } from './prompts';
import { puppet } from './puppeteer';
import { dataParser, ParsedData } from './dataParser';
import { manualCheckObj } from './manualCheckObj';
import open from 'open';

interface Program {
start(): Promise<void>;
Expand Down Expand Up @@ -37,7 +38,7 @@ export const program: Program = {
await program.loop(parsed, inputURL.url);
} catch (error) {
spinner.stop();

const errors = await prompts.askError(error);
if (errors.startOver === 'quit') process.exit(0);
else if (errors.startOver === 'search again') program.start();
Expand All @@ -52,7 +53,10 @@ export const program: Program = {

const options = await prompts.askOptions(parsed, targetLevel);
if (options.res === 'quit') process.exit(0);
else if (options.res === 'search again') program.start();
else if (options.res.trim().slice(0, 4) === 'http') {
open(options.res.trim());
program.loop(parsed, path);
} else if (options.res === 'search again') program.start();
// check if nested
else if (options.res[0] === ' ') {
// grabs string between arrow and '(n) issues types: TBD total sub issues'
Expand All @@ -71,7 +75,6 @@ export const program: Program = {
}
}
},

}
};

program.start();
21 changes: 13 additions & 8 deletions src/menu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import open from 'open';
import { ParsedData, IssueInfo } from './dataParser';

// type issueLevel = typeof issueLevel<keyof typeof issueLevel>

export interface MenuContents {
levelName: string;
opened: boolean;
Expand Down Expand Up @@ -90,16 +89,17 @@ export const menu: Dropdown = {
stringify: (levelObj, nested) => {
let option = '';
option += ' '.repeat(nested);

if (nested > 1) {
// bottom level
if (levelObj.levelName.slice(0, 4) === 'http') {
option += 'ENTER for more info: ';
}
option += levelObj.levelName;
} else if (nested === 1) {
// middle level
option += levelObj.opened ? levelObj.arrows[1] : levelObj.arrows[0];
option += ` ${levelObj.levelName} - ENTER for (${levelObj.subLevel.length}) total error location(s)`;
if (levelObj.subLevel[0].html !== '') {
option += ` ${levelObj.levelName} - ENTER for (${levelObj.subLevel.length}) total error location(s)`;
} else {
option += ` ${levelObj.levelName} - ENTER for URL to more information`;
}
} else {
// top level
option += levelObj.opened ? levelObj.arrows[1] : levelObj.arrows[0];
Expand All @@ -109,7 +109,12 @@ export const menu: Dropdown = {
if (issue.specificIssues.length) subIssues += issue.specificIssues.length;
});
}
option += ` ${levelObj.levelName} (${levelObj.subLevel.length}) issues type(s), (${subIssues}) total error location(s)`;
// change hardcoding for manual testing
if (levelObj.levelName !== 'manualTest') {
option += ` ${levelObj.levelName} (${levelObj.subLevel.length}) issues type(s), (${subIssues}) total error location(s)`;
} else {
option += ` ${levelObj.levelName} ENTER for more information regarding manual testing`;
}
}
return option;
},
Expand Down
4 changes: 2 additions & 2 deletions src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export const prompts: Prompts = {
type: 'list',
pageSize: 35,
message: 'anything else?',
choices: ['search again', 'quit', ...paths],
choices: ['search again', 'quit', new inquirer.Separator(), ...paths],
},
];
return inquirer.prompt(questions);
},

askError: (error) => {
askError: error => {
const questions = [
{
name: 'startOver',
Expand Down
Loading