Merge branch 'main' of ssh://85.143.175.152:222/dry_wash_inc/dry-wash-pl
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
This commit is contained in:
commit
9111724519
6
__mocks__/lottiefiles-mock.tsx
Normal file
6
__mocks__/lottiefiles-mock.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import { jest } from '@jest/globals';
|
||||
import React from 'react';
|
||||
|
||||
jest.mock('@lottiefiles/react-lottie-player', () => ({
|
||||
Player: jest.fn(() => <></>),
|
||||
}));
|
@ -6,7 +6,7 @@ test.beforeEach('check server is up', async ({ page }) => {
|
||||
const makeOrderText = page.getByText('Сделать заказ', { exact: true });
|
||||
await expect(makeOrderText).toBeVisible();
|
||||
} catch (error) {
|
||||
console.error('server not up');
|
||||
console.error('server not up', error);
|
||||
test.skip();
|
||||
}
|
||||
});
|
||||
|
30648
package-lock.json
generated
30648
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -58,6 +58,7 @@
|
||||
"@eslint/js": "^9.14.0",
|
||||
"@playwright/test": "^1.50.1",
|
||||
"@stylistic/eslint-plugin": "^2.10.1",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@types/node": "^22.13.1",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"eslint": "^9.14.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { FetchBaseQueryError } from "@reduxjs/toolkit/query";
|
||||
import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
||||
|
||||
import { BaseResponse } from "../../models/api";
|
||||
import { BaseResponse } from '../../models/api';
|
||||
|
||||
export const extractBodyFromResponse = <Body>(response: BaseResponse<Body>) => {
|
||||
if (response.success) {
|
||||
@ -8,8 +8,14 @@ export const extractBodyFromResponse = <Body>(response: BaseResponse<Body>) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const extractErrorMessageFromResponse = ({ data }: FetchBaseQueryError) => {
|
||||
if (typeof data === 'object' && 'message' in data && typeof data.message === 'string') {
|
||||
export const extractErrorMessageFromResponse = ({
|
||||
data,
|
||||
}: FetchBaseQueryError) => {
|
||||
if (
|
||||
typeof data === 'object' &&
|
||||
'message' in data &&
|
||||
typeof data.message === 'string'
|
||||
) {
|
||||
return data.message;
|
||||
}
|
||||
};
|
||||
|
@ -28,27 +28,28 @@ class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
||||
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
||||
console.error('4545');
|
||||
this.setState({ error, errorInfo });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { hasError } = this.state;
|
||||
//TODO: добавить анимацию после залива 404 страницы
|
||||
//TODO: может сделать обертку для хука, чтоб язык менялся без перезагрузки
|
||||
|
||||
if (hasError) {
|
||||
return (
|
||||
<Center minH='100vh'>
|
||||
<Center minH='100vh' data-testid='error-boundary'>
|
||||
<VStack spacing={4} textAlign='center'>
|
||||
<Heading as='h1' size='2xl'>
|
||||
<Heading as='h1' size='2xl' data-testid='error-title'>
|
||||
{i18next.t('~:dry-wash.errorBoundary.title')}
|
||||
</Heading>
|
||||
<Text fontSize='lg'>
|
||||
<Text fontSize='lg' data-testid='error-description'>
|
||||
{i18next.t('~:dry-wash.errorBoundary.description')}
|
||||
</Text>
|
||||
<Button
|
||||
colorScheme='teal'
|
||||
size='lg'
|
||||
variant='outline'
|
||||
data-testid='error-reload-button'
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
{i18next.t('~:dry-wash.errorBoundary.button.reload')}
|
||||
|
@ -0,0 +1,45 @@
|
||||
import * as React from 'react';
|
||||
import { describe, expect, it, jest } from '@jest/globals';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import ErrorBoundary from '../ErrorBoundary';
|
||||
import { store } from '../../../__data__/store';
|
||||
|
||||
const ProblematicComponent = () => {
|
||||
useEffect(() => {
|
||||
throw new Error('Test Error');
|
||||
}, []);
|
||||
|
||||
return <div>Этот текст не должен появиться</div>;
|
||||
};
|
||||
jest.mock('@brojs/cli', () => {
|
||||
return {
|
||||
getNavigationValue: () => '/auth/login',
|
||||
getConfigValue: () => '/api',
|
||||
};
|
||||
});
|
||||
|
||||
describe('ErrorBoundary', () => {
|
||||
it('должен отобразить запасной UI при ошибке', async () => {
|
||||
const { container } = render(
|
||||
<Provider store={store}>
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter>
|
||||
<ProblematicComponent />
|
||||
</BrowserRouter>
|
||||
</ErrorBoundary>
|
||||
</Provider>,
|
||||
);
|
||||
|
||||
const button = await waitFor(() =>
|
||||
screen.getByTestId('error-reload-button'),
|
||||
);
|
||||
|
||||
expect(button).not.toBeNull();
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`ErrorBoundary должен отобразить запасной UI при ошибке 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="css-1o0ed15"
|
||||
data-testid="error-boundary"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-zefqyp"
|
||||
>
|
||||
<h1
|
||||
class="chakra-heading css-0"
|
||||
data-testid="error-title"
|
||||
/>
|
||||
<p
|
||||
class="chakra-text css-1ezsviu"
|
||||
data-testid="error-description"
|
||||
/>
|
||||
<button
|
||||
class="chakra-button css-4xx2wk"
|
||||
data-testid="error-reload-button"
|
||||
type="button"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
@ -15,13 +15,13 @@ import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import OrderItem from '../OrderItem';
|
||||
import { OrderProps } from '../OrderItem/OrderItem';
|
||||
import DateNavigator from '../DateNavigator';
|
||||
import {
|
||||
useGetMastersQuery,
|
||||
useGetOrdersQuery,
|
||||
} from '../../__data__/service/api';
|
||||
import useShowToast from '../../hooks/useShowToast';
|
||||
import { OrderArm } from '../../models/api';
|
||||
|
||||
const TABLE_HEADERS = [
|
||||
'carNumber' as const,
|
||||
@ -70,7 +70,6 @@ const Orders = () => {
|
||||
<Heading size='lg' mb='5'>
|
||||
{t('title')}
|
||||
</Heading>
|
||||
|
||||
<DateNavigator
|
||||
currentDate={currentDate}
|
||||
onPreviousDate={() =>
|
||||
@ -112,7 +111,7 @@ const Orders = () => {
|
||||
allMasters={masters}
|
||||
key={index}
|
||||
{...order}
|
||||
status={order.status as OrderProps['status']}
|
||||
status={order.status as OrderArm['status']}
|
||||
/>
|
||||
))}
|
||||
</Tbody>
|
||||
|
@ -5,6 +5,7 @@ export const PageSpinner: FC = () => {
|
||||
return (
|
||||
<Flex w='full' h='100vh' justifyContent='center' alignItems='center'>
|
||||
<Spinner
|
||||
data-testid='spinner'
|
||||
thickness='5px'
|
||||
speed='0.65s'
|
||||
emptyColor='gray.200'
|
||||
|
@ -47,6 +47,7 @@ const Sidebar = () => {
|
||||
w='100%'
|
||||
colorScheme={isActive(URLs.armMaster.url) ? 'green' : 'blue'}
|
||||
variant={isActive(URLs.armMaster.url) ? 'solid' : 'ghost'}
|
||||
data-testid='master-button'
|
||||
>
|
||||
{t('master')}
|
||||
</Button>
|
||||
|
643
src/pages/__tests__/__snapshots__/masters.test.tsx.snap
Normal file
643
src/pages/__tests__/__snapshots__/masters.test.tsx.snap
Normal file
@ -0,0 +1,643 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Master Page render 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="css-1yeiifd"
|
||||
>
|
||||
<div
|
||||
class="css-13owfwq"
|
||||
>
|
||||
<h2
|
||||
class="chakra-heading css-173d1bl"
|
||||
>
|
||||
Сухой мастер
|
||||
</h2>
|
||||
<div
|
||||
class="chakra-stack css-1cggwyz"
|
||||
>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-18yoix2"
|
||||
href="/order"
|
||||
>
|
||||
Заказы
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
data-testid="master-button"
|
||||
href="/master"
|
||||
>
|
||||
Мастера
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="css-jiwy8d"
|
||||
>
|
||||
<div
|
||||
class="css-1glkkdp"
|
||||
>
|
||||
<div
|
||||
class="css-sd3fvu"
|
||||
>
|
||||
<h2
|
||||
class="chakra-heading css-1jb3vzl"
|
||||
>
|
||||
|
||||
Мастера
|
||||
</h2>
|
||||
<button
|
||||
class="chakra-button css-h211ee"
|
||||
type="button"
|
||||
>
|
||||
+
|
||||
Добавить
|
||||
</button>
|
||||
</div>
|
||||
<table
|
||||
class="chakra-table css-5605sr"
|
||||
>
|
||||
<thead
|
||||
class="css-0"
|
||||
>
|
||||
<tr
|
||||
class="css-0"
|
||||
>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Имя
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Актуальная занятость
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Телефон
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Действия
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody
|
||||
class="css-0"
|
||||
>
|
||||
<tr
|
||||
class="css-0"
|
||||
>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-editable css-vtl58r"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-c2wmld"
|
||||
>
|
||||
<span
|
||||
class="chakra-editable__preview css-1gasyng"
|
||||
>
|
||||
Иван Иванов
|
||||
</span>
|
||||
<input
|
||||
class="chakra-editable__input chakra-input css-2lpiar"
|
||||
hidden=""
|
||||
value="Иван Иванов"
|
||||
/>
|
||||
<div
|
||||
class="css-1l4w6pd"
|
||||
>
|
||||
<button
|
||||
aria-label="Edit"
|
||||
class="chakra-button css-1pqvhxt"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<p
|
||||
class="chakra-text css-q9k0mw"
|
||||
>
|
||||
Свободен
|
||||
</p>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-editable css-vtl58r"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-c2wmld"
|
||||
>
|
||||
<span
|
||||
class="chakra-editable__preview css-1gasyng"
|
||||
>
|
||||
+7 900 123 45 67
|
||||
</span>
|
||||
<input
|
||||
class="chakra-editable__input chakra-input css-2lpiar"
|
||||
hidden=""
|
||||
value="+7 900 123 45 67"
|
||||
/>
|
||||
<div
|
||||
class="css-1l4w6pd"
|
||||
>
|
||||
<button
|
||||
aria-label="Edit"
|
||||
class="chakra-button css-1pqvhxt"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<button
|
||||
aria-controls="menu-list-:r2:"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="menu"
|
||||
class="chakra-button chakra-menu__menu-button css-13sr8jm"
|
||||
id="menu-button-:r2:"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="css-ktd6ms"
|
||||
style="visibility: hidden; position: absolute; min-width: max-content; inset: 0 auto auto 0;"
|
||||
>
|
||||
<div
|
||||
aria-orientation="vertical"
|
||||
class="chakra-menu__menu-list css-s5t7bz"
|
||||
id="menu-list-:r2:"
|
||||
role="menu"
|
||||
style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.8) translateZ(0);"
|
||||
tabindex="-1"
|
||||
>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
class="chakra-menu__menuitem css-y7jzs3"
|
||||
data-index="0"
|
||||
id="menu-list-:r2:-menuitem-:r3:"
|
||||
role="menuitem"
|
||||
tabindex="-1"
|
||||
type="button"
|
||||
>
|
||||
Удалить мастера
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
class="css-0"
|
||||
>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-editable css-vtl58r"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-c2wmld"
|
||||
>
|
||||
<span
|
||||
class="chakra-editable__preview css-1gasyng"
|
||||
>
|
||||
Олег Макаров
|
||||
</span>
|
||||
<input
|
||||
class="chakra-editable__input chakra-input css-2lpiar"
|
||||
hidden=""
|
||||
value="Олег Макаров"
|
||||
/>
|
||||
<div
|
||||
class="css-1l4w6pd"
|
||||
>
|
||||
<button
|
||||
aria-label="Edit"
|
||||
class="chakra-button css-1pqvhxt"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<p
|
||||
class="chakra-text css-q9k0mw"
|
||||
>
|
||||
Свободен
|
||||
</p>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-editable css-vtl58r"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-c2wmld"
|
||||
>
|
||||
<span
|
||||
class="chakra-editable__preview css-1gasyng"
|
||||
>
|
||||
79001234567
|
||||
</span>
|
||||
<input
|
||||
class="chakra-editable__input chakra-input css-2lpiar"
|
||||
hidden=""
|
||||
value="79001234567"
|
||||
/>
|
||||
<div
|
||||
class="css-1l4w6pd"
|
||||
>
|
||||
<button
|
||||
aria-label="Edit"
|
||||
class="chakra-button css-1pqvhxt"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<button
|
||||
aria-controls="menu-list-:r5:"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="menu"
|
||||
class="chakra-button chakra-menu__menu-button css-13sr8jm"
|
||||
id="menu-button-:r5:"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="css-ktd6ms"
|
||||
style="visibility: hidden; position: absolute; min-width: max-content; inset: 0 auto auto 0;"
|
||||
>
|
||||
<div
|
||||
aria-orientation="vertical"
|
||||
class="chakra-menu__menu-list css-s5t7bz"
|
||||
id="menu-list-:r5:"
|
||||
role="menu"
|
||||
style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.8) translateZ(0);"
|
||||
tabindex="-1"
|
||||
>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
class="chakra-menu__menuitem css-y7jzs3"
|
||||
data-index="0"
|
||||
id="menu-list-:r5:-menuitem-:r6:"
|
||||
role="menuitem"
|
||||
tabindex="-1"
|
||||
type="button"
|
||||
>
|
||||
Удалить мастера
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
class="css-0"
|
||||
>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-editable css-vtl58r"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-c2wmld"
|
||||
>
|
||||
<span
|
||||
class="chakra-editable__preview css-1gasyng"
|
||||
>
|
||||
Иван Галкин
|
||||
</span>
|
||||
<input
|
||||
class="chakra-editable__input chakra-input css-2lpiar"
|
||||
hidden=""
|
||||
value="Иван Галкин"
|
||||
/>
|
||||
<div
|
||||
class="css-1l4w6pd"
|
||||
>
|
||||
<button
|
||||
aria-label="Edit"
|
||||
class="chakra-button css-1pqvhxt"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-1f0wxn3"
|
||||
>
|
||||
<span
|
||||
class="chakra-badge css-1g1qw76"
|
||||
/>
|
||||
<span
|
||||
class="chakra-badge css-1g1qw76"
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<div
|
||||
class="chakra-editable css-vtl58r"
|
||||
>
|
||||
<div
|
||||
class="chakra-stack css-c2wmld"
|
||||
>
|
||||
<span
|
||||
class="chakra-editable__preview css-1gasyng"
|
||||
>
|
||||
+7 900 123 45 67
|
||||
</span>
|
||||
<input
|
||||
class="chakra-editable__input chakra-input css-2lpiar"
|
||||
hidden=""
|
||||
value="+7 900 123 45 67"
|
||||
/>
|
||||
<div
|
||||
class="css-1l4w6pd"
|
||||
>
|
||||
<button
|
||||
aria-label="Edit"
|
||||
class="chakra-button css-1pqvhxt"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
<button
|
||||
aria-controls="menu-list-:r8:"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="menu"
|
||||
class="chakra-button chakra-menu__menu-button css-13sr8jm"
|
||||
id="menu-button-:r8:"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"
|
||||
/>
|
||||
<path
|
||||
d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="css-ktd6ms"
|
||||
style="visibility: hidden; position: absolute; min-width: max-content; inset: 0 auto auto 0;"
|
||||
>
|
||||
<div
|
||||
aria-orientation="vertical"
|
||||
class="chakra-menu__menu-list css-s5t7bz"
|
||||
id="menu-list-:r8:"
|
||||
role="menu"
|
||||
style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.8) translateZ(0);"
|
||||
tabindex="-1"
|
||||
>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
class="chakra-menu__menuitem css-y7jzs3"
|
||||
data-index="0"
|
||||
id="menu-list-:r8:-menuitem-:r9:"
|
||||
role="menuitem"
|
||||
tabindex="-1"
|
||||
type="button"
|
||||
>
|
||||
Удалить мастера
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
hidden=""
|
||||
id="__chakra_env"
|
||||
/>
|
||||
</div>
|
||||
`;
|
@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Arm Page render 1`] = `
|
||||
exports[`order page получение списка заказов 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="css-1yeiifd"
|
||||
@ -32,6 +32,7 @@ exports[`Arm Page render 1`] = `
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
data-testid="master-button"
|
||||
href="/auth/login"
|
||||
>
|
||||
Мастера
|
||||
@ -74,173 +75,7 @@ exports[`Arm Page render 1`] = `
|
||||
<p
|
||||
class="chakra-text css-52ukzg"
|
||||
>
|
||||
09.02.2025
|
||||
</p>
|
||||
<button
|
||||
class="chakra-button css-ez23ye"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<table
|
||||
class="chakra-table css-5605sr"
|
||||
>
|
||||
<thead
|
||||
class="css-0"
|
||||
>
|
||||
<tr
|
||||
class="css-0"
|
||||
>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Номер машины
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Дата заказа
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Статус
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Мастер
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Телефон
|
||||
</th>
|
||||
<th
|
||||
class="css-1szkfps"
|
||||
>
|
||||
Расположение
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody
|
||||
class="css-0"
|
||||
>
|
||||
<tr
|
||||
class="css-0"
|
||||
>
|
||||
<td
|
||||
class="css-1v9gmks"
|
||||
colspan="6"
|
||||
>
|
||||
<div
|
||||
class="chakra-spinner css-1j92705"
|
||||
>
|
||||
<span
|
||||
class="css-8b45rq"
|
||||
>
|
||||
Loading...
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
hidden=""
|
||||
id="__chakra_env"
|
||||
/>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Arm Page render 2`] = `
|
||||
<div>
|
||||
<div
|
||||
class="css-1yeiifd"
|
||||
>
|
||||
<div
|
||||
class="css-13owfwq"
|
||||
>
|
||||
<h2
|
||||
class="chakra-heading css-173d1bl"
|
||||
>
|
||||
Сухой мастер
|
||||
</h2>
|
||||
<div
|
||||
class="chakra-stack css-1cggwyz"
|
||||
>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
href="/auth/login"
|
||||
>
|
||||
Заказы
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
href="/auth/login"
|
||||
>
|
||||
Мастера
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="css-jiwy8d"
|
||||
>
|
||||
<div
|
||||
class="css-1glkkdp"
|
||||
>
|
||||
<h2
|
||||
class="chakra-heading css-1xer3cv"
|
||||
>
|
||||
Заказы
|
||||
</h2>
|
||||
<div
|
||||
class="css-1u3smh"
|
||||
>
|
||||
<button
|
||||
class="chakra-button css-ez23ye"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<p
|
||||
class="chakra-text css-52ukzg"
|
||||
>
|
||||
09.02.2025
|
||||
2/16/2025
|
||||
</p>
|
||||
<button
|
||||
class="chakra-button css-ez23ye"
|
98
src/pages/__tests__/masters.test.tsx
Normal file
98
src/pages/__tests__/masters.test.tsx
Normal file
@ -0,0 +1,98 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
jest,
|
||||
beforeAll,
|
||||
afterEach,
|
||||
afterAll,
|
||||
} from '@jest/globals';
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
|
||||
import ErrorBoundary from '../../components/ErrorBoundary';
|
||||
import { store } from '../../__data__/store';
|
||||
import Page from '../arm';
|
||||
|
||||
const server = setupServer(
|
||||
http.get('/api/arm/masters', () => {
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
body: [
|
||||
{
|
||||
id: '4545423234',
|
||||
name: 'Иван Иванов',
|
||||
phone: '+7 900 123 45 67',
|
||||
},
|
||||
{
|
||||
name: 'Олег Макаров',
|
||||
phone: '79001234567',
|
||||
id: '23423442',
|
||||
},
|
||||
{
|
||||
id: '345354234',
|
||||
name: 'Иван Галкин',
|
||||
schedule: [
|
||||
{
|
||||
id: 'order1',
|
||||
startWashTime: '2024-11-24T10:30:00.000Z',
|
||||
endWashTime: '2024-11-24T16:30:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 'order2',
|
||||
startWashTime: '2024-11-24T11:30:00.000Z',
|
||||
endWashTime: '2024-11-24T17:30:00.000Z',
|
||||
},
|
||||
],
|
||||
phone: '+7 900 123 45 67',
|
||||
},
|
||||
],
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
jest.mock('@brojs/cli', () => {
|
||||
return {
|
||||
getNavigationValue: (key: string) =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
require('../../../bro.config').navigations[key],
|
||||
getConfigValue: () => '/api',
|
||||
};
|
||||
});
|
||||
|
||||
describe('Master Page', () => {
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('render ', async () => {
|
||||
server.events.on('request:start', ({ request }) => {
|
||||
console.log('Outgoing:', request.method, request.url);
|
||||
});
|
||||
|
||||
const { container } = render(
|
||||
<Provider store={store}>
|
||||
<ChakraProvider theme={chakraTheme}>
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter>
|
||||
<Page mockUser={{ name: 'ilnaz' }} />
|
||||
</BrowserRouter>
|
||||
</ErrorBoundary>
|
||||
</ChakraProvider>
|
||||
</Provider>,
|
||||
);
|
||||
|
||||
const button = await waitFor(() => screen.getByTestId('master-button'));
|
||||
|
||||
fireEvent.click(button);
|
||||
|
||||
await waitFor(() => screen.getByText('Иван Иванов'));
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
67
src/pages/__tests__/ordersEmpty.test.tsx
Normal file
67
src/pages/__tests__/ordersEmpty.test.tsx
Normal file
@ -0,0 +1,67 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
describe,
|
||||
it,
|
||||
jest,
|
||||
beforeAll,
|
||||
afterEach,
|
||||
afterAll,
|
||||
} from '@jest/globals';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import ErrorBoundary from '../../components/ErrorBoundary';
|
||||
import { store } from '../../__data__/store';
|
||||
import Page from '../arm';
|
||||
|
||||
const server = setupServer(
|
||||
http.post('/api/arm/orders', () => {
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
body: [],
|
||||
});
|
||||
}),
|
||||
http.get('/api/arm/masters', () => {
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
body: [],
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
jest.mock('@brojs/cli', () => {
|
||||
return {
|
||||
getNavigationValue: () => '/auth/login',
|
||||
getConfigValue: () => '/api',
|
||||
};
|
||||
});
|
||||
|
||||
describe('order page', () => {
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('получение пустого списка', async () => {
|
||||
server.events.on('request:start', ({ request }) => {
|
||||
console.log('Outgoing:', request.method, request.url);
|
||||
});
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<ChakraProvider theme={chakraTheme}>
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter>
|
||||
<Page mockUser={{ name: 'ilnaz' }} />
|
||||
</BrowserRouter>
|
||||
</ErrorBoundary>
|
||||
</ChakraProvider>
|
||||
</Provider>,
|
||||
);
|
||||
|
||||
await waitFor(() => screen.getByText('Список пуст'));
|
||||
});
|
||||
});
|
64
src/pages/__tests__/ordersError.test.tsx
Normal file
64
src/pages/__tests__/ordersError.test.tsx
Normal file
@ -0,0 +1,64 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
describe,
|
||||
it,
|
||||
jest,
|
||||
beforeAll,
|
||||
afterEach,
|
||||
afterAll,
|
||||
expect,
|
||||
} from '@jest/globals';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import ErrorBoundary from '../../components/ErrorBoundary';
|
||||
import { store } from '../../__data__/store';
|
||||
import Page from '../arm';
|
||||
import { PageSpinner } from '../../components';
|
||||
|
||||
const server = setupServer(
|
||||
http.get('/api/arm/orders', () => {
|
||||
return HttpResponse.json({}, { status: 500 });
|
||||
}),
|
||||
);
|
||||
|
||||
jest.mock('@brojs/cli', () => {
|
||||
return {
|
||||
getNavigationValue: () => '/auth/login',
|
||||
getConfigValue: () => '/api',
|
||||
};
|
||||
});
|
||||
|
||||
describe('order page', () => {
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('обработка ошибки при загрузке данных', async () => {
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<ChakraProvider theme={chakraTheme}>
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter>
|
||||
<Page mockUser={{ name: 'ilnaz' }} />
|
||||
</BrowserRouter>
|
||||
</ErrorBoundary>
|
||||
</ChakraProvider>
|
||||
</Provider>,
|
||||
);
|
||||
|
||||
await waitFor(() => screen.getByText('Ошибка при загрузке данных'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Routers', () => {
|
||||
it('отображает PageSpinner ', async () => {
|
||||
render(<PageSpinner />);
|
||||
|
||||
expect(await screen.findByTestId('spinner')).toBeTruthy();
|
||||
});
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
describe,
|
||||
it,
|
||||
@ -98,12 +98,12 @@ jest.mock('@brojs/cli', () => {
|
||||
};
|
||||
});
|
||||
|
||||
describe('Arm Page', () => {
|
||||
describe('order page', () => {
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('render ', async () => {
|
||||
it('получение списка заказов ', async () => {
|
||||
server.events.on('request:start', ({ request }) => {
|
||||
console.log('Outgoing:', request.method, request.url);
|
||||
});
|
||||
@ -120,8 +120,6 @@ describe('Arm Page', () => {
|
||||
</Provider>,
|
||||
);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
await waitFor(() => screen.getByText('A123BC'));
|
||||
|
||||
expect(container).toMatchSnapshot();
|
@ -21,5 +21,5 @@
|
||||
"**/*.test.ts",
|
||||
"**/*.test.tsx",
|
||||
"node_modules/@types/jest"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user