Skip to content

Commit fc865e4

Browse files
authored
Merge pull request #1227 from ita-social-projects/develop
Update master
2 parents 13a87d9 + 0af619a commit fc865e4

File tree

155 files changed

+16679
-4215
lines changed

Some content is hidden

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

155 files changed

+16679
-4215
lines changed
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
dev
2-
## JIRA
1+
### JIRA
32

43
* [Main JIRA ticket](https://jira.softserve.academy/secure/RapidBoard.jspa?rapidView=id)
54

5+
### About this PR
66

7-
## Code reviewers
7+
This PR add PR for Street Code client repo along with test coverage collection for Sonar Cloud
88

9-
- [ ] @github_username
9+
### Related PR
1010

11-
### Second Level Review
12-
13-
- [ ] @github_username
14-
15-
## Summary of issue
16-
17-
ToDo
18-
19-
## Summary of change
20-
21-
ToDo
22-
23-
## Testing approach
24-
25-
ToDo
26-
27-
## CHECK LIST
28-
- [ ] СI passed
29-
- [ ] Сode coverage >=95%
11+
### Check list
3012
- [ ] PR is reviewed manually again (to make sure you have 100% ready code)
31-
- [ ] All reviewers agreed to merge the PR
32-
- [ ] I've checked new feature as logged in and logged out user if needed
3313
- [ ] PR meets all conventions
14+
15+
### How does it looks

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PR-check
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
types: [opened, synchronize, reopended]
8+
9+
jobs:
10+
sonard_cloud:
11+
runs-on: ubuntu-latest
12+
13+
# Steps represent a sequence of tasks that will be executed as part of the job
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Install modules
19+
run: npm i
20+
21+
- name: Build project
22+
run: npm run build
23+
24+
# when lint error will be fixed - add step with lint as well
25+
26+
- name: Run unit tests
27+
run: npm run test:cover
28+
29+
- name: SonarQube Scan
30+
uses: sonarsource/sonarqube-scan-action@master
31+
env:
32+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
33+
SONAR_HOST_URL: https://sonarcloud.io

.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
@@ -9,22 +9,38 @@ Back-end part: https://github.com/ita-social-projects/StreetCode.git.
99

1010
## Table of Contents
1111

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

2945
---
3046

@@ -51,6 +67,29 @@ To setup this project use this command in project folder:
5167
npm install
5268
```
5369

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

__mocks__/@stores/root-store.tsx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
export const mockID = 1;
22
export const mockIsOpen = true;
33
export const mockSetModal = jest.fn();
4+
export const mockUpdateNews = jest.fn();
5+
export const mockCreateNews = jest.fn();
46

5-
export const useModalContext = () => {
6-
return {
7-
modalStore: {
8-
setModal: mockSetModal,
9-
modalsState: {
10-
deleteStreetcode: {
11-
isOpen: mockIsOpen,
12-
fromCardId: mockID,
13-
},
14-
}
15-
}
16-
}
17-
}
7+
export const useModalContext = () => ({
8+
modalStore: {
9+
setModal: mockSetModal,
10+
modalsState: {
11+
deleteStreetcode: {
12+
isOpen: mockIsOpen,
13+
fromCardId: mockID,
14+
},
15+
},
16+
},
17+
});
18+
19+
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+
},
33+
});
34+
35+
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+
};

0 commit comments

Comments
 (0)