Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,33 @@ jobs:
echo "host=${HOST}" >> "$GITHUB_OUTPUT"
echo "namespace=${NAMESPACE}" >> "$GITHUB_OUTPUT"

build:
test:
runs-on: self-hosted
needs: setup-env
timeout-minutes: 5
steps:
- name: Actions checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run tests
run: yarn test
env:
NODE_OPTIONS: "--max-old-space-size=2048"

build:
runs-on: self-hosted
needs: [setup-env, test]
steps:
- name: Docker build & push
run: |
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,33 @@ jobs:
echo "namespace=${NAMESPACE}" >> "$GITHUB_OUTPUT"
echo "image_tag=${IMAGE_TAG}" >> "$GITHUB_OUTPUT"

build:
test:
runs-on: self-hosted
needs: setup-env
timeout-minutes: 5
steps:
- name: Actions checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install Yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run tests
run: yarn test
env:
NODE_OPTIONS: "--max-old-space-size=2048"

build:
runs-on: self-hosted
needs: [setup-env, test]
steps:
- name: Docker build & push
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ node_modules

.DS_Store

docker-compose.yml
docker-compose.yml

coverage
15 changes: 14 additions & 1 deletion apps/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"dev:localserver:host": "VITE_API_URL=https://localhost:8000/api vite --host",
"build": "tsc -b && vite build",
"preview": "yarn build && vite preview",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"eslint": "eslint \"**/*.js\" \"src/**/*.{ts,tsx}\" --max-warnings 0",
"eslint:fix": "eslint --fix \"**/*.js\" \"src/**/*.{ts,tsx}\"",
"stylelint": "stylelint \"src/**/*.scss\" --max-warnings 0",
Expand Down Expand Up @@ -60,24 +63,34 @@
"devDependencies": {
"@repo/eslint-config": "*",
"@repo/models": "*",
"@repo/react-testing-library-config": "*",
"@repo/stores": "*",
"@repo/stylelint-config": "*",
"@repo/types": "*",
"@repo/typescript-config": "*",
"@repo/ui": "*",
"@repo/utils": "*",
"@repo/vitest-config": "*",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^24.0.0",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.4.1",
"@vitest/coverage-v8": "^2.1.8",
"autoprefixer": "^10.4.13",
"eslint": "^9.29.0",
"jsdom": "^25.0.1",
"postcss": "^8.5.5",
"prettier": "^3.5.3",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"stylelint": "^16.20.0",
"terser": "^5.43.1",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vite-plugin-compression2": "^2.2.0"
"vite-plugin-compression2": "^2.2.0",
"vitest": "^2.1.8"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Sheet } from '@gravity-ui/uikit';
import { EventFormFieldValues } from '@repo/types/calendar';
import { CalendarEventForm } from '@repo/ui';
import { dateToNextNearestHalfHour, gravityDateToTemporal, temporalToGravityDate } from '@repo/utils';
import { getDefaultEndTime, gravityDateToTemporal, temporalToGravityDate } from '@repo/utils';
import { observer } from 'mobx-react-lite';
import { useCallback, useMemo } from 'react';

Expand All @@ -20,10 +20,8 @@ const CreateEventSheet: React.FC = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [createEvent.openState.isOpen]);

const nearestStartDateTime = dateToNextNearestHalfHour(selectedDateNowTime);

const startDate = temporalToGravityDate(selectedDateNowTime);
const endDate = temporalToGravityDate(nearestStartDateTime.add({ hours: 1 }));
const endDate = temporalToGravityDate(getDefaultEndTime(selectedDateNowTime));

const onSubmit = useCallback(
async (data: EventFormFieldValues) => {
Expand Down
7 changes: 7 additions & 0 deletions apps/core/src/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, it, expect } from 'vitest';

describe('Core App test', () => {
it('should work', () => {
expect(true).toBe(true);
});
});
3 changes: 2 additions & 1 deletion apps/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"include": [
"src/**/*",
"vite.config.ts"
"vite.config.ts",
"vitest.config.ts"
]
}
24 changes: 24 additions & 0 deletions apps/core/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// <reference types="vitest" />
import { resolve } from 'path';

import { createReactVitestConfig } from '@repo/vitest-config';
import react from '@vitejs/plugin-react';

export default createReactVitestConfig(
{
plugins: [react()],
},
{
'@': resolve(__dirname, './src'),
'@repo/ui': resolve(__dirname, '../../packages/ui/src'),
'@repo/ui/*': resolve(__dirname, '../../packages/ui/src/*'),
'@repo/utils': resolve(__dirname, '../../packages/utils/src'),
'@repo/utils/*': resolve(__dirname, '../../packages/utils/src/*'),
'@repo/models': resolve(__dirname, '../../packages/models/src'),
'@repo/models/*': resolve(__dirname, '../../packages/models/src/*'),
'@repo/stores': resolve(__dirname, '../../packages/stores/src'),
'@repo/stores/*': resolve(__dirname, '../../packages/stores/src/*'),
'@repo/types': resolve(__dirname, '../../packages/types/src'),
'@repo/types/*': resolve(__dirname, '../../packages/types/src/*'),
},
);
6 changes: 6 additions & 0 deletions config/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,10 @@ export default [
'prettier/prettier': 'error',
},
},
{
files: ['**/*.test.tsx', '**/*.spec.tsx', '**/*.test.jsx', '**/*.spec.jsx'],
rules: {
'react/no-multi-comp': 'off',
},
},
];
36 changes: 36 additions & 0 deletions config/react-testing-library-config/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { render, RenderOptions } from '@testing-library/react';
import { ReactElement, ReactNode } from 'react';

export interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
theme?: 'light' | 'dark';
locale?: string;
}

export function customRender(
ui: ReactElement,
options: CustomRenderOptions = {}
) {
const {
theme = 'light',
locale = 'ru',
...renderOptions
} = options;

const AllTheProviders = ({ children }: { children: ReactNode }) => {
return (
<div data-theme={theme} data-locale={locale}>
{children}
</div>
);
};

return render(ui, {
wrapper: AllTheProviders,
...renderOptions,
});
}

export { customRender as render };

export * from '@testing-library/react';
export { userEvent } from '@testing-library/user-event';
28 changes: 28 additions & 0 deletions config/react-testing-library-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@repo/react-testing-library-config",
"description": "DateData React Testing Library configuration and utilities",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"engines": {
"node": ">=22.0.0"
},
"main": "index.tsx",
"devDependencies": {
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"typescript": "^5.8.3"
},
"peerDependencies": {
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"react": "^19.1.0",
"react-dom": "^19.1.0"
}
}
102 changes: 102 additions & 0 deletions config/vitest-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { defineConfig } from 'vitest/config';
import { resolve } from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = resolve(__filename, '..');

export const baseConfig = {
test: {
globals: true,
setupFiles: [resolve(__dirname, './setup.ts')],
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/cypress/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*'
],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**/*.{js,cjs,mjs,ts,mts,cts,jsx,tsx}'],
exclude: [
'coverage/**',
'dist/**',
'**/*.d.ts',
'cypress/**',
'test{,s}/**',
'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}',
'**/__tests__/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'**/eslint.config.{js,ts,cjs,mjs}',
'**/.{eslint,mocha,prettier}rc.{js,cjs,yml,yaml,json}',
'**/.stylelintrc.{js,cjs,yml,yaml,json}',
'**/stylelint.config.{js,ts,cjs,mjs}',
'**/postcss.config.{js,ts,cjs,mjs}',
'**/tailwind.config.{js,ts,cjs,mjs}',
'**/*.{stories,story}.{js,cjs,mjs,ts,tsx,jsx}',
'**/.storybook/**',
'**/index.{js,cjs,mjs,ts,tsx,jsx}'
]
}
}
};

export const reactConfig = {
...baseConfig,
test: {
...baseConfig.test,
environment: 'jsdom',
setupFiles: [resolve(__dirname, './setup-react.ts')]
}
};

export const nodeConfig = {
...baseConfig,
test: {
...baseConfig.test,
environment: 'node'
}
};

export function createVitestConfig(config = {}, aliases = {}) {
return defineConfig({
...config,
...baseConfig,
resolve: {
alias: {
...aliases
}
}
});
}

export function createReactVitestConfig(config = {}, aliases = {}) {
return defineConfig({
...config,
...reactConfig,
resolve: {
alias: {
...aliases
}
}
});
}

export function createNodeVitestConfig(config = {}, aliases = {}) {
return defineConfig({
...config,
...nodeConfig,
resolve: {
alias: {
...aliases
}
}
});
}

export default baseConfig;
22 changes: 22 additions & 0 deletions config/vitest-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@repo/vitest-config",
"description": "DateData Vitest configuration",
"version": "0.0.0",
"license": "MIT",
"type": "module",
"engines": {
"node": ">=22.0.0"
},
"main": "index.js",
"devDependencies": {
"@repo/react-testing-library-config": "*",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@vitejs/plugin-react": "^4.4.1",
"jsdom": "^25.0.1",
"vite": "^6.3.5",
"vitest": "^2.1.8"
}
}
Loading