Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add isBot flag to users to simplify matching - Ack #934 #1093

Merged
merged 3 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions client/components/ManageBotRunDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from './queries';
import DeleteButton from '../common/DeleteButton';
import BotRunTestStatusList from '../BotRunTestStatusList';
import { isBot } from '../../utils/automation';

import './ManageBotRunDialog.css';
import MarkBotRunFinishedButton from './MarkBotRunFinishedButton';
Expand Down Expand Up @@ -59,7 +58,7 @@ const ManageBotRunDialog = ({
() =>
testers.filter(
t =>
!isBot(t) &&
!t.isBot &&
!testPlanReportAssignedTestersQuery?.testPlanReport.draftTestPlanRuns.some(
d => d.tester.id === t.id
)
Expand Down
11 changes: 4 additions & 7 deletions client/components/TestQueue/AssignTesterDropdown/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import {
import { useMutation, useQuery } from '@apollo/client';
import { LoadingStatus, useTriggerLoad } from '../../common/LoadingStatus';
import { SCHEDULE_COLLECTION_JOB_MUTATION } from '../../AddTestToQueueWithConfirmation/queries';
import {
isBot,
isSupportedByResponseCollector
} from '../../../utils/automation';
import { isSupportedByResponseCollector } from '../../../utils/automation';

import './AssignTesterDropdown.css';

Expand Down Expand Up @@ -77,7 +74,7 @@ const AssignTesterDropdown = ({
});
}, `Updating Test Plan Assignees. Deleting Test Plan Run for ${tester.username}`);
} else {
if (isBot(tester)) {
if (tester.isBot) {
await triggerLoad(async () => {
await scheduleCollection({
variables: {
Expand Down Expand Up @@ -131,12 +128,12 @@ const AssignTesterDropdown = ({
const testerIsAssigned = isTesterAssigned(username);
const classname = [
testerIsAssigned ? 'assigned' : 'not-assigned',
isBot(tester) ? 'bot' : 'human'
tester.isBot ? 'bot' : 'human'
].join(' ');
let icon;
if (testerIsAssigned) {
icon = faCheck;
} else if (isBot(tester)) {
} else if (tester.isBot) {
const supportedByBot =
isSupportedByResponseCollector(
testPlanReportAtBrowserQuery?.testPlanReport
Expand Down
5 changes: 5 additions & 0 deletions client/components/TestQueue/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const TEST_QUEUE_PAGE_QUERY = gql`
id
username
roles
isBot
}
ats {
id
Expand Down Expand Up @@ -77,6 +78,7 @@ export const TEST_QUEUE_PAGE_QUERY = gql`
tester {
id
username
isBot
}
testResultsLength
}
Expand Down Expand Up @@ -128,6 +130,7 @@ export const TEST_PLAN_REPORT_QUERY = gql`
tester {
id
username
isBot
}
testResults {
id
Expand Down Expand Up @@ -267,6 +270,7 @@ export const ASSIGN_TESTER_MUTATION = gql`
tester {
id
username
isBot
}
}
}
Expand Down Expand Up @@ -304,6 +308,7 @@ export const REMOVE_TESTER_MUTATION = gql`
tester {
id
username
isBot
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions client/components/TestQueueCompletionStatusListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faRobot } from '@fortawesome/free-solid-svg-icons';
import BotTestCompletionStatus from './BotTestCompletionStatus';
import { isBot } from '../../utils/automation';
import PreviouslyAutomatedTestCompletionStatus from './PreviouslyAutomatedTestCompletionStatus';

const TestQueueCompletionStatusListItem = ({
Expand All @@ -12,14 +11,13 @@ const TestQueueCompletionStatusListItem = ({
id
}) => {
const { testResultsLength, tester } = testPlanRun;
const testerIsBot = useMemo(() => isBot(tester), [tester]);
const testPlanRunPreviouslyAutomated = useMemo(
() => testPlanRun.initiatedByAutomation,
[testPlanRun]
);

const renderTesterInfo = () => {
if (testerIsBot) {
if (tester.isBot) {
return (
<span aria-describedby={id}>
<FontAwesomeIcon icon={faRobot} />
Expand All @@ -44,7 +42,7 @@ const TestQueueCompletionStatusListItem = ({
};

const renderTestCompletionStatus = () => {
if (testerIsBot) {
if (tester.isBot) {
return (
<BotTestCompletionStatus
id={id}
Expand Down Expand Up @@ -84,7 +82,8 @@ TestQueueCompletionStatusListItem.propTypes = {
testResultsLength: PropTypes.number.isRequired,
initiatedByAutomation: PropTypes.bool.isRequired,
tester: PropTypes.shape({
username: PropTypes.string.isRequired
username: PropTypes.string.isRequired,
isBot: PropTypes.bool.isRequired
}).isRequired
}).isRequired,
id: PropTypes.string.isRequired
Expand Down
5 changes: 2 additions & 3 deletions client/components/TestQueueRow/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { LoadingStatus, useTriggerLoad } from '../common/LoadingStatus';
import './TestQueueRow.css';
import { useAriaLiveRegion } from '../providers/AriaLiveRegionProvider';
import TestQueueCompletionStatusListItem from '../TestQueueCompletionStatusListItem';
import { isBot } from '../../utils/automation';
import AssignTesterDropdown from '../TestQueue/AssignTesterDropdown';
import BotRunTestStatusList from '../BotRunTestStatusList';
import ManageBotRunDialogWithButton from '../ManageBotRunDialog/WithButton';
Expand Down Expand Up @@ -315,8 +314,8 @@ const TestQueueRow = ({
};

const renderSecondaryActions = () => {
const botTestPlanRun = draftTestPlanRuns.find(({ tester }) =>
isBot(tester)
const botTestPlanRun = draftTestPlanRuns.find(
({ tester: { isBot } }) => isBot
);

if (isAdmin && !isLoading) {
Expand Down
3 changes: 1 addition & 2 deletions client/components/TestRun/TestNavigator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { Col } from 'react-bootstrap';
import React, { useMemo } from 'react';
import '@fortawesome/fontawesome-svg-core/styles.css';
import { isBot } from '../../utils/automation';
import { COLLECTION_JOB_STATUS_BY_TEST_PLAN_RUN_ID_QUERY } from './queries';
import { useQuery } from '@apollo/client';

Expand All @@ -24,7 +23,7 @@ const TestNavigator = ({
handleTestClick = () => {},
testPlanRun = null
}) => {
const isBotCompletedTest = isBot(testPlanRun?.tester);
const isBotCompletedTest = testPlanRun?.tester?.isBot;

const { data: collectionJobQuery } = useQuery(
COLLECTION_JOB_STATUS_BY_TEST_PLAN_RUN_ID_QUERY,
Expand Down
9 changes: 4 additions & 5 deletions client/components/TestRun/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import './TestRun.css';
import ReviewConflicts from '../ReviewConflicts';
import createIssueLink from '../../utils/createIssueLink';
import { convertDateToString } from '../../utils/formatter';
import { isBot } from '../../utils/automation';

const TestRun = () => {
const params = useParams();
Expand Down Expand Up @@ -895,7 +894,7 @@ const TestRun = () => {
const renderTestsCompletedInfoBox = () => {
let isReviewingBot = false;
if (openAsUserId) {
isReviewingBot = isBot(openAsUser);
isReviewingBot = openAsUser.isBot;
}

let content;
Expand Down Expand Up @@ -1037,7 +1036,7 @@ const TestRun = () => {
href={issueLink}
/>
</li>
{isBot(openAsUser) && externalLogsUrl ? (
{openAsUser?.isBot && externalLogsUrl ? (
<li>
<OptionButton
text="View Log"
Expand Down Expand Up @@ -1125,7 +1124,7 @@ const TestRun = () => {
submitButtonRef={
testRendererSubmitButtonRef
}
isReviewingBot={isBot(openAsUser)}
isReviewingBot={openAsUser?.isBot}
isSubmitted={isTestSubmitClicked}
isEdit={isTestEditClicked}
setIsRendererReady={setIsRendererReady}
Expand Down Expand Up @@ -1222,7 +1221,7 @@ const TestRun = () => {
let openAsUserHeading = null;

if (openAsUserId) {
if (isBot(openAsUser)) {
if (openAsUser.isBot) {
openAsUserHeading = (
<div className="test-info-entity reviewing-as bot">
Reviewing tests of{' '}
Expand Down
6 changes: 6 additions & 0 deletions client/components/TestRun/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const TEST_RUN_PAGE_QUERY = gql`
tester {
id
username
isBot
}
testResults {
id
Expand Down Expand Up @@ -179,6 +180,7 @@ export const TEST_RUN_PAGE_QUERY = gql`
users {
id
username
isBot
}
}
`;
Expand Down Expand Up @@ -211,6 +213,7 @@ export const TEST_RUN_PAGE_ANON_QUERY = gql`
id
tester {
username
isBot
}
}
scenarioResult {
Expand Down Expand Up @@ -304,6 +307,7 @@ export const FIND_OR_CREATE_TEST_RESULT_MUTATION = gql`
tester {
id
username
isBot
}
testResults {
id
Expand Down Expand Up @@ -498,6 +502,7 @@ export const FIND_OR_CREATE_TEST_RESULT_MUTATION = gql`
testPlanRun {
id
tester {
isBot
username
}
}
Expand Down Expand Up @@ -596,6 +601,7 @@ export const SAVE_TEST_RESULT_MUTATION = gql`
tester {
id
username
isBot
}
testResults {
id
Expand Down
6 changes: 3 additions & 3 deletions client/tests/AssignTesterDropdown.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jest.mock('@apollo/client', () => {
});

const mockPossibleTesters = [
{ id: '1', username: 'bee' },
{ id: '2', username: 'puppy' },
{ id: '3', username: 'NVDA Bot' }
{ id: '1', username: 'bee', isBot: false },
{ id: '2', username: 'puppy', isBot: false },
{ id: '3', username: 'NVDA Bot', isBot: true }
];

const mockProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ export default testQueuePageQuery => [
{
id: '1',
username: 'foo-bar',
roles: ['ADMIN', 'TESTER']
roles: ['ADMIN', 'TESTER'],
isBot: false
},
{
id: '4',
username: 'bar-foo',
roles: ['TESTER']
roles: ['TESTER'],
isBot: false
},
{
id: '5',
username: 'boo-far',
roles: ['TESTER']
roles: ['TESTER'],
isBot: false
}
],
testPlanVersions: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default testQueuePageQuery => [
me: {
id: '101',
username: 'alflennik',
roles: ['ADMIN', 'TESTER']
roles: ['ADMIN', 'TESTER'],
isBot: false
},
ats: [
{
Expand Down Expand Up @@ -173,13 +174,20 @@ export default testQueuePageQuery => [
{
id: '1',
username: 'esmeralda-baggins',
roles: ['TESTER', 'ADMIN']
roles: ['TESTER', 'ADMIN'],
isBot: false
},
{
id: '2',
username: 'tom-proudfeet',
roles: ['TESTER'],
isBot: false
},
{ id: '2', username: 'tom-proudfeet', roles: ['TESTER'] },
{
id: '101',
username: 'alflennik',
roles: ['TESTER', 'ADMIN']
roles: ['TESTER', 'ADMIN'],
isBot: false
}
],
testPlanVersions: [
Expand Down Expand Up @@ -243,7 +251,8 @@ export default testQueuePageQuery => [
id: '1',
tester: {
id: '1',
username: 'esmeralda-baggins'
username: 'esmeralda-baggins',
isBot: false
},
testResultsLength: 0,
initiatedByAutomation: false
Expand Down Expand Up @@ -272,7 +281,8 @@ export default testQueuePageQuery => [
id: '1',
tester: {
id: '1',
username: 'esmeralda-baggins'
username: 'esmeralda-baggins',
isBot: false
},
testResultsLength: 0,
initiatedByAutomation: false
Expand All @@ -299,21 +309,30 @@ export default testQueuePageQuery => [
draftTestPlanRuns: [
{
id: '3',
tester: { id: '2', username: 'tom-proudfeet' },
tester: {
id: '2',
username: 'tom-proudfeet',
isBot: false
},
testResultsLength: 3,
initiatedByAutomation: false
},
{
id: '101',
tester: { id: '101', username: 'alflennik' },
tester: {
id: '101',
username: 'alflennik',
isBot: false
},
testResultsLength: 1,
initiatedByAutomation: false
},
{
id: '2',
tester: {
id: '1',
username: 'esmeralda-baggins'
username: 'esmeralda-baggins',
isBot: false
},
testResultsLength: 3,
initiatedByAutomation: false
Expand Down
Loading
Loading