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

Commit 4804c37

Browse files
authored
Merge pull request #78 from cisagov/timeline-tests
Timeline tests
2 parents 410037d + bac4d99 commit 4804c37

File tree

15 files changed

+427
-190
lines changed

15 files changed

+427
-190
lines changed

applications/client/src/views/Campaign/Explore/Panels/Command/Command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const Command = observer<CommandProps>(
4848
{command?.info.time.format(`${dateShortFormat} ${timeFormat}`)}
4949
</Txt>
5050
<Spacer />
51-
<Txt cy-test="operator-info">{command?.info.operator}</Txt>
51+
<Txt cy-test="command-operator">{command?.info.operator}</Txt>
5252
{isCollapsed && showPath && (
5353
<>
5454
<Spacer>{' • '}</Spacer>

applications/client/src/views/Campaign/Explore/components/Comment/CommentBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export const CommentBox = observer<CommentBoxProps>(
399399
<span>
400400
<CarbonIcon cy-test="comment-icon" icon={Chat16} />
401401
<Spacer />
402-
<Txt>
402+
<Txt cy-test="user-that-commented">
403403
{annotation?.user !== undefined ? (
404404
annotation?.user
405405
) : (

applications/client/src/views/Campaign/Timeline/BarLabels.tsx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,42 @@ export const BarLabelDate = observer<BarLabelsProps>(({ bar, dateFormatter }) =>
2424
{dateStart}
2525
</Txt>
2626
) : sameDate && dateFormatter === dateTimeFormat ? (
27-
<Txt block bold small>{`${dateStart} - ${dateEnd.split(' ')[1]}`}</Txt>
27+
<Txt cy-test="timeline-tooltip-date-time" block bold small>{`${dateStart} - ${dateEnd.split(' ')[1]}`}</Txt>
2828
) : (
2929
<Txt block bold small>{`${dateStart} - ${dateEnd}`}</Txt>
3030
);
3131
});
3232

3333
export const BarLabelOnHover = observer<BarLabelsProps>(({ bar, dateFormatter }) => (
34-
<div css={barPopoverStyles}>
34+
<div cy-test="timeline-tooltip-static" css={barPopoverStyles}>
3535
<BarLabelDate bar={bar} dateFormatter={dateFormatter} />
3636
<FlexSplitter />
3737
<Flex css={{ paddingTop: '0.2rem' }}>
38-
<Txt muted small css={marginStyles(1)}>
38+
<Txt cy-test="timeline-beacons" muted small css={marginStyles(1)}>
3939
Beacons
4040
</Txt>
4141
<FlexSplitter />
42-
<Txt small>{bar?.beaconNumbers}</Txt>
42+
<Txt cy-test="timeline-beacon-count" small>
43+
{bar?.beaconNumbers}
44+
</Txt>
4345
</Flex>
4446
<Flex>
45-
<Txt muted small css={marginStyles(1)}>
47+
<Txt cy-test="timeline-total-commands" muted small css={marginStyles(1)}>
4648
Total commands
4749
</Txt>
4850
<FlexSplitter />
49-
<Txt small>{bar?.beaconCount}</Txt>
51+
<Txt cy-test="timeline-total-command-count" small>
52+
{bar?.beaconCount}
53+
</Txt>
5054
</Flex>
5155
<Flex>
52-
<Txt muted small css={marginStyles(1)}>
56+
<Txt cy-test="timeline-active-beacons" muted small css={marginStyles(1)}>
5357
Active Beacon commands
5458
</Txt>
5559
<FlexSplitter />
56-
<Txt small>{bar?.activeBeaconCount}</Txt>
60+
<Txt cy-test="timeline-active-beacon-count" small>
61+
{bar?.activeBeaconCount}
62+
</Txt>
5763
</Flex>
5864
</div>
5965
));
@@ -74,15 +80,15 @@ export const BarLabelBeaconList = observer<BarLabelsProps>(({ bar, dateFormatter
7480
});
7581
};
7682
return (
77-
<div css={barPopoverStyles}>
83+
<div cy-test="timeline-tooltip-clickable" css={barPopoverStyles}>
7884
<BarLabelDate bar={bar} dateFormatter={dateFormatter} />
7985
<FlexSplitter />
8086
<Flex css={{ padding: '0.2rem 0' }}>
81-
<Txt small bold>
87+
<Txt cy-test="timeline-beacon-header" small bold>
8288
Beacons
8389
</Txt>
8490
<FlexSplitter />
85-
<Txt small bold>
91+
<Txt cy-test="timeline-command-header" small bold>
8692
Commands
8793
</Txt>
8894
</Flex>
@@ -92,14 +98,16 @@ export const BarLabelBeaconList = observer<BarLabelsProps>(({ bar, dateFormatter
9298
css={barPopoverRowStyles}
9399
onClick={() => routeToBeacon(beaconCommand.beaconId as string)}
94100
>
95-
<Txt small css={marginStyles(0.5)}>
101+
<Txt cy-test="timeline-beacon-name" small css={marginStyles(0.5)}>
96102
{store.graphqlStore.beacons.get(beaconCommand.beaconId as string)?.displayName}
97103
</Txt>
98-
<Txt muted small css={marginStyles(4)}>
99-
{store.graphqlStore.beacons.get(beaconCommand.beaconId as string)?.meta[0]?.maybeCurrent?.username}
104+
<Txt cy-test="timeline-beacon-operator" muted small css={marginStyles(4)}>
105+
{store.graphqlStore.beacons.get(beaconCommand.beaconId as string)?.meta[0].maybeCurrent?.username}
100106
</Txt>
101107
<FlexSplitter />
102-
<Txt small>{beaconCommand.commandCount}</Txt>
108+
<Txt cy-test="timeline-beacon-command-count" small>
109+
{beaconCommand.commandCount}
110+
</Txt>
103111
</Flex>
104112
))}
105113
</div>

applications/client/src/views/Campaign/Timeline/Bars.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const Bars = observer<BarsProps>(({ xScale, bars, start, end, dimensions,
6060
}}
6161
renderTarget={({ isOpen, ref, ...targetProps }) => (
6262
<g
63+
cy-test="timeline-bar"
6364
ref={ref}
6465
{...targetProps}
6566
onMouseDown={(e) => {

applications/client/src/views/Campaign/Timeline/Timeline.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const Timeline = observer<TimelineProps>(({ ...props }) => {
110110
<Header small cy-test="timeline-header" css={headerStyle}>
111111
Timeline
112112
</Header>
113-
<ButtonGroup>
113+
<ButtonGroup cy-test="timeline-edit-dates">
114114
{state.showDateRangeInput && state.dateRange.length === 2 ? (
115115
<DateRangeInput2
116116
disabled={disableControls}
@@ -149,9 +149,9 @@ export const Timeline = observer<TimelineProps>(({ ...props }) => {
149149
css={{ marginRight: `-6px !important` }}
150150
>
151151
<Txt small monospace>
152-
<Txt>{startDateMoment.isValid() ? startDateMoment.format(dateFormat) : datePlaceholder}</Txt>
152+
<Txt cy-test="timeline-start-date">{startDateMoment.isValid() ? startDateMoment.format(dateFormat) : datePlaceholder}</Txt>
153153
<Spacer>&mdash;</Spacer>
154-
<Txt>{endDateMoment.isValid() ? endDateMoment.format(dateFormat) : datePlaceholder}</Txt>
154+
<Txt cy-test="timeline-end-date">{endDateMoment.isValid() ? endDateMoment.format(dateFormat) : datePlaceholder}</Txt>
155155
</Txt>
156156
</Button>
157157
)}

applications/redeye-e2e/src/integration/e2e/redteam/beacon-count.skip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('Beacon counts', () => {
8484
});
8585
});
8686
// Go back to Hosts and log beacon count for second host
87-
cy.clickExporerMode();
87+
cy.clickExplorerMode();
8888
cy
8989
.get('[cy-test=row-beacon-count]')
9090
.eq(1)

applications/redeye-e2e/src/integration/e2e/redteam/command-to-beacon.cy.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ describe('Navigate to beacon through command details', () => {
1919
cy
2020
.get('[cy-test=hostBeaconInfo]')
2121
.eq(0)
22+
.children()
23+
.eq(2)
2224
.invoke('text')
2325
.then((text) => {
24-
let commandText = text.split('COMPUTER02')[1];
25-
// cy.log(commandText);
26-
// FIND A BETTER WAY OF DOING THIS SO WE'RE NOT DEPENDENT ON TEXT TO SPLIT THE PIECES OF INFO
27-
2826
// Click on the beacon name
29-
cy.get('[cy-test=hostBeaconInfo]').contains(commandText).click();
27+
cy.get('[cy-test=hostBeaconInfo]').contains(text).click();
3028

3129
// Verify that the page directed to the appropriate beacon
3230
cy
@@ -40,7 +38,7 @@ describe('Navigate to beacon through command details', () => {
4038
.invoke('text')
4139
.then((userName) => {
4240
// cy.log(userName);
43-
expect(beaconName + ' ' + userName).to.eq(commandText);
41+
expect(beaconName + ' ' + userName).to.eq(text);
4442
});
4543
});
4644
});

applications/redeye-e2e/src/integration/e2e/redteam/graphql/globalOperators.cy.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ describe('Query Global Operators', () => {
1515
}
1616
}`;
1717
const variables = `{"password": "937038570"}`;
18-
graphqlRequest(query, variables).then((res) => {
19-
expect(res.body.data.globalOperators[0].id).to.eq('analyst');
20-
expect(res.body.data.globalOperators[0].name).to.eq('analyst');
18+
graphqlRequest(query, variables).then((response) => {
19+
const res = response.body.data.globalOperators;
20+
const match = Cypress._.find(res, { id: 'cypress' });
21+
cy.wrap(match).its('name').should('eq', 'cypress');
2122
});
2223

2324
cy.returnToCampaignCard();

0 commit comments

Comments
 (0)