Skip to content

Commit 24f4cd9

Browse files
committed
Merge branch 'develop' of https://github.com/ita-social-projects/StreetCode_Client into develop
2 parents 7f04adc + 82157c9 commit 24f4cd9

14 files changed

Lines changed: 580 additions & 318 deletions

File tree

__mocks__/@stores/root-store.tsx

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,32 @@ export const mockSetModal = jest.fn();
44
export const mockUpdateNews = jest.fn();
55
export const mockCreateNews = jest.fn();
66

7-
export const useModalContext = () => {
8-
return {
9-
modalStore: {
10-
setModal: mockSetModal,
11-
modalsState: {
12-
deleteStreetcode: {
13-
isOpen: mockIsOpen,
14-
fromCardId: mockID,
15-
},
16-
}
17-
}
18-
}
19-
}
7+
export const useModalContext = () => ({
8+
modalStore: {
9+
setModal: mockSetModal,
10+
modalsState: {
11+
deleteStreetcode: {
12+
isOpen: mockIsOpen,
13+
fromCardId: mockID,
14+
},
15+
},
16+
},
17+
});
2018

2119
export const useMobx = () => ({
22-
newsStore: {
23-
updateNews: mockUpdateNews,
24-
createNews: mockCreateNews,
25-
getNewsArray: [
26-
{
27-
id: 1,
28-
title: 'title',
29-
text: 'text',
30-
url: 'url',
31-
creationDate: '2024-01-29',
32-
},
33-
],
34-
},
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+
},
3533
});
3634

37-
export default useMobx;
35+
export default useMobx;

__mocks__/antd/Modal.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

__mocks__/antd/es/date/dayjs.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const WEEKDAY_SHORTS = ['Нд', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'];
2+
const MONTH_SHORTS = ['Січ', 'Лют', 'Бер', 'Кві', 'Тра', 'Чер', 'Лип', 'Сер', 'Вер', 'Жов', 'Лис', 'Гру'];
3+
4+
const DAY_JS_UK_LOCALE = {
5+
WEEKDAY_SHORTS,
6+
MONTH_SHORTS
7+
}
8+
9+
export default DAY_JS_UK_LOCALE;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React, { ReactNode } from "react";
2+
import dayjs from "dayjs";
3+
import "dayjs/locale/uk";
4+
const dayJsUa = require("dayjs/locale/uk");
5+
6+
interface MockLocaleProviderProps {
7+
children: ReactNode;
8+
}
9+
10+
interface LangData {
11+
shortWeekDays: string[];
12+
shortMonths: string[];
13+
}
14+
15+
const MockLocaleProvider: React.FC<MockLocaleProviderProps> & {
16+
lang: LangData;
17+
} = ({ children }) => {
18+
dayjs.locale("uk");
19+
20+
Object.assign(MockLocaleProvider.lang, {
21+
shortWeekDays: dayJsUa.weekdaysShort(),
22+
shortMonths: dayJsUa.monthsShort(),
23+
});
24+
25+
return (
26+
<>
27+
<input type="date" name="creation-date"/>
28+
{children}
29+
</>
30+
);
31+
};
32+
33+
MockLocaleProvider.lang = {
34+
shortWeekDays: [],
35+
shortMonths: [],
36+
};
37+
38+
export default MockLocaleProvider;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, { useState } from "react";
2+
3+
interface UploadMockProps {
4+
onChange: (fileList: File | null) => void;
5+
}
6+
7+
const UploadMock: React.FC<UploadMockProps> = ({ onChange }) => {
8+
const [selectedFile, setSelectedFile] = useState<File | null>(null);
9+
10+
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
11+
const file = event.target.files && event.target.files[0];
12+
setSelectedFile(file || null);
13+
if(!selectedFile===null) onChange(selectedFile);
14+
};
15+
16+
return (
17+
<div>
18+
<input type="file" data-testid="file-input" onChange={handleFileChange} />
19+
</div>
20+
);
21+
};
22+
23+
export default UploadMock;

__mocks__/fileMock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const mockedSvg = 'test-file-stub';
2+
export default mockedSvg;

docker-compose.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ services:
6666
STREETCODE_Payment__Token: ${PAYMENT_TOKEN}
6767
STREETCODE_EMAILCONFIGURATION__PASSWORD: ${EMAIL_PASSWORD}
6868
STREETCODE_RECAPTCHA__SECRETKEY: ${RECAPTCHA_SECRET_KEY}
69-
STREETCODE_CORS__AllowedOrigins: '["*"]'
70-
STREETCODE_CORS__AllowedHeaders: '["*"]'
71-
STREETCODE_CORS__AllowedMethods: '["*"]'
72-
STREETCODE_CORS__PreflightMaxAge: 1
69+
STREETCODE_CORS__AllowedOrigins: ${CORS_ALLOWED_ORIGINS}
70+
STREETCODE_CORS__AllowedHeaders: ${CORS_ALLOWED_HEADERS}
71+
STREETCODE_CORS__AllowedMethods: ${CORS_ALLOWED_METHODS}
72+
STREETCODE_CORS__ExposedHeaders: ${CORS_EXPOSED_HEADERS}
73+
STREETCODE_CORS__PreflightMaxAge: "600"
7374
STREETCODE_IPRATELIMITING__GENERALRULES__0__LIMIT: 500
7475
ASPNETCORE_ENVIRONMENT: ${SWAGGER_APP_ENVIRONMENT}
7576
volumes:

jest.config.ts

Lines changed: 47 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,52 @@
1-
import type { JestConfigWithTsJest } from 'ts-jest';
1+
import type { JestConfigWithTsJest } from "ts-jest";
22

33
const jestConfig: JestConfigWithTsJest = {
4-
preset: 'ts-jest',
5-
testEnvironment: 'jsdom',
6-
roots: ['<rootDir>'],
7-
moduleNameMapper: {
8-
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
9-
'antd': '<rootDir>/__mocks__/antd/Modal',
10-
'^@assets/(.*)$': '<rootDir>/src/assets/$1',
11-
'^@/(.*)$': '<rootDir>/src/$1',
12-
'^@app/(.*)$': '<rootDir>/src/app/$1',
13-
'^@sass/(.*)$': '<rootDir>/src/assets/sass/$1',
14-
'^@images/(.*)$': '<rootDir>/src/assets/images/$1',
15-
'^@features/(.*)$': '<rootDir>/src/features/$1',
16-
'^@api/(.*)$': '<rootDir>/src/app/api/$1',
17-
'^@stores/(.*)$': '<rootDir>/src/app/stores/$1',
18-
'^@models/(.*)$': '<rootDir>/src/models/$1',
19-
'^@components/(.*)$': '<rootDir>/src/app/common/components/$1',
20-
'^@hooks/(.*)$': '<rootDir>/src/app/common/hooks/$1',
21-
'^@constants/(.*)$': '<rootDir>/src/app/common/constants/$1',
22-
'^@utils/(.*)$': '<rootDir>/src/app/common/utils/$1',
23-
// DEV_NOTE: Down below is the right solution for compiling files by path
24-
// But we need to fix ALL typo errors before it could be compiled
25-
// Temp solution - mocking modules.
26-
// After fixing type error remove mocks or continue using them(as more simple solution)
27-
/*
28-
'^@/(.*)$': '<rootDir>/src/$1',
29-
'^@app/(.*)$': '<rootDir>/src/app/$1',
30-
'^@sass/(.*)$': '<rootDir>/src/assets/sass/$1',
31-
'^@images/(.*)$': '<rootDir>/src/assets/images/$1',
32-
'^@features/(.*)$': '<rootDir>/src/features/$1',
33-
'^@api/(.*)$': '<rootDir>/src/app/api/$1',
34-
'^@stores/(.*)$': '<rootDir>/src/app/stores/$1',
35-
'^@models/(.*)$': '<rootDir>/src/models/$1',
36-
'^@components/(.*)$': '<rootDir>/src/app/common/components/$1',
37-
'^@hooks/(.*)$': '<rootDir>/src/app/common/hooks/$1',
38-
'^@constants/(.*)$': '<rootDir>/src/app/common/constants/$1',
39-
'^@utils/(.*)$': '<rootDir>/src/app/common/utils/$1',
40-
*/
4+
preset: "ts-jest",
5+
testEnvironment: "jsdom",
6+
roots: ["<rootDir>"],
7+
moduleNameMapper: {
8+
"\\.(css|less|sass|scss)$": "identity-obj-proxy",
9+
"^@assets/(.*)$": "<rootDir>/src/assets/$1",
10+
"^antd/es/upload$": "<rootDir>/__mocks__/antd/es/upload/upload.tsx",
11+
"^antd/es/date-picker/locale/uk_UA$": "<rootDir>/__mocks__/antd/es/date/localeprovider.tsx",
12+
"^antd/locale/(.*)$": "<rootDir>/node_modules/antd/locale/$1",
13+
"^antd/es/table$": "<rootDir>/node_modules/antd/es/table",
14+
"^@stores/root-store$": "<rootDir>/__mocks__/@stores/root-store.tsx",
15+
"^antd/(.*)$": "<rootDir>/node_modules/antd/es/$1",
16+
17+
"^@/(.*)$": "<rootDir>/src/$1",
18+
"^@app/(.*)$": "<rootDir>/src/app/$1",
19+
"^@sass/(.*)$": "<rootDir>/src/assets/sass/$1",
20+
"^@images/(.*)$": "<rootDir>/src/assets/images/$1",
21+
"^@features/(.*)$": "<rootDir>/src/features/$1",
22+
"^@api/(.*)$": "<rootDir>/src/app/api/$1",
23+
"^@stores/(.*)$": "<rootDir>/src/app/stores/$1",
24+
"^@models/(.*)$": "<rootDir>/src/models/$1",
25+
"^@components/(.*)$": "<rootDir>/src/app/common/components/$1",
26+
"^@hooks/(.*)$": "<rootDir>/src/app/common/hooks/$1",
27+
"^@constants/(.*)$": "<rootDir>/src/app/common/constants/$1",
28+
"^@utils/(.*)$": "<rootDir>/src/app/common/utils/$1",
29+
},
30+
verbose: true,
31+
collectCoverageFrom: [
32+
"src/**/*.{ts,js}", // temp disable coverage collection for tsx, jsx until type errors will be fixed
33+
],
34+
globals: {
35+
_env_: {
36+
API_URL: "https://mock_URL.com",
4137
},
42-
verbose: true,
43-
collectCoverageFrom: [
44-
"src/**/*.{ts,js}" // temp disable coverage collection for tsx, jsx until type errors will be fixed
45-
],
46-
globals: {
47-
_env_: {
48-
API_URL: 'https://mock_URL.com',
49-
}
38+
},
39+
transform: {
40+
"^.+\\.svg$": "jest-transformer-svg",
41+
},
42+
coverageThreshold: {
43+
global: {
44+
statements: 0.1,
45+
branches: 0.0,
46+
functions: 0.0,
47+
lines: 0.1,
5048
},
51-
transform: {
52-
"^.+\\.svg$": "jest-transformer-svg",
53-
},
54-
coverageThreshold: {
55-
global: {
56-
statements: 0.1,
57-
branches: 0.0,
58-
functions: 0.0,
59-
lines: 0.1,
60-
}
61-
},
62-
}
49+
},
50+
};
6351

64-
export default jestConfig
52+
export default jestConfig;

src/app/common/components/Editor/QEditor.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ const Editor: React.FC<EditorProps> = ({
107107
}
108108
};
109109

110-
const handleQuillRef = (el) => {
110+
const handleQuillRef = (el: ReactQuill | null) => {
111111
quillRef.current = el;
112112
if (qRef) {
113-
qRef.current = el;
113+
// qRef.current = el; temp commented
114114
}
115115
};
116116

0 commit comments

Comments
 (0)