Skip to content

Commit

Permalink
♻️ refactor(typings): use .d.ts file for typings
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed May 27, 2024
1 parent 426b984 commit 6a68fb1
Show file tree
Hide file tree
Showing 55 changed files with 65 additions and 227 deletions.
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const customJestConfig = {

coverageProvider: "v8",

collectCoverageFrom: ["src/**/*.{ts,tsx}", "!**/Stories.tsx"],
collectCoverageFrom: ["src/**/*.{ts,tsx}", "!**/Stories.tsx", "!**/.d.ts"],

moduleDirectories: ["node_modules", "src"],

Expand Down
10 changes: 10 additions & 0 deletions src/__tests__/_/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: Infinity,
retry: (failureCount, error: any) => {
const statusCode = (error as Response)?.status;
if (!statusCode) {
return true;
}
if (`${statusCode}`.startsWith("4")) {
return false;
}
return failureCount < 3;
},
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/_/api-handlers/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rest } from "msw";
import { FilterOperators, ITableView } from "shared/types/data";
import { ITableView, FilterOperators } from "shared/types/data";
import { BASE_TEST_URL } from "./_utils";

const ENTITY_CONFIG = {};
Expand Down
107 changes: 0 additions & 107 deletions src/__tests__/_/forCodeCoverage.spec.ts

This file was deleted.

20 changes: 10 additions & 10 deletions src/__tests__/integrations/variables__credentials.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TestProviders } from "__tests__/_/Provider";

setupApiHandlers();

describe.skip("pages/integrations/variables => credentials", () => {
describe("pages/integrations/variables => credentials", () => {
const useRouter = jest.spyOn(require("next/router"), "useRouter");
beforeAll(() => {
localStorage.setItem(AuthActions.JWT_TOKEN_STORAGE_KEY, "foo");
Expand All @@ -40,7 +40,7 @@ describe.skip("pages/integrations/variables => credentials", () => {

expect(
within(priviledgeSection).queryByText(
`For security reasons, Please input your account password to be able to manage Secrets`
`For security reasons, Please input your account password to reveal credentials`
)
).not.toBeInTheDocument();
expect(
Expand All @@ -53,7 +53,7 @@ describe.skip("pages/integrations/variables => credentials", () => {
).not.toBeInTheDocument();
expect(
within(priviledgeSection).queryByRole(`button`, {
name: "Reveal Secrets",
name: "Reveal Credentials",
})
).not.toBeInTheDocument();
});
Expand All @@ -71,7 +71,7 @@ describe.skip("pages/integrations/variables => credentials", () => {
await userEvent.click(screen.getByRole("tab", { name: "Secrets" }));
expect(
within(priviledgeSection).getByText(
`For security reasons, Please input your account password to be able to manage Secrets`
`For security reasons, Please input your account password to reveal credentials`
)
).toBeInTheDocument();
expect(
Expand All @@ -84,7 +84,7 @@ describe.skip("pages/integrations/variables => credentials", () => {
).toBeInTheDocument();
expect(
within(priviledgeSection).getByRole(`button`, {
name: "Reveal Secrets",
name: "Reveal Credentials",
})
).toBeInTheDocument();
});
Expand Down Expand Up @@ -169,7 +169,7 @@ describe.skip("pages/integrations/variables => credentials", () => {
);
await userEvent.click(
within(priviledgeSection).getByRole("button", {
name: "Reveal Secrets",
name: "Reveal Credentials",
})
);

Expand Down Expand Up @@ -215,7 +215,7 @@ describe.skip("pages/integrations/variables => credentials", () => {
);
await userEvent.click(
within(priviledgeSection).getByRole("button", {
name: "Reveal Secrets",
name: "Reveal Credentials",
})
);

Expand All @@ -236,15 +236,15 @@ describe.skip("pages/integrations/variables => credentials", () => {

expect(
within(priviledgeSection).queryByText(
`For security reasons, Please input your account password to be able to manage Secrets`
`For security reasons, Please input your account password to reveal credentials`
)
).not.toBeInTheDocument();
expect(
within(priviledgeSection).queryByLabelText(`Password`)
).not.toBeInTheDocument();
expect(
within(priviledgeSection).queryByRole(`button`, {
name: "Reveal Secrets",
name: "Reveal Credentials",
})
).not.toBeInTheDocument();
});
Expand Down Expand Up @@ -281,7 +281,7 @@ describe.skip("pages/integrations/variables => credentials", () => {
});
});

describe("update", () => {
describe.skip("update", () => {
it("should update secret", async () => {
render(
<TestProviders>
Expand Down
2 changes: 0 additions & 2 deletions src/backend/data/types.ts → src/backend/data/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export interface IPaginationFilters {
sortBy?: string;
}

export const FOR_CODE_COV = 1;

export interface IDataApiService {
fetchData(
entity: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ export type IActionConfig = {
apiKey: string;
domain: string;
};

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type IActionConfig = {
serverToken: string;
};

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type IActionConfig = {
apiKey: string;
};

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type IActionConfig = {
apiKey: string;
};

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type IActionConfig = {
token: string;
};

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ export type IActionConfig = {
authUser: string;
authPassword: string;
};

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ export type IActionConfig = {
authToken: string;
accountSid: string;
};

export const FOR_CODE_COV = 1;
2 changes: 0 additions & 2 deletions src/backend/lib/config-persistence/portal/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type { PortalConfigDomain } from "./main/types";

export const FOR_CODE_COV = 1;

export { updateMetaData, createMetaData } from "./main";
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export type PortalConfigDomain = "";

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export { type PortalKeyValueDomain } from "./main";

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export type PortalKeyValueDomain = "";

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ export type ValidationImplType<T extends unknown> = (
req: NextApiRequest & { user?: IAccountProfile },
config?: unknown
) => Promise<T>;

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ export type ValidationKeys = {
method?: RequestMethod[];
body?: unknown;
};

export const FOR_CODE_COV = 1;
2 changes: 0 additions & 2 deletions src/backend/menu/types.ts → src/backend/menu/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ export interface IBaseNavigationMenuApiService {
navItems: INavigationMenuItem[]
): Promise<INavigationMenuItem[]>;
}

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ export interface IStorageIntegrationsImplemention<T> {
integrationConfigurationSchema: IAppliedSchemaFormConfig<T>;
store: (integrationConfig: T, file: File) => Promise<string>;
}

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ export interface IRenderFormInputProps {
from?: string;
rightActions?: IFormInputRightAction[];
}

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ export interface IGroupActionButton extends IActionButton {
id: string;
order?: number;
}

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ export interface IEmptyWrapperProps {
text: MessageDescriptor;
createNew?: { action: string | (() => void); label: MessageDescriptor };
}

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ export interface ISharedFormInput extends ILabelAndErrorProps {
placeholder?: MessageDescriptor;
disabled?: boolean;
}

export const FOR_CODE_COV = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { IntermediateCheckBox } from ".";

describe("IntermediateCheckBox", () => {
it("should render checked state correctly", () => {
render(
<IntermediateCheckBox state="checked" onClick={jest.fn} label="Test " />
);

expect(screen.getByRole("checkbox", { name: "Test" })).toBeChecked();
});

it("should render un-checked state correctly", () => {
render(
<IntermediateCheckBox state="unchecked" onClick={jest.fn} label="Test " />
);

expect(screen.getByRole("checkbox", { name: "Test" })).not.toBeChecked();
});

it("should render partial state correctly", () => {
render(
<IntermediateCheckBox state="partial" onClick={jest.fn} label="Test " />
);

expect(
screen.getByRole("checkbox", { name: "Test" })
).toBePartiallyChecked();
});

it("should call onClick with the correct state when pressed", async () => {
const onClick = jest.fn();
render(
<IntermediateCheckBox state="partial" onClick={onClick} label="Test " />
);

await userEvent.click(screen.getByRole("checkbox", { name: "Test" }));

expect(onClick).toHaveBeenCalledWith("partial");
});
});
Loading

0 comments on commit 6a68fb1

Please sign in to comment.