Merge remote-tracking branch 'origin/main' into feature/upload-car-image
Some checks failed
it-academy/dry-wash-pl/pipeline/pr-main There was a failure building this commit
Some checks failed
it-academy/dry-wash-pl/pipeline/pr-main There was a failure building this commit
This commit is contained in:
commit
811e0e3f24
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"i18n-ally.localesPaths": [
|
||||||
|
"locales"
|
||||||
|
]
|
||||||
|
}
|
32
Jenkinsfile
vendored
32
Jenkinsfile
vendored
@ -1,7 +1,7 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'node:20'
|
image 'node:22'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,25 +30,21 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('checks') {
|
stage('eslint') {
|
||||||
parallel {
|
steps {
|
||||||
stage('eslint') {
|
sh 'npm run eslint'
|
||||||
steps {
|
}
|
||||||
sh 'npm run eslint'
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('test') {
|
stage('test') {
|
||||||
steps {
|
steps {
|
||||||
sh 'npm run test'
|
sh 'npm run test'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('build') {
|
stage('build') {
|
||||||
steps {
|
steps {
|
||||||
sh 'npm run build'
|
sh 'npm run build'
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
"build": "npm run clean && brojs build --dev",
|
"build": "npm run clean && brojs build --dev",
|
||||||
"build:prod": "npm run clean && brojs build",
|
"build:prod": "npm run clean && brojs build",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"eslint": "npx eslint .",
|
"eslint": "npx eslint src",
|
||||||
"eslint:fix": "npx eslint . --fix",
|
"eslint:fix": "npx eslint src --fix",
|
||||||
"preversion": "npm run eslint"
|
"preversion": "npm run eslint"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
@ -7,7 +7,9 @@ export const store = configureStore({
|
|||||||
[api.reducerPath]: api.reducer,
|
[api.reducerPath]: api.reducer,
|
||||||
},
|
},
|
||||||
middleware: (getDefaultMiddleware) =>
|
middleware: (getDefaultMiddleware) =>
|
||||||
getDefaultMiddleware().concat(api.middleware),
|
getDefaultMiddleware({
|
||||||
|
serializableCheck: false
|
||||||
|
}).concat(api.middleware),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type RootState = ReturnType<typeof store.getState>;
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
|
@ -28,7 +28,6 @@ class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|||||||
|
|
||||||
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
||||||
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
||||||
console.error('4545');
|
|
||||||
this.setState({ error, errorInfo });
|
this.setState({ error, errorInfo });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ jest.mock('@brojs/cli', () => {
|
|||||||
|
|
||||||
describe('ErrorBoundary', () => {
|
describe('ErrorBoundary', () => {
|
||||||
it('должен отобразить запасной UI при ошибке', async () => {
|
it('должен отобразить запасной UI при ошибке', async () => {
|
||||||
|
// Подавляем вывод ошибки в консоль во время теста
|
||||||
|
const consoleSpy = jest.spyOn(console, 'error');
|
||||||
|
consoleSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
@ -39,7 +43,9 @@ describe('ErrorBoundary', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(button).not.toBeNull();
|
expect(button).not.toBeNull();
|
||||||
|
|
||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
|
|
||||||
|
// Восстанавливаем console.error после теста
|
||||||
|
consoleSpy.mockRestore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`Master Page render 1`] = `
|
exports[`Master Page should display master list and show details when master button is clicked 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class="css-1yeiifd"
|
class="css-1yeiifd"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`Order View page, initial load shows order details 1`] = `
|
exports[`Страница просмотра заказа отображает детали заказа после успешной загрузки 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class="chakra-container css-3n6qh3"
|
class="chakra-container css-3n6qh3"
|
||||||
@ -126,7 +126,7 @@ exports[`Order View page, initial load shows order details 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Order View page, initial load shows order details loading 1`] = `
|
exports[`Страница просмотра заказа отображает индикатор загрузки деталей заказа 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class="chakra-container css-3n6qh3"
|
class="chakra-container css-3n6qh3"
|
||||||
@ -171,7 +171,7 @@ exports[`Order View page, initial load shows order details loading 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Order View page, initial load shows order error 1`] = `
|
exports[`Страница просмотра заказа отображает ошибку при некорректном ID заказа 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class="chakra-container css-3n6qh3"
|
class="chakra-container css-3n6qh3"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`order page получение списка заказов 1`] = `
|
exports[`Страница заказов должна корректно отображать список заказов после загрузки данных 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class="css-1yeiifd"
|
class="css-1yeiifd"
|
||||||
@ -75,7 +75,7 @@ exports[`order page получение списка заказов 1`] = `
|
|||||||
<p
|
<p
|
||||||
class="chakra-text css-52ukzg"
|
class="chakra-text css-52ukzg"
|
||||||
>
|
>
|
||||||
16.02.2025
|
20.02.2025
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
class="chakra-button css-ez23ye"
|
class="chakra-button css-ez23ye"
|
||||||
|
@ -54,6 +54,41 @@ const server = setupServer(
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
http.post('/api/arm/orders', () => {
|
||||||
|
return HttpResponse.json({
|
||||||
|
success: true,
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
id: 'order1',
|
||||||
|
carNumber: 'A123BC',
|
||||||
|
startWashTime: '2024-11-24T10:30:00.000Z',
|
||||||
|
endWashTime: '2024-11-24T16:30:00.000Z',
|
||||||
|
orderDate: '2024-11-24T08:41:46.366Z',
|
||||||
|
status: 'pending',
|
||||||
|
phone: '79001234563',
|
||||||
|
location: 'Казань, ул. Баумана, 1',
|
||||||
|
master: {
|
||||||
|
name: 'Олег Макаров',
|
||||||
|
phone: '79001234567',
|
||||||
|
id: '23423442',
|
||||||
|
},
|
||||||
|
notes: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'order2',
|
||||||
|
carNumber: 'A245BC',
|
||||||
|
startWashTime: '2024-11-24T11:30:00.000Z',
|
||||||
|
endWashTime: '2024-11-24T17:30:00.000Z',
|
||||||
|
orderDate: '2024-11-24T07:40:46.366Z',
|
||||||
|
status: 'progress',
|
||||||
|
phone: '79001234567',
|
||||||
|
location: 'Казань, ул. Баумана, 43',
|
||||||
|
master: [],
|
||||||
|
notes: '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
jest.mock('@brojs/cli', () => {
|
jest.mock('@brojs/cli', () => {
|
||||||
@ -70,11 +105,7 @@ describe('Master Page', () => {
|
|||||||
afterEach(() => server.resetHandlers());
|
afterEach(() => server.resetHandlers());
|
||||||
afterAll(() => server.close());
|
afterAll(() => server.close());
|
||||||
|
|
||||||
it('render ', async () => {
|
it('should display master list and show details when master button is clicked', async () => {
|
||||||
server.events.on('request:start', ({ request }) => {
|
|
||||||
console.log('Outgoing:', request.method, request.url);
|
|
||||||
});
|
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ChakraProvider theme={chakraTheme}>
|
<ChakraProvider theme={chakraTheme}>
|
||||||
@ -88,10 +119,14 @@ describe('Master Page', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const button = await waitFor(() => screen.getByTestId('master-button'));
|
const button = await waitFor(() => screen.getByTestId('master-button'));
|
||||||
|
|
||||||
fireEvent.click(button);
|
fireEvent.click(button);
|
||||||
|
|
||||||
await waitFor(() => screen.getByText('Иван Иванов'));
|
// Проверяем отображение всех мастеров
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.getByText('Иван Иванов')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Олег Макаров')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Иван Галкин')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -11,12 +11,12 @@ jest.mock('react-router-dom', () => ({
|
|||||||
useParams: jest.fn(),
|
useParams: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Order View page, initial load', () => {
|
describe('Страница просмотра заказа', () => {
|
||||||
beforeAll(() => server.listen());
|
beforeAll(() => server.listen());
|
||||||
afterEach(() => server.resetHandlers());
|
afterEach(() => server.resetHandlers());
|
||||||
afterAll(() => server.close());
|
afterAll(() => server.close());
|
||||||
|
|
||||||
test('shows order details loading', () => {
|
test('отображает индикатор загрузки деталей заказа', () => {
|
||||||
(useParams as jest.Mock).mockReturnValue({ orderId: 'id1' });
|
(useParams as jest.Mock).mockReturnValue({ orderId: 'id1' });
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
@ -33,7 +33,7 @@ describe('Order View page, initial load', () => {
|
|||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shows order details', async () => {
|
test('отображает детали заказа после успешной загрузки', async () => {
|
||||||
(useParams as jest.Mock).mockReturnValue({ orderId: 'id1' });
|
(useParams as jest.Mock).mockReturnValue({ orderId: 'id1' });
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
@ -52,7 +52,7 @@ describe('Order View page, initial load', () => {
|
|||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shows order error', async () => {
|
test('отображает ошибку при некорректном ID заказа', async () => {
|
||||||
(useParams as jest.Mock).mockReturnValue({ orderId: null });
|
(useParams as jest.Mock).mockReturnValue({ orderId: null });
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
|
@ -46,10 +46,6 @@ describe('order page', () => {
|
|||||||
afterAll(() => server.close());
|
afterAll(() => server.close());
|
||||||
|
|
||||||
it('получение пустого списка', async () => {
|
it('получение пустого списка', async () => {
|
||||||
server.events.on('request:start', ({ request }) => {
|
|
||||||
console.log('Outgoing:', request.method, request.url);
|
|
||||||
});
|
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ChakraProvider theme={chakraTheme}>
|
<ChakraProvider theme={chakraTheme}>
|
||||||
|
@ -21,9 +21,43 @@ import Page from '../arm';
|
|||||||
import { PageSpinner } from '../../components';
|
import { PageSpinner } from '../../components';
|
||||||
|
|
||||||
const server = setupServer(
|
const server = setupServer(
|
||||||
http.get('/api/arm/orders', () => {
|
http.post('/api/arm/orders', () => {
|
||||||
return HttpResponse.json({}, { status: 500 });
|
return HttpResponse.json({}, { status: 500 });
|
||||||
}),
|
}),
|
||||||
|
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', () => {
|
jest.mock('@brojs/cli', () => {
|
||||||
|
@ -98,16 +98,12 @@ jest.mock('@brojs/cli', () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('order page', () => {
|
describe('Страница заказов', () => {
|
||||||
beforeAll(() => server.listen());
|
beforeAll(() => server.listen());
|
||||||
afterEach(() => server.resetHandlers());
|
afterEach(() => server.resetHandlers());
|
||||||
afterAll(() => server.close());
|
afterAll(() => server.close());
|
||||||
|
|
||||||
it('получение списка заказов ', async () => {
|
it('должна корректно отображать список заказов после загрузки данных', async () => {
|
||||||
server.events.on('request:start', ({ request }) => {
|
|
||||||
console.log('Outgoing:', request.method, request.url);
|
|
||||||
});
|
|
||||||
|
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ChakraProvider theme={chakraTheme}>
|
<ChakraProvider theme={chakraTheme}>
|
||||||
|
Loading…
Reference in New Issue
Block a user