Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #76 from cisagov/cypress/refactor-campaign-comments
Browse files Browse the repository at this point in the history
Cypress/refactor campaign comments
  • Loading branch information
sang2925 authored Feb 7, 2023
2 parents 5ea9743 + 3ccae6d commit 54dc976
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 303 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ RedEye can assist an operator to efficiently:
- Display and evaluate complex assessment data to enable effective decision making.
- Gain a clearer understanding of the attack path taken and the hosts compromised during a Red Team assessment or penetration test.

[![RedEye](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/rsybgk/main&style=flat-square&logo=cypress)](https://dashboard.cypress.io/projects/rsybgk/runs)
Red Team:
[![Red Team](https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/rsybgk&style=flat&logo=cypress)](https://cloud.cypress.io/projects/rsybgk/runs)

Blue Team:
[![Blue Team](https://img.shields.io/endpoint?url=https://cloud.cypress.io/badge/simple/46ahz3&style=flat&logo=cypress)](https://cloud.cypress.io/projects/46ahz3/runs)

## [User Guide](<docs/User Guide.md>)

Expand Down
6 changes: 1 addition & 5 deletions applications/redeye-e2e/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ module.exports = defineConfig({
reporterOptions: {
configFile: './reporter-config.json',
},
retries: {
runMode: 1,
},

e2e: {

setupNodeEvents(on, config) {
on('task', {
// ===== task to use node 'fs' (filesystem) to read directory=====
Expand All @@ -47,7 +44,6 @@ module.exports = defineConfig({
},
});
},
experimentalSessionAndOrigin: true,
specPattern: '../../**/*.cy.js',
supportFile: './src/support/index.js',
excludeSpecPattern: '*.skip.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/// <reference types="cypress" />

describe('Add Delete Campaign Comments', () => {
const camp = 'addDeleteComments';
const fileName = 'gt.redeye';
const cmd = 'dcsync';
const comment = 'Another comment';
const tag = 'testing';

let count;
it('Add campaign comments and check counts', () => {
cy.uploadCampaign(camp, fileName);

cy
.get('[cy-test=comment-count]')
.find('span')
.then((num) => num.text().split(' ').shift())
.as('campaignCommentCount');

//Open campaign and log starting number of comments via Comments tab - should equal campaign card count
cy.selectCampaign(camp);

cy.clickCommentsTab();

cy.wait(1000);

cy
.get('[cy-test=comment-group]')
.its('length')
.then((num) => parseInt(num))
.as('commentsTabCount');

// Log starting number of comments via Presentation Mode - should equal campaign card and Comments tab counts
cy.clickPresentationMode();

cy.wait(1000);

cy
.get('[cy-test=all] [cy-test=count]')
.find('span')
.first()
.should('be.visible')
.invoke('text')
.as('presentationCommentCount');

cy.get('@campaignCommentCount').then((campaignCommentCount) => {
cy.get('@commentsTabCount').then((commentsTabCount) => {
cy.get('@presentationCommentCount').then((presentationCommentCount) => {
expect(+campaignCommentCount)
.to.eq(+commentsTabCount)
.and.to.eq(+presentationCommentCount);
});
});
});

// // Add a new comment
cy.clickExplorerMode();

cy.clickCommandTypesTab();

cy.selectCommandType(cmd);

cy.addNewComment('0', comment, tag);

// Log new number of comments via Comments tab - should be 1 more
cy.clickExplorerMode();

cy.clickCommentsTab();

cy.wait(1000);

cy.get('@commentsTabCount').then((commentsTabCount) => {
cy
.get('[cy-test=comment-group]')
.its('length')
.then((num) => {
const commentsTabCount2 = parseInt(num);
expect(commentsTabCount2).to.eq(commentsTabCount + 1);
});
});

// Log new number of comments via Presentation Mode - should be one more
cy.clickPresentationMode();

cy.wait(1000);

cy.get('@presentationCommentCount').then((presentationCommentCount) => {
cy
.get('[cy-test=all] [cy-test=count]')
.find('span')
.first()
.then((num) => {
const presentationCommentCount2 = num.text();
expect(+presentationCommentCount2).to.eq(+presentationCommentCount + +'1');
});
});

// Return to campaign menu and log new number of comments - should be one more than original, and all comment counts should match
cy.returnToCampaignCard();

cy.wait(1000);

cy.get('@campaignCommentCount').then((campaignCommentCount) => {
cy
.get('[cy-test=comment-count]')
.find('span')
.then((num) => {
const campaignCommentCount2 = num.text();
expect(+campaignCommentCount2).to.eq(+campaignCommentCount + +'1');
});
});
});

it('Delete campaign comments and check counts', () => {
cy
.get('[cy-test=comment-count]')
.find('span')
.invoke('text')
.then((num) => {
count = num.split(' ').shift();
})
.as('campaignCommentCount');

cy.selectCampaign(camp);

cy.clickCommandTypesTab();

cy.selectCommandType(cmd);

cy.deleteComment(0);

// Log new number of comments via Comments tab - should be 1 less
cy.clickExplorerMode();

cy.clickCommentsTab();

cy.wait(1000);

cy
.get('[cy-test=comment-group]')
.its('length')
.then((num) => parseInt(num))
.then((commentsTabCount) => {
expect(commentsTabCount).to.eq(+count - +'1');
});

// Log new number of comments via Presentation Mode - should be one less
cy.clickPresentationMode();

cy.wait(1000);

cy
.get('[cy-test=all] [cy-test=count]')
.find('span')
.first()
.then((num) => {
const presentationCommentCount = num.text();
expect(+presentationCommentCount).to.eq(+count - +'1');
});

// Return to campaign menu and log new number of comments - should be one less than original, and all comment counts should match
cy.returnToCampaignCard();

cy.wait(1000);

cy
.get('[cy-test=comment-count]')
.find('span')
.invoke('text')
.then((newCount) => {
expect(+newCount).to.eq(+count - +'1');
});
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Loading

0 comments on commit 54dc976

Please sign in to comment.