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

Commit

Permalink
Flaky tests update (#133)
Browse files Browse the repository at this point in the history
* update commenting function cypress
* remove all graphql wait
* removed graphql wait blue team
* update node to 16.20 workflow
* Update command to address test failure.

---------

Co-authored-by: Courtney Carpenter <ccarpenter28@gmail.com>
  • Loading branch information
sang2925 and ccarpenter28 committed May 11, 2023
1 parent a3a0f9d commit 5aa7f42
Show file tree
Hide file tree
Showing 26 changed files with 205 additions and 267 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.19.0]
node-version: [16.20.0]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Cache
uses: actions/setup-node@v3
with:
node-version: 16.19.0
node-version: 16.20.0
cache: 'yarn'

- run: yarn install --immutable --inline-builds
Expand All @@ -66,7 +66,7 @@ jobs:
fail-fast: false
matrix:
containers: [1, 2]
node-version: [16.19.0]
node-version: [16.20.0]

steps:
- name: Checkout
Expand All @@ -77,7 +77,7 @@ jobs:
- name: Cache
uses: actions/setup-node@v3
with:
node-version: 16.19.0
node-version: 16.20.0
cache: 'yarn'

- name: Download the build folders
Expand All @@ -98,7 +98,6 @@ jobs:
config: baseUrl=http://localhost:3500
record: true
parallel: true
headed: true
config-file: applications/redeye-e2e/cypress.config.js
spec: applications/redeye-e2e/src/integration/e2e/redteam/**/**/**/*.cy.js
ci-build-id: ${{ needs.prepare.outputs.uuid }}
Expand All @@ -116,7 +115,7 @@ jobs:
fail-fast: false
matrix:
containers: [1, 2]
node-version: [16.19.0]
node-version: [16.20.0]

steps:
- name: Checkout
Expand All @@ -127,7 +126,7 @@ jobs:
- name: Cache
uses: actions/setup-node@v3
with:
node-version: 16.19.0
node-version: 16.20.0
cache: 'yarn'

- name: Download the build folders
Expand All @@ -148,7 +147,6 @@ jobs:
config: baseUrl=http://localhost:3500
record: true
parallel: true
headed: true
config-file: applications/redeye-e2e/cypress.config.js
spec: applications/redeye-e2e/src/integration/e2e/blueteam/**/*.cy.js
ci-build-id: ${{ needs.prepare.outputs.uuid }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('Search and filter campaigns and verify beacon counts', () => {
cy.selectCampaign(camp);
cy.clickSearch();
cy.get('[cy-test=search]').click().type(cmd).type('{enter}');
cy.wait('@searchCommands');
cy.get('[cy-test=search-result-item]').should('have.length.gt', 0).and('contain', cmd);
cy.closeSearch();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ describe('View Raw Logs', () => {
// Expand first command
cy.get('[cy-test=info-row]').eq(0).click();
cy.wait(500);
cy.get('[cy-test=openRawLogs]').should('be.visible');
cy.get('[cy-test=openRawLogs]').should('be.visible').click();

// Click "Show Raw Logs" link; verify log appears
cy.get('[cy-test=openRawLogs]').click();
verifyRawLogs();
});

Expand All @@ -38,10 +36,8 @@ describe('View Raw Logs', () => {
// Click expandable row under first comment
cy.get('[cy-test=command-info]').eq(0).click();
cy.wait(500);
cy.get('[cy-test=openRawLogs]').should('be.visible');
cy.get('[cy-test=openRawLogs]').should('be.visible').click();

// Click "Show Raw Logs" link; verify log appears
cy.get('[cy-test=openRawLogs]').click();
verifyRawLogs();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,149 +1,81 @@
/// <reference types="cypress" />
import 'cypress-map';

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.searchForCampaign(camp);

cy.get('[cy-test=comment-count]')
.find('span')
.then((num) => num.text().split(' ').shift())
.as('campaignCommentCount');
cy.get('[cy-test=comment-count] > span')
.map('innerText')
.map(parseInt)
.reduce(Cypress._.add, 0)
.as('campaignCommentCount')
.asEnv('campaignCommentCount')
.should('equals', 5);

// Open campaign and log starting number of comments via Comments tab
cy.selectCampaign(camp);
cy.clickCommentsTab();
cy.get('[data-test-id=virtuoso-item-list]').should('exist');

cy.get('[cy-test=comment-group]')
.its('length')
.then((num) => parseInt(num))
.as('commentsTabCount');
.map('innerText')
.as('commentsTabCount')
.asEnv('commentsTabCount')
.should('have.length', 5);

// Log starting number of comments via Presentation Mode
cy.clickPresentationMode();
cy.get('[cy-test=presentation-root]').should('exist');
cy.get('[cy-test=all] [cy-test=count]')
.find('span')
.first()
.should('be.visible')
.invoke('text')
.as('presentationCommentCount');

// Verify comment counts all match
cy.get('@campaignCommentCount').then((campaignCommentCount) => {
cy.get('@commentsTabCount').then((commentsTabCount) => {
cy.get('@presentationCommentCount').then((presentationCommentCount) => {
expect(+campaignCommentCount)
.to.eq(+commentsTabCount)
.and.to.eq(+presentationCommentCount);
});
});
});
.map('innerText')
.map(parseInt)
.reduce(Cypress._.add, 0)
.as('presentationCommentCount')
.asEnv('presentationCommentCount')
.should('equals', 5);

// Add a new comment
cy.clickExplorerMode();
cy.clickCommandTypesTab();
cy.selectCommandType(cmd);
cy.addNewComment('0', comment, tag);
cy.addNewComment('0', 'Another comment', 'testing');

cy.clickPresentationMode();
cy.get('@presentationCommentCount').should('equals', 6);

// Log new number of comments via Comments tab - should be 1 more
cy.clickExplorerMode();
cy.clickCommentsTab();
cy.get('[data-test-id=virtuoso-item-list]').should('exist');
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);
});
});
cy.get('@commentsTabCount').should('have.length', 6);

// Log new number of comments via Presentation Mode - should be one more
cy.clickPresentationMode();
cy.get('[cy-test=presentation-root]').should('exist');
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.get('[cy-test=campaign-card]').its('length').should('be.gte', 1);
cy.searchForCampaign(camp);
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');
});
});
cy.get('@campaignCommentCount').should('equals', 6);
});

it('Delete campaign comments and check counts', () => {
// Search for campaign and log number of comments on campaign card
cy.searchForCampaign(camp);
cy.get('[cy-test=comment-count]')
.find('span')
.invoke('text')
.then((num) => {
count = num.split(' ').shift();
})
.as('campaignCommentCount');

// Open campaign, go to command, delete a comment
cy.selectCampaign(camp);
cy.clickCommandTypesTab();
cy.selectCommandType(cmd);
cy.deleteComment(0);

cy.clickPresentationMode();
expect(Cypress.env('presentationCommentCount')).to.equal(5);

// Log new number of comments via Comments tab - should be 1 less
cy.clickExplorerMode();
cy.clickCommentsTab();
cy.get('[data-test-id=virtuoso-item-list]').should('exist');
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.get('[cy-test=presentation-root]').should('exist');
cy.get('[cy-test=all] [cy-test=count]')
.find('span')
.first()
.then((num) => {
const presentationCommentCount = num.text();
expect(+presentationCommentCount).to.eq(+count - +'1');
});
expect(Cypress.env('commentsTabCount')).to.have.length(5);

// 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.get('[cy-test=campaign-card]').its('length').should('be.gte', 1);
cy.searchForCampaign(camp);
cy.get('[cy-test=comment-count]')
.find('span')
.invoke('text')
.then((newCount) => {
expect(+newCount).to.eq(+count - +'1');
});
expect(Cypress.env('campaignCommentCount')).to.equal(5);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('Search and filter campaigns and verify beacon counts', () => {
cy.selectCampaign(camp);
cy.clickSearch();
cy.get('[cy-test=search]').click().type(cmd).type('{enter}');
cy.wait('@searchCommands');
cy.get('[cy-test=search-result-item]').should('have.length.gt', 0).and('contain', cmd);
cy.closeSearch();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('Command counts', () => {
Cypress.$('[cy-test=row-command-count]').each(function () {
sum += +Cypress.$(this).text() || 0;
});
cy.log(sum);
expect(sum).to.eq(+commandTotal);
});
});
Expand All @@ -49,7 +48,6 @@ describe('Command counts', () => {
Cypress.$('[cy-test=row-command-count]').each(function () {
sum += +Cypress.$(this).text() || 0;
});
cy.log(sum);
expect(sum).to.eq(+commandTotal);
});
});
Expand All @@ -69,16 +67,13 @@ describe('Command counts', () => {
.eq(0)
.invoke('text')
.then((countHost1) => {
// cy.log(countHost1);

// Click host to open details
cy.get('[cy-test=info-row]').eq(1).click();

// Log number of commands showing - should match umber in host row

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
// cy.log(returnedUrl);

const query = `query commandIds($beaconId: String, $campaignId: String!, $commandIds: [String!], $commandType: String, $hostId: String, $operatorId: String, $sort: SortType) {
commandIds(beaconId: $beaconId, campaignId: $campaignId, commandIds: $commandIds, commandType: $commandType, hostId: $hostId, operatorId: $operatorId, sort: $sort)
Expand Down Expand Up @@ -118,7 +113,6 @@ describe('Command counts', () => {

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
// cy.log(returnedUrl);

const query = `query commandIds($beaconId: String, $campaignId: String!, $commandIds: [String!], $commandType: String, $hostId: String, $operatorId: String, $sort: SortType) {
commandIds(beaconId: $beaconId, campaignId: $campaignId, commandIds: $commandIds, commandType: $commandType, hostId: $hostId, operatorId: $operatorId, sort: $sort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ describe('Edit Campaign Comments', () => {
const editedComment = 'Edited comment text';
const fileName = 'gt.redeye';
const comment = 'commenthere';
const tag = 'testing';
const tag1 = 'test_1';
const tag2 = 'test_2';

it('Add comment and edit the text afterward', () => {
Expand All @@ -21,15 +19,11 @@ describe('Edit Campaign Comments', () => {

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

cy.get('[cy-test=add-comment]').eq(0).scrollIntoView().should('be.visible').click({ force: true });
cy.get('[cy-test=add-comment]').eq(0).should('be.visible').click({ force: true });

cy.get('[cy-test=existing-comment-display]')
.scrollIntoView()
.should('be.visible')
.and('contain', comment)
.and('contain', tag2);
cy.get('[cy-test=existing-comment-display]').should('be.visible').should('contain', comment).and('contain', tag2);

cy.get('[cy-test=add-comment]').eq(0).click({ force: true });
cy.get('[cy-test=add-comment]').eq(0).should('be.visible').click({ force: true });

// After saving comment, edit the comment text
cy.editExistingComment(0, editedComment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('Query Beacons', () => {

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
cy.log(returnedUrl);

const query = `query beacons($campaignId: String!) {
beacons(campaignId: $campaignId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('Query CommandTypes', () => {

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
cy.log(returnedUrl);

const query = `query commandTypes($campaignId: String!) {
commandTypes(campaignId: $campaignId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('Query Commands & CommandsIds', () => {

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
cy.log(returnedUrl);

const query = `query commandIds($beaconId: String, $campaignId: String!, $commandIds: [String!], $commandType: String, $hostId: String, $operatorId: String, $sort: SortType) {
commandIds(beaconId: $beaconId, campaignId: $campaignId, commandIds: $commandIds, commandType: $commandType, hostId: $hostId, operatorId: $operatorId, sort: $sort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('Query Hosts', () => {

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
cy.log(returnedUrl);

const query = `query hosts($campaignId: String!) {
hosts(campaignId: $campaignId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe('Get All Links', () => {

cy.url().then((url) => {
const returnedUrl = url.split('/')[5];
cy.log(returnedUrl);

const query = `query links($campaignId: String!) {
links(campaignId: $campaignId) {
Expand Down
Loading

0 comments on commit 5aa7f42

Please sign in to comment.