Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alicanerdurmaz committed Dec 6, 2024
1 parent 71c5f55 commit ba190e2
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 28 deletions.
21 changes: 1 addition & 20 deletions documentation/blog/2023-09-20-next-ui-panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,13 @@ Steps we'll cover:

- [What is Refine](#what-is-refine)
- [How to create a Refine application](#how-to-create-a-refine-application)
- [Tidy things up](#tidy-things-up)
- [What is NextUI](#what-is-nextui)
- [How to set up NextUI in a Refine application](#how-to-set-up-nextui-in-a-refine-application)
- [Install NextUI and its dependencies](#install-nextui-and-its-dependencies)
- [Add Tailwind CSS configuration file](#add-tailwind-css-configuration-file)
- [Add Tailwind CSS directives](#add-tailwind-css-directives)
- [Set up NextUI provider](#set-up-nextui-provider)
- [How to build React admin dashboard with NextUI and Refine](#how-to-build-react-admin-dashboard-with-nextui-and-refine)
- [Create key performance indicator card](#create-key-performance-indicator-card)
- [Represent the key performance indicators using charts](#represent-the-key-performance-indicators-using-charts)
- [Represent the recent sales in a table](#represent-the-recent-sales-in-a-table)
- [How to build React admin dashboard with NextUI and Refine]
- [How to build product CRUD pages with NextUI and Refine](#how-to-build-product-crud-pages-with-nextui-and-refine)
- [Products list page](#products-list-page)
- [Products create page](#products-create-page)
- [Products edit page](#products-edit-page)
- [Products show page](#products-show-page)
- [How to build categories CRUD pages with NextUI and Refine](#how-to-build-categories-crud-pages-with-nextui-and-refine)
- [Categories list page](#categories-list-page)
- [Categories create page](#categories-create-page)
- [Categories edit page](#categories-edit-page)
- [Categories show page](#categories-show-page)
- [Update the layout](#update-the-layout)
- [Update the navigation menu](#update-the-navigation-menu)
- [Update the breadcrumb](#update-the-breadcrumb)
- [Conclusion](#conclusion)
- [Live CodeSandbox Example](#live-codesandbox-example)

## What is Refine

Expand Down
10 changes: 10 additions & 0 deletions packages/antd/test/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@testing-library/jest-dom";
import "@testing-library/jest-dom/extend-expect";
import { configure } from "@testing-library/dom";
import * as util from "util";

jest.retryTimes(3, { logErrorsBeforeRetry: true });

Expand All @@ -19,6 +20,15 @@ window.matchMedia = jest.fn().mockImplementation((query) => {
};
});

Object.defineProperty(window, "TextEncoder", {
writable: true,
value: util.TextEncoder,
});
Object.defineProperty(window, "TextDecoder", {
writable: true,
value: util.TextDecoder,
});

window.scroll = jest.fn();
window.alert = jest.fn();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import routerProvider, {
DocumentTitleHandler,
} from "@refinedev/react-router";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { BrowserRouter, Route, Routes } from "react-router";
const App = () => {
return (
Expand Down Expand Up @@ -54,7 +54,105 @@ import routerProvider, {
DocumentTitleHandler,
} from "@refinedev/react-router";
import { BrowserRouter, Route, Routes, Outlet } from "react-router-dom";
import { BrowserRouter, Route, Routes, Outlet } from "react-router";
import { ConfigProvider, App as AntdApp } from "antd";
import "@refinedev/antd/dist/reset.css";
const App = () => {
return (
<BrowserRouter>
<GitHubBanner />
<ConfigProvider theme={RefineThemes.Blue}>
<AntdApp>
<Refine
dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
routerProvider={routerProvider}
options={{
syncWithLocation: true,
warnWhenUnsavedChanges: true,
}}
notificationProvider={useNotificationProvider}
>
<Routes>
<Route
element={
<ThemedLayoutV2>
<Outlet />
</ThemedLayoutV2>
}
>
<Route index element={<WelcomePage />} />
<Route path="*" element={<ErrorComponent />} />
</Route>
</Routes>
<UnsavedChangesNotifier />
<DocumentTitleHandler />
</Refine>
</AntdApp>
</ConfigProvider>
</BrowserRouter>
);
};
export default App;"
`;

exports[`ant-design transformer should transform the file
----------------------------------------------------
import {
GitHubBanner,
Refine,
ErrorComponent,
WelcomePage,
} from "@refinedev/core";
import dataProvider from "@refinedev/simple-rest";
import routerProvider, {
UnsavedChangesNotifier,
DocumentTitleHandler,
} from "@refinedev/react-router";
import { BrowserRouter, Route, Routes } from "react-router";
const App = () => {
return (
<BrowserRouter>
<GitHubBanner />
<Refine
dataProvider={dataProvider("https://api.fake-rest.refine.dev")}
routerProvider={routerProvider}
options={{
syncWithLocation: true,
warnWhenUnsavedChanges: true,
}}
>
<Routes>
<Route index element={<WelcomePage />} />
<Route path="*" element={<ErrorComponent />} />
</Routes>
<UnsavedChangesNotifier />
<DocumentTitleHandler />
</Refine>
</BrowserRouter>
);
};
export default App;
---------------------------------------------------- 1`] = `
"import { GitHubBanner, Refine, WelcomePage } from "@refinedev/core";
import {
useNotificationProvider,
RefineThemes,
ThemedLayoutV2,
ErrorComponent,
} from "@refinedev/antd";
import dataProvider from "@refinedev/simple-rest";
import routerProvider, {
UnsavedChangesNotifier,
DocumentTitleHandler,
} from "@refinedev/react-router";
import { BrowserRouter, Route, Routes, Outlet } from "react-router";
import { ConfigProvider, App as AntdApp } from "antd";
import "@refinedev/antd/dist/reset.css";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default App;
"import { Refine, WelcomePage, ErrorComponent } from "@refinedev/core";
import routerProvider from "@refinedev/react-router";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { BrowserRouter, Routes, Route } from "react-router";
function App() {
return (
Expand Down Expand Up @@ -57,7 +57,7 @@ export default App;
"import { Refine, WelcomePage, ErrorComponent } from "@refinedev/core";
import routerProvider from "@refinedev/react-router";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { BrowserRouter, Routes, Route } from "react-router";
import { UseListExample, UseOneExample, UseUpdateExample } from "examples";
Expand Down Expand Up @@ -85,7 +85,7 @@ exports[`react-router transformer should transform the file
import { Refine, WelcomePage, ErrorComponent } from "@refinedev/core";
import routerProvider from "@refinedev/react-router";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { BrowserRouter, Routes, Route } from "react-router";
function App() {
return (
Expand All @@ -105,7 +105,50 @@ export default App;
"import { Refine, WelcomePage, ErrorComponent } from "@refinedev/core";
import routerProvider from "@refinedev/react-router";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { BrowserRouter, Routes, Route } from "react-router";
function App() {
return (
<BrowserRouter>
<Refine routerProvider={routerProvider}>
<Routes>
<Route index element={<WelcomePage />} />
<Route path="*" element={<ErrorComponent />} />
</Routes>
</Refine>
</BrowserRouter>
);
}
export default App;"
`;

exports[`react-router transformer should transform the file
----------------------------------------------------
import { Refine, WelcomePage, ErrorComponent } from "@refinedev/core";
import routerProvider from "@refinedev/react-router";
import { BrowserRouter, Routes, Route } from "react-router";
function App() {
return (
<BrowserRouter>
<Refine routerProvider={routerProvider}>
<Routes>
<Route index element={<WelcomePage />} />
<Route path="*" element={<ErrorComponent />} />
</Routes>
</Refine>
</BrowserRouter>
);
}
export default App;
---------------------------------------------------- 1`] = `
"import { Refine, WelcomePage, ErrorComponent } from "@refinedev/core";
import routerProvider from "@refinedev/react-router";
import { BrowserRouter, Routes, Route } from "react-router";
function App() {
return (
Expand Down
9 changes: 9 additions & 0 deletions packages/core/test/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ window.matchMedia = jest.fn().mockImplementation((query) => {
};
});

Object.defineProperty(window, "TextEncoder", {
writable: true,
value: util.TextEncoder,
});
Object.defineProperty(window, "TextDecoder", {
writable: true,
value: util.TextDecoder,
});

window.scroll = jest.fn();
window.alert = jest.fn();

Expand Down
2 changes: 1 addition & 1 deletion packages/inferencer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"dev": "tsup --watch",
"prepare": "pnpm build",
"publint": "publint --strict=true --level=suggestion",
"test": "jest --passWithNoTests --runInBand",
"test": "jest --passWithNoTests --runInBand --updateSnapshot",
"types": "node ../shared/generate-declarations.js"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ exports[`ChakraEditInferencer should match the snapshot 1`] = `
class="css-oquf3a"
>
<a
data-discover="true"
href="/posts"
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ exports[`ChakraShowInferencer should match the snapshot 1`] = `
class="css-i08qke"
>
<a
data-discover="true"
href="/posts"
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ exports[`MantineEditInferencer should match the snapshot 1`] = `
>
<a
class="mantine-Text-root mantine-Anchor-root mantine-1ut1du9"
data-discover="true"
href="/posts"
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ exports[`MantineShowInferencer should match the snapshot 1`] = `
>
<a
class="mantine-Text-root mantine-Anchor-root mantine-1ut1du9"
data-discover="true"
href="/posts"
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ exports[`MuiEditInferencer should match the snapshot 1`] = `
class="MuiBox-root css-u4p24i"
>
<a
data-discover="true"
href="/posts"
style="text-decoration: none;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ exports[`MuiShowInferencer should match the snapshot 1`] = `
class="MuiBox-root css-10egq61"
>
<a
data-discover="true"
href="/posts"
style="text-decoration: none;"
>
Expand Down
10 changes: 10 additions & 0 deletions packages/mui/test/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@testing-library/jest-dom";
import "@testing-library/jest-dom/extend-expect";
import { configure } from "@testing-library/dom";
import * as util from "util";

configure({
asyncUtilTimeout: 10000,
Expand All @@ -17,6 +18,15 @@ window.matchMedia = jest.fn().mockImplementation((query) => {
};
});

Object.defineProperty(window, "TextEncoder", {
writable: true,
value: util.TextEncoder,
});
Object.defineProperty(window, "TextDecoder", {
writable: true,
value: util.TextDecoder,
});

window.scroll = jest.fn();
window.alert = jest.fn();

Expand Down
10 changes: 10 additions & 0 deletions packages/nextjs-router/src/test/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@testing-library/jest-dom";
import "@testing-library/jest-dom/extend-expect";
import { configure } from "@testing-library/dom";
import * as util from "util";

jest.retryTimes(3, { logErrorsBeforeRetry: true });

Expand All @@ -19,6 +20,15 @@ window.matchMedia = jest.fn().mockImplementation((query) => {
};
});

Object.defineProperty(window, "TextEncoder", {
writable: true,
value: util.TextEncoder,
});
Object.defineProperty(window, "TextDecoder", {
writable: true,
value: util.TextDecoder,
});

window.scroll = jest.fn();
window.alert = jest.fn();

Expand Down
1 change: 1 addition & 0 deletions packages/react-hook-form/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
preset: "ts-jest",
rootDir: "./",
displayName: "react-hook-form",
setupFilesAfterEnv: ["<rootDir>/test/jest.setup.ts"],
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/dist/"],
testEnvironment: "jsdom",
transform: {
Expand Down
Loading

0 comments on commit ba190e2

Please sign in to comment.