Skip to content

Commit

Permalink
fix for adding missing rows
Browse files Browse the repository at this point in the history
  • Loading branch information
evmiguel committed May 2, 2023
1 parent 391f481 commit f0ed25e
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 63 deletions.
118 changes: 64 additions & 54 deletions client/components/TestManagement/StatusSummaryRow/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const PhaseText = styled.span`
}
`;

const NoPhaseText = styled.span`
margin-left: 12px;
`;

const PhaseDot = styled.span`
display: inline-block;
height: 10px;
Expand Down Expand Up @@ -114,63 +118,69 @@ const StatusSummaryRow = ({ reportResult, testPlanVersion }) => {
<tr>
<th>
{testPlanVersion.title}
<PhaseText className={phase.toLowerCase()}>
{phase}
</PhaseText>
{Object.entries(reportResult).length > 0 && (
<PhaseText className={phase.toLowerCase()}>
{phase}
</PhaseText>
)}
</th>
<td>
<Dropdown className="change-phase">
<Dropdown.Toggle
id={nextId()}
ref={dropdownUpdateReportStatusButtonRef}
variant="secondary"
aria-label={`Change test plan phase for ${testPlanVersion.title}`}
>
<PhaseDot className={phase.toLowerCase()} />
{phase}
</Dropdown.Toggle>
<Dropdown.Menu role="menu">
<Dropdown.Item
role="menuitem"
disabled={phase === 'Draft'}
onClick={async () => {
await bulkUpdateReportStatus(
testPlanReports.map(i => i.id),
'DRAFT'
);
}}
>
<PhaseDot className="draft" />
Draft
</Dropdown.Item>
<Dropdown.Item
role="menuitem"
disabled={phase === 'Candidate'}
onClick={async () => {
await bulkUpdateReportStatus(
testPlanReports.map(i => i.id),
'CANDIDATE'
);
}}
>
<PhaseDot className="candidate" />
Candidate
</Dropdown.Item>
<Dropdown.Item
role="menuitem"
disabled={phase === 'Recommended'}
onClick={async () => {
await bulkUpdateReportStatus(
testPlanReports.map(i => i.id),
'RECOMMENDED'
);
}}
{(Object.entries(reportResult).length <= 0 && (
<NoPhaseText>Not tested</NoPhaseText>
)) || (
<Dropdown className="change-phase">
<Dropdown.Toggle
id={nextId()}
ref={dropdownUpdateReportStatusButtonRef}
variant="secondary"
aria-label={`Change test plan phase for ${testPlanVersion.title}`}
>
<PhaseDot className="recommended" />
Recommended
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
<PhaseDot className={phase.toLowerCase()} />
{phase}
</Dropdown.Toggle>
<Dropdown.Menu role="menu">
<Dropdown.Item
role="menuitem"
disabled={phase === 'Draft'}
onClick={async () => {
await bulkUpdateReportStatus(
testPlanReports.map(i => i.id),
'DRAFT'
);
}}
>
<PhaseDot className="draft" />
Draft
</Dropdown.Item>
<Dropdown.Item
role="menuitem"
disabled={phase === 'Candidate'}
onClick={async () => {
await bulkUpdateReportStatus(
testPlanReports.map(i => i.id),
'CANDIDATE'
);
}}
>
<PhaseDot className="candidate" />
Candidate
</Dropdown.Item>
<Dropdown.Item
role="menuitem"
disabled={phase === 'Recommended'}
onClick={async () => {
await bulkUpdateReportStatus(
testPlanReports.map(i => i.id),
'RECOMMENDED'
);
}}
>
<PhaseDot className="recommended" />
Recommended
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
)}
</td>
</tr>

Expand Down
49 changes: 40 additions & 9 deletions client/components/TestManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const TestManagement = () => {
const [pageReady, setPageReady] = useState(false);
const [ats, setAts] = useState([]);
const [browsers, setBrowsers] = useState([]);
const [testPlans, setTestPlans] = useState([]);
const [testPlanVersions, setTestPlanVersions] = useState([]);
const [testPlanReports, setTestPlanReports] = useState([]);

Expand All @@ -34,11 +35,13 @@ const TestManagement = () => {
ats = [],
browsers = [],
testPlanVersions = [],
testPlanReports = []
testPlanReports = [],
testPlans = []
} = data;
setAts(ats);
setTestPlanVersions(testPlanVersions);
setTestPlanReports(testPlanReports);
setTestPlans(testPlans);
setBrowsers(browsers);
setPageReady(true);
}
Expand Down Expand Up @@ -102,6 +105,7 @@ const TestManagement = () => {
] = null;
});
});

testPlanReports.forEach(testPlanReport => {
const { testPlanVersion, at, browser } = testPlanReport;
const directory = testPlanVersion.testPlan.directory;
Expand All @@ -117,6 +121,12 @@ const TestManagement = () => {
].testPlanVersion = testPlanVersion;
});

testPlans.forEach(testPlan => {
if (!(testPlan.directory in tabularReportsByDirectory)) {
tabularReportsByDirectory[testPlan.directory] = testPlan;
}
});

const combineObject = originalObject => {
let combinedTestPlanVersionIdArray = [];
let resultTestPlanTargets = Object.values(originalObject)[0];
Expand Down Expand Up @@ -223,21 +233,42 @@ const TestManagement = () => {
<tbody>
{/* Sort the summary items by title */}
{Object.values(tabularReportsByDirectory)
.sort((a, b) =>
Object.values(a)[0].testPlanVersion
.title <
Object.values(b)[0].testPlanVersion
.title
? -1
: 1
)
.sort((a, b) => {
return (
a.title ||
Object.values(a)[0].testPlanVersion
.title
).localeCompare(
b.title ||
Object.values(b)[0]
.testPlanVersion.title
);
})
.map(tabularReport => {
let reportResult = null;
let testPlanVersionId = null;

// Evaluate what is prioritised across the
// collection of testPlanVersions
if (
typeof Object.values(
tabularReport
)[0] !== 'object'
) {
return (
<StatusSummaryRow
key={
tabularReport
.latestTestPlanVersion
.id
}
testPlanVersion={
tabularReport.latestTestPlanVersion
}
reportResult={{}}
/>
);
} else if (
Object.values(tabularReport)
.length > 1
) {
Expand Down
9 changes: 9 additions & 0 deletions client/components/TestManagement/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export const TEST_MANAGEMENT_PAGE_QUERY = gql`
id
name
}
testPlans {
directory
id
title
latestTestPlanVersion {
id
title
}
}
testPlanVersions {
id
title
Expand Down
1 change: 1 addition & 0 deletions server/graphql-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const graphqlSchema = gql`
as a directory, and this allows you to do both.
"""
id: ID!
title: String!
"""
Corresponds to directory in the ARIA-AT repo which stores the test plan,
e.g. "checkbox-tri-state" or "disclosure-navigation"
Expand Down
1 change: 1 addition & 0 deletions server/models/services/TestPlanVersionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ const getTestPlans = async ({
directory as "id",
directory as "directory",
id as "latestTestPlanVersionId",
"title",
"updatedAt"
FROM "TestPlanVersion"
${whereClause}
Expand Down

0 comments on commit f0ed25e

Please sign in to comment.