Skip to content

Commit

Permalink
fix: tests failed to open catalog list (#261)
Browse files Browse the repository at this point in the history
### Navigation Failing

For some reason the first click when selecting catalogs in the drawer
selector fails. This leads to A LOT of tests failing as we use this
function in pretty much all our tests.

This temporary fix will let us test other functionality rather than just
always failing. We really should **completely rework** how we navigate
to each document type in the future as this code is extremely fragile.

### Loading Invalid Components Failing

When we intentionally put in invalid data, a `TypeError` is thrown. We
are still able to reload new data after that failure, so we catch the
exception. This test may be want to reconsidered when
EasyDynamics/oscal-react-library#872 or
subsequent related issues are completed.
  • Loading branch information
tuckerzp authored May 26, 2023
1 parent 5596439 commit 591a4e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions end-to-end-tests/cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ describe("Errors caused by loading a bad component definition", () => {
});

it("do not persist after loading a valid component in Viewer", () => {
// Ignore TypeErrors for this test
cy.on(
"uncaught:exception",
(err) => !err.message.includes("Cannot read properties of undefined")
);

const sspExampleUrl =
"https://raw.githubusercontent.com/usnistgov/oscal-content/main/examples/ssp/json/ssp-example.json";
cy.navToCdefEditor(COMP_DEF_TITLE_ORIG);
Expand Down
21 changes: 17 additions & 4 deletions end-to-end-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,23 @@ Cypress.Commands.add("navToEditorByDrawer", (oscalType, pageTitle) => {
cy.wait(requestsMade, { timeout: 60000 });
}

cy.get('ul[aria-label="file system navigator"] li', { timeout: 30000 })
.should("have.attr", "aria-expanded", "false")
.contains(oscalType)
.click();
cy.get('ul[aria-label="file system navigator"] li', { timeout: 30000 }).should(
"have.attr",
"aria-expanded",
"false"
);

cy.contains(oscalType).trigger("click");

// TODO: For some reason the first click when selecting catalogs in the
// drawer selector fails. This leads to A LOT of tests failing as we use
// this function in pretty much all our tests.
// This temporary fix will let us test other functionality rather than just
// always failing. We really should completely rework how we navigate to each
// document type in the future as this code is extremely fragile.
if (oscalType === oscalObjectTypes[3].oscalType) {
cy.contains(oscalType).trigger("click");
}

cy.contains(pageTitle).click();
});
Expand Down

0 comments on commit 591a4e7

Please sign in to comment.