Skip to content

Commit

Permalink
feat(cypress): Test locations & roles display (#232)
Browse files Browse the repository at this point in the history
To avoid regression after
EasyDynamics/oscal-react-library#728
is merged in, this tests that locations and roles display properly.

It will require changes from
EasyDynamics/oscal-demo-content#35
for the tests to pass.

---------

Co-authored-by: Kyle Laker <klaker@easydynamics.com>
  • Loading branch information
tuckerzp and Kyle Laker authored Mar 23, 2023
1 parent ceda600 commit fd2df6e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-container-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: EasyDynamics/oscal-demo-content
ref: "test-content"
path: all-in-one/oscal-content

- name: Set Up Docker Buildx
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-container-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: EasyDynamics/oscal-demo-content
ref: "test-content"
path: all-in-one/oscal-content

- name: Set Up Docker Buildx
Expand Down
43 changes: 42 additions & 1 deletion end-to-end-tests/cypress/e2e/OSCAL/OSCAL_Load_Tests.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Loading system security plans', () => {
it('displays Enterprise Asset Owners Party', () => {
cy.navToSspEditor(SSP_TITLE_ORIG);
cy.waitForLoad();
cy.contains("Parties").click();
cy.get(`[aria-label="Enterprise Asset Owners details button"]`).click();
cy.contains("No address information provided");
cy.contains("No telephone information provided");
Expand All @@ -34,6 +35,7 @@ describe('Loading system security plans', () => {
it('displays Enterprise Asset Administrators Party', () => {
cy.navToSspEditor(SSP_TITLE_ORIG);
cy.waitForLoad();
cy.contains("Parties").click();
cy.get(`[aria-label="Enterprise Asset Administrators details button"]`).click();
cy.contains("0000 St");
cy.contains("+18005555555");
Expand All @@ -47,6 +49,7 @@ describe('Loading Component Definitions', () => {
cy.navToCdefEditor(COMP_DEF_TITLE_ORIG)
cy.waitForLoad();
cy.contains(COMP_DEF_TITLE_ORIG).should('be.visible')
cy.contains("Parties").click();
cy.contains('Test Vendor').should('be.visible')
cy.scrollTo('bottom')
})
Expand All @@ -58,9 +61,47 @@ describe('Loading Component Definitions', () => {
cy.contains('OSCAL Component URL').first().should('exist').next().click().clear().type(Cypress.env('base_url') + "/oscal/v1/component-definitions/8223d65f-57a9-4689-8f06-2a975ae2ad72")
cy.contains('Reload').click()
cy.contains(COMP_DEF_TITLE_ORIG).should('be.visible')
cy.contains("Parties").click();
cy.contains('Test Vendor').should('be.visible')
cy.scrollTo('bottom')
})
});

it('loads metadata roles', () => {
cy.navToCdefEditor(COMP_DEF_TITLE_ORIG);
cy.waitForLoad();
cy.contains("Roles").click();
cy.contains("Document creator");
cy.contains("Contact");
});

it('loads metadata role details', () => {
cy.navToCdefEditor(COMP_DEF_TITLE_ORIG);
cy.waitForLoad();
cy.contains("Roles").click();
cy.get(`[aria-label="Document creator details button"]`).click();
cy.contains("Creates documents describing the system");
});

it('loads metadata locations', () => {
cy.navToCdefEditor(COMP_DEF_TITLE_ORIG);
cy.waitForLoad();
cy.contains("Locations").click();
cy.contains("NIST");
cy.contains("Not Specified");
});

it('loads metadata location details', () => {
cy.navToCdefEditor(COMP_DEF_TITLE_ORIG);
cy.waitForLoad();
cy.contains("Locations").click();
cy.get(`[aria-label="NIST details button"]`).click();
cy.contains("100 Bureau Drive");
cy.contains("Mail Stop 8970");
cy.contains("Gaithersburg, MD 20899-8970");
cy.contains("301-975-8616");
cy.contains("itl_inquiries@nist.gov");
cy.contains("https://www.nist.gov/");
});
})

describe('Errors caused by loading a bad component definition', () => {
Expand Down
1 change: 0 additions & 1 deletion end-to-end-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,3 @@ Cypress.Commands.add("setTestSspJson", (sspJson) => {
sspJson
);
});

6 changes: 4 additions & 2 deletions end-to-end-tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.on('uncaught:exception', (err, runnable) => {
Cypress.on('uncaught:exception', (err) => {
// monaco-editor sometimes throws errors when reloading
// and we don't want to fail the test so we return false
if (err.message.includes("Failed to execute 'importScripts' on 'WorkerGlobalScope'")) {
return false
}

if (err.message.includes("Cannot read properties of null (reading 'getText')")) {
return false
}

// TODO: Find a fix where we don't need to avoid this exception
// https://github.com/EasyDynamics/oscal-editor-deployment/issues/121
if (err.message.includes("ResizeObserver loop limit exceeded")) {
if (err.message.includes("ResizeObserver loop")) {
return false
}
})

0 comments on commit fd2df6e

Please sign in to comment.