Skip to content

Commit cdd212d

Browse files
stalgiaghoward-e
andauthored
feat: Issues table for Test Plan Review page (#1269)
* First pass on adding issues table to test review * Code simplification in TestPlanVersionsPage * Update snapshots, handle missing data * Update client/components/TestReview/queries.js Co-authored-by: Howard Edwards <[email protected]> --------- Co-authored-by: Howard Edwards <[email protected]>
1 parent 18fd21c commit cdd212d

File tree

4 files changed

+67
-17
lines changed

4 files changed

+67
-17
lines changed

client/components/TestPlanVersionsPage/index.jsx

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef } from 'react';
1+
import React, { useMemo, useRef } from 'react';
22
import { useQuery } from '@apollo/client';
33
import { TEST_PLAN_VERSIONS_PAGE_QUERY } from './queries';
44
import PageStatus from '../common/PageStatus';
@@ -88,6 +88,12 @@ const TestPlanVersionsPage = () => {
8888
const expandedVersionSections = useRef();
8989
const toggleVersionSections = useRef();
9090

91+
// GraphQL results are read only so they need to be cloned
92+
// before passing to SortableIssuesTable
93+
const issues = useMemo(() => {
94+
return data ? [...data.testPlan.issues] : [];
95+
}, [data]);
96+
9197
if (error) {
9298
return (
9399
<PageStatus
@@ -192,23 +198,12 @@ const TestPlanVersionsPage = () => {
192198
return derivedPhaseDeprecatedDuring;
193199
};
194200

195-
const testPlan = data.testPlan;
201+
const { testPlan, ats } = data;
196202

197-
// GraphQL results are read only so they need to be cloned before sorting
198-
const issues = [...testPlan.issues].sort((a, b) => {
199-
const aCreatedAt = new Date(a.createdAt);
200-
const bCreatedAt = new Date(b.createdAt);
201-
return bCreatedAt - aCreatedAt;
203+
const testPlanVersions = testPlan.testPlanVersions.slice().sort((a, b) => {
204+
return new Date(b.updatedAt) - new Date(a.updatedAt);
202205
});
203206

204-
const ats = data.ats;
205-
206-
const testPlanVersions = data.testPlan.testPlanVersions
207-
.slice()
208-
.sort((a, b) => {
209-
return new Date(b.updatedAt) - new Date(a.updatedAt);
210-
});
211-
212207
const timelineForAllVersions = [];
213208

214209
testPlanVersions.forEach(testPlanVersion => {

client/components/TestReview/index.jsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Fragment, useState } from 'react';
1+
import React, { Fragment, useMemo, useState } from 'react';
22
import { useQuery } from '@apollo/client';
33
import { TEST_REVIEW_PAGE_QUERY } from './queries';
44
import { Container } from 'react-bootstrap';
@@ -11,6 +11,7 @@ import styled from '@emotion/styled';
1111
import { derivePhaseName } from '../../utils/aria';
1212
import { dates } from 'shared';
1313
import supportJson from '../../resources/support.json';
14+
import SortableIssuesTable from '../SortableIssuesTable';
1415

1516
const Ul = styled.ul`
1617
li {
@@ -35,6 +36,12 @@ const TestReview = () => {
3536
});
3637
const [activeFilter, setActiveFilter] = useState('All ATs');
3738

39+
// GraphQL results are read only so they need to be cloned
40+
// before passing to SortableIssuesTable
41+
const issues = useMemo(() => {
42+
return data ? [...data.testPlanVersion.testPlan.issues] : [];
43+
}, [data]);
44+
3845
if (loading) {
3946
return (
4047
<PageStatus
@@ -230,6 +237,7 @@ const TestReview = () => {
230237
}
231238
)}
232239
</ul>
240+
<SortableIssuesTable issues={issues} />
233241
<h2>Tests</h2>
234242
<FilterButtonContainer>
235243
<FilterButtons

client/components/TestReview/queries.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { gql } from '@apollo/client';
22
import {
33
AT_FIELDS,
4-
TEST_PLAN_VERSION_FIELDS
4+
TEST_PLAN_VERSION_FIELDS,
5+
ISSUE_FIELDS
56
} from '@components/common/fragments';
67

78
export const TEST_REVIEW_PAGE_QUERY = gql`
89
${AT_FIELDS}
910
${TEST_PLAN_VERSION_FIELDS}
11+
${ISSUE_FIELDS('all')}
1012
query TestReviewPageQuery($testPlanVersionId: ID!) {
1113
testPlanVersion(id: $testPlanVersionId) {
1214
...TestPlanVersionFields
15+
testPlan {
16+
issues {
17+
...IssueFieldsAll
18+
at {
19+
...AtFields
20+
}
21+
}
22+
}
1323
tests {
1424
id
1525
title

client/tests/e2e/snapshots/saved/_test-review_8.html

+37
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,43 @@ <h2>Supporting Documentation</h2>
123123
>
124124
</li>
125125
</ul>
126+
<h2 id="github-issues">GitHub Issues (0 open, 0&nbsp;closed)</h2>
127+
<ul
128+
class="d-flex align-items-center my-3"
129+
aria-label="Filter GitHub issues"
130+
role="group">
131+
<li aria-hidden="true">Filter</li>
132+
<li>
133+
<button
134+
type="button"
135+
data-test="filter-open"
136+
aria-pressed="true"
137+
class="css-14jv778 btn active btn-secondary">
138+
Open
139+
</button>
140+
</li>
141+
<li>
142+
<button
143+
type="button"
144+
data-test="filter-closed"
145+
aria-pressed="false"
146+
class="css-14jv778 btn btn-secondary">
147+
Closed
148+
</button>
149+
</li>
150+
<li>
151+
<button
152+
type="button"
153+
data-test="filter-all"
154+
aria-pressed="false"
155+
class="css-14jv778 btn btn-secondary">
156+
All
157+
</button>
158+
</li>
159+
</ul>
160+
<div aria-labelledby="github-issues" class="css-gy9uo3">
161+
No GitHub Issues
162+
</div>
126163
<h2>Tests</h2>
127164
<div class="css-ifttx1">
128165
<ul

0 commit comments

Comments
 (0)