Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

MAT-7101: Add test case list checkboxes #767

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useMemo } from "react";
import React, { useState, useEffect, useMemo, HTMLProps } from "react";
import tw from "twin.macro";
import "styled-components/macro";
import { Measure, TestCase } from "@madie/madie-models";
Expand Down Expand Up @@ -110,6 +110,34 @@
}));
};

function IndeterminateCheckbox({
indeterminate,
className = "",
onChange,
id,
...rest
}: {
indeterminate?: boolean;
} & HTMLProps<HTMLInputElement>) {
const ref = React.useRef<HTMLInputElement>(null!);

Check warning on line 122 in src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx#L122

Added line #L122 was not covered by tests

React.useEffect(() => {

Check warning on line 124 in src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx#L124

Added line #L124 was not covered by tests
if (typeof indeterminate === "boolean") {
ref.current.indeterminate = !rest.checked && indeterminate;
}
}, [ref, indeterminate]);

return (

Check warning on line 130 in src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx#L130

Added line #L130 was not covered by tests
<input
type="checkbox"
ref={ref}
className={className + " cursor-pointer"}
onChange={onChange}
{...rest}
/>
);
}

type TCRow = {
status: any;
group: string;
Expand All @@ -130,6 +158,36 @@
const columns = useMemo<ColumnDef<TCRow>[]>(() => {
const columnDefs = [];

if (featureFlags?.TestCaseListButtons) {
columnDefs.push({

Check warning on line 162 in src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx#L162

Added line #L162 was not covered by tests
id: "select",
header: ({ table }) => (
<IndeterminateCheckbox

Check warning on line 165 in src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx#L165

Added line #L165 was not covered by tests
{...{
checked: table.getIsAllRowsSelected(),
indeterminate: table.getIsSomePageRowsSelected(),
onChange: table.getToggleAllPageRowsSelectedHandler(),
}}
/>
),
cell: ({ row }) => {
return (

Check warning on line 174 in src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/testCaseLanding/common/TestCaseTable/TestCaseTable.tsx#L174

Added line #L174 was not covered by tests
<div className="px-1">
<IndeterminateCheckbox
{...{
checked: row.getIsSelected(), //props.selectedIds[row.original.id],
disabled: !row.getCanSelect(),
indeterminate: row.getIsSomeSelected(),
onChange: row.getToggleSelectedHandler(),
id: row.original.id,
}}
/>
</div>
);
},
});
}

if (featureFlags?.TestCaseID) {
columnDefs.push({
header: "Case #",
Expand Down
1 change: 1 addition & 0 deletions src/types/madie-madie-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare module "@madie/madie-util" {
qdmHideJson: boolean;
TestCaseListSearch: boolean;
TestCaseID: boolean;
TestCaseListButtons: boolean;
}

export interface ServiceConfig {
Expand Down
Loading