switch to pnpm
This commit is contained in:
@@ -13,8 +13,18 @@ jobs:
|
||||
env:
|
||||
CI_JOB_NUMBER: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: andresz1/size-limit-action@v1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 7
|
||||
run_install: false
|
||||
|
||||
- name: Check bundle size
|
||||
uses: andresz1/size-limit-action@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
directory: frontend
|
||||
|
||||
@@ -22,22 +22,40 @@ jobs:
|
||||
node: [16.15.1]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- run: npm ci --loglevel warn
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 7
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
run: |
|
||||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --loglevel warn
|
||||
working-directory: ./frontend
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ github.workspace }}/frontend/node_modules/.cache
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: npm run check:translation
|
||||
- name: Run translations check
|
||||
run: pnpm run check:translation
|
||||
working-directory: ./frontend
|
||||
|
||||
check-typescript:
|
||||
@@ -47,22 +65,40 @@ jobs:
|
||||
node: [16.15.1]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- run: npm ci --loglevel warn
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 7
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
run: |
|
||||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --loglevel warn
|
||||
working-directory: ./frontend
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ github.workspace }}/frontend/node_modules/.cache
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: npm run check:types
|
||||
- name: Run type check
|
||||
run: pnpm run check:types
|
||||
working-directory: ./frontend
|
||||
|
||||
lint:
|
||||
@@ -72,15 +108,40 @@ jobs:
|
||||
node: [16.15.1]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- run: npm ci --loglevel warn
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 7
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
run: |
|
||||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --loglevel warn
|
||||
working-directory: ./frontend
|
||||
|
||||
- run: npm run lint
|
||||
- name: Run linters
|
||||
run: pnpm run lint
|
||||
working-directory: ./frontend
|
||||
|
||||
test:
|
||||
@@ -90,18 +151,43 @@ jobs:
|
||||
node: [16.15.1]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- run: npm ci --loglevel warn
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
id: pnpm-install
|
||||
with:
|
||||
version: 7
|
||||
run_install: false
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-cache
|
||||
run: |
|
||||
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm i --loglevel warn
|
||||
working-directory: ./frontend
|
||||
|
||||
- run: npm run test:coverage
|
||||
- name: Collect tests coverage
|
||||
run: pnpm run test --coverage
|
||||
working-directory: ./frontend
|
||||
|
||||
- name: submit coverage
|
||||
run: node ${{ github.workspace }}/frontend/node_modules/.bin/codecov
|
||||
- name: Submit coverage
|
||||
run: ${{ github.workspace }}/frontend/node_modules/.bin/codecov
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
+2
-2
@@ -45,9 +45,9 @@ RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \
|
||||
ADD frontend/package.json /srv/frontend/package.json
|
||||
ADD frontend/package-lock.json /srv/frontend/package-lock.json
|
||||
WORKDIR /srv/frontend
|
||||
RUN mkdir node_modules
|
||||
RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \
|
||||
CI=true npm ci --loglevel warn \
|
||||
npm i -g pnpm && \
|
||||
CI=true pnpm i --loglevel warn \
|
||||
else \
|
||||
echo "skip frontend build" \
|
||||
; fi
|
||||
|
||||
@@ -3,11 +3,15 @@ FROM node:16.15.1-alpine as build-frontend-deps
|
||||
ARG CI
|
||||
|
||||
ENV SKIP_FRONTEND_TEST=true
|
||||
ENV CI=true
|
||||
|
||||
RUN apk add --no-cache --update git
|
||||
ADD frontend/package.json /srv/frontend/package.json
|
||||
ADD frontend/package-lock.json /srv/frontend/package-lock.json
|
||||
RUN cd /srv/frontend && CI=true npm ci
|
||||
RUN
|
||||
cd /srv/frontend && \
|
||||
apk add --no-cache --update git && \
|
||||
npm i -g pnpm && \
|
||||
pnpm i
|
||||
|
||||
FROM node:16.15.1-alpine as build-frontend
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ describe('<Auth/>', () => {
|
||||
|
||||
it('should show validation error for token', async () => {
|
||||
StaticStore.config.auth_providers = ['email'];
|
||||
jest.spyOn(api, 'emailSignin').mockImplementationOnce(async () => null);
|
||||
const emailSignin = jest.spyOn(api, 'emailSignin').mockImplementationOnce(async () => null);
|
||||
|
||||
const { getByText, getByTitle, getByPlaceholderText } = render(<Auth />);
|
||||
|
||||
@@ -183,7 +183,7 @@ describe('<Auth/>', () => {
|
||||
target: { value: 'email@email.com' },
|
||||
});
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await waitFor(() => expect(api.emailSignin).toBeCalled());
|
||||
await waitFor(() => expect(emailSignin).toBeCalled());
|
||||
|
||||
expect(getByText('Back')).toHaveClass('auth-back-button');
|
||||
expect(getByTitle('Close sign-in dropdown')).toHaveClass('auth-close-button');
|
||||
|
||||
@@ -31,7 +31,7 @@ function setup(overrideProps: Partial<Props> = {}, overrideConfig: Partial<typeo
|
||||
id: '1',
|
||||
...overrideProps,
|
||||
} as Props;
|
||||
|
||||
// @ts-ignore
|
||||
const CommentFormWithIntl = () => <CommentForm {...props} intl={useIntl()} />;
|
||||
|
||||
return render(<CommentFormWithIntl />);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import { waitFor } from '@testing-library/preact';
|
||||
import { fireEvent } from '@testing-library/dom';
|
||||
import { waitFor, fireEvent } from '@testing-library/preact';
|
||||
|
||||
import { render } from 'tests/utils';
|
||||
import * as api from 'common/api';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import { fireEvent } from '@testing-library/preact';
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/preact';
|
||||
|
||||
import { render } from 'tests/utils';
|
||||
import { Select } from './select';
|
||||
@@ -14,32 +14,32 @@ const items = [
|
||||
|
||||
describe('<Select/>', () => {
|
||||
it('should has static class names', () => {
|
||||
const { container } = render(<Select items={items} selected={items[0]} />);
|
||||
const selectElement = container.querySelector('.select-element');
|
||||
|
||||
expect(container.querySelector('.select')).toBeInTheDocument();
|
||||
expect(container.querySelector('.select-arrow')).toBeInTheDocument();
|
||||
expect(selectElement).toBeInTheDocument();
|
||||
fireEvent.focus(selectElement as HTMLSelectElement);
|
||||
expect(container.querySelector('.select_focused')).toBeInTheDocument();
|
||||
render(<Select items={items} selected={items[0]} />);
|
||||
expect(screen.getByRole('combobox')).toHaveClass('select-element');
|
||||
expect(screen.getByTestId('select-root')).toHaveClass('select');
|
||||
expect(screen.getByTestId('select-arrow')).toHaveClass('select-arrow');
|
||||
});
|
||||
|
||||
it('should render selected item', () => {
|
||||
const { container, getAllByText } = render(<Select items={items} selected={items[0]} />);
|
||||
const selectedOption = container.querySelector('option');
|
||||
render(<Select items={items} selected={items[0]} />);
|
||||
|
||||
expect(getAllByText(items[0].label)).toHaveLength(2);
|
||||
const selectedItem = items[0];
|
||||
const selectedOption = screen.getAllByRole<HTMLOptionElement>('option')[0];
|
||||
|
||||
expect(screen.getAllByText(selectedItem.label)).toHaveLength(2);
|
||||
expect(selectedOption).toBeInTheDocument();
|
||||
expect(selectedOption?.selected).toBeTruthy();
|
||||
expect(selectedOption?.textContent).toBe(items[0].label);
|
||||
expect(selectedOption.selected).toBeTruthy();
|
||||
expect(selectedOption.textContent).toBe(selectedItem.label);
|
||||
});
|
||||
|
||||
it('should highlight select on focus', async () => {
|
||||
const { container } = render(<Select items={items} selected={items[0]} />);
|
||||
const select = container.querySelector('select');
|
||||
render(<Select items={items} selected={items[0]} />);
|
||||
|
||||
expect(container.querySelector('select')).toBeInTheDocument();
|
||||
fireEvent.focus(select as HTMLSelectElement);
|
||||
expect(container.querySelector('.rootFocused')).toBeInTheDocument();
|
||||
fireEvent.focus(screen.getByRole('combobox'));
|
||||
await waitFor(() => {
|
||||
const rootElement = screen.getByTestId('select-root');
|
||||
expect(rootElement).toHaveClass('select_focused');
|
||||
expect(rootElement).toHaveClass('rootFocused');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -31,6 +31,7 @@ export function Select({ items, selected, size = 'md', ...props }: Props) {
|
||||
|
||||
return (
|
||||
<span
|
||||
data-testid="select-root"
|
||||
className={clsx('select', styles.root, size && styles[size], {
|
||||
[styles.rootFocused]: focus,
|
||||
select_focused: focus,
|
||||
@@ -38,7 +39,7 @@ export function Select({ items, selected, size = 'md', ...props }: Props) {
|
||||
})}
|
||||
>
|
||||
{selectedItem.label}
|
||||
<ArrowIcon size={iconSize[size]} className={clsx('select-arrow', styles.arrow)} />
|
||||
<ArrowIcon data-testid="select-arrow" size={iconSize[size]} className={clsx('select-arrow', styles.arrow)} />
|
||||
<select
|
||||
{...props}
|
||||
onFocus={() => setFocus(true)}
|
||||
|
||||
@@ -23,13 +23,11 @@ const config: Config = {
|
||||
},
|
||||
],
|
||||
},
|
||||
transformIgnorePatterns: ['node_modules/(?!(@testing-library/preact|preact|@github|lodash-es))'],
|
||||
transformIgnorePatterns: ['node_modules/.pnpm/(?!(@testing-library|preact|@github|lodash-es))'],
|
||||
moduleDirectories: ['node_modules', 'app'],
|
||||
moduleNameMapper: {
|
||||
'\\.css': 'identity-obj-proxy',
|
||||
'\\.svg': '<rootDir>/app/__stubs__/svg.tsx',
|
||||
'^react$': 'preact/compat',
|
||||
'^react-dom$': 'preact/compat',
|
||||
},
|
||||
setupFiles: ['<rootDir>/jest.setup.ts'],
|
||||
setupFilesAfterEnv: [
|
||||
|
||||
Generated
-31443
File diff suppressed because it is too large
Load Diff
+10
-2
@@ -35,13 +35,18 @@
|
||||
"intersection-observer": "^0.12.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"node-emoji": "^1.11.0",
|
||||
"preact": "^10.6.2",
|
||||
"preact": "10.6.2",
|
||||
"react": "npm:@preact/compat@^17.1.1",
|
||||
"react-dom": "npm:@preact/compat@^17.1.1",
|
||||
"react-intl": "^6.0.4",
|
||||
"react-redux": "^8.0.2",
|
||||
"redux": "^4.2.0",
|
||||
"redux-thunk": "^2.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/plugin-syntax-flow": "^7.18.6",
|
||||
"@babel/plugin-transform-react-jsx": "^7.18.6",
|
||||
"@babel/preset-env": "^7.18.6",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
"@formatjs/cli": "^5.0.2",
|
||||
@@ -49,6 +54,7 @@
|
||||
"@prefresh/babel-plugin": "^0.4.3",
|
||||
"@prefresh/webpack": "^3.3.4",
|
||||
"@size-limit/preset-app": "^7.0.8",
|
||||
"@swc/core": "1.2.205",
|
||||
"@swc/jest": "^0.2.21",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/preact": "^3.2.2",
|
||||
@@ -56,16 +62,18 @@
|
||||
"@types/eslint": "^8.4.5",
|
||||
"@types/jest": "^28.1.4",
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"@types/node": "^18.0.1",
|
||||
"@types/node-emoji": "^1.8.1",
|
||||
"@types/react-redux": "^7.1.24",
|
||||
"@types/redux-mock-store": "^1.0.3",
|
||||
"@types/testing-library__jest-dom": "^5.14.5",
|
||||
"@types/webpack-env": "^1.17.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.3",
|
||||
"@typescript-eslint/parser": "^5.30.3",
|
||||
"babel-loader": "^8.2.5",
|
||||
"babel-plugin-jsx-remove-data-test-id": "^3.0.0",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"codecov": "^3.8.2",
|
||||
"codecov": "^3.8.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^6.7.1",
|
||||
"css-minimizer-webpack-plugin": "^4.0.0",
|
||||
|
||||
Generated
+10997
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,11 @@
|
||||
"baseUrl": "app",
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"paths": {
|
||||
"react": ["../node_modules/preact/compat"],
|
||||
"react-dom": ["../node_modules/preact/compat"]
|
||||
}
|
||||
},
|
||||
"include": ["app/typings", "app/**/*.tsx", "app/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
|
||||
@@ -91,10 +91,6 @@ module.exports = (_, { mode, analyze }) => {
|
||||
|
||||
const resolve = {
|
||||
extensions: ['.ts', '.tsx', '.js'],
|
||||
alias: {
|
||||
react: 'preact/compat',
|
||||
'react-dom': 'preact/compat',
|
||||
},
|
||||
plugins: [new TsconfigPathsPlugin()],
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user