Skip to content

Commit cd0c0f0

Browse files
committed
[ui] eject from react-create-app and fix jest config
1 parent 936f5b7 commit cd0c0f0

File tree

10 files changed

+49
-50
lines changed

10 files changed

+49
-50
lines changed

quickwit/quickwit-ui/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
build
3+
dist
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// eslint-disable-next-line no-undef
2+
module.exports = {
3+
setupFiles: ["react-app-polyfill/jsdom"], // polyfill jsdom api (such as fetch)
4+
5+
setupFilesAfterEnv: ["@testing-library/jest-dom"],
6+
7+
testEnvironment: "jsdom",
8+
9+
transform: {
10+
// transform js file (typescript and es6 import)
11+
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": [
12+
"babel-jest",
13+
{
14+
presets: [["babel-preset-react-app", { runtime: "automatic" }]],
15+
babelrc: false,
16+
configFile: false,
17+
},
18+
],
19+
20+
// transform asset files
21+
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": "jest-transform-stub",
22+
},
23+
24+
moduleNameMapper: {
25+
"monaco-editor": "<rootDir>/mocks/monacoMock.js",
26+
"swagger-ui-react": "<rootDir>/mocks/swaggerUIMock.js",
27+
"@mui/x-charts": "<rootDir>/mocks/x-charts.js",
28+
},
29+
30+
resetMocks: true,
31+
};

quickwit/quickwit-ui/src/components/ApiUrlFooter.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ import { Box, Button, styled, Typography } from "@mui/material";
1717
import { QUICKWIT_LIGHT_GREY } from "../utils/theme";
1818

1919
const Footer = styled(Box)`
20-
display: flex;
21-
height: 25px;
22-
padding: 0px 5px;
23-
position: absolute;
24-
bottom: 0px;
25-
font-size: 0.90em;
26-
background-color: ${QUICKWIT_LIGHT_GREY};
27-
opacity: 0.7;
20+
display: flex;
21+
height: 25px;
22+
padding: 0px 5px;
23+
position: absolute;
24+
bottom: 0px;
25+
font-size: 0.9em;
26+
background-color: ${QUICKWIT_LIGHT_GREY};
27+
opacity: 0.7;
2828
`;
2929

3030
export default function ApiUrlFooter(url: string) {
3131
const urlMaxLength = 80;
3232
const origin =
33+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
34+
// @ts-ignore
3335
process.env.NODE_ENV === "development"
3436
? "http://localhost:7280"
3537
: window.location.origin;

quickwit/quickwit-ui/src/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import { describe, expect, it } from "@jest/globals";
1516
import { render, screen } from "@testing-library/react";
1617
import { BrowserRouter } from "react-router-dom";
1718
import App from "./views/App";

quickwit/quickwit-ui/src/providers/EditorProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from "react";
2323

2424
type ContextProps = {
25-
editorRef: MutableRefObject<any | null> | null;
25+
editorRef: MutableRefObject<unknown | null> | null;
2626
monacoRef: MutableRefObject<typeof monacoEditor | null> | null;
2727
};
2828

@@ -33,8 +33,8 @@ const defaultValues = {
3333

3434
const EditorContext = createContext<ContextProps>(defaultValues);
3535

36-
export const EditorProvider = ({ children }: PropsWithChildren<{}>) => {
37-
const editorRef = useRef<any | null>(null);
36+
export const EditorProvider = ({ children }: PropsWithChildren<unknown>) => {
37+
const editorRef = useRef<unknown | null>(null);
3838
const monacoRef = useRef<typeof monacoEditor | null>(null);
3939

4040
return (

quickwit/quickwit-ui/src/react-app-env.d.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

quickwit/quickwit-ui/src/services/client.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import { describe, expect, it, jest } from "@jest/globals";
1516
import { SearchRequest } from "../utils/models";
1617
import { Client } from "./client";
1718

1819
describe("Client unit test", () => {
1920
it("Should construct correct search URL", async () => {
2021
// Mocking the fetch function to simulate network requests
21-
const mockFetch = jest.fn(() =>
22+
const mockFetch = jest.fn((_url: string, _options?: unknown) =>
2223
Promise.resolve({ ok: true, json: () => Promise.resolve({}) }),
2324
);
2425
(global as any).fetch = mockFetch; // eslint-disable-line @typescript-eslint/no-explicit-any

quickwit/quickwit-ui/src/setupTests.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

quickwit/quickwit-ui/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
"jsx": "react-jsx",
2222
"types": ["vite/client"]
2323
},
24-
"include": ["src", "typings", "tests", "tests/integration/index.test.ts"]
24+
"exclude": ["build"]
2525
}

quickwit/quickwit-ui/typings/fonts.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)