Skip to content

Commit

Permalink
Merge branch 'master' into auto-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception authored Jul 6, 2024
2 parents f0dfd6b + 5270c02 commit 1f912fd
Show file tree
Hide file tree
Showing 618 changed files with 2,416 additions and 1,916 deletions.
12 changes: 10 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
jest: true,
},
extends: ["next/core-web-vitals", "plugin:prettier/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand All @@ -21,8 +20,14 @@ module.exports = {
},
overrides: [
{
parser: "@typescript-eslint/parser",
files: ["**/*.ts", "**/*.tsx"],
plugins: ["tailwindcss", "react"],
plugins: [
"tailwindcss",
"react",
"@typescript-eslint",
"simple-import-sort",
],
extends: [
"plugin:react/recommended",
"plugin:tailwindcss/recommended",
Expand All @@ -35,6 +40,8 @@ module.exports = {
project: "./tsconfig.json",
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-useless-constructor": "off",
Expand All @@ -59,6 +66,7 @@ module.exports = {
"no-empty-function": "off",
"no-unused-vars": "off",
"react/no-danger": "off",
"react/no-unstable-nested-components": "off",
"import/no-extraneous-dependencies": "off",
"consistent-return": "off",
"default-case": "off",
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-tailwindcss": "^3.17.4",
"fake-indexeddb": "^5.0.2",
"gettext-parser": "^8.0.0",
Expand Down
1 change: 0 additions & 1 deletion scripts/translate.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-continue */
import gettextParser from "gettext-parser";

import fs from "fs";
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/_/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { ReactNode } from "react";
import { LinguiProvider } from "translations/utils";
import type { Messages } from "@lingui/core";
import {
QueryCache,
QueryClient,
QueryClientProvider,
} from "@tanstack/react-query";
import { ThemeProvider } from "next-themes";
import type { ReactNode } from "react";
import { LinguiProvider } from "translations/utils";

import { ConfirmAlert } from "@/components/app/confirm-alert";
import { Toaster } from "@/components/app/toast/toaster";

Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AuthActions } from "frontend/hooks/auth/auth.actions";
import { rest } from "msw";
import { REQUEST_ERROR_CODES } from "shared/constants/auth";
import type { IAuthenticatedUserBag } from "shared/types/user";

import { BASE_TEST_URL } from "./_utils";

let ME: IAuthenticatedUserBag = {
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

export const authApiHandlers = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { rest } from "msw";
import type { ITableView } from "shared/types/data";
import { FilterOperators } from "shared/types/data";

import { BASE_TEST_URL } from "./_utils";

const ENTITY_CONFIG = {};
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/_/api-handlers/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MutationHelpers } from "frontend/lib/data/useMutate/mutation-helpers";
import { rest } from "msw";
import type { IWidgetConfig } from "shared/types/dashboard";
import { MutationHelpers } from "frontend/lib/data/useMutate/mutation-helpers";

import { BASE_TEST_URL } from "./_utils";

let DASHBOARD_WIDGETS: IWidgetConfig[] = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { rest } from "msw";
import { reduceStringToNumber } from "shared/lib/strings";

import { BASE_TEST_URL } from "./_utils";

const allData = ({
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/entities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { rest } from "msw";
import type { IEntityField } from "shared/types/db";

import { BASE_TEST_URL } from "./_utils";

export const entitiesApiHandlers = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/form-actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

const FORM_ACTIONS = [
Expand Down
16 changes: 8 additions & 8 deletions src/__tests__/_/api-handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { setupApiHandlers } from "./setup";
import { accountApiHandlers } from "./account";
import { authApiHandlers } from "./auth";
import { entitiesApiHandlers } from "./entities";
import { dataApiHandlers } from "./data";
import { rolesApiHandlers } from "./roles";
import { configApiHandlers } from "./config";
import { dashboardApiHandlers } from "./dashboard";
import { dataApiHandlers } from "./data";
import { entitiesApiHandlers } from "./entities";
import { formActionsApiHandlers } from "./form-actions";
import { integrationsApiHandlers } from "./integrations";
import { versionApiHandlers } from "./versions";
import { portalApiHandlers } from "./portal";
import { integrationsListApiHandlers } from "./integrations-list";
import { menuApiHandlers } from "./menu";
import { portalApiHandlers } from "./portal";
import { rolesApiHandlers } from "./roles";
import { setupApiHandlers } from "./setup";
import { userPreferencesApiHandlers } from "./user-preferences";
import { formActionsApiHandlers } from "./form-actions";
import { integrationsListApiHandlers } from "./integrations-list";
import { versionApiHandlers } from "./versions";

export const apiHandlers = [
...setupApiHandlers,
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/integrations-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

export const integrationsListApiHandlers = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
} from "msw";
import { rest } from "msw";
import type { IKeyValue } from "shared/types/options";

import { BASE_TEST_URL } from "./_utils";

const CONSTANTS = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/menu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { rest } from "msw";
import type { INavigationMenuItem } from "shared/types/menu";
import { NavigationMenuItemType } from "shared/types/menu";

import { BASE_TEST_URL } from "./_utils";

const MENU: INavigationMenuItem[] = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/roles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

let ROLES = [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

export const SETUP_CHECK_DATA = {
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/user-preferences.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

const USER_PREFERENCES = {
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/_/api-handlers/versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rest } from "msw";

import { BASE_TEST_URL } from "./_utils";

export const versionApiHandlers = [
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/_/setupAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cleanup } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";

import { cleanup } from "@testing-library/react";

afterEach(() => {
cleanup();
});
3 changes: 2 additions & 1 deletion src/__tests__/_/setupApihandlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { setupServer } from "msw/node";
import { AuthActions } from "frontend/hooks/auth/auth.actions";
import { setupServer } from "msw/node";

import { apiHandlers } from "./api-handlers";

export const server = setupServer(...apiHandlers);
Expand Down
15 changes: 14 additions & 1 deletion src/__tests__/_/utils/closeAllToasts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import userEvent, {
PointerEventsCheckLevel,
} from "@testing-library/user-event";

export const closeAllToasts = async () => {
await userEvent.keyboard("{Escape}");
Expand All @@ -15,3 +17,14 @@ export const getToastMessage = async () => {
return (await within(screen.getByRole("region")).findByRole("status"))
.textContent;
};

export const confirmDelete = async () => {
const confirmBox = await screen.findByRole("alertdialog", {
name: "Confirm Delete",
});

await userEvent.click(
await within(confirmBox).findByRole("button", { name: "Continue" }),
{ pointerEventsCheck: PointerEventsCheckLevel.Never }
);
};
5 changes: 2 additions & 3 deletions src/__tests__/_app.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render, screen } from "@testing-library/react";

import MyApp from "pages/_app";
import type { CustomNextPage } from "frontend/_layouts/types";
import MyApp from "pages/_app";

import { USE_ROUTER_PARAMS } from "./_/constants";

describe("pages/users", () => {
Expand All @@ -19,7 +19,6 @@ describe("pages/users", () => {

render(
<MyApp
// eslint-disable-next-line react/jsx-no-bind
Component={Foo}
pageProps={{ title: "Hello" }}
router={jest.fn as any}
Expand Down
7 changes: 3 additions & 4 deletions src/__tests__/account/logout.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import AccountPassword from "pages/account/password";

import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";

Object.defineProperty(window, "location", {
value: {
...window.location,
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/account/password.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import AccountPassword from "pages/account/password";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import {
closeAllToasts,
getToastMessage,
} from "__tests__/_/utils/closeAllToasts";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import AccountPassword from "pages/account/password";

setupApiHandlers();

Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/account/preferences.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import UserPreferences from "pages/account/preferences";

import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { getToastMessage } from "../_/utils/closeAllToasts";

setupApiHandlers();
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/account/profile.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import AccountProfile from "pages/account/profile";

import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { getToastMessage } from "../_/utils/closeAllToasts";

setupApiHandlers();
Expand Down
7 changes: 3 additions & 4 deletions src/__tests__/admin/[entity]/[id]/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { render, screen } from "@testing-library/react";
import EntityDetails from "pages/admin/[entity]/[id]/index";

import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { render, screen } from "@testing-library/react";
import EntityDetails from "pages/admin/[entity]/[id]/index";

setupApiHandlers();

Expand Down
7 changes: 3 additions & 4 deletions src/__tests__/admin/[entity]/[id]/update.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { render, screen, waitFor } from "@testing-library/react";
import EntityUpdate from "pages/admin/[entity]/[id]/update";

import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { USE_ROUTER_PARAMS } from "__tests__/_/constants";
import { TestProviders } from "__tests__/_/Provider";
import { setupApiHandlers } from "__tests__/_/setupApihandlers";
import { render, screen, waitFor } from "@testing-library/react";
import EntityUpdate from "pages/admin/[entity]/[id]/update";

setupApiHandlers();

Expand Down
Loading

0 comments on commit 1f912fd

Please sign in to comment.