error boundary + disable keycloak
This commit is contained in:
1 parent
19c0ef2882
commit
d2426c6c62
10 files changed
+49
-19
No files matched your search
Generated
+16
-12
@@ -19,6 +19,7 @@
|
||||
"keycloak-js": "^26.0.7",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-error-boundary": "^6.1.6",
|
||||
"react-redux": "^9.2.0",
|
||||
"react-router-dom": "^6.28.0"
|
||||
},
|
||||
@@ -27,7 +28,6 @@
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.1.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@types/webpack-env": "^1.18.5",
|
||||
@@ -3787,17 +3787,6 @@
|
||||
"@types/istanbul-lib-report": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/jest": {
|
||||
"version": "29.5.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz",
|
||||
"integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"expect": "^29.0.0",
|
||||
"pretty-format": "^29.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/jsdom": {
|
||||
"version": "20.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz",
|
||||
@@ -12857,6 +12846,21 @@
|
||||
"react": "^18.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/react-error-boundary": {
|
||||
"version": "6.1.6",
|
||||
"resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-6.1.6.tgz",
|
||||
"integrity": "sha512-CDXPnXDGyFIbkwaaJ6u+xgsRmJhSi6YdgUDW1vnyKHfXp1a9pfAlM+ZET2CDu80/A+8iRcmXN0NSY9BCCoWP5A==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.0.0 || ^19.0.0",
|
||||
"react": "^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-error-overlay": {
|
||||
"version": "6.0.11",
|
||||
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"keycloak-js": "^26.0.7",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-error-boundary": "^6.1.6",
|
||||
"react-redux": "^9.2.0",
|
||||
"react-router-dom": "^6.28.0"
|
||||
},
|
||||
|
||||
@@ -3,8 +3,13 @@ import { describe, test, expect } from '@jest/globals';
|
||||
|
||||
describe('Тесты на функцию sum', () => {
|
||||
test('1 + 2 = 3', () => {
|
||||
// Подготовка к тесту. Моки
|
||||
|
||||
|
||||
const result = sum(1, 2);
|
||||
|
||||
expect(result).toBe(3);
|
||||
|
||||
// Очистка моков, состояния
|
||||
});
|
||||
});
|
||||
@@ -18,8 +18,8 @@ jest.mock<typeof import('@brojs/cli')>('@brojs/cli', () => {
|
||||
|
||||
return {
|
||||
...originalBroJsCli,
|
||||
getConfigValue: () => {
|
||||
getConfigValue: jest.fn(() => {
|
||||
return 'mocked_value';
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import { HeadingStyled } from './index.style';
|
||||
import { HeadingProps, HeadingVariant } from './types';
|
||||
|
||||
const Heading = ({ children, variant = HeadingVariant.h1, className }: HeadingProps) => {
|
||||
|
||||
return (
|
||||
<HeadingStyled className={className} as={variant} variant={variant}>
|
||||
{children}
|
||||
|
||||
@@ -2,9 +2,19 @@ import React from 'react';
|
||||
import Heading from '../../components/heading';
|
||||
import { useGetListQuery } from '../../store/api';
|
||||
|
||||
let render = 0;
|
||||
|
||||
const ListPage = (): React.ReactElement => {
|
||||
const { data, isLoading, error } = useGetListQuery(undefined);
|
||||
|
||||
if (!render)
|
||||
throw new Promise((res) =>
|
||||
setTimeout(() => {
|
||||
render++;
|
||||
res(<p>Hello from promise</p>);
|
||||
}, 4000)
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Heading>List Page New</Heading>
|
||||
|
||||
@@ -8,7 +8,8 @@ import { useKeycloak } from './keycloak';
|
||||
const store = setupStore();
|
||||
|
||||
const Main = (): React.ReactElement | string => {
|
||||
const { isLoading } = useKeycloak();
|
||||
// const { isLoading } = useKeycloak();
|
||||
const { isLoading } = { isLoading: false };
|
||||
|
||||
if (isLoading) {
|
||||
return 'Loading...';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React from 'react';
|
||||
import React, { Suspense } from 'react';
|
||||
import { createBrowserRouter } from 'react-router-dom';
|
||||
import ListPage from '../list';
|
||||
import DetailPage from '../detail';
|
||||
import { getNavigationValue } from '@brojs/cli';
|
||||
import Layout from './components/layout';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{
|
||||
@@ -12,7 +13,13 @@ export const router = createBrowserRouter([
|
||||
children: [
|
||||
{
|
||||
path: getNavigationValue('kfu-24-teacher.main'),
|
||||
element: <ListPage />
|
||||
element: (
|
||||
<ErrorBoundary fallback={<p>List page Error</p>}>
|
||||
<Suspense fallback={<p>List page Loading</p>}>
|
||||
<ListPage />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
)
|
||||
},
|
||||
{
|
||||
path: getNavigationValue('kfu-24-teacher.detail'),
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ const delay =
|
||||
setTimeout(next, ms);
|
||||
};
|
||||
|
||||
router.use(keycloak.middleware());
|
||||
// router.use(keycloak.middleware());
|
||||
router.use(delay());
|
||||
router.use('/list', listRouter);
|
||||
@@ -5,7 +5,8 @@ module.exports = router;
|
||||
const data = require('./data/list.json');
|
||||
const keycloak = require('../keycloak');
|
||||
|
||||
router.get('/', keycloak.protect(), (req, res) => {
|
||||
// router.get('/', keycloak.protect(), (req, res) => {
|
||||
router.get('/', (req, res) => {
|
||||
res.send(data);
|
||||
// res.status(500).send({
|
||||
// message: 'Internal server error'
|
||||
|
||||
Reference in new issue
Block a user