From 591a4e77764dc8d4049fa1bcba98aafad84701d6 Mon Sep 17 00:00:00 2001 From: Zachary Tucker Date: Fri, 26 May 2023 14:31:14 -0400 Subject: [PATCH] fix: tests failed to open catalog list (#261) ### 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 https://github.com/EasyDynamics/oscal-react-library/issues/872 or subsequent related issues are completed. --- .../cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js | 6 ++++++ end-to-end-tests/cypress/support/commands.js | 21 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/end-to-end-tests/cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js b/end-to-end-tests/cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js index a045d3f7..e740ad96 100644 --- a/end-to-end-tests/cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js +++ b/end-to-end-tests/cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js @@ -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); diff --git a/end-to-end-tests/cypress/support/commands.js b/end-to-end-tests/cypress/support/commands.js index ac62a373..96281cb2 100644 --- a/end-to-end-tests/cypress/support/commands.js +++ b/end-to-end-tests/cypress/support/commands.js @@ -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(); });