Skip to content

Commit

Permalink
🧪 test(table-filters): add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Nov 11, 2023
1 parent 5354d70 commit 857d73c
Show file tree
Hide file tree
Showing 42 changed files with 673 additions and 320 deletions.
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const CONFIG_VALUES = {
primaryDark: `#111111`,
},
disabled_entities: ["disabled-entity-1", "disabled-entity-2"],
menu_entities_order: [],
disabled_menu_entities: ["entity-3"],
};

Expand Down
8 changes: 6 additions & 2 deletions src/__tests__/_/forCodeCoverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ import { FOR_CODE_COV as $36 } from "shared/types/storage";
import { FOR_CODE_COV as $37 } from "frontend/views/Dashboard/Widget/_manage/types";
import { FOR_CODE_COV as $38 } from "shared/types/dashboard/types";
import { FOR_CODE_COV as $39 } from "shared/types/dashboard/base";
import { FOR_CODE_COV as $40 } from "frontend/design-system/layouts/types";
import { FOR_CODE_COV as $40 } from "frontend/lib/data/useMutate/types";
import { FOR_CODE_COV as $41 } from "frontend/design-system/components/Form/_types";
import { FOR_CODE_COV as $42 } from "backend/menu/types";
import { FOR_CODE_COV as $43 } from "frontend/lib/form/types";
import { FOR_CODE_COV as $44 } from "frontend/design-system/components/Table/filters/types";

import { noop } from "shared/lib/noop";

Expand Down Expand Up @@ -83,7 +85,9 @@ noop(
$39,
$40,
$41,
$42
$42,
$43,
$44
);

describe("Code coverage ignores plain types file", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/admin/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("pages/admin", () => {

expect(await getTableRows(widget)).toMatchInlineSnapshot(`
[
"nameage",
"NameAge",
"John6",
"Jane5",
]
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/admin/settings/menu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { setupApiHandlers } from "__tests__/_/setupApihandlers";

setupApiHandlers();

describe.skip("pages/admin/settings/menu", () => {
describe("pages/admin/settings/menu", () => {
beforeAll(() => {
const useRouter = jest.spyOn(require("next/router"), "useRouter");
useRouter.mockImplementation(() => ({
Expand Down Expand Up @@ -68,12 +68,12 @@ describe.skip("pages/admin/settings/menu", () => {
);

await userEvent.click(
screen.getByRole("button", { name: "Save Menu Entities Settings" })
screen.getByRole("button", { name: "Save Menu Settings" })
);

expect(
await screen.findByRole("status", {}, { timeout: 20000 })
).toHaveTextContent("Menu Entities Settings Saved Successfully");
).toHaveTextContent("Menu Settings Saved Successfully");
});

it("should display updated entities state", async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/admin/settings/theme.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("pages/admin/settings/theme", () => {
);
});

it("should display not update the other scheme color", async () => {
it("should not display the other scheme color", async () => {
render(
<ApplicationRoot>
<ThemeSettings />
Expand Down
2 changes: 1 addition & 1 deletion src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import * as randomstring from "randomstring";
import { checkNodeVersion } from "./checkNodeVersion";
// TODO test this compiles well

(async () => {
const path = require("path");
const fs = require("fs-extra");
Expand Down
6 changes: 0 additions & 6 deletions src/frontend/_layouts/app/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ const Template: Story<IProps> = (args) => (
export const Default = Template.bind({});
Default.args = {};

export const NoIcon = Template.bind({});
NoIcon.args = {
hideIcon: true,
};

export const WithChildren = Template.bind({});
WithChildren.args = {
children: (
Expand Down
7 changes: 2 additions & 5 deletions src/frontend/design-system/components/EmptyWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Typo } from "frontend/design-system/primitives/Typo";

export interface IProps {
text: string;
hideIcon?: true;
children?: ReactNode;
}

Expand All @@ -18,12 +17,10 @@ const Root = styled.div`
background: ${USE_ROOT_COLOR("base-color")};
`;

export function EmptyWrapper({ text, hideIcon, children }: IProps) {
export function EmptyWrapper({ text, children }: IProps) {
return (
<Root>
{hideIcon ? null : (
<Droplet size={50} color={USE_ROOT_COLOR("muted-text")} />
)}
<Droplet size={50} color={USE_ROOT_COLOR("muted-text")} />
<br />
<br />
<Typo.MD color="muted"> {text} </Typo.MD>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface ISimpleSelect {
value: number | string;
fullWidth?: boolean;
sm?: true;
ariaLabel?: string;
}

const SimpleSelectStyled = styled(Input)<{ fullWidth?: boolean }>`
Expand All @@ -33,10 +34,12 @@ export function SimpleSelect({
value,
fullWidth,
sm,
ariaLabel,
}: ISimpleSelect) {
return (
<SimpleSelectStyled
as="select"
aria-label={ariaLabel}
value={value}
sm={sm}
fullWidth={fullWidth}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ interface IFormMultiSelect {
selectData: ISelectData[];
values: string[];
onChange: (values: string[]) => void;
ariaLabel?: string;
}

export function FormMultiSelect({
selectData,
values = [],
onChange,
ariaLabel,
}: IFormMultiSelect) {
return (
<SelectStyled
Expand All @@ -41,6 +43,7 @@ export function FormMultiSelect({
onChange={(newValues: any) => {
onChange(newValues.map(({ value }: ISelectData) => value));
}}
aria-label={ariaLabel}
options={selectData}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jest.mock("react-easy-sort", () => ({
),
}));

describe.skip("SortList", () => {
describe("SortList", () => {
it("should render labels if present else value", () => {
render(
<SortList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function FilterTableByBooleans({
value: value === "" ? undefined : value === "true",
});
}}
ariaLabel="Select Boolean"
fullWidth
value={
// eslint-disable-next-line no-nested-ternary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function FilterTableByIdField({
onChange={(e: React.BaseSyntheticEvent) => {
setFilter({
...filterValue,
value: e.target.value || undefined,
value: e.target.value,
});
}}
placeholder="Enter value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ export function FilterTableByNumbers({
onChange={(e) =>
setFilter({
...filterValue,
value: +e.target.value || undefined,
value: +e.target.value,
})
}
aria-label="Value 1"
/>
{filterValue?.operator === FilterOperators.BETWEEN && (
<>
Expand All @@ -30,9 +31,10 @@ export function FilterTableByNumbers({
onChange={(e) =>
setFilter({
...filterValue,
value2: +e.target.value || undefined,
value2: +e.target.value,
})
}
aria-label="Value 2"
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function FilterTableByStatus({
<FormMultiSelect
selectData={bag}
values={filterValue?.value || []}
ariaLabel="Select Status"
onChange={(value) => {
setFilter({
...filterValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function FilterTableByText({
onChange={(e: React.BaseSyntheticEvent) => {
setFilter({
...filterValue,
value: e.target.value || undefined,
value: e.target.value,
});
}}
placeholder="Search"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ export function RenderFilterOperator<T>({
label: FILTER_OPERATOR_LABELS[operator],
})),
]}
ariaLabel="Select Filter Operator"
fullWidth
onChange={(value) => {
setFilter({
...filterValue,
operator: (value as FilterOperators) || undefined,
operator: value as FilterOperators,
});
}}
value={filterValue?.operator || ""}
Expand Down
Loading

0 comments on commit 857d73c

Please sign in to comment.