Skip to content

Commit 6c8a79e

Browse files
committed
Merge branch 'develop' into feature/issue-963
2 parents d89b2de + 2e82f05 commit 6c8a79e

File tree

76 files changed

+23350
-12876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+23350
-12876
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ npm-debug.log*
3232
yarn-debug.log*
3333
yarn-error.log*
3434
package-lock.json
35+
36+
#certificate
37+
/cert

README.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,38 @@ Back-end part: https://github.com/ita-social-projects/StreetCode.git.
1616

1717
## Table of Contents
1818

19-
- [Installation](#installation)
20-
- [Required to install](#required-to-install)
21-
- [Clone](#clone)
22-
- [Setup](#setup)
23-
- [How to run local](#how-to-run-local)
24-
- [Usage](#usage)
25-
- [How to run tests](#how-to-run-tests)
26-
- [Documentation](#documentation)
27-
- [Contributing](#contributing)
28-
- [GitHub flow](#github-flow)
29-
- [Issue flow](#github-flow)
30-
- [Team](#team)
31-
- [FAQ](#faq)
32-
- [Support](#support)
33-
- [About Us](#about-us)
34-
- [License](#license)
19+
- [Streetcode](#streetcode)
20+
- [Table of Contents](#table-of-contents)
21+
- [Installation](#installation)
22+
- [Required to install](#required-to-install)
23+
- [Clone](#clone)
24+
- [Setup](#setup)
25+
- [Prerequisites](#prerequisites)
26+
- [Installation Steps](#installation-steps)
27+
- [How to run local](#how-to-run-local)
28+
- [Usage](#usage)
29+
- [How to run tests](#how-to-run-tests)
30+
- [Documentation](#documentation)
31+
- [Contributing](#contributing)
32+
- [Gitflow](#gitflow)
33+
- [Step 1](#step-1)
34+
- [Step 2](#step-2)
35+
- [Step 3](#step-3)
36+
- [Step 4](#step-4)
37+
- [Step 5](#step-5)
38+
- [Step 6](#step-6)
39+
- [Step 7](#step-7)
40+
- [Step 8](#step-8)
41+
- [Step 9](#step-9)
42+
- [Hotfixes](#hotfixes)
43+
- [Step 1](#step-1-1)
44+
- [Step 2](#step-2-1)
45+
- [Issue flow](#issue-flow)
46+
- [Team](#team)
47+
- [FAQ](#faq)
48+
- [Support](#support)
49+
- [About Us](#about-us)
50+
- [License](#license)
3551

3652
---
3753

@@ -58,6 +74,29 @@ To setup this project use this command in project folder:
5874
npm install
5975
```
6076

77+
To facilitate the usage of Workbox in our project, we have a few setup steps. Follow these instructions carefully:
78+
79+
#### Prerequisites
80+
81+
Before proceeding, ensure you have [Chocolatey](https://chocolatey.org/install) installed on your system.
82+
83+
#### Installation Steps
84+
85+
1. Install `mkcert` by running the following command from PowerShell (administrative):
86+
```
87+
choco install mkcert
88+
```
89+
2. Create a `cert` folder in the root directory of cloned project.
90+
3. Navigate to the `cert` folder in your console.
91+
4. Run the following commands to generate SSL certificates:
92+
```
93+
mkcert -install
94+
```
95+
```
96+
mkcert localhost 127.0.0.1
97+
```
98+
5. In `webpack.dev.js` file update DevServer section according to comment left there.
99+
61100
### How to run local
62101
To start project locally, write following command:
63102
```

__mocks__/@stores/root-store.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ export const mockUpdateNews = jest.fn();
55
export const mockCreateNews = jest.fn();
66

77
export const useModalContext = () => ({
8-
modalStore: {
9-
setModal: mockSetModal,
10-
modalsState: {
11-
deleteStreetcode: {
12-
isOpen: mockIsOpen,
13-
fromCardId: mockID,
14-
},
8+
modalStore: {
9+
setModal: mockSetModal,
10+
modalsState: {
11+
deleteStreetcode: {
12+
isOpen: mockIsOpen,
13+
fromCardId: mockID,
14+
},
15+
},
1516
},
16-
},
1717
});
1818

1919
export const useMobx = () => ({
20-
newsStore: {
21-
updateNews: mockUpdateNews,
22-
createNews: mockCreateNews,
23-
getNewsArray: [
24-
{
25-
id: 1,
26-
title: "title",
27-
text: "text",
28-
url: "url",
29-
creationDate: "2024-01-29",
30-
},
31-
],
32-
},
20+
newsStore: {
21+
updateNews: mockUpdateNews,
22+
createNews: mockCreateNews,
23+
getNewsArray: [
24+
{
25+
id: 1,
26+
title: 'title',
27+
text: 'text',
28+
url: 'url',
29+
creationDate: '2024-01-29',
30+
},
31+
],
32+
},
3333
});
3434

3535
export default useMobx;

__mocks__/antd/antd.tsx

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
/* eslint-disable jsx-a11y/control-has-associated-label */
2+
import React, {
3+
ChangeEventHandler,
4+
MouseEventHandler,
5+
ReactNode,
6+
} from 'react';
7+
8+
export { default as Form } from './es/form/Form';
9+
10+
type ModalProps = {
11+
title: string;
12+
open: boolean;
13+
onOk: MouseEventHandler<HTMLButtonElement>;
14+
onCancel: MouseEventHandler<HTMLButtonElement>;
15+
children: ReactNode;
16+
};
17+
18+
type InputProps = {
19+
showCount: boolean;
20+
maxLength: number;
21+
value: string;
22+
};
23+
24+
type FileUploaderProps = {
25+
onChange: typeof jest.fn;
26+
fileList: any[];
27+
className: string;
28+
multiple: boolean;
29+
accept: string;
30+
listType: string;
31+
maxCount: number;
32+
onPreview: typeof jest.fn;
33+
onRemove: typeof jest.fn;
34+
uploadTo: string;
35+
onSuccessUpload: typeof jest.fn;
36+
children: ReactNode;
37+
};
38+
39+
export type MockPaginationProps = {
40+
current: number;
41+
total: number;
42+
pageSize: number;
43+
onChange: typeof jest.fn;
44+
};
45+
46+
type ButtonProps = {
47+
className: string;
48+
onClick: MouseEventHandler<HTMLButtonElement>;
49+
children: ReactNode;
50+
};
51+
52+
type PopoverProps = {
53+
content: string;
54+
trigger: string;
55+
children: ReactNode;
56+
};
57+
58+
type SelectProps = {
59+
className: string;
60+
onSelect: MouseEventHandler<HTMLButtonElement>;
61+
mode: string;
62+
onDeselect: MouseEventHandler<HTMLButtonElement>;
63+
value: Array<any>;
64+
children: ReactNode;
65+
};
66+
67+
type CheckboxProps = {
68+
checked: boolean;
69+
onChange: ChangeEventHandler<HTMLInputElement>;
70+
};
71+
72+
type OptionProps = {
73+
value?: string;
74+
};
75+
76+
export const mockConfig = jest.fn();
77+
78+
export const Modal = ({
79+
title,
80+
open,
81+
onOk,
82+
onCancel,
83+
children,
84+
}: ModalProps) => (
85+
<>
86+
<div className="modalTitle">{title}</div>
87+
<div className="isModalOpen">{JSON.stringify(open)}</div>
88+
<button type="button" className="modalOkButton" onClick={onOk}>
89+
okButton
90+
</button>
91+
<button type="button" className="modalCancelButton" onClick={onCancel}>
92+
cancelButton
93+
</button>
94+
<div className="modal-children">{children}</div>
95+
</>
96+
);
97+
98+
export const Button = ({ className, onClick, children }: ButtonProps) => (
99+
<>
100+
<div data-test-id="button-class" className={className} />
101+
<button type="button" data-test-id="button-button" onClick={onClick} />
102+
<div data-test-id="modal-children">{children}</div>
103+
</>
104+
);
105+
106+
export const message = {
107+
config: mockConfig,
108+
};
109+
110+
export const Popover = ({ content, trigger, children }: PopoverProps) => (
111+
<>
112+
<div data-test-id="popover-content">{content}</div>
113+
<div data-test-id="popover-trigger">{trigger}</div>
114+
<div data-test-id="popover-children">{children}</div>
115+
</>
116+
);
117+
118+
const Option = ({ value }: OptionProps) => (
119+
<div data-test-id="option-value">{value}</div>
120+
);
121+
122+
const Select = ({
123+
className,
124+
onSelect,
125+
mode,
126+
onDeselect,
127+
value,
128+
children,
129+
}: SelectProps) => (
130+
<>
131+
<div className={className} data-test-id="select-class-name" />
132+
<button
133+
type="button"
134+
data-test-id="select-on-select"
135+
onClick={onSelect}
136+
/>
137+
<div data-test-id="select-mode">{mode}</div>
138+
<button
139+
type="button"
140+
data-test-id="select-on-deselect"
141+
onClick={onDeselect}
142+
/>
143+
<div data-test-id="select-value">{value}</div>
144+
<div data-test-id="select-children">{children}</div>
145+
</>
146+
);
147+
148+
Select.Option = Option;
149+
150+
export { Select };
151+
152+
export const Input = ({ value, showCount, maxLength }: InputProps) => (
153+
<>
154+
<div data-testid="input-show-count">{showCount}</div>
155+
<div data-testid="input-max-length">{maxLength}</div>
156+
<input data-testid="input-value" value={value} />
157+
</>
158+
);
159+
160+
export const Checkbox = ({ checked, onChange }: CheckboxProps) => (
161+
<input type="checkbox" checked={checked} onChange={onChange} />
162+
);
163+
164+
export const MockPagination = ({ current, total, pageSize, onChange }: MockPaginationProps) => {
165+
const totalPages = total % pageSize === 0 ? total / pageSize : (total / pageSize) + 1;
166+
return (
167+
<ul>
168+
<li>
169+
<button type="button" disabled={current === 1} onChange={onChange}>{'<'}</button>
170+
</li>
171+
<li>
172+
<input type="text" size={3} />
173+
{totalPages}
174+
</li>
175+
<li>
176+
<button type="button" disabled={current >= totalPages} onChange={onChange}>{'>'}</button>
177+
</li>
178+
</ul>
179+
);
180+
};

__mocks__/antd/es/form/Form.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { MouseEventHandler, ReactNode } from "react"
2+
import Item from "./FormItem"
3+
4+
type FormProps = {
5+
form?: any,
6+
layout?: string,
7+
onFinish?: MouseEventHandler<HTMLButtonElement>
8+
children?: ReactNode
9+
}
10+
11+
const Form = ({ form, layout, onFinish, children }: FormProps) => {
12+
return (
13+
<>
14+
<div data-testid="form-form">{form && "form exists"}</div>
15+
<div data-testid="form-layout">{layout}</div>
16+
<button type='button' data-testid="form-on-finish" onClick={onFinish}/>
17+
<div data-testid="form-children">{children}</div>
18+
</>
19+
)
20+
}
21+
22+
const mockSetFieldsValue = jest.fn();
23+
const mockResetFields = jest.fn();
24+
25+
const useForm = () => {
26+
return [{
27+
setFieldsValue: mockSetFieldsValue,
28+
resetFields: mockResetFields,
29+
}]
30+
};
31+
32+
33+
Form.useForm = useForm;
34+
Form.Item = Item;
35+
export default Form;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { ReactNode } from "react";
2+
3+
type Rule = {
4+
required?: boolean;
5+
};
6+
7+
type FormItemProps = {
8+
name?: string;
9+
label?: string;
10+
className?: string;
11+
valuePropName?: string;
12+
children?: ReactNode;
13+
};
14+
15+
const FormItem = ({
16+
name,
17+
label,
18+
className,
19+
valuePropName,
20+
children,
21+
}: FormItemProps) => {
22+
return (
23+
<>
24+
<div data-testid="form-item-label">{label}</div>
25+
<div data-testid="form-item-name">{name}</div>
26+
<div data-testid="form-item-class">{className}</div>
27+
<div data-testid="form-item-value-prop-name">{valuePropName}</div>
28+
<div data-testid="form-item-children">{children}</div>
29+
</>
30+
);
31+
};
32+
33+
export default FormItem;

0 commit comments

Comments
 (0)