Update frontend dependencies to latest, bump pnpm to 10, clear all npm audit alerts
pnpm 8.15.9 -> 10.10.0 (packageManager + lockfile regenerated to v9). Frontend CI (ci-frontend.yml, ci-frontend-api.yml, release.yml) and the production Dockerfile bumped from node 16 + pnpm 8 to node 20 + pnpm 10 (pnpm 10 requires node 18+). pnpm audit: no known vulnerabilities (was 63 alerts). packages/api: bumped to latest including the major test stack - vitest 4, jsdom 29, @vitest/coverage-v8 4, @typescript-eslint 8.62, typescript 5.9, prettier 3.9, @types/node 26, and msw 1 -> 2. Migrated tests/test-utils.ts to the msw 2 http/HttpResponse API (capturing a compatible request shape) and made test base URLs absolute so node 20's native fetch is intercepted; added the jsdom base URL. type-check:api, lint:api and coverage:api (45 tests) all pass. apps/remark42: safe in-major bumps (webpack 5.108, postcss, mini-css-extract, html-webpack-plugin, ts-loader, webpack-dev-server 5.2.5, core-js, clsx 2, lodash-es 4.18, dotenv 17, @types/*). Transitive vulns patched via pnpm.overrides. type-check, lint, build, jest coverage (299 tests) and translations all pass. pnpm 10's stricter layout required a few pins to keep the app's preact-compat setup compiling: preact 10.6.2 (override), react-intl 6.0.5 and @testing-library/preact 3.2.2 (newer types break the build), tsconfig paths for preact, @types/minimatch 5.1.2 (6.x is an empty stub) and cheerio 1.0.0-rc.12 (1.2 is ESM and breaks jest 28). Held: react/react-dom (preact compat alias), babel 7, eslint 8, stylelint 14, jest 28, typescript 4.7 (app), redux/react-redux - majors that change the bundle or need a config migration. Build output verified against a clean master build: apps/remark42 output is functionally identical (the only diffs are webpack module-id numbering and css-module class tokens from the webpack/css-loader bump; all HTML, CSS values and translations byte-identical).
This commit is contained in:
@@ -22,7 +22,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [ 16 ]
|
||||
node: [ 20 ]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [ 16 ]
|
||||
node: [ 20 ]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -69,7 +69,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [ 16 ]
|
||||
node: [ 20 ]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -105,7 +105,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
node: [20]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
node: [20]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -69,7 +69,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
node: [20]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -105,7 +105,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
@@ -141,7 +141,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Check bundle size
|
||||
@@ -158,7 +158,7 @@ jobs:
|
||||
contents: read
|
||||
strategy:
|
||||
matrix:
|
||||
node: [16]
|
||||
node: [20]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -169,7 +169,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: Install node
|
||||
|
||||
@@ -38,13 +38,13 @@ jobs:
|
||||
- name: install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: install node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
@@ -113,13 +113,13 @@ jobs:
|
||||
- name: install pnpm
|
||||
uses: pnpm/action-setup@v6.0.4
|
||||
with:
|
||||
version: 8
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: install node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 16
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
FROM --platform=$BUILDPLATFORM node:16.20-alpine AS frontend-deps
|
||||
FROM --platform=$BUILDPLATFORM node:20-alpine AS frontend-deps
|
||||
|
||||
ARG SKIP_FRONTEND_TEST
|
||||
ARG SKIP_FRONTEND_BUILD
|
||||
@@ -11,7 +11,7 @@ COPY ./frontend/apps/remark42/package.json /srv/frontend/apps/remark42/
|
||||
RUN \
|
||||
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
|
||||
apk add --no-cache --update git && \
|
||||
npm i -g pnpm@8; \
|
||||
npm i -g pnpm@10; \
|
||||
fi
|
||||
|
||||
RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store/v3 \
|
||||
|
||||
@@ -22,23 +22,23 @@
|
||||
"translation:check": "node ./tasks/checkTranslation.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.15 <=22.*",
|
||||
"pnpm": "8.*"
|
||||
"node": ">=16.15",
|
||||
"pnpm": ">=8"
|
||||
},
|
||||
"packageManager": "pnpm@8.15.9",
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"dependencies": {
|
||||
"@github/markdown-toolbar-element": "^2.1.1",
|
||||
"@github/text-expander-element": "^2.2.2",
|
||||
"@ungap/custom-elements": "^1.1.0",
|
||||
"clsx": "^1.1.1",
|
||||
"core-js": "^3.23.3",
|
||||
"@github/markdown-toolbar-element": "^2.2.3",
|
||||
"@github/text-expander-element": "^2.9.4",
|
||||
"@ungap/custom-elements": "^1.3.0",
|
||||
"clsx": "^2.1.1",
|
||||
"core-js": "^3.49.0",
|
||||
"intersection-observer": "^0.12.2",
|
||||
"lodash-es": "^4.17.23",
|
||||
"lodash-es": "^4.18.1",
|
||||
"node-emoji": "^1.11.0",
|
||||
"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-intl": "6.0.5",
|
||||
"react-redux": "^8.0.2",
|
||||
"redux": "^4.2.0",
|
||||
"redux-thunk": "^2.4.1"
|
||||
@@ -52,24 +52,24 @@
|
||||
"@formatjs/cli": "^5.0.2",
|
||||
"@mavrin/stylelint-declaration-use-css-custom-properties": "^2.0.0",
|
||||
"@prefresh/babel-plugin": "^0.4.3",
|
||||
"@prefresh/core": "^1.3.4",
|
||||
"@prefresh/core": "^1.5.10",
|
||||
"@prefresh/webpack": "^3.3.4",
|
||||
"@size-limit/file": "^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",
|
||||
"@testing-library/preact": "3.2.2",
|
||||
"@testing-library/preact-hooks": "^1.1.0",
|
||||
"@types/enzyme": "^3.10.12",
|
||||
"@types/enzyme": "^3.10.19",
|
||||
"@types/eslint": "^8.4.5",
|
||||
"@types/jest": "^28.1.4",
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@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/react-redux": "^7.1.34",
|
||||
"@types/redux-mock-store": "^1.5.0",
|
||||
"@types/testing-library__jest-dom": "^5.14.5",
|
||||
"@types/webpack-env": "^1.17.0",
|
||||
"@types/webpack-env": "^1.18.8",
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.3",
|
||||
"@typescript-eslint/parser": "^5.30.3",
|
||||
"babel-loader": "^8.2.5",
|
||||
@@ -80,9 +80,9 @@
|
||||
"css-loader": "^6.7.1",
|
||||
"css-minimizer-webpack-plugin": "^4.0.0",
|
||||
"cssnano": "^5.1.12",
|
||||
"dotenv": "^16.0.1",
|
||||
"dotenv": "^17.4.2",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-preact-pure": "^4.0.1",
|
||||
"enzyme-adapter-preact-pure": "^4.1.0",
|
||||
"eslint": "^8.18.0",
|
||||
"eslint-config-preact": "^1.3.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
@@ -97,35 +97,35 @@
|
||||
"fast-async": "^6.3.8",
|
||||
"file-loader": "^6.2.0",
|
||||
"fork-ts-checker-webpack-plugin": "^7.2.11",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"html-webpack-plugin": "^5.6.7",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"incstr": "^1.2.3",
|
||||
"jest": "^28.1.2",
|
||||
"jest-environment-jsdom": "^28.1.2",
|
||||
"jest-fetch-mock": "^3.0.3",
|
||||
"jest-localstorage-mock": "^2.4.21",
|
||||
"mini-css-extract-plugin": "^2.6.1",
|
||||
"jest-localstorage-mock": "^2.4.26",
|
||||
"mini-css-extract-plugin": "^2.10.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.5.10",
|
||||
"postcss-html": "^1.4.1",
|
||||
"postcss": "^8.5.16",
|
||||
"postcss-html": "^1.8.1",
|
||||
"postcss-loader": "^7.0.0",
|
||||
"postcss-preset-env": "^7.7.2",
|
||||
"prettier": "^2.7.1",
|
||||
"redux-mock-store": "^1.5.4",
|
||||
"redux-mock-store": "^1.5.5",
|
||||
"size-limit": "^7.0.8",
|
||||
"style-loader": "^3.3.1",
|
||||
"stylelint": "^14.9.1",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-standard": "^26.0.0",
|
||||
"stylelint-value-no-unknown-custom-properties": "^4.0.0",
|
||||
"ts-loader": "^9.3.1",
|
||||
"ts-node": "^10.8.1",
|
||||
"ts-loader": "^9.6.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
||||
"typescript": "^4.7.4",
|
||||
"url-loader": "^4.1.1",
|
||||
"webpack": "^5.104.1",
|
||||
"webpack": "^5.108.3",
|
||||
"webpack-bundle-analyzer": "^4.5.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^5.2.4"
|
||||
"webpack-dev-server": "^5.2.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
"sourceMap": true,
|
||||
"paths": {
|
||||
"react": ["../node_modules/preact/compat"],
|
||||
"react-dom": ["../node_modules/preact/compat"]
|
||||
"react-dom": ["../node_modules/preact/compat"],
|
||||
"preact": ["../node_modules/preact"],
|
||||
"preact/*": ["../node_modules/preact/*"]
|
||||
}
|
||||
},
|
||||
"include": ["app/typings", "app/**/*.tsx", "app/**/*.ts"],
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
"author": "Paul Mineev <paul@mineev.me>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.57.0",
|
||||
"@types/node": "^22.9.0",
|
||||
"nanoid": "^5.0.8",
|
||||
"playwright": "1.57.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.6.3"
|
||||
"@playwright/test": "1.61.1",
|
||||
"@types/node": "^26.0.1",
|
||||
"nanoid": "^5.1.16",
|
||||
"playwright": "1.61.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
+71
-2
@@ -17,10 +17,79 @@
|
||||
"type-check:api": "turbo run type-check --filter=@remark42/api",
|
||||
"lint:api": "turbo run lint --filter=@remark42/api"
|
||||
},
|
||||
"packageManager": "pnpm@8.15.9",
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"devDependencies": {
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"turbo": "^1.4.3"
|
||||
"turbo": "^2.10.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"decode-uri-component@<0.2.1": ">=0.2.1",
|
||||
"loader-utils@>=2.0.0 <2.0.3": ">=2.0.3 <3.0.0",
|
||||
"loader-utils@>=2.0.0 <2.0.4": ">=2.0.4 <3.0.0",
|
||||
"json5@<1.0.2": ">=1.0.2",
|
||||
"json5@>=2.0.0 <2.2.2": ">=2.2.2",
|
||||
"tough-cookie@<4.1.3": ">=4.1.3",
|
||||
"micromatch@<4.0.8": ">=4.0.8",
|
||||
"esbuild@<=0.24.2": ">=0.25.0",
|
||||
"word-wrap@<1.2.4": ">=1.2.4",
|
||||
"cookie@<0.7.0": ">=0.7.0",
|
||||
"@babel/runtime-corejs3@<7.26.10": ">=7.26.10 <8.0.0",
|
||||
"@babel/runtime@<7.26.10": ">=7.26.10 <8.0.0",
|
||||
"@babel/helpers@<7.26.10": ">=7.26.10 <8.0.0",
|
||||
"cross-spawn@<6.0.6": ">=6.0.6",
|
||||
"cross-spawn@>=7.0.0 <7.0.5": ">=7.0.5",
|
||||
"tmp@<=0.2.3": ">=0.2.4",
|
||||
"form-data@>=4.0.0 <4.0.4": ">=4.0.4",
|
||||
"nanoid@>=4.0.0 <5.0.9": ">=5.0.9",
|
||||
"glob@>=10.2.0 <10.5.0": ">=10.5.0 <11.0.0",
|
||||
"diff@>=4.0.0 <4.0.4": ">=4.0.4",
|
||||
"semver@>=2.0.0-alpha <5.7.2": ">=5.7.2",
|
||||
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
|
||||
"semver@>=6.0.0 <6.3.1": ">=6.3.1",
|
||||
"serialize-javascript@<=7.0.2": ">=7.0.3",
|
||||
"svgo@>=2.1.0 <2.8.1": ">=2.8.1",
|
||||
"flatted@<3.4.0": ">=3.4.0",
|
||||
"flatted@<=3.4.1": ">=3.4.2",
|
||||
"lodash-es@>=4.0.0 <=4.17.23": ">=4.18.0",
|
||||
"lodash@>=4.0.0 <=4.17.23": ">=4.18.0",
|
||||
"lodash-es@<=4.17.23": ">=4.18.0",
|
||||
"lodash@<=4.17.23": ">=4.18.0",
|
||||
"serialize-javascript@>=6.0.0 <6.0.2": ">=6.0.2",
|
||||
"@xmldom/xmldom@<0.8.12": ">=0.8.12",
|
||||
"@babel/traverse@<7.23.2": ">=7.23.2 <8.0.0",
|
||||
"fast-uri@<=3.1.0": ">=3.1.1",
|
||||
"fast-uri@<=3.1.1": ">=3.1.2",
|
||||
"@xmldom/xmldom@<0.8.13": ">=0.8.13",
|
||||
"turbo@>=1.1.0 <2.9.14": ">=2.9.14",
|
||||
"@tootallnate/once@<2.0.1": ">=2.0.1",
|
||||
"serialize-javascript@>=5.0.0 <7.0.5": ">=7.0.5",
|
||||
"uuid@<11.1.1": ">=11.1.1",
|
||||
"@babel/plugin-transform-modules-systemjs@>=7.12.0 <=7.29.3": ">=7.29.4 <8.0.0",
|
||||
"lodash@>=4.0.0 <=4.17.22": ">=4.17.23",
|
||||
"shell-quote@>=1.1.0 <=1.8.3": ">=1.8.4",
|
||||
"tmp@<0.2.6": ">=0.2.6",
|
||||
"form-data@>=4.0.0 <4.0.6": ">=4.0.6",
|
||||
"launch-editor@<=2.14.0": ">=2.14.1",
|
||||
"@babel/core@<=7.29.0": ">=7.29.6 <8.0.0",
|
||||
"webpack-dev-server@<5.2.5": ">=5.2.5",
|
||||
"http-proxy-middleware@>=0.16.0 <2.0.10": ">=2.0.10",
|
||||
"turbo@<=2.9.13": ">=2.9.14",
|
||||
"yaml@>=1.0.0 <2.0.0": ">=1.10.3 <2.0.0",
|
||||
"yaml@>=2.0.0 <3.0.0": ">=2.9.0 <3.0.0",
|
||||
"js-yaml@>=3.0.0 <4.0.0": ">=3.14.2 <4.0.0",
|
||||
"js-yaml@>=4.0.0 <5.0.0": ">=5.0.0 <6.0.0",
|
||||
"minimatch@>=3.0.0 <4.0.0": ">=3.1.3 <4.0.0",
|
||||
"minimatch@>=9.0.0 <10.0.0": ">=9.0.7 <10.0.0",
|
||||
"ajv@>=8.0.0 <9.0.0": ">=8.18.0 <9.0.0",
|
||||
"ws@>=7.0.0 <8.0.0": ">=7.5.11 <8.0.0",
|
||||
"ws@>=8.0.0 <9.0.0": ">=8.21.0 <9.0.0",
|
||||
"brace-expansion@>=1.0.0 <2.0.0": ">=1.1.12 <2.0.0",
|
||||
"brace-expansion@>=2.0.0 <3.0.0": ">=2.0.2 <3.0.0",
|
||||
"preact": "10.6.2",
|
||||
"@types/minimatch": "5.1.2",
|
||||
"cheerio": "1.0.0-rc.12"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,24 +29,23 @@
|
||||
"type-check": "tsc --noEmit",
|
||||
"lint-staged:lint": "eslint --fix --ext .cjs,.mjs,.ts"
|
||||
},
|
||||
"packageManager": "pnpm@8.15.9",
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.19.64",
|
||||
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
||||
"@typescript-eslint/parser": "^8.13.0",
|
||||
"@vitest/coverage-v8": "^2.1.4",
|
||||
"@types/node": "^26.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.62.1",
|
||||
"@typescript-eslint/parser": "^8.62.1",
|
||||
"@vitest/coverage-v8": "^4.1.9",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"jsdom": "^25.0.1",
|
||||
"msw": "^1.3.5",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.6",
|
||||
"jsdom": "^29.1.1",
|
||||
"msw": "^2.14.6",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^3.3.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vitest": "^2.1.4",
|
||||
"whatwg-fetch": "^3.6.2"
|
||||
"prettier": "^3.9.4",
|
||||
"ts-node": "^10.9.2",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.1.9"
|
||||
},
|
||||
"type": "module",
|
||||
"files": [
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Context {
|
||||
|
||||
describe<Context>('Admin Client', (adminClient) => {
|
||||
beforeEach<Context>((ctx) => {
|
||||
ctx.client = createAdminClient({ siteId: 'mysite', baseUrl: '/remark42' })
|
||||
ctx.client = createAdminClient({ siteId: 'mysite', baseUrl: 'http://localhost/remark42' })
|
||||
})
|
||||
|
||||
adminClient('should return list of blocked users', async ({ client }) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Content {
|
||||
|
||||
describe<Content>('Auth Client', (authClient) => {
|
||||
beforeEach<Content>((ctx) => {
|
||||
ctx.client = createAuthClient({ siteId: 'mysite', baseUrl: '/remark42' })
|
||||
ctx.client = createAuthClient({ siteId: 'mysite', baseUrl: 'http://localhost/remark42' })
|
||||
})
|
||||
|
||||
authClient('should authorize as anonymouse', async ({ client }) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createClient } from '../..'
|
||||
|
||||
describe('Client', () => {
|
||||
it('should create a client', () => {
|
||||
const params = { siteId: 'mysite', baseUrl: '/remark42' }
|
||||
const params = { siteId: 'mysite', baseUrl: 'http://localhost/remark42' }
|
||||
const client = createClient(params)
|
||||
|
||||
expect(client).toBeDefined()
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Context {
|
||||
|
||||
describe<Context>('Public Client', (publicClient) => {
|
||||
beforeEach<Context>((ctx) => {
|
||||
ctx.client = createPublicClient({ siteId: 'mysite', baseUrl: '/remark42' })
|
||||
ctx.client = createPublicClient({ siteId: 'mysite', baseUrl: 'http://localhost/remark42' })
|
||||
})
|
||||
|
||||
publicClient('getConfig: should return config', async ({ client }) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ interface Context {
|
||||
|
||||
describe<Context>('Fetcher', (fetcher) => {
|
||||
beforeEach<Context>((ctx) => {
|
||||
ctx.client = createFetcher('remark42', '')
|
||||
ctx.client = createFetcher('remark42', 'http://localhost')
|
||||
})
|
||||
|
||||
fetcher('get', async ({ client }) => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'whatwg-fetch'
|
||||
import { afterAll, afterEach, beforeAll } from 'vitest'
|
||||
import { server } from './test-utils'
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import { rest, RestRequest } from 'msw'
|
||||
import { http, HttpResponse } from 'msw'
|
||||
import { setupServer } from 'msw/node'
|
||||
|
||||
export const server = setupServer()
|
||||
|
||||
interface CapturedRequest {
|
||||
url: URL
|
||||
method: string
|
||||
headers: Headers
|
||||
json: () => Promise<unknown>
|
||||
text: () => Promise<string>
|
||||
}
|
||||
|
||||
interface RequestRef {
|
||||
req: RestRequest
|
||||
req: CapturedRequest
|
||||
}
|
||||
|
||||
export function mockEndpoint(
|
||||
@@ -20,15 +28,26 @@ export function mockEndpoint(
|
||||
const result = { req: {} } as RequestRef
|
||||
|
||||
server.use(
|
||||
rest[method](url, (req, res, ctx) => {
|
||||
const transformers = [ctx.status(status), ctx.json(body)]
|
||||
|
||||
if (headers) {
|
||||
transformers.push(ctx.set(headers))
|
||||
http[method](url, ({ request }) => {
|
||||
const captured = request.clone()
|
||||
result.req = {
|
||||
url: new URL(request.url),
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
json: () => captured.clone().json(),
|
||||
text: () => captured.clone().text(),
|
||||
}
|
||||
|
||||
result.req = req
|
||||
return res(...transformers)
|
||||
const responseHeaders = new Headers()
|
||||
if (headers) {
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
responseHeaders.set(key, Array.isArray(value) ? value.join(', ') : value)
|
||||
}
|
||||
}
|
||||
|
||||
return body === undefined
|
||||
? new HttpResponse(null, { status, headers: responseHeaders })
|
||||
: HttpResponse.json(body, { status, headers: responseHeaders })
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@ import { defineConfig } from 'vitest/config'
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
environmentOptions: {
|
||||
jsdom: {
|
||||
url: 'http://localhost',
|
||||
},
|
||||
},
|
||||
setupFiles: ['./tests/setup.ts'],
|
||||
include: ['tests/**/*.test.ts'],
|
||||
},
|
||||
|
||||
Generated
+11354
-9906
File diff suppressed because it is too large
Load Diff
+2
-3
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"$schema": "https://turborepo.org/schema.json",
|
||||
"baseBranch": "origin/master",
|
||||
"pipeline": {
|
||||
"$schema": "https://turborepo.com/schema.json",
|
||||
"tasks": {
|
||||
"dev": {},
|
||||
"start": {},
|
||||
"build": {
|
||||
|
||||
Reference in New Issue
Block a user