-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathSummarizeTestPlanReport.jsx
296 lines (279 loc) · 11.5 KB
/
SummarizeTestPlanReport.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import { createGitHubIssueWithTitleAndBody } from '../TestRun';
import { getTestPlanTargetTitle, getTestPlanVersionTitle } from './getTitles';
import { Breadcrumb, Button, Container } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faExclamationCircle,
faExternalLinkAlt,
faHome
} from '@fortawesome/free-solid-svg-icons';
import { differenceBy } from 'lodash';
import { convertDateToString } from '../../utils/formatter';
import DisclaimerInfo from '../DisclaimerInfo';
import TestPlanResultsTable from './TestPlanResultsTable';
import DisclosureComponent from '../common/DisclosureComponent';
import { Navigate } from 'react-router';
import { useParams } from 'react-router-dom';
const getTestersRunHistory = (
testPlanReport,
testId,
draftTestPlanRuns = []
) => {
const { id: testPlanReportId, at, browser } = testPlanReport;
let lines = [];
draftTestPlanRuns.forEach(draftTestPlanRun => {
const { testPlanReport, testResults, tester } = draftTestPlanRun;
const testResult = testResults.find(item => item.test.id === testId);
if (
testPlanReportId === testPlanReport.id &&
testPlanReport.status === 'CANDIDATE' &&
testResult?.completedAt
) {
lines.push(
<li
key={`${testResult.atVersion.id}-${testResult.browserVersion.id}-${testResult.test.id}-${tester.username}`}
>
Tested with{' '}
<b>
{at.name} {testResult.atVersion.name}
</b>{' '}
and{' '}
<b>
{browser.name} {testResult.browserVersion.name}
</b>{' '}
by{' '}
<b>
<a href={`https://github.com/${tester.username}`}>
{tester.username}
</a>
</b>{' '}
on{' '}
{convertDateToString(
testResult.completedAt,
'MMMM DD, YYYY'
)}
.
</li>
);
}
});
return (
<ul
style={{
marginBottom: '0'
}}
>
{lines}
</ul>
);
};
const SummarizeTestPlanReport = ({ testPlanReports }) => {
const { testPlanReportId } = useParams();
const testPlanReport = testPlanReports.find(
each => each.id == testPlanReportId
);
if (!testPlanReport) return <Navigate to="/404" />;
const { testPlanVersion, at, browser } = testPlanReport;
// Construct testPlanTarget
const testPlanTarget = {
id: `${at.id}${browser.id}`,
at,
browser
};
const skippedTests = differenceBy(
testPlanReport.runnableTests,
testPlanReport.finalizedTestResults,
testOrTestResult => testOrTestResult.test?.id ?? testOrTestResult.id
);
return (
<Container id="main" as="main" tabIndex="-1">
<Helmet>
<title>
{getTestPlanTargetTitle(testPlanTarget)} for
{getTestPlanVersionTitle(testPlanVersion)} | ARIA-AT Reports
</title>
</Helmet>
<h1>
{getTestPlanVersionTitle(testPlanVersion)} with
{getTestPlanTargetTitle(testPlanTarget)}
</h1>
<Breadcrumb
label="Breadcrumb"
listProps={{
'aria-label': 'Breadcrumb Navigation'
}}
>
<LinkContainer to="/reports">
<Breadcrumb.Item>
<FontAwesomeIcon icon={faHome} />
Test Reports
</Breadcrumb.Item>
</LinkContainer>
<LinkContainer to={`/report/${testPlanVersion.id}`}>
<Breadcrumb.Item>
{getTestPlanVersionTitle(testPlanVersion)}
</Breadcrumb.Item>
</LinkContainer>
<Breadcrumb.Item active>
{getTestPlanTargetTitle(testPlanTarget)}
</Breadcrumb.Item>
</Breadcrumb>
<h2>Introduction</h2>
<p>
This page shows detailed results for each test, including
individual commands that the tester entered into the AT, the
output which was captured from the AT in response, and whether
that output was deemed passing or failing for each of the
assertions. The open test button next to each test allows you to
preview the test in your browser.
</p>
{testPlanReport.finalizedTestResults.map(testResult => {
const test = testResult.test;
const gitHubIssueLinkWithTitleAndBody =
createGitHubIssueWithTitleAndBody({ test, testPlanReport });
// TODO: fix renderedUrl
let modifiedRenderedUrl = test.renderedUrl.replace(
/.+(?=\/tests)/,
'https://aria-at.netlify.app'
);
return (
<Fragment key={testResult.id}>
<div className="test-result-heading">
<h2 id={`result-${testResult.id}`} tabIndex="-1">
<span className="test-details">
Details for test:
</span>
{test.title}
<DisclaimerInfo
reportStatus={testPlanReport.status}
/>
</h2>
<div className="test-result-buttons">
<Button
target="_blank"
rel="noreferrer"
href={gitHubIssueLinkWithTitleAndBody}
variant="secondary"
>
<FontAwesomeIcon
icon={faExclamationCircle}
color="#94979b"
/>
Raise an Issue
</Button>
<Button
target="_blank"
rel="noreferrer"
href={modifiedRenderedUrl}
variant="secondary"
>
<FontAwesomeIcon
icon={faExternalLinkAlt}
color="#94979b"
/>
Open Test
</Button>
</div>
</div>
<TestPlanResultsTable
test={test}
testResult={testResult}
/>
<DisclosureComponent
componentId={`run-history-${testResult.id}`}
title="Run History"
disclosureContainerView={getTestersRunHistory(
testPlanReport,
testResult.test.id,
testPlanReport.draftTestPlanRuns
)}
/>
</Fragment>
);
})}
{skippedTests.length ? (
<Fragment>
<div className="skipped-tests-heading">
<h2 id="skipped-tests" tabIndex="-1">
Skipped Tests
</h2>
<p>
The following tests have been skipped in this test
run:
</p>
</div>
<ol className="skipped-tests">
{skippedTests.map(test => (
<li key={test.id}>
<a href={test.renderedUrl}>{test.title}</a>
</li>
))}
</ol>
</Fragment>
) : null}
</Container>
);
};
SummarizeTestPlanReport.propTypes = {
testPlanReports: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
testPlanVersion: PropTypes.object.isRequired,
runnableTests: PropTypes.arrayOf(PropTypes.object.isRequired)
.isRequired,
at: PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
}).isRequired,
browser: PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
}).isRequired,
finalizedTestResults: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
test: PropTypes.shape({
title: PropTypes.string.isRequired,
renderedUrl: PropTypes.string.isRequired
}).isRequired,
scenarioResults: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
output: PropTypes.string.isRequired,
assertionResults: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
passed: PropTypes.bool.isRequired,
failedReason: PropTypes.string,
assertion: PropTypes.shape({
text: PropTypes.string.isRequired
}).isRequired
}).isRequired
).isRequired,
unexpectedBehaviors: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
text: PropTypes.string.isRequired
}).isRequired
).isRequired,
unexpectedBehaviorNote: PropTypes.string
}).isRequired
).isRequired
}).isRequired
).isRequired,
draftTestPlanRuns: PropTypes.arrayOf(
PropTypes.shape({
tester: PropTypes.shape({
username: PropTypes.string.isRequired
})
})
)
}).isRequired
)
};
export default SummarizeTestPlanReport;