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

Cypress test updates #74

Merged
merged 17 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
dbf1ab3
New tests to verify username shows up appropraitely on comments and t…
ccarpenter28 Dec 5, 2022
4de365b
Updated tests to verify files are downloaded when exporting campaigns…
ccarpenter28 Dec 6, 2022
aec8ebb
Updated beacon count and command count tests with additional verifica…
ccarpenter28 Dec 23, 2022
5a819e7
Updates to commands and command definitions.
ccarpenter28 Jan 3, 2023
c317c08
Commenting out logs.
ccarpenter28 Jan 5, 2023
6130b4b
Merge branch 'github-develop' into redeye-cypress-tests-2
ccarpenter28 Jan 16, 2023
4c5e5f1
Remove duplicate tests after merging. Moving new tests under the redt…
ccarpenter28 Jan 16, 2023
85e5bff
Updates to cypress.config file for the export graph and timeline tests.
ccarpenter28 Jan 17, 2023
00a22ec
Merge commit 'bf1e3d23add8715c31c2aa2a79c60d116cb289cb' into redeye-c…
ccarpenter28 Jan 17, 2023
29c9995
Commented out a command-row-navigation test that currently fails due …
ccarpenter28 Jan 17, 2023
d7e8f29
Minor updates to reverse a couple unnecessary changes.
ccarpenter28 Jan 26, 2023
0dafa78
Merge branch 'develop' of https://github.com/cisagov/RedEye into rede…
ccarpenter28 Jan 27, 2023
dd6b4e8
Removing unneccessary line from the expand-collapse test.
ccarpenter28 Feb 1, 2023
f510f5b
Minor update to import line of command-count test.
ccarpenter28 Feb 1, 2023
58454db
Update readFile path
ccarpenter28 Feb 1, 2023
2d9f76a
Update for failure in blue team/cant-add-comments
ccarpenter28 Feb 1, 2023
2df4aa3
skip campaign comments test
sang2925 Feb 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const UserSettingsOverlay = observer<UserSettingsOverlayProps>(({ onSubmi
`}
>
<p>Change Username</p>
<LoginForm submitText="Update" onSubmit={onSubmit} />
<Button minimal text="Log out" onClick={() => store.auth.logOut()} />
<LoginForm submitText="Update" cy-test="update" onSubmit={onSubmit} />
<Button minimal text="Log out" cy-test="logout" onClick={() => store.auth.logOut()} />
</div>
</Dialog>
);
Expand Down
2 changes: 1 addition & 1 deletion applications/client/src/components/Forms/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const LoginForm = observer<LoginFormProps>(({ onSubmit, submitText = 'Log
);

return (
<form {...props} onSubmit={state.handleSubmit} autoComplete="on">
<form cy-test="login-form" {...props} onSubmit={state.handleSubmit} autoComplete="on">
{!store.appMeta.blueTeam && (
<>
<InputGroup
Expand Down
1 change: 1 addition & 0 deletions applications/client/src/views/Campaign/Campaign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ type CollapsedContentProps = ComponentProps<'div'> & ButtonProps & {};
export const CollapsedContent: FC<CollapsedContentProps> = ({ children, icon, ...props }) => (
<div {...props} css={collapsedContentWrapperStyle}>
<Button
cy-test="expand-panel"
icon={icon}
// onClick={onClick}
minimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ export const Command = observer<CommandProps>(
/>
)}
<div className={skeletonClass} css={rowTextStyle}>
<Txt ellipsize small muted block running title={command?.info.contextTooltipText}>
<Txt monospace>{command?.info.time.format(`${dateShortFormat} ${timeFormat}`)}</Txt>
<Txt cy-test="command-header" ellipsize small muted block running title={command?.info.contextTooltipText}>
<Txt cy-test="command-date-time" monospace>
{command?.info.time.format(`${dateShortFormat} ${timeFormat}`)}
</Txt>
<Spacer />
<Txt>{command?.info.operator}</Txt>
<Txt cy-test="operator-info">{command?.info.operator}</Txt>
{isCollapsed && showPath && (
<>
<Spacer>{' • '}</Spacer>
Expand All @@ -55,7 +57,7 @@ export const Command = observer<CommandProps>(
)}
</Txt>
{!isCollapsed && showPath && <NavBreadcrumbs cy-test="hostBeaconInfo" command={command} hideRoot muted />}
<Txt title={command?.info.commandTooltip} block ellipsize>
<Txt cy-test="command-info" title={command?.info.commandTooltip} block ellipsize>
<Txt emphasis bold cy-test="command-type">
{command?.info.commandType}
</Txt>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,16 @@ export const CommentBox = observer<CommentBoxProps>(
<div {...props}>
<div css={headerWrapperStyle}>
<span>
<CarbonIcon icon={Chat16} />
<CarbonIcon cy-test="comment-icon" icon={Chat16} />
<Spacer />
<Txt>
{annotation?.user !== undefined ? (
annotation?.user
) : (
<span>
<Txt bold>New Comment</Txt>
<Txt cy-test="new-comment-header" bold>
New Comment
</Txt>
{state.commandIds.length > 1 && <Txt muted> on {state.commandIds.length} Commands</Txt>}
</span>
)}
Expand Down Expand Up @@ -627,7 +629,7 @@ export const CommentBox = observer<CommentBoxProps>(
text="Edit"
/>
)}
{allowReply && <Button minimal small onClick={() => reply?.()} text="Reply" />}
{allowReply && <Button cy-test="reply" minimal small onClick={() => reply?.()} text="Reply" />}
{allowEdit && (
<>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const ControlBar = observer<ControlBarProps>(
*/}
{isCollapsible && (
<Button
cy-test="collapse-all"
icon={<CarbonIcon icon={CollapseCategories16} />}
title="Collapse All"
onClick={() => {
Expand Down
16 changes: 11 additions & 5 deletions applications/client/src/views/Campaign/Search/Rows/SearchRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ export const SearchRow = observer<SearchRowProps>(
)}
{children && <div css={childrenStyles}>{children}</div>}
<div css={iconsStyle}>
{hostsCount !== undefined && <IconLabel value={hostsCount} title="Hosts" icon={icons.host} />}
{tagsCount !== undefined && <IconLabel value={tagsCount} title="Tags" icon={icons.tags} />}
{commandsCount !== undefined && <IconLabel value={commandsCount} title="Commands" icon={icons.commands} />}
{beaconsCount !== undefined && <IconLabel value={beaconsCount} title="Beacons" icon={icons.beacon} />}
{commentsCount !== undefined && <IconLabel value={commentsCount} title="Comments" icon={icons.comment} />}
{hostsCount !== undefined && <IconLabel value={hostsCount} title="Hosts" cy-test="host-count" icon={icons.host} />}
{tagsCount !== undefined && <IconLabel value={tagsCount} title="Tags" cy-test="tag-count" icon={icons.tags} />}
{commandsCount !== undefined && (
<IconLabel value={commandsCount} title="Commands" cy-test="command-count" icon={icons.commands} />
)}
{beaconsCount !== undefined && (
<IconLabel value={beaconsCount} title="Beacons" cy-test="beacon-count" icon={icons.beacon} />
)}
{commentsCount !== undefined && (
<IconLabel value={commentsCount} title="Comments" cy-test="comment-count" icon={icons.comment} />
)}
</div>
</div>
);
Expand Down
6 changes: 4 additions & 2 deletions applications/client/src/views/Campaigns/CampaignCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ export const CampaignCard = observer<CampaignCardProps>(({ isCurrent, campaign }
`}
>
<Txt>Last opened by:</Txt>
<Txt bold>{campaign.lastOpenedBy?.id ?? 'None'}</Txt>
<Txt cy-test="last-opened-by" bold>
{campaign.lastOpenedBy?.id ?? 'None'}
</Txt>
</Txt>
<Txt meta muted small block>
<Txt bold skeleton={campaign.isParsing}>
<Txt cy-test="campaign-dates" bold skeleton={campaign.isParsing}>
{state.startTime}&mdash;{state.endTime}
</Txt>
<Spacer>•</Spacer>
Expand Down
32 changes: 31 additions & 1 deletion applications/redeye-e2e/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { defineConfig } = require('cypress');

const fs = require('fs');
const path = require('path');

module.exports = defineConfig({
fixturesFolder: './src/fixtures',
modifyObstructiveCode: false,
Expand All @@ -17,7 +20,34 @@ module.exports = defineConfig({
runMode: 1,
},
e2e: {
setupNodeEvents(on, config) {},

setupNodeEvents(on, config) {
on('task', {
// ===== task to use node 'fs' (filesystem) to read directory=====
readdir({ dirPath }) {
return new Promise((resolve, reject) => {
try {
const dirData = fs.readdirSync(dirPath);
resolve(dirData);
} catch (e) {
reject(e);
}
});
},
// ===== task to use node 'fs' (filesystem) to delete downloaded files from cypress/downloads
deleteDownloads({ dirPath }) {
fs.readdir(dirPath, (err, files) => {
for (const file of files) {
fs.unlink(path.join(dirPath, file), (err) => {
console.log('Removed ' + file);
});
}
});
return null;
},
});
},
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
Expand Up @@ -9,7 +9,7 @@ describe('Verify Adding Comments are disabled, but able to view exisiting commen

cy.selectCampaign(camp);

cy.selectHostName('COMPUTER02');
cy.selectHostByName('COMPUTER02');

//Click on first visible add comment button
cy.get('[cy-test=add-comment]').should('be.visible').first().click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Beacon counts', () => {
.eq(0)
.invoke('text')
.then((countHost1) => {
cy.log(countHost1);
// cy.log(countHost1);

// Click host to open details
cy.get('[cy-test=info-row]').eq(1).click();
Expand All @@ -84,13 +84,13 @@ describe('Beacon counts', () => {
});
});
// Go back to Hosts and log beacon count for second host
cy.get('[cy-test=explorer-mode]').click();
cy.clickExporerMode();
cy
.get('[cy-test=row-beacon-count]')
.eq(1)
.invoke('text')
.then((countHost2) => {
cy.log(countHost2);
// cy.log(countHost2);

// Click host to open deatails
cy.get('[cy-test=info-row]').eq(2).click();
Expand All @@ -111,28 +111,55 @@ describe('Beacon counts', () => {
cy.selectCampaign(camp);

// Open campaign and go to Operator tab; log beacon count
cy.get('[cy-test=operators]').click();
cy.clickOperatorsTab();
cy
.get('[cy-test=row-beacon-count]')
.invoke('text')
.then((countRow) => {
cy.log(countRow);
// cy.log(countRow);

// Open operator and go to Beacons tab
cy.get('[cy-test=operator-row]').click();
cy.get('[cy-test=beacons]').click();

cy.clickBeaconsTab();
// Log number of beacons showing - should match number from Operator tab count
cy
.get('[cy-test=info-row]')
.its('length')
.then((countOperatorBeacons) => {
cy.log(countOperatorBeacons);
// cy.log(countOperatorBeacons);
expect(+countOperatorBeacons).to.eq(+countRow);
});
});
});

it('Verify beacon counts from Search modal', () => {
// Open campaign and go to Search modal
cy.selectCampaign(camp);
cy.clickSearch();

// Enter search term
cy.searchCampaignFor('analyst');

// Log the number of commands showing for the Operator result
cy
.get('[cy-test=beacon-count]')
.invoke('text')
.then((beaconCount1) => {
// cy.log(beaconCount1);

// Click the Operator, go to list of beacons; verify count matches number in search
cy.get('[cy-test=search-result-item]').contains('Operator').click();
cy.clickBeaconsTab();
cy
.get('[cy-test=info-row]')
.its('length')
.then((beaconCount2) => {
// cy.log(beaconCount2);
expect(+beaconCount2).to.eq(+beaconCount1);
});
});
});

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