From b7cc1eb251ea29735cae44c38bde3478b935362f Mon Sep 17 00:00:00 2001 From: merlin Date: Wed, 28 Dec 2022 01:19:19 +0300 Subject: [PATCH] #81 fix: jest,repo,ci> fix troubles with enums + change CI services after changed Owners of repo --- .github/workflows/review.yml | 4 +- README.md | 11 ++-- docs/index.md | 6 --- docs/react/jest.md | 24 ++++----- package.json | 20 +------ sonar-project.properties | 6 +-- src/index.tsx | 2 +- src/lib/editableGrid/Cell.tsx | 1 + src/lib/editableGrid/EditableGrid.tsx | 1 + src/lib/editableGrid/Header.tsx | 2 + src/lib/editableGrid/Table.tsx | 3 ++ ...typesEditableGrid.d.ts => EditableGrid.ts} | 21 ++++---- .../types/{typesHeader.d.ts => Header.ts} | 11 ++-- src/lib/editableGrid/types/Table.ts | 30 +++++++++++ .../types/{typesTable.d.ts => index.d.ts} | 54 +++++++------------ src/lib/editableGrid/types/typesCell.d.ts | 8 --- src/lib/editableGrid/utils.ts | 2 + src/plugins/counter/Counter.tsx | 2 +- src/plugins/counter/counterSlice.ts | 2 +- src/setupTests.ts | 3 -- 20 files changed, 101 insertions(+), 112 deletions(-) rename src/lib/editableGrid/types/{typesEditableGrid.d.ts => EditableGrid.ts} (66%) rename src/lib/editableGrid/types/{typesHeader.d.ts => Header.ts} (52%) create mode 100644 src/lib/editableGrid/types/Table.ts rename src/lib/editableGrid/types/{typesTable.d.ts => index.d.ts} (64%) delete mode 100644 src/lib/editableGrid/types/typesCell.d.ts diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index 3215809..d8e18ed 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -60,8 +60,8 @@ jobs: with: # Additional arguments for the sonarcloud scanner args: - -Dsonar.projectKey=dm-rybalchenko_excel-app - -Dsonar.organization=dm-rybalchenko + -Dsonar.projectKey=cybermerlin_family-budget + -Dsonar.organization=cybermerlin finish: needs: review diff --git a/README.md b/README.md index bd5068b..7216fdc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Develop health](https://github.com/dm-rybalchenko/family_budget/actions/workflows/review.yml/badge.svg?branch=develop)](https://github.com/dm-rybalchenko/family_budget/actions/workflows/review.yml) -[![Coverage Status](https://coveralls.io/repos/github/dm-rybalchenko/family_budget/badge.svg?branch=develop)](https://coveralls.io/github/dm-rybalchenko/family_budget?branch=develop) +[![Develop health](https://github.com/cybermerlin/family_budget/actions/workflows/review.yml/badge.svg?branch=develop)](https://github.com/cybermerlin/family_budget/actions/workflows/review.yml) +[![Coverage Status](https://coveralls.io/repos/github/cybermerlin/family_budget/badge.svg?branch=develop)](https://coveralls.io/github/cybermerlin/family_budget?branch=develop) [![Visit docs](https://img.shields.io/badge/docs-visit%20site-orange)](https://formidable.com/open-source/family_budget/wiki/) -[GitHub Discussions: Chat With Us](https://github.com/dm-rybalchenko/family_budget/discussions) +[GitHub Discussions: Chat With Us](https://github.com/cybermerlin/family_budget/discussions) [![License: GPL](https://img.shields.io/badge/License-GPL-yellow.svg)](LICENSE) # Family Budget @@ -65,8 +65,8 @@ Run only the necessary commands. - Make Fork repository from GitHub (copy all branches). - Used to target an existing repository and create a clone, or copy of the target repository. - - source of code ```git clone https://github.com/dm-rybalchenko/family_budget``` - - source of **Wiki** ```git clone https://github.com/dm-rybalchenko/family_budget.wiki.git``` + - source of code ```git clone https://github.com/cybermerlin/family_budget``` + - source of **Wiki** ```git clone https://github.com/cybermerlin/family_budget.wiki.git``` - Go to the project folder. ```cd ./family_budget``` @@ -85,4 +85,3 @@ And then open the browser and enter the address that the system will write in th ## [Documentaions](docs/index.md) -*look\click at the link of this header.* diff --git a/docs/index.md b/docs/index.md index e8c6601..1047b2e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,14 +1,11 @@ ### [Learn More](react/more.md) -*click by header.* #### [React](react/index.md) -*click by header.* ### [Components](react/components.md) -*click by header.* ### TypeScript Definitions @@ -31,14 +28,11 @@ file: ### [GraphQL](GraphQL/index.md) -*click by header.* ### Infrastructure #### [DevOps](infrastructure/DevOps.md) -*click by header.* #### [NodeJS](nodejs/index.md) -*click by header.* diff --git a/docs/react/jest.md b/docs/react/jest.md index 52ebcb7..8fcda09 100644 --- a/docs/react/jest.md +++ b/docs/react/jest.md @@ -5,7 +5,6 @@ - [React Testing Library Cheatsheet](https://testing-library.com/docs/react-testing-library/cheatsheet) - [Jest DOM matchers cheatsheet](https://github.com/testing-library/jest-dom) - ##### Debugging 1. Open in the Chrome browser: [Inspector](chrome://inspect/#devices) @@ -26,20 +25,19 @@ "testEnvironment": "jsdom", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": [ - "js", - "ts", - "jsx", - "tsx", - "json", - "node", - "web.js", - "web.ts", - "web.tsx", - "web.jsx" + "js", + "ts", + "jsx", + "tsx", + "json", + "node", + "web.js", + "web.ts", + "web.tsx", + "web.jsx" ], "setupFilesAfterEnv": [ - "/src/setupTests.ts" + "/src/setupTests.ts" ] } ``` - diff --git a/package.json b/package.json index 10bcf70..72259b5 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "prod": "CI=false && react-scripts build", "start": "react-scripts start", "storybook": "start-storybook -p 6006 -s public", - "test": "react-scripts test", + "test": "react-scripts test --bail", "test-dbg": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand", "test-zero": "node ./node_modules/jest/bin/jest.js" }, @@ -162,24 +162,6 @@ "transformIgnorePatterns": [ "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$", "^.+\\.module\\.(css|sass|scss)$" - ], - "bail": true, - "testEnvironment": "jsdom", - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", - "moduleFileExtensions": [ - "js", - "ts", - "jsx", - "tsx", - "json", - "node", - "web.js", - "web.ts", - "web.tsx", - "web.jsx" - ], - "setupFilesAfterEnv": [ - "/src/setupTests.ts" ] } } diff --git a/sonar-project.properties b/sonar-project.properties index 90e06b2..45d3cff 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,8 +1,8 @@ -sonar.projectKey=dm-rybalchenko_excel-app -sonar.organization=dm-rybalchenko +sonar.projectKey=cybermerlin_family_budget +sonar.organization=cybermerlin # This is the name and version displayed in the SonarCloud UI. -sonar.projectName=excel-app +sonar.projectName=family_budget sonar.projectVersion=0.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. diff --git a/src/index.tsx b/src/index.tsx index 3f04816..b6186ea 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -import { ApolloClient, ApolloProvider, HttpLink, InMemoryCache } from '@apollo/client'; +import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; import React from 'react'; import ReactDOM from 'react-dom/client'; import { Provider } from 'react-redux'; diff --git a/src/lib/editableGrid/Cell.tsx b/src/lib/editableGrid/Cell.tsx index 6ba211e..fc43e56 100644 --- a/src/lib/editableGrid/Cell.tsx +++ b/src/lib/editableGrid/Cell.tsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import ContentEditable from 'react-contenteditable'; import { createPortal } from 'react-dom'; import { usePopper } from 'react-popper'; +import { EActionTypes, EDataTypes, TCellProps } from 'src/lib/editableGrid/types/EditableGrid'; import { findFormula } from 'src/plugins/math/pureMath/handlersCountCellsData'; import Badge from './Badge'; import { gray } from './colors'; diff --git a/src/lib/editableGrid/EditableGrid.tsx b/src/lib/editableGrid/EditableGrid.tsx index af4c084..39f1536 100644 --- a/src/lib/editableGrid/EditableGrid.tsx +++ b/src/lib/editableGrid/EditableGrid.tsx @@ -3,6 +3,7 @@ import { useEffect, useReducer } from 'react'; import './style.scss'; import Table from './Table'; +import { EActionTypes, EDataTypes, TAction } from './types/EditableGrid'; import { makeData, randomColor, shortId } from './utils'; diff --git a/src/lib/editableGrid/Header.tsx b/src/lib/editableGrid/Header.tsx index 68e1302..0fe682f 100644 --- a/src/lib/editableGrid/Header.tsx +++ b/src/lib/editableGrid/Header.tsx @@ -1,6 +1,8 @@ import { useEffect, useState } from 'react'; import { usePopper } from 'react-popper'; +import { EActionTypes, EDataTypes } from 'src/lib/editableGrid/types/EditableGrid'; +import { THeaderProps } from 'src/lib/editableGrid/types/Header'; import { gray } from './colors'; import ArrowDownIcon from './img/ArrowDown'; import ArrowLeftIcon from './img/ArrowLeft'; diff --git a/src/lib/editableGrid/Table.tsx b/src/lib/editableGrid/Table.tsx index 5e6de7a..da2c9e3 100644 --- a/src/lib/editableGrid/Table.tsx +++ b/src/lib/editableGrid/Table.tsx @@ -2,7 +2,9 @@ import clsx from 'clsx'; import { useCallback, useMemo } from 'react'; import { useBlockLayout, useResizeColumns, useSortBy, useTable } from 'react-table'; import { FixedSizeList } from 'react-window'; +import { EActionTypes } from 'src/lib/editableGrid/types/EditableGrid'; +import { TRowCells, TTableProps } from './types/Table'; import Cell from './Cell'; import Header from './Header'; import PlusIcon from './img/Plus'; @@ -22,6 +24,7 @@ let defaultColumn = { * This variable is used to count and assign row id's */ let idRow = 0; + export default function Table({ columns, data, diff --git a/src/lib/editableGrid/types/typesEditableGrid.d.ts b/src/lib/editableGrid/types/EditableGrid.ts similarity index 66% rename from src/lib/editableGrid/types/typesEditableGrid.d.ts rename to src/lib/editableGrid/types/EditableGrid.ts index 6832a87..87069db 100644 --- a/src/lib/editableGrid/types/typesEditableGrid.d.ts +++ b/src/lib/editableGrid/types/EditableGrid.ts @@ -1,10 +1,4 @@ -declare type TState = { - columns: any[]; - data: any[]; - skipReset: boolean; -} - -declare type TAction = { +export type TAction = { type: EActionTypes; value?: string; columnId?: string; @@ -17,9 +11,9 @@ declare type TAction = { } /** - * For actions for the EditableGrid + * For actions for the EditableGrid column's header */ -declare enum EActionTypes { +export enum EActionTypes { ADD_OPTION_TO_COLUMN = 'add_option_to_column', ADD_ROW = 'add_row', UPDATE_COLUMN_TYPE = 'update_column_type', @@ -31,9 +25,16 @@ declare enum EActionTypes { ENABLE_RESET = 'enable_reset' } -declare enum EDataTypes { +export enum EDataTypes { NUMBER = 'number', TEXT = 'text', SELECT = 'select', UNDEFINED = 'null' } + +export type TCellProps = { + value: string; + row: { index: number }; + column: { id: string, dataType: EDataTypes, options: TOptionsColumn[] }; + dataDispatch: (arg: { [key: string]: any }) => void; +}; diff --git a/src/lib/editableGrid/types/typesHeader.d.ts b/src/lib/editableGrid/types/Header.ts similarity index 52% rename from src/lib/editableGrid/types/typesHeader.d.ts rename to src/lib/editableGrid/types/Header.ts index 58cf899..64b1aef 100644 --- a/src/lib/editableGrid/types/typesHeader.d.ts +++ b/src/lib/editableGrid/types/Header.ts @@ -1,11 +1,13 @@ -export {}; +import { EDataTypes } from "./EditableGrid"; -declare type THeaderProps = { + +export declare type THeaderProps = { column: THeaderColumn; setSortBy: (arg: any[]) => void; - dataDispatch: (arg: { [key: EDataTypes]: any }) => void; + dataDispatch: (arg: Record) => void; } -declare type THeaderColumn = { + +export declare type THeaderColumn = { id: string; created?: boolean; label: string; @@ -13,4 +15,3 @@ declare type THeaderColumn = { getResizerProps: () => any[]; getHeaderProps: () => any[]; } -declare type TButtonEvent = React.MouseEvent; diff --git a/src/lib/editableGrid/types/Table.ts b/src/lib/editableGrid/types/Table.ts new file mode 100644 index 0000000..e23bbfd --- /dev/null +++ b/src/lib/editableGrid/types/Table.ts @@ -0,0 +1,30 @@ +import { EDataTypes } from './EditableGrid'; + + +export type TColumn = { + id: string; + label: string; + accessor?: string; + dataType: EDataTypes; + options?: TOptionsColumn[]; + width?: number; + maxWidth?: number; + minWidth?: number; + disableResizing?: boolean; + isResizing?: boolean; +} + +export declare type TRowCells = { + column: TColumn[]; + row: TRow[]; + value?: string | number; + getCellProps: () => { [key: string]: any }; + render: (type?: string, props?: { [key: string]: any }) => any; +} + +export declare type TTableProps = { + columns: TColumn[]; + data: any[]; + skipReset: boolean; + dispatch: (arg?: Record) => void; +} diff --git a/src/lib/editableGrid/types/typesTable.d.ts b/src/lib/editableGrid/types/index.d.ts similarity index 64% rename from src/lib/editableGrid/types/typesTable.d.ts rename to src/lib/editableGrid/types/index.d.ts index 5b5c01f..3bf7ccb 100644 --- a/src/lib/editableGrid/types/typesTable.d.ts +++ b/src/lib/editableGrid/types/index.d.ts @@ -1,32 +1,13 @@ -declare type TTableProps = { - columns: TColumn[]; +declare type TButtonEvent = React.MouseEvent; + +declare type TState = { + columns: any[]; data: any[]; skipReset: boolean; - dispatch: (arg?: { [key: string]: any }) => void; -} -declare type TRenderRowProps = { - index: number, - style: { - heigth: number, - left: number, - right?: number, - position: string, - top: number, - width: string, - } -} -declare type TColumn = { - id: string; - label: string; - accessor?: string; - dataType: EDataTypes; - options?: TOptionsColumn[]; - width?: number; - maxWidth?: number; - minWidth?: number; - disableResizing?: boolean; - isResizing?: boolean; } + +declare type TOptionsColumn = { label: string, backgroundColor: string } + declare type TRow = { allCells: TRowCells[]; cells: TRowCells[]; @@ -39,13 +20,6 @@ declare type TRow = { subRows: any[]; values?: string | number; } -declare type TRowCells = { - column: TColumn[]; - row: TRow[]; - value?: string | number; - getCellProps: () => { [key: string]: any }; - render: (type?: string, props?: { [key: string]: any }) => any; -} declare type TRowOriginal = { ID: number; age: number; @@ -65,5 +39,17 @@ declare type TUseTableProps = { declare type THeaderGroups = { getFooterGroupProps: (props?: { [key: string]: any }) => any; getHeaderGroupProps: (props?: { [key: string]: any }) => any; - headers: { [key: string]: any }[]; + headers: Record[]; +} + +declare type TRenderRowProps = { + index: number, + style: { + heigth: number, + left: number, + right?: number, + position: string, + top: number, + width: string, + } } diff --git a/src/lib/editableGrid/types/typesCell.d.ts b/src/lib/editableGrid/types/typesCell.d.ts deleted file mode 100644 index b0901ae..0000000 --- a/src/lib/editableGrid/types/typesCell.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare type TCellProps = { - value: string; - row: { index: number }; - column: { id: string, dataType: EDataTypes, options: TOptionsColumn[] }; - dataDispatch: (arg: { [key: string]: any }) => void; -} - -declare type TOptionsColumn = { label: string, backgroundColor: string } diff --git a/src/lib/editableGrid/utils.ts b/src/lib/editableGrid/utils.ts index 781f2cf..72d937c 100644 --- a/src/lib/editableGrid/utils.ts +++ b/src/lib/editableGrid/utils.ts @@ -1,4 +1,6 @@ import { faker } from '@faker-js/faker/locale/ru'; +import { EDataTypes } from 'src/lib/editableGrid/types/EditableGrid'; +import { TColumn } from 'src/lib/editableGrid/types/Table'; //#region StringOfLength type StringOfLength = string & { diff --git a/src/plugins/counter/Counter.tsx b/src/plugins/counter/Counter.tsx index 3f1ff9d..af0cce2 100644 --- a/src/plugins/counter/Counter.tsx +++ b/src/plugins/counter/Counter.tsx @@ -1,7 +1,7 @@ import { Button } from 'antd'; import React, { useState } from 'react'; -import { useAppDispatch, useAppSelector } from '../../app/hooks'; +import { useAppDispatch, useAppSelector } from 'src/app/hooks'; import styles from './Counter.module.scss'; import { decrement, increment, incrementAsync, incrementByAmount, incrementIfOdd, selectCount } from './counterSlice'; diff --git a/src/plugins/counter/counterSlice.ts b/src/plugins/counter/counterSlice.ts index e8c533d..a986be2 100644 --- a/src/plugins/counter/counterSlice.ts +++ b/src/plugins/counter/counterSlice.ts @@ -1,6 +1,6 @@ import { createAsyncThunk, createSlice, PayloadAction } from '@reduxjs/toolkit'; -import { AppThunk, RootState } from '../../app/store'; +import { AppThunk, RootState } from 'src/app/store'; import { fetchCount } from './counterAPI'; diff --git a/src/setupTests.ts b/src/setupTests.ts index 2ac35d8..16aad80 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -17,6 +17,3 @@ window.crypto = { } } as Crypto; globalThis.window = window; -debugger; -console.log(EDataTypes.UNDEFINED); -// https://github.com/kulshekhar/ts-jest/discussions/3936