From 77d9fff7080d5e841243d59c826eecaaa4447c0a Mon Sep 17 00:00:00 2001 From: c-bata Date: Thu, 16 Nov 2023 15:38:33 +0900 Subject: [PATCH] Fix broken tests --- optuna_dashboard/ts/components/DataGrid.tsx | 2 +- typescript_tests/DataGrid.test.tsx | 47 ++------------------- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/optuna_dashboard/ts/components/DataGrid.tsx b/optuna_dashboard/ts/components/DataGrid.tsx index 64f5303b..faa7e75c 100644 --- a/optuna_dashboard/ts/components/DataGrid.tsx +++ b/optuna_dashboard/ts/components/DataGrid.tsx @@ -262,7 +262,7 @@ function DataGridHeaderColumn(props: { setFilterMenuAnchorEl(null) }} > - {filterChoices.map((choice, i) => ( + {filterChoices.map((choice) => ( { diff --git a/typescript_tests/DataGrid.test.tsx b/typescript_tests/DataGrid.test.tsx index 475e360a..6d13deb7 100644 --- a/typescript_tests/DataGrid.test.tsx +++ b/typescript_tests/DataGrid.test.tsx @@ -1,7 +1,7 @@ import React from "react" global.URL.createObjectURL = jest.fn() -import { cleanup, render, fireEvent } from "@testing-library/react" +import { cleanup, render } from "@testing-library/react" import { DataGrid, DataGridColumn, @@ -9,6 +9,7 @@ import { afterEach(cleanup) +// TODO(c-bata): Add tests to check filterChoices option it("Filter rows of DataGrid", () => { interface DummyAttribute { id: number @@ -23,7 +24,7 @@ it("Filter rows of DataGrid", () => { { id: 5, key: "foo", value: 3 }, ] const columns: DataGridColumn[] = [ - { field: "key", label: "Key", filterable: true }, + { field: "key", label: "Key" }, { field: "value", label: "Value", @@ -39,46 +40,4 @@ it("Filter rows of DataGrid", () => { /> ) expect(queryAllByText("bar").length).toBe(2) - - // Filter rows by "foo" - fireEvent.click(queryAllByText("foo")[0]) - expect(queryAllByText("foo").length).toBe(3) - expect(queryAllByText("bar").length).toBe(0) -}) - -it("Filter rows after sorted", () => { - interface DummyAttribute { - id: number - key: string - value: number - } - const dummyAttributes = [ - { id: 1, key: "foo", value: 4000 }, - { id: 2, key: "bar", value: 1000 }, - { id: 3, key: "bar", value: 2000 }, - { id: 4, key: "foo", value: 3000 }, - { id: 5, key: "foo", value: 5000 }, - ] - const columns: DataGridColumn[] = [ - { field: "key", label: "Key", filterable: true }, - { - field: "value", - label: "Value", - sortable: true, - }, - ] - - const { getByText, queryAllByText } = render( - - columns={columns} - rows={dummyAttributes} - keyField={"id"} - /> - ) - // Sort and filter rows - fireEvent.click(getByText("Value")) - fireEvent.click(queryAllByText("bar")[0]) - - expect(queryAllByText("1000").length).toBe(1) - expect(queryAllByText("2000").length).toBe(1) })