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

Commit

Permalink
DEVPROD-3088: Fix checkbox behavior for regex search on Configure Pat…
Browse files Browse the repository at this point in the history
…ch page (#2294)
  • Loading branch information
minnakt authored Mar 8, 2024
1 parent 4a2bcf7 commit 9049229
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ describe("Configure Patch Page", () => {
cy.dataCy("selected-task-disclaimer").contains(
`0 tasks across 0 build variants`,
);
cy.dataCy("task-filter-input").type("dist");
cy.dataCy("task-filter-input").type("^dist");
cy.dataCy("task-checkbox").should("have.length", 2);
cy.contains("Select all tasks in view").click();
cy.dataCy("selected-task-disclaimer").contains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ describe("configureTasks", () => {
expect(checkbox).toBeInTheDocument();
expect(checkbox).not.toBeChecked();
expect(setSelectedBuildVariantTasks).not.toHaveBeenCalled();
await user.click(screen.getByText("Select all tasks in these variants"));
await user.type(screen.getByDataCy("task-filter-input"), "^c");
await user.click(screen.getByText("Select all tasks in view"));
expect(setSelectedBuildVariantTasks).toHaveBeenCalledWith({
ubuntu2004: { compile: true, test: true },
ubuntu1804: { compile: true, lint: true },
ubuntu2004: { compile: true, test: false },
ubuntu1804: { compile: true, lint: false },
});
});
it("applying a search should filter the tasks", async () => {
Expand All @@ -247,7 +248,6 @@ describe("configureTasks", () => {
setSelectedAliases={() => {}}
/>,
);

await user.type(screen.getByDataCy("task-filter-input"), "compile");
expect(screen.queryAllByDataCy("task-checkbox")).toHaveLength(1);
const checkbox = screen.getByLabelText("compile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ const ConfigureTasks: React.FC<Props> = ({
const onClickSelectAll = (e: React.ChangeEvent<HTMLInputElement>) => {
const selectedBuildVariantsCopy = { ...selectedBuildVariantTasks };
const selectedAliasesCopy = { ...selectedAliases };
const searchAsRegex = new RegExp(search);
selectedBuildVariants.forEach((v) => {
if (selectedBuildVariantsCopy?.[v] !== undefined) {
Object.keys(selectedBuildVariantsCopy[v]).forEach((task) => {
if (search !== "" && !task.includes(search)) return;
if (searchAsRegex && !searchAsRegex.test(task)) return;
selectedBuildVariantsCopy[v][task] = e.target.checked;
});
} else if (selectedAliasesCopy?.[v] !== undefined) {
Expand Down

0 comments on commit 9049229

Please sign in to comment.