Skip to content

Commit

Permalink
Updated progress function to also aggregate summary counts by level (#5)
Browse files Browse the repository at this point in the history
* missed typo "anythng"

* Updated progress function to also aggregate summary counts by term (levels). Displaying those values before each table. Adjusted the tests to consider the new div in there.

* Added assertions for new summary section.

* Added term labels for display purposes in new summary view.

Co-authored-by: Mike Gifford <[email protected]>
  • Loading branch information
dmundra and mgifford authored Jan 25, 2023
1 parent 090f301 commit 9d399f1
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cypress/integration/catalog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("Catalogs", () => {

cy.get("button").contains("View Report").click();

cy.get("#success_criteria_level_a-editor + table tbody tr").should(
cy.get("#success_criteria_level_a-summary + table tbody tr").should(
"contain",
wcag21Criteria
);
Expand All @@ -74,7 +74,7 @@ describe("Catalogs", () => {

cy.get("button").contains("View Report").click();

cy.get("#success_criteria_level_a-editor + table tbody tr").should(
cy.get("#success_criteria_level_a-summary + table tbody tr").should(
"not.contain",
wcag21Criteria
);
Expand Down
28 changes: 27 additions & 1 deletion cypress/integration/import.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ describe("Import", () => {
hardware: 0,
software: 0,
support_documentation_and_services: 4,
summary: 25,
summary_supports: 58,
summary_partially: 3,
summary_does_not_supports: 5,
summary_na: 34,
},
{
filename: "govready-0.9.yaml",
Expand All @@ -32,6 +37,11 @@ describe("Import", () => {
hardware: 0,
software: 0,
support_documentation_and_services: 4,
summary: 25,
summary_supports: 32,
summary_partially: 9,
summary_does_not_supports: 7,
summary_na: 52,
},
];

Expand Down Expand Up @@ -128,7 +138,23 @@ describe("Import", () => {
"contain",
`Last Modified Date: ${yamlExample.lastModifiedDate}`
)
.should("contain", `Version: ${yamlExample.version}`);
.should("contain", `Version: ${yamlExample.version}`)
.get('[id="success_criteria_level_a-summary"] p')
.should(
"contain",
`Conformance to the ${yamlExample.summary} criteria listed below is distributed as follows:`
)
.get('[id="success_criteria_level_a-summary"] li')
.should("contain", `${yamlExample.summary_supports} supported`)
.should(
"contain",
`${yamlExample.summary_partially} partially supported`
)
.should(
"contain",
`${yamlExample.summary_does_not_supports} not supported`
)
.should("contain", `${yamlExample.summary_na} not applicable`);

cy.get("@consoleError").should("not.be.called");
});
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("Report", () => {

cy.get("a[href='/report#non-text-content-editor']").click();

cy.get("#success_criteria_level_a-editor + table tbody tr")
cy.get("#success_criteria_level_a-summary + table tbody tr")
.should("be.focused")
.should("contain", "Web: Supports")
.should("contain", "Web: Does support non-text content.");
Expand All @@ -155,7 +155,7 @@ describe("Report", () => {
cy.get("a[href='/report#non-text-content-editor']").click();

cy.get(
"#success_criteria_level_a-editor + table tbody tr td:nth-child(3) a"
"#success_criteria_level_a-summary + table tbody tr td:nth-child(3) a"
)
.should("have.attr", "href")
.and("contains", "https://www.drupal.org/");
Expand Down Expand Up @@ -202,6 +202,6 @@ describe("Report", () => {

cy.get("#hardware-editor + table").should("not.exist");

cy.get("#software-editor + table").should("exist");
cy.get("#software-summary + table").should("exist");
});
});
4 changes: 2 additions & 2 deletions src/components/Component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
<HelpText type="components" field="notes" />
</div>
{:else}
<p>Could not find component '{component}' for critera '{criteria}' in '{chapterId}'.</p>
<p>Could not find component '{component}' for criteria '{criteria}' in '{chapterId}'.</p>
{/if}
{:else}
<p>Could not find component '{component}' for critera '{criteria}' in '{chapterId}'.</p>
<p>Could not find component '{component}' for criteria '{criteria}' in '{chapterId}'.</p>
{/if}
19 changes: 19 additions & 0 deletions src/components/report/ReportChapter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
import ReportChapterTableResult from "./ReportChapterTableResult.svelte";
import HeaderWithAnchor from "../HeaderWithAnchor.svelte";
import { sanitizeMarkdown } from "../../utils/sanitizeMarkdown.js";
import { getProgressPerChapter } from "../../utils/getEvaluatedItems.js";
import { getCatalog } from "../../utils/getCatalogs.js";
import termLabel from "../../data/termLabel.yaml";
export let standard;
export let chapterId;
export let download = false;
let catalogName = $evaluation.catalog;
let catalog = getCatalog($evaluation.catalog);
let terms = catalog.terms;
$: chapter = getCatalogChapter(catalogName, chapterId);
$: progressPerChapter = getProgressPerChapter($evaluation);
</script>

<style>
Expand Down Expand Up @@ -44,6 +50,19 @@
{/if}

{#if $evaluation['chapters'][chapterId]['criteria'] && !$evaluation['chapters'][chapterId]['disabled'] }
<div id="{chapterId}-summary">
<p>
Conformance to the {$evaluation['chapters'][chapterId]['criteria'].length} criteria listed below is distributed as follows:
</p>
<ul>
{#each terms as term}
{#if termLabel[term.id]}
<li>{progressPerChapter[chapterId]['evaluated_by_term'][term.id]} {termLabel[term.id]}</li>
{/if}
{/each}
</ul>
</div>

<table class="usa-table">
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion src/data/helpText.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ report:
last_modified_date: "Last modified date is a read-only field that is automatically updated."
version: "Version is a read-only field that is automatically updated when report is uploaded."
notes: "Any comments that you would like to add for the report. This can include related projects."
evaluation_methods_used: "Please describe in detail how this report was created. What tools and processes were used. How many and what type of pages were evaluated, along with anythng else which would provide context."
evaluation_methods_used: "Please describe in detail how this report was created. What tools and processes were used. How many and what type of pages were evaluated, along with anything else which would provide context."
legal_disclaimer: "Optional field for legal disclaimer. Please list license here if it is not released under an open license. "
repository: "URL for the git repository that contains the ACR."
feedback: "Details about feedback from author."
Expand Down
4 changes: 4 additions & 0 deletions src/data/termLabel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
supports: "supported"
partially-supports: "partially supported"
does-not-support: "not supported"
not-applicable: "not applicable"
17 changes: 13 additions & 4 deletions src/utils/getEvaluatedItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export function getProgressPerChapter(evaluation) {
let progressPerChapter = {};

function getEvaluatedForChapter(chapter) {
const components = [];
const components_with_terms = {};
terms.forEach((term) => {
components_with_terms[term.id] = 0;
});
if (evaluation.chapters[chapter.id].criteria) {
evaluation.chapters[chapter.id].criteria.forEach((item) => {
item.components.forEach((component) => {
Expand All @@ -13,12 +16,12 @@ export function getProgressPerChapter(evaluation) {
component["adherence"]["level"] &&
component["adherence"]["level"] != ""
) {
components.push(component);
components_with_terms[component["adherence"]["level"]]++;
}
});
});
}
return components.length;
return components_with_terms;
}

function getTotalForChapter(chapter) {
Expand All @@ -32,11 +35,17 @@ export function getProgressPerChapter(evaluation) {
}

let catalog = getCatalog(evaluation.catalog);
const terms = catalog.terms;
catalog.chapters.forEach((chapter) => {
const total = getTotalForChapter(chapter);
const evaluated = getEvaluatedForChapter(chapter);
const evaluated_by_term = getEvaluatedForChapter(chapter);
let evaluated = 0;
terms.forEach((term) => {
evaluated += evaluated_by_term[term.id];
});

progressPerChapter[chapter.id] = {
evaluated_by_term: evaluated_by_term,
evaluated: evaluated,
total: total,
};
Expand Down

0 comments on commit 9d399f1

Please sign in to comment.