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: Only include CollectionJob metrics in Bot Status calculation on Test Queue page when tester.isBot is true #1237

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions client/components/BotRunTestStatusList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ const BotRunTestStatusList = ({ testPlanReportId }) => {
};
let anyPossibleUpdates = false;
if (testPlanRunsQueryResult?.testPlanRuns) {
for (const { collectionJob } of testPlanRunsQueryResult.testPlanRuns) {
if (collectionJob?.testStatus) {
for (const {
collectionJob,
tester
} of testPlanRunsQueryResult.testPlanRuns) {
if (collectionJob?.testStatus && tester?.isBot) {
for (const { status } of collectionJob.testStatus) {
counter[status]++;
if (status === 'QUEUED' || status === 'RUNNING') {
Expand Down
1 change: 1 addition & 0 deletions client/components/BotRunTestStatusList/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const TEST_PLAN_RUNS_TEST_RESULTS_QUERY = gql`
id
tester {
username
isBot
}
testResults {
id
Expand Down
56 changes: 50 additions & 6 deletions client/tests/BotRunTestStatusList.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('correctly displays statuses for single COMPLETED test run', async () => {
{
id: '0',
testResults: new Array(3).fill(null),
tester: { username: 'bot' },
tester: { username: 'bot', isBot: true },
collectionJob: {
status: COLLECTION_JOB_STATUS.COMPLETED,
testStatus: [
Expand Down Expand Up @@ -59,7 +59,7 @@ test('correctly ignores test results from a human-submitted test plan run', asyn
{
id: '0',
testResults: new Array(2).fill(null),
tester: { username: 'bot' },
tester: { username: 'bot', isBot: true },
collectionJob: {
status: COLLECTION_JOB_STATUS.COMPLETED,
testStatus: [
Expand All @@ -71,7 +71,7 @@ test('correctly ignores test results from a human-submitted test plan run', asyn
{
id: '1',
testResults: new Array(2).fill(null),
tester: { username: 'human' },
tester: { username: 'human', isBot: false },
collectionJob: null
}
];
Expand All @@ -90,12 +90,56 @@ test('correctly ignores test results from a human-submitted test plan run', asyn
});
});

// See gh-1237 - Check if user is a bot, to include in Bot Status calculation on Test Queue page
// https://github.com/w3c/aria-at-app/pull/1237
test('correctly ignores test results from a human-submitted test plan run with a collectionJob attribute', async () => {
const testPlanRuns = [
{
id: '0',
testResults: new Array(3).fill(null),
tester: { username: 'bot', isBot: true },
collectionJob: {
status: COLLECTION_JOB_STATUS.COMPLETED,
testStatus: [
{ status: COLLECTION_JOB_STATUS.COMPLETED },
{ status: COLLECTION_JOB_STATUS.COMPLETED },
{ status: COLLECTION_JOB_STATUS.COMPLETED }
]
}
},
{
id: '1',
testResults: new Array(3).fill(null),
tester: { username: 'human', isBot: false },
status: COLLECTION_JOB_STATUS.COMPLETED,
testStatus: [
{ status: COLLECTION_JOB_STATUS.COMPLETED },
{ status: COLLECTION_JOB_STATUS.COMPLETED },
{ status: COLLECTION_JOB_STATUS.COMPLETED }
]
}
];

const mocks = getMocks(testPlanRuns);

const { getByText } = render(
<MockedProvider mocks={mocks} addTypename={false}>
<BotRunTestStatusList testPlanReportId="1" />
</MockedProvider>
);

await waitFor(async () => {
expect(getByText('3 Tests Completed')).toBeInTheDocument();
expect(getByText('0 Tests Queued')).toBeInTheDocument();
});
});

test('correctly displays statuses for CANCELLED test run', async () => {
const testPlanRuns = [
{
id: '0',
testResults: new Array(2).fill(null),
tester: { username: 'bot' },
tester: { username: 'bot', isBot: true },
collectionJob: {
status: COLLECTION_JOB_STATUS.CANCELLED,
testStatus: [
Expand Down Expand Up @@ -127,7 +171,7 @@ test('correctly displays statuses for multiple RUNNING and QUEUED test runs', as
{
id: '0',
testResults: new Array(2).fill(null),
tester: { username: 'bot' },
tester: { username: 'bot', isBot: true },
collectionJob: {
status: COLLECTION_JOB_STATUS.RUNNING,
testStatus: [
Expand All @@ -140,7 +184,7 @@ test('correctly displays statuses for multiple RUNNING and QUEUED test runs', as
{
id: '1',
testResults: new Array(2).fill(null),
tester: { username: 'bot' },
tester: { username: 'bot', isBot: true },
collectionJob: {
status: COLLECTION_JOB_STATUS.CANCELLED,
testStatus: [
Expand Down
Loading