Skip to content

Commit 0a7cb3c

Browse files
committed
[ui] eject from react-create-app and fix jest config
1 parent a55bc5d commit 0a7cb3c

File tree

11 files changed

+51
-51
lines changed

11 files changed

+51
-51
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 ContentCopyIcon from "@mui/icons-material/ContentCopy";
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 { expect, describe, 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,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

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

@@ -42,7 +43,7 @@ describe("Client unit test", () => {
4243
};
4344

4445
const client = new Client();
45-
expect(client.buildSearchBody(searchRequest, null)).toBe(
46+
expect(client.buildSearchBody(searchRequest, null)).toEqual(
4647
'{"query":"severity_error:ERROR","max_hits":20,"start_timestamp":100,"end_timestamp":200,"sort_by_field":"+timestamp"}',
4748
);
4849

quickwit/quickwit-ui/src/setupTests.ts

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

quickwit/quickwit-ui/src/views/ClusterView.test.jsx

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 { expect, jest, test, beforeEach, afterEach } from "@jest/globals";
1516
import { render, unmountComponentAtNode } from "react-dom";
1617
import { waitFor } from "@testing-library/react";
1718
import { screen } from "@testing-library/dom";

quickwit/quickwit-ui/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"isolatedModules": true,
2020
"noEmit": true,
2121
"jsx": "react-jsx",
22-
"types": ["vite/client"]
22+
"types": ["vite/client", "@types/jest"]
2323
},
24-
"include": ["src", "typings", "tests", "tests/integration/index.test.ts"]
24+
"exclude": ["dist", "build"]
2525
}

0 commit comments

Comments
 (0)