Skip to content

Commit 54a5375

Browse files
authored
fix: page query response time reduction and server load improvements (#1592)
* Remove rest results from test queue query * server side caching for test plans * fix: remove unneeded draftTestPlanRuns from query * Delayed report rerun load with caching * Unnecessary fetch in test plan report status dialog * cache-first TestQueue * Aggressive Apollo caching * code splitting, lazy loading, don't query tests when not needed * remove query of User.at in TestQueue * do not query collection job for percent poll * don't query testPlanReportStatuses, TestQueue * Cache first TestQueue * webpack prefetching * report level fetch/refetch, TestQueue * report level fetch/refetch, TestQueue * Cleanup, lint * Delay git property load until disclosure open * Handle cache resolution on report rows * Better total scenario count resolver * Update snapshots * Delay fetching full testPlanReports * Use dataloader, honor attributes in test plan resolver * Fix TestQueue.test * Adjust assigntesterdropdown * Fix on hold * Refetch report rows on assign tester through ManageBotRunDialog, graphql test update * Wait for refetch in TestRun e2e test * Update snapshots * More waits for secondary load in the TestRun.e2e * Refetch collection job on cancel * Handle delayed row fetch in conditional render for feature table * Don't use eval click in TestRun.e2e. * TestRun.e2e don't attempt click if el not found * ReportRerun, wait for table with tab loads * Update webpack.prod.js * Correct version sorting * Add atversion to row query * refetch row after delay on start bot run in report * Update snaps * Update snapshots * Handle reload at subroute with Tab better * Fix tests after merge, update snaps * Update snapshots
1 parent 4f80595 commit 54a5375

File tree

81 files changed

+4176
-1681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4176
-1681
lines changed

client/components/AddTestToQueueWithConfirmation/index.jsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useMemo, useRef, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import { Button } from 'react-bootstrap';
44
import BasicModal from '../common/BasicModal';
5-
import { useMutation, useQuery } from '@apollo/client';
5+
import { useMutation, useQuery, useApolloClient } from '@apollo/client';
66
import { LoadingStatus, useTriggerLoad } from '../common/LoadingStatus';
77
import {
88
getBotUsernameFromAtBrowser,
@@ -14,7 +14,10 @@ import {
1414
EXISTING_TEST_PLAN_REPORTS,
1515
ADD_TEST_QUEUE_MUTATION
1616
} from './queries';
17-
import { TEST_QUEUE_PAGE_QUERY } from '../TestQueue/queries';
17+
import {
18+
TEST_QUEUE_PAGE_QUERY,
19+
TEST_QUEUE_EXPANDED_ROW_QUERY
20+
} from '../TestQueue/queries';
1821
import { TEST_PLAN_REPORT_STATUS_DIALOG_QUERY } from '../TestPlanReportStatusDialog/queries';
1922
import { ME_QUERY } from '../App/queries';
2023

@@ -28,6 +31,7 @@ function AddTestToQueueWithConfirmation({
2831
buttonText = 'Add to Test Queue',
2932
triggerUpdate = () => {}
3033
}) {
34+
const client = useApolloClient();
3135
const [showPreserveReportDataMessage, setShowPreserveReportDataMessage] =
3236
useState(false);
3337
const [showConfirmation, setShowConfirmation] = useState(false);
@@ -61,6 +65,7 @@ function AddTestToQueueWithConfirmation({
6165
directory: testPlanVersion?.testPlan?.directory
6266
},
6367
fetchPolicy: 'cache-and-network',
68+
nextFetchPolicy: 'cache-first',
6469
skip: !testPlanVersion?.id
6570
}
6671
);
@@ -296,8 +301,30 @@ function AddTestToQueueWithConfirmation({
296301
await scheduleCollection({
297302
variables: {
298303
testPlanReportId: testPlanReport.id
299-
}
304+
},
305+
refetchQueries: [
306+
ME_QUERY,
307+
EXISTING_TEST_PLAN_REPORTS,
308+
TEST_QUEUE_PAGE_QUERY,
309+
TEST_PLAN_REPORT_STATUS_DIALOG_QUERY
310+
],
311+
awaitRefetchQueries: true
300312
});
313+
314+
// Wait a moment for React to re-render and mount the new row component
315+
await new Promise(resolve => setTimeout(resolve, 100));
316+
317+
// Manually fetch the expanded row query to update the cache
318+
// This ensures the run appears immediately
319+
try {
320+
await client.query({
321+
query: TEST_QUEUE_EXPANDED_ROW_QUERY,
322+
variables: { testPlanReportId: testPlanReport.id },
323+
fetchPolicy: 'network-only'
324+
});
325+
} catch (error) {
326+
// If the query fails, that's okay - it will load when the component mounts
327+
}
301328
}, 'Scheduling Collection Job');
302329
setShowConfirmation(true);
303330
};

client/components/BotRunTestStatusList/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const BotRunTestStatusList = ({ testPlanReportId }) => {
3333
} = useQuery(TEST_PLAN_RUNS_TEST_RESULTS_QUERY, {
3434
variables: { testPlanReportId },
3535
fetchPolicy: 'cache-and-network',
36+
nextFetchPolicy: 'cache-first',
3637
pollInterval
3738
});
3839

client/components/CandidateReview/index.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ import { ME_QUERY } from '../App/queries';
77

88
const CandidateReview = () => {
99
const { loading, data, error } = useQuery(CANDIDATE_REVIEW_PAGE_QUERY, {
10-
fetchPolicy: 'cache-and-network'
10+
fetchPolicy: 'cache-and-network',
11+
nextFetchPolicy: 'cache-first'
1112
});
1213

13-
const { data: meData } = useQuery(ME_QUERY);
14+
const { data: meData } = useQuery(ME_QUERY, {
15+
fetchPolicy: 'cache-and-network',
16+
nextFetchPolicy: 'cache-first'
17+
});
1418
const { me } = meData;
1519

1620
if (error) {

client/components/DataManagement/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import styles from './DataManagement.module.css';
2424
const DataManagement = () => {
2525
const { loading, data, error, refetch } = useQuery(
2626
DATA_MANAGEMENT_PAGE_QUERY,
27-
{ fetchPolicy: 'cache-and-network' }
27+
{
28+
fetchPolicy: 'cache-and-network',
29+
nextFetchPolicy: 'cache-first'
30+
}
2831
);
2932

3033
const [pageReady, setPageReady] = useState(false);

client/components/DataManagement/queries.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@ import {
33
AT_FIELDS,
44
AT_VERSION_FIELDS,
55
BROWSER_FIELDS,
6-
BROWSER_VERSION_FIELDS,
76
ISSUE_FIELDS,
87
ME_FIELDS,
98
TEST_PLAN_FIELDS,
109
TEST_PLAN_REPORT_FIELDS,
11-
TEST_PLAN_VERSION_FIELDS,
12-
TEST_RESULT_FIELDS
10+
TEST_PLAN_VERSION_FIELDS
1311
} from '@components/common/fragments';
1412

1513
export const DATA_MANAGEMENT_PAGE_QUERY = gql`
1614
${AT_FIELDS}
1715
${AT_VERSION_FIELDS}
1816
${BROWSER_FIELDS}
19-
${BROWSER_VERSION_FIELDS}
2017
${ISSUE_FIELDS()}
2118
${ME_FIELDS}
2219
${TEST_PLAN_FIELDS}
2320
${TEST_PLAN_REPORT_FIELDS}
24-
${TEST_RESULT_FIELDS}
2521
query DataManagementPage {
2622
me {
2723
...MeFields
@@ -87,26 +83,6 @@ export const DATA_MANAGEMENT_PAGE_QUERY = gql`
8783
browser {
8884
...BrowserFields
8985
}
90-
draftTestPlanRuns {
91-
tester {
92-
username
93-
}
94-
testPlanReport {
95-
id
96-
}
97-
testResults {
98-
...TestResultFields
99-
test {
100-
id
101-
}
102-
atVersion {
103-
...AtVersionFields
104-
}
105-
browserVersion {
106-
...BrowserVersionFields
107-
}
108-
}
109-
}
11086
}
11187
}
11288
}

client/components/GraphQLProvider/GraphQLProvider.jsx

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import {
99
concat
1010
} from '@apollo/client';
1111

12-
// Dynamically set GraphQL request headers
13-
// See https://www.apollographql.com/docs/react/networking/advanced-http-networking#customizing-request-logic
1412
const headerMiddleware = new ApolloLink((operation, forward) => {
1513
const currentTransactionId = sessionStorage.getItem('currentTransactionId');
1614
if (currentTransactionId) {
@@ -33,25 +31,60 @@ const client = new ApolloClient({
3331
fields: {
3432
me: { merge: true },
3533
testPlanVersion: { merge: true },
36-
testPlanVersions: { merge: false },
3734
testPlanReport: { merge: true },
38-
testPlanReports: { merge: false },
3935
collectionJobByTestPlanRunId: {
4036
merge(existing, incoming) {
4137
return { ...existing, ...incoming };
4238
}
4339
}
4440
}
4541
},
46-
Mutation: {
47-
fields: {
48-
testPlanReport: { merge: false },
49-
testPlanRun: { merge: false },
50-
testPlanVersion: { merge: false }
51-
}
42+
At: {
43+
keyFields: ['id']
44+
},
45+
AtVersion: {
46+
keyFields: ['id']
47+
},
48+
Browser: {
49+
keyFields: ['id']
50+
},
51+
BrowserVersion: {
52+
keyFields: ['id']
53+
},
54+
TestPlan: {
55+
keyFields: ['id']
56+
},
57+
TestPlanVersion: {
58+
keyFields: ['id']
59+
},
60+
TestPlanReport: {
61+
keyFields: ['id']
62+
},
63+
TestPlanRun: {
64+
keyFields: ['id']
65+
},
66+
TestResult: {
67+
keyFields: ['id']
68+
},
69+
CollectionJob: {
70+
keyFields: ['id']
71+
},
72+
User: {
73+
keyFields: ['id']
74+
},
75+
AriaHtmlFeaturesMetrics: {
76+
keyFields: false
5277
}
5378
}
54-
})
79+
}),
80+
defaultOptions: {
81+
query: {
82+
errorPolicy: 'all'
83+
},
84+
watchQuery: {
85+
errorPolicy: 'all'
86+
}
87+
}
5588
});
5689

5790
const resetCache = async () => {

client/components/ManageBotRunDialog/StartBotRunButton/index.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import useConfirmationModal from '../../../hooks/useConfirmationModal';
88
import { useTriggerLoad } from '../../common/LoadingStatus';
99
import BasicModal from '../../common/BasicModal';
1010
import { SCHEDULE_COLLECTION_JOB_MUTATION } from '../../AddTestToQueueWithConfirmation/queries';
11-
import { TEST_QUEUE_PAGE_QUERY } from '../../TestQueue/queries';
11+
import {
12+
TEST_QUEUE_PAGE_QUERY,
13+
TEST_QUEUE_EXPANDED_ROW_QUERY
14+
} from '../../TestQueue/queries';
1215
import { TEST_PLAN_REPORT_STATUS_DIALOG_QUERY } from '../../TestPlanReportStatusDialog/queries';
1316

1417
const StartBotRunButton = ({ testPlanReport, onChange }) => {
@@ -62,7 +65,11 @@ const StartBotRunButton = ({ testPlanReport, onChange }) => {
6265
variables: { testPlanReportId: testPlanReport.id },
6366
refetchQueries: [
6467
TEST_QUEUE_PAGE_QUERY,
65-
TEST_PLAN_REPORT_STATUS_DIALOG_QUERY
68+
TEST_PLAN_REPORT_STATUS_DIALOG_QUERY,
69+
{
70+
query: TEST_QUEUE_EXPANDED_ROW_QUERY,
71+
variables: { testPlanReportId: testPlanReport.id }
72+
}
6673
],
6774
awaitRefetchQueries: true
6875
});

client/components/ManageBotRunDialog/StopRunningCollectionButton/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const StopRunningCollectionButton = ({ collectionJob, onClick = () => {} }) => {
1313
variables: {
1414
collectionJobId: collectionJob.id
1515
},
16-
skip: !collectionJob
16+
skip: !collectionJob,
17+
refetchQueries: ['CollectionJobIdByTestPlanRunId']
1718
});
1819

1920
if (!collectionJob) {

client/components/ManageBotRunDialog/index.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const ManageBotRunDialog = ({
4040
variables: {
4141
testPlanRunId: testPlanRun.id
4242
},
43-
fetchPolicy: 'cache-and-network'
43+
fetchPolicy: 'cache-first'
4444
}
4545
);
4646

@@ -57,7 +57,7 @@ const ManageBotRunDialog = ({
5757
variables: {
5858
testPlanReportId
5959
},
60-
fetchPolicy: 'cache-and-network'
60+
fetchPolicy: 'cache-only'
6161
}
6262
);
6363

@@ -75,7 +75,9 @@ const ManageBotRunDialog = ({
7575

7676
const { isAdmin, isTester } = evaluateAuth(me);
7777

78-
const [assignTester] = useMutation(ASSIGN_TESTER_MUTATION);
78+
const [assignTester] = useMutation(ASSIGN_TESTER_MUTATION, {
79+
refetchQueries: ['TestQueueExpandedRow']
80+
});
7981

8082
const isBotRunFinished = useMemo(() => {
8183
const status = collectionJobQuery?.collectionJobByTestPlanRunId?.status;
@@ -187,7 +189,9 @@ const ManageBotRunDialog = ({
187189
collectionJobQuery,
188190
isAdmin,
189191
isTester,
190-
isBotRunFinished
192+
isBotRunFinished,
193+
me?.id,
194+
assignTester
191195
]);
192196

193197
const deleteConfirmationContent = (

client/components/ManageBotRunDialog/queries.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ export const TEST_PLAN_REPORT_ASSIGNED_TESTERS_QUERY = gql`
1515
testPlanReport(id: $testPlanReportId) {
1616
id
1717
draftTestPlanRuns {
18+
id
1819
tester {
1920
id
21+
username
22+
isBot
2023
}
2124
}
2225
}

0 commit comments

Comments
 (0)