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

feat: Include Trend Reports table on reports page #1092

Merged
merged 4 commits into from
May 21, 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
142 changes: 140 additions & 2 deletions client/components/Reports/SummarizeTestPlanReport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { Helmet } from 'react-helmet';
import { getTestPlanTargetTitle, getTestPlanVersionTitle } from './getTitles';
import { Breadcrumb, Button, Container } from 'react-bootstrap';
import { Breadcrumb, Button, Container, Table } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
Expand All @@ -12,11 +12,12 @@ import {
} from '@fortawesome/free-solid-svg-icons';
import styled from '@emotion/styled';
import { getMetrics } from 'shared';
import { none } from './None';
import { convertDateToString } from '../../utils/formatter';
import DisclaimerInfo from '../DisclaimerInfo';
import TestPlanResultsTable from '../common/TestPlanResultsTable';
import DisclosureComponent from '../common/DisclosureComponent';
import { Navigate, useLocation, useParams } from 'react-router-dom';
import { Link, Navigate, useLocation, useParams } from 'react-router-dom';
import createIssueLink from '../../utils/createIssueLink';

const ResultsContainer = styled.div`
Expand Down Expand Up @@ -91,6 +92,7 @@ const SummarizeTestPlanReport = ({ testPlanVersion, testPlanReports }) => {
if (!testPlanReport) return <Navigate to="/404" />;

const { at, browser, recommendedAtVersion } = testPlanReport;
const overallMetrics = getMetrics({ testPlanReport });

// Construct testPlanTarget
const testPlanTarget = {
Expand All @@ -100,6 +102,138 @@ const SummarizeTestPlanReport = ({ testPlanVersion, testPlanReports }) => {
atVersion: recommendedAtVersion
};

const renderVersionsSummaryTable = () => {
if (testPlanVersion.phase !== 'RECOMMENDED') return null;

const title = `${testPlanTarget.at.name} Versions Summary`;
const testPlanReportsForTarget = testPlanVersion.testPlanReports.filter(
testPlanReport =>
testPlanReport.at.id === at.id &&
testPlanReport.browser.id === browser.id
);
testPlanReportsForTarget.sort(
(a, b) =>
new Date(b.recommendedAtVersion.releasedAt) -
new Date(a.recommendedAtVersion.releasedAt)
);

return (
<>
<h2>{title}</h2>
<p>
The following table displays a summary of data for all
versions of {testPlanTarget.at.name} that have been tested.
</p>
<Table bordered responsive>
<thead>
<tr>
<th>Versions</th>
<th>Must-Have Behaviors</th>
<th>Should-Have Behaviors</th>
<th>May-Have Behaviors</th>
</tr>
</thead>
<tbody>
{testPlanReportsForTarget.map(testPlanReport => {
const { recommendedAtVersion, metrics } =
testPlanReport;
const {
mustFormatted,
shouldFormatted,
mayFormatted
} = metrics;

return (
<tr
key={`VersionsSummaryRow_${testPlanReport.id}`}
>
<td>
{testPlanReportId ===
testPlanReport.id ? (
<>{recommendedAtVersion.name}</>
) : (
<Link
to={
`/report/${testPlanVersion.id}` +
`/targets/${testPlanReport.id}`
}
>
{recommendedAtVersion.name}
</Link>
)}
</td>
<td>{mustFormatted || none}</td>
<td>{shouldFormatted || none}</td>
<td>{mayFormatted || none}</td>
</tr>
);
})}
</tbody>
</Table>
</>
);
};

const renderResultsForTargetTable = () => {
const title = `Results for ${getTestPlanTargetTitle(testPlanTarget)}`;
return (
<>
<h2>{title}</h2>
<Table
bordered
responsive
aria-label={`Results for ${getTestPlanTargetTitle(
testPlanTarget
)}`}
>
<thead>
<tr>
<th>Test Name</th>
<th>Must-Have Behaviors</th>
<th>Should-Have Behaviors</th>
<th>May-Have Behaviors</th>
</tr>
</thead>
<tbody>
{testPlanReport.finalizedTestResults.map(testResult => {
const {
mustFormatted,
shouldFormatted,
mayFormatted
} = getMetrics({
testResult
});
return (
<tr key={testResult.id}>
<td>
<Link
to={
`/report/${testPlanVersion.id}` +
`/targets/${testPlanReport.id}` +
`#result-${testResult.id}`
}
>
{testResult.test.title}
</Link>
</td>
<td>{mustFormatted || none}</td>
<td>{shouldFormatted || none}</td>
<td>{mayFormatted || none}</td>
</tr>
);
})}
<tr>
<td>All Tests</td>
<td>{overallMetrics.mustFormatted || none}</td>
<td>{overallMetrics.shouldFormatted || none}</td>
<td>{overallMetrics.mayFormatted || none}</td>
</tr>
</tbody>
</Table>
</>
);
};

return (
<Container id="main" as="main" tabIndex="-1">
<Helmet>
Expand Down Expand Up @@ -177,6 +311,10 @@ const SummarizeTestPlanReport = ({ testPlanVersion, testPlanReports }) => {
</li>
) : null}
</ul>

{renderVersionsSummaryTable()}
{renderResultsForTargetTable()}

{testPlanReport.finalizedTestResults.map((testResult, index) => {
const test = testResult.test;

Expand Down
8 changes: 4 additions & 4 deletions client/components/Reports/SummarizeTestPlanVersion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ const SummarizeTestPlanVersion = ({ testPlanVersion, testPlanReports }) => {
<thead>
<tr>
<th>Test Name</th>
<th>MUST HAVE Behaviors</th>
<th>SHOULD HAVE Behaviors</th>
<th>MAY HAVE Behaviors</th>
<th>Must-Have Behaviors</th>
<th>Should-Have Behaviors</th>
<th>May-Have Behaviors</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -188,7 +188,7 @@ const SummarizeTestPlanVersion = ({ testPlanVersion, testPlanReports }) => {
SummarizeTestPlanVersion.propTypes = {
testPlanVersion: PropTypes.shape({
gitSha: PropTypes.string,
testPlan: PropTypes.string,
testPlan: PropTypes.object,
directory: PropTypes.string,
versionString: PropTypes.string,
id: PropTypes.string.isRequired,
Expand Down
1 change: 1 addition & 0 deletions client/components/Reports/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const REPORT_PAGE_QUERY = gql`
recommendedAtVersion {
id
name
releasedAt
}
runnableTests {
id
Expand Down
Loading