Skip to content

Commit

Permalink
Feature/12 disabled chapters (#20)
Browse files Browse the repository at this point in the history
* Added check to remove disabled chapters from the 'Applicable Standards/Guidelines' table.

* Added another check to look for notes for a given chapter.

* Added check to remove standards/guideline header if disabled or no notes.

* Updated tests for disabled chapters. Removed video generation to speed up CI.
  • Loading branch information
dmundra authored May 18, 2023
1 parent ba8e573 commit 80bb2a3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"baseUrl": "http://localhost:10001",
"video": true,
"video": false,
"videosFolder": "cypress/results",
"reporter": "junit",
"reporterOptions": {
Expand Down
14 changes: 14 additions & 0 deletions cypress/integration/report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,22 @@ describe("Report", () => {

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

cy.get(".applicable-standards-guidelines-table").should(
"not.contain",
"Chapter 4: Hardware"
);

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

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

cy.get(".applicable-standards-guidelines-table").should(
"contain",
"Chapter 5: Software"
);

cy.get("#software-summary").should("exist");

cy.get("#software-summary + table").should("exist");
});
});
4 changes: 3 additions & 1 deletion src/components/report/ReportChapter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
}
</style>

<HeaderWithAnchor id={chapterId} level=3 {download}>{chapter.label}</HeaderWithAnchor>
{#if !$evaluation['chapters'][chapterId]['disabled'] || $evaluation['chapters'][chapterId]['notes']}
<HeaderWithAnchor id={chapterId} level=3 {download}>{chapter.label}</HeaderWithAnchor>
{/if}

{#if $evaluation['chapters'][chapterId]['notes']}
<div id="{chapterId}-notes" class="chapter-notes-section">
Expand Down
2 changes: 1 addition & 1 deletion src/components/report/ReportHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
{#each catalog.standards as standard }
<tr>
<td><a href="{standard.url}" target="_blank">{standard.label}<span class="visuallyhidden"> (opens in a new window or tab)</span></a></td>
<td>{@html standardsIncluded($evaluation.catalog, standard.chapters)}</td>
<td>{@html standardsIncluded($evaluation.catalog, standard.chapters, $evaluation.chapters)}</td>
</tr>
{/each}
</tbody>
Expand Down
13 changes: 11 additions & 2 deletions src/utils/getCatalogItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ export function getCatalogChapter(catalogName, chapterId) {
}
}

export function standardsIncluded(catalogName, standardChapters) {
export function standardsIncluded(
catalogName,
standardChapters,
evaluationChapters
) {
const result = [];
for (const standardChapter of standardChapters) {
const catalogChapter = getCatalogChapter(catalogName, standardChapter);
result.push(`<li>${catalogChapter.label}</li>`);
if (
!evaluationChapters[standardChapter].disabled ||
evaluationChapters[standardChapter].notes
) {
result.push(`<li>${catalogChapter.label}</li>`);
}
}
return sanitizeHtml(`<ul>${result.join("")}</ul>`);
}
Expand Down

0 comments on commit 80bb2a3

Please sign in to comment.