diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7dedd75..c988b021 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,7 @@ jobs: cache-dependency-path: backend/package-lock.json - run: npm ci - run: npm run lint + - run: npm test -- --run - run: npm run build frontend: diff --git a/README.md b/README.md index df4bbe15..a5057921 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ http://it2810-03.idi.ntnu.no/project2/ | Frontend | React, TypeScript, Vite, Apollo Client, React Router, i18next | | Backend | Node.js, TypeScript, Apollo Server (GraphQL) | | Database | MongoDB, running on the course VM | -| Testing | Vitest, React Testing Library, jsdom | +| Testing | Vitest, React Testing Library, jsdom, mongodb-memory-server | | Tooling | ESLint, Prettier, GitHub Actions | ## Architecture @@ -83,29 +83,42 @@ This starts both the backend (http://localhost:3001) and the frontend. Open http See [backend/README.md](backend/README.md) for more details about the backend setup (in Norwegian). -### Available scripts - kan slettes? +## Testing -The project has three `package.json` files: one in the repo root, one in `backend` and one in `frontend`. The root `package.json` contains no app code. It only holds scripts that run the matching script in `backend` and `frontend` for you, so you don't have to switch between folders. Run these from the repo root: +Both the frontend and the backend are tested with [Vitest](https://vitest.dev/). -| Command | What it does | When to use it | -| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -| `npm run install:all` | Runs `npm install` in the root, `backend` and `frontend`. | After cloning, and after pulling changes to any `package.json`. | -| `npm run dev` | Starts the backend (`tsx watch`, port 3001) and the frontend (Vite, port 5173) in the same terminal with [concurrently](https://www.npmjs.com/package/concurrently). Output is prefixed with `[backend]` (blue) and `[frontend]` (green). Both restart or reload automatically when you save a file. Stop both with `Ctrl+C`. | Day-to-day development. The SSH tunnel must be open first. | -| `npm run build` | Compiles the backend with `tsc` to `backend/dist`, then type checks and builds the frontend with Vite to `frontend/dist`. Stops at the first error. | To check that everything compiles, and before deploying. | -| `npm run lint` | Runs ESLint in `backend`, then in `frontend`. | Before you push or open a pull request. | -| `npm test` | Runs the frontend tests once with Vitest and exits. | Before you push or open a pull request. | -#### Scripts in `backend` and `frontend` +- **Frontend:** Pages, components and hooks are tested with React Testing Library in a simulated browser (jsdom). Calls to the backend are mocked, so the backend does not need to be running. +- **Backend:** The database connection and the GraphQL server are tested against a real MongoDB that runs in memory ([mongodb-memory-server](https://www.npmjs.com/package/mongodb-memory-server)). The tests never use the database on the VM, so they do not need the VPN or the SSH tunnel. MongoDB is downloaded once the first time the backend tests run. -You can also run scripts in one part of the project only, either with `cd backend` / `cd frontend` or with `--prefix` from the root (for example `npm run dev --prefix backend`). This is useful if you only work on one side, or want the backend and frontend output in separate terminals. +See [tests.md](docs/tests.md) for what each test file covers. -| Folder | Command | What it does | -| ---------- | ----------------- | ----------------------------------------------------------------------------- | -| `backend` | `npm run dev` | Starts the GraphQL server and restarts it when you change a file. | -| `backend` | `npm start` | Runs the compiled server from `dist/`. Run `npm run build` first. | -| `frontend` | `npm run dev` | Starts the Vite dev server on http://localhost:5173/project2/. | -| `frontend` | `npm test` | Runs Vitest in watch mode, so the tests run again every time you save a file. | -| `frontend` | `npm run preview` | Serves the production build from `dist/` locally. Run `npm run build` first. | +### Run the tests + +Run these from the repo root: + +```bash + +npm run test:backend +npm run test:frontend +``` + +### Run the tests with coverage + +```bash +# Coverage for only the backend or only the frontend +npm run test:backend -- --coverage +npm run test:frontend -- --coverage +``` + +The coverage table is printed in the terminal. A detailed report is saved in `frontend/coverage/index.html` and `backend/coverage/index.html`, which you can open in a browser to see which lines are not tested. + +### Test coverage +TODO! + +### Continuous integration + +GitHub Actions ([.github/workflows/ci.yml](.github/workflows/ci.yml)) runs on every pull request and on every push to `main`. It checks the formatting with Prettier, and runs lint, tests and build for both the backend and the frontend. ## Quality and design @@ -115,4 +128,4 @@ and work practices. ## Known issues TODO! -If you type and switch pages within half a second after updating your profile, the last few letters are not saved, because the debounce didn't have time to send. \ No newline at end of file +If you type and switch pages within half a second after updating your profile, the last few letters are not saved, because the debounce didn't have time to send. diff --git a/backend/package-lock.json b/backend/package-lock.json index bdaacda7..e4bcd521 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -16,12 +16,15 @@ "devDependencies": { "@eslint/js": "^10.0.1", "@types/node": "^26.6.3", + "@vitest/coverage-v8": "^5.0.5", "eslint": "^10.12.0", "eslint-config-prettier": "^10.1.8", "globals": "^17.13.0", + "mongodb-memory-server": "^11.3.0", "tsx": "^4.23.15", "typescript": "~6.0.2", - "typescript-eslint": "^8.71.0" + "typescript-eslint": "^8.71.0", + "vitest": "^5.0.5" }, "engines": { "node": ">=20" @@ -264,6 +267,66 @@ "node": ">=16" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.11.tgz", + "integrity": "sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.11.tgz", + "integrity": "sha512-OZ6+oaK7GMyg3IfCpj8JOmn8n+w2rJbDT0LLfVDTLb1ZFeKDh3AiNELgCMUw175IJHSkLl74hG0M0VLsvx+gag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.11" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.11.tgz", + "integrity": "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.11", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -859,12 +922,12 @@ } }, "node_modules/@graphql-tools/merge": { - "version": "9.2.4", - "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.2.4.tgz", - "integrity": "sha512-vV+8uWNWn0+OsqT0r22lZuoT0cTe6fBqBtpLHre2rriLjI/ZTrsOHmabLPTUOyzgFnRrS2PzFSYGL3zKL1Wj4Q==", + "version": "9.2.8", + "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.2.8.tgz", + "integrity": "sha512-OsCEmJ9RIMT4LB/1jBbyKHe7pMIlfGhLAQ0FVNaZqteydDUC+rTI9wZ+yaKqxQpPOFFycD+UtMhovg19lPq92Q==", "license": "MIT", "dependencies": { - "@graphql-tools/utils": "^12.0.1", + "@graphql-tools/utils": "^12.1.0", "tslib": "^2.4.0" }, "engines": { @@ -875,13 +938,13 @@ } }, "node_modules/@graphql-tools/schema": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.1.1.tgz", - "integrity": "sha512-24jJghRxEW+SG1lbJ45Zg9HEZ8ZKS923ihbFjOicspFLpryxJkWp6gZJ7D8tCVaSAhli4x1+1wDPAfhT8mLqxg==", + "version": "10.1.5", + "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.1.5.tgz", + "integrity": "sha512-F0Onw0ZBREakKGqcgsKhdSCjOXgmntzQWL0QA+/WrwKmnJ7nJRyGKUJavwuVZL2TrXblaIUvQxm4t1h3FuA3cA==", "license": "MIT", "dependencies": { - "@graphql-tools/merge": "^9.2.4", - "@graphql-tools/utils": "^12.0.1", + "@graphql-tools/merge": "^9.2.8", + "@graphql-tools/utils": "^12.1.0", "tslib": "^2.4.0" }, "engines": { @@ -892,13 +955,13 @@ } }, "node_modules/@graphql-tools/utils": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-12.0.1.tgz", - "integrity": "sha512-8YC6jn4xYDS6YTY6xDAgQAs/nGgvzRaIGHS8GeSfVItQzNK7Ms24CQtE3EJY+amvR+tBnhRSX0N83aGj+V/RIg==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-12.1.0.tgz", + "integrity": "sha512-+mOuIX7u83/BHG0L9JviMzKid1j35cxOWhLoox47TXHAJ6Tnn30RgrmEQPmk1FhmaQbhJEcwYBDVyieUvZopJw==", "license": "MIT", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", - "@whatwg-node/promise-helpers": "^1.0.0", + "@whatwg-node/promise-helpers": "^2.0.0", "cross-inspect": "1.0.1", "tslib": "^2.4.0" }, @@ -984,6 +1047,34 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@keyv/bigmap": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", @@ -1009,14 +1100,25 @@ "license": "MIT" }, "node_modules/@mongodb-js/saslprep": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.5.5.tgz", - "integrity": "sha512-0PV4mvjGd2Q2/viDvXuoSNzTjQngHvtuWUry1vqvcK4Q/CTeO1zEKMf9set01DMocJnogl/pyNAdvyk+Pe0kQA==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.6.1.tgz", + "integrity": "sha512-D4CQtk9IwjCLAvCf1xvHEod3960q8XMUzfmdRU9qjUNlHnesGuTOvJcOTaPm9koZ1caUKA2aTbszZiAkcmSgmg==", "license": "MIT", "dependencies": { "sparse-bitfield": "^3.0.3" } }, + "node_modules/@oxc-project/types": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.155.0.tgz", + "integrity": "sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q==", + "dev": true, + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, "node_modules/@protobufjs/aspromise": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", @@ -1080,6 +1182,302 @@ "integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==", "license": "BSD-3-Clause" }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.15.tgz", + "integrity": "sha512-aLcgK9gIJ3YRvrrtfSBbRa27F5WrpiTaPulnFpsHPxpUHgFlSgnU4854MHwoRGEBhfRJDWCS2WQ7lIjskE9Olw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.15.tgz", + "integrity": "sha512-xD7DdZCrbThKuxNg7ooQmvp07ys4J/pnSEMTG3/OdOWl6daC67m/Q4fL78sRHMxTH/N4fGUbYhcPM0MF5WFHkg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.15.tgz", + "integrity": "sha512-m2WuQ6r0B4OTYxyPpNLtXaMRbRDUbG8YQV2Q3KTdSSK8Th6KHCnC8jVCJt8bvYeSB5WivkkNbc85mKadaSdOxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.15.tgz", + "integrity": "sha512-5RtnsHM36nodM9WbMy+zip0LGS/G+y5wro5RHrpOlr4ac24+1zSi9kiV2MP1myZeZ/ifEHfulQcWjnAXzc2C2A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.15.tgz", + "integrity": "sha512-g3l09pyFqhu+135JKkbkwiKGQmwU5hUMUPJ4VdBADvuqR8d33L6H578rh8m7rtxbdp+VmX/+nzI7nvhSZlzpUQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.15.tgz", + "integrity": "sha512-nIe3VugI97nGQtspPxDqA4sXMUpeiocKIP/CqpY/u/vgbT+alX+cVxu1C/oVBPKg4feNTmYovE91v4DgXvXNwQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.15.tgz", + "integrity": "sha512-iTBjXx+B5QSvgI89lJfmqh4wTh8NabR1YZIIN3hNx4zSG0EVfVqkOvLulNpG4251pbd6/IAmZ/LefVk1Y4rPhw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.15.tgz", + "integrity": "sha512-uN26XOnVR7rqQupG3V9oAG2EGGatWjcJHOeDOHUFCh4TBWmP2tHTFoVN13aYbwfm0aHqJAEmcwhAu6sooIjfqQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.15.tgz", + "integrity": "sha512-9nWkcdd+H+XhaA3fQIwpHnKIrfx/PQ6rO0pivr78Og07tXlUlctBBJoEYLPfhTmCR/QxEVdn6uPjHV5SymPhdw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.15.tgz", + "integrity": "sha512-Ggh0ciFjLwIusLSLz7LZYEaGdxOAUJXI+Qu5JCbhPJJHEt8vP+IjRATTJheiJsdzzTYgUiHUiw3X1Ea3ZpMBdA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.15.tgz", + "integrity": "sha512-FHg60rS6DBePAYZ9X9F67x+JObFdmgn6tupA1C/a3B+CufFmTD4mX+e8M75tCiAO3foR/6xwVBI0KQiI7sn/rw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.15.tgz", + "integrity": "sha512-/cvV/7v5VGz/moiz0XKRj2dE8DzsKyhIu1KpOvJGPjRywg3yscON889UGvAe8zfiJLHup7VLjBduoGWi3HusWQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.15.tgz", + "integrity": "sha512-MyzC5Hrv/sm+Z7TSGKP/j8001RO2xQm1zOpCNVL4j0cY/VhBZviludA2YFQ7i4lH6ZAXxQm0lcMdBzM+99mE7w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.15.tgz", + "integrity": "sha512-+PgYiS+AH5omy6L45ZLxybasauJaj3M8buoT83D+nzPmCayXlxUV9hydhciCKVyIg0B/v0BtXPDE1uGqNwCPpg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.15.tgz", + "integrity": "sha512-HFZd2QNQYn1JbIi+Hpd7H+r/lkWxcfIu28nirZ6eCn2LafuvmExMlb/P96Sfx5tf7pPArw39IdhmCF8vmV+NhQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/esrecurse": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", @@ -1108,9 +1506,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "26.6.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.3.tgz", - "integrity": "sha512-dsqMQQoeTLqu9wynDD00q573mNzso3IdQOAfHRJqLCcmCFPoGo9A1bDpUcv/9tnKpErQWv9uKeGfl37EIS02Yg==", + "version": "26.6.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz", + "integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==", "dev": true, "license": "MIT", "dependencies": { @@ -1133,17 +1531,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.1.tgz", - "integrity": "sha512-nNlBf6HuotqMgZvSkWD5hNdemiBIxQ2NmrlgfcUIeZRs+BbakjscCQRq/Hb74EFVnFiSWWdL12JruqwBy3ERDw==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.0.tgz", + "integrity": "sha512-aysKgysPX9XOv/dk95UkvUDe++Q3n3dJPG9CEWT3RUccxfkPJ+Qn6nhKPDhZXU6Ofo9kgwGWwKyQCnZIXTgngg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.71.1", - "@typescript-eslint/type-utils": "8.71.1", - "@typescript-eslint/utils": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1", + "@typescript-eslint/scope-manager": "8.72.0", + "@typescript-eslint/type-utils": "8.72.0", + "@typescript-eslint/utils": "8.72.0", + "@typescript-eslint/visitor-keys": "8.72.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -1156,15 +1554,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.71.1", + "@typescript-eslint/parser": "^8.72.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz", - "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==", + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", + "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", "dev": true, "license": "MIT", "engines": { @@ -1172,16 +1570,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.1.tgz", - "integrity": "sha512-oM/5sAqz/l1v/zYK1qTOPrn2+JIrBGC1V6uNYucRO5gh6eT9vWJ/RhPbGE59byvZEUQ4VP6XkLBaS5Jti5jpvw==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.0.tgz", + "integrity": "sha512-0O+x3ynciD6zuXb1CKSu165haQV6ey53DKhHHUnujP7U+XlltJG+/keT0Xhd1HXCze+IHf7Tvt39ovyepX/LNw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.71.1", - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1", + "@typescript-eslint/scope-manager": "8.72.0", + "@typescript-eslint/types": "8.72.0", + "@typescript-eslint/typescript-estree": "8.72.0", + "@typescript-eslint/visitor-keys": "8.72.0", "debug": "^4.4.3" }, "engines": { @@ -1197,14 +1595,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.1.tgz", - "integrity": "sha512-Oijc9RUsohHjncg6iGi7gCtjnEjYt9FWv9u6ygK8uKcHK5eLjLAkqERQ9BaytbpceOFdk6kifPCS/zAZE+A99g==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.0.tgz", + "integrity": "sha512-bzHngBbmIgzj6TsTjVUCntGx6FFLgE7mPjpO0PzHycOaZHXqS43XnrkFIHRS16LLr/xO6FHSXG3GJFo/F4bSBQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.71.1", - "@typescript-eslint/types": "^8.71.1", + "@typescript-eslint/tsconfig-utils": "^8.72.0", + "@typescript-eslint/types": "^8.72.0", "debug": "^4.4.3" }, "engines": { @@ -1219,14 +1617,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.1.tgz", - "integrity": "sha512-1YUDZXdTnXLlob03SFHBipdyMBsDVm7zoSz0ytTJ39dk5J1TgsTK03VlR/dLXG/RLLUrPcYbD4rp23BmHxHP0w==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.0.tgz", + "integrity": "sha512-JewPyJOYcXBSAS7PIgufscHOwZqhTGyBRiQJhhuDln66tMchxvvt7nJ90JKKIoOelmdHA3kAQbm9cEUHc4JSEA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1" + "@typescript-eslint/types": "8.72.0", + "@typescript-eslint/visitor-keys": "8.72.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1237,9 +1635,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.1.tgz", - "integrity": "sha512-oTvkml5SxXhgg+WWKhod5qWQICDXtOB+/Hi9VdPKFAANJ2b7YOgMffgvzXuqog7R6A/JtrzRf128dsxummyWhg==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.0.tgz", + "integrity": "sha512-0vbxCf7xLVPSjcOdm6eQbgViH8EDJ8xnl1laLT9yoqSz2YmcSfSg5Vdl0JUvZf6rcuJ0ZivJIuMD4edTg8obaA==", "dev": true, "license": "MIT", "engines": { @@ -1254,15 +1652,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.1.tgz", - "integrity": "sha512-kH3t3jZCYv2PZSBEWPKTariLrCaoF1CLoPitYFBJOhAGEwWnSRAtGEifrfrpBa4K9JlwWNZotgA5w3/wLSk/FQ==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.0.tgz", + "integrity": "sha512-gEXxmmbSTSOVTC37IYYvremOM31v+UN2W772bJxmVYPhAOPSUxtacyb7wkm1EhkYKU6KzFJsdU44DCV4to0LWw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1", - "@typescript-eslint/utils": "8.71.1", + "@typescript-eslint/types": "8.72.0", + "@typescript-eslint/typescript-estree": "8.72.0", + "@typescript-eslint/utils": "8.72.0", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -1279,9 +1677,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.1.tgz", - "integrity": "sha512-ybYnPTUwg3VQQOFEiBPLs8Jxl1ry2vXdn1kVKguomBbvxpetdu3MKTNDqFNUrlG8ylP9MpZosmXMFYlGQHk1oQ==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.0.tgz", + "integrity": "sha512-Adfoy59kxNEjT5E5fnyrp7GpHYuWs8ONbdohu4ez6IU46qDq8LltG90tLmkucZB2uhYL8mqBjtXqGd8yhfjXqQ==", "dev": true, "license": "MIT", "engines": { @@ -1293,16 +1691,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.1.tgz", - "integrity": "sha512-pSKSEK1JJpHs6KiKVtABCE4iJK5d7FLFzDXQNBQ2oRY7LEd3UwOt3TZemTgu9syTIf56dJWlTn/pdmrO9oKUXQ==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.0.tgz", + "integrity": "sha512-gwLfFgWcw15tN2KXDCJvxEOQjPn+P3j/n3eSqkZ5sX4VpW9Cosodr+tWwBZRvJT3TcKx6HnPRGZMCNAiP1Xhug==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.71.1", - "@typescript-eslint/tsconfig-utils": "8.71.1", - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1", + "@typescript-eslint/project-service": "8.72.0", + "@typescript-eslint/tsconfig-utils": "8.72.0", + "@typescript-eslint/types": "8.72.0", + "@typescript-eslint/visitor-keys": "8.72.0", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -1321,16 +1719,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.1.tgz", - "integrity": "sha512-CBjT6gfAz3DW2j9Q4moFnqt208Aq+506sVGXfpRcyAeqn0EpayL0mjdWoCO2t3RC7GewNrFxdeehuEaPg6DMzQ==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.0.tgz", + "integrity": "sha512-0up3oArJZBYnzOaEXKo8DmI43QvMZyPoFEt9LWzRJcyl/RcJjfKKPebknN1VbTgXBf3M/KggUh5uUMdURLnseg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.71.1", - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1" + "@typescript-eslint/scope-manager": "8.72.0", + "@typescript-eslint/types": "8.72.0", + "@typescript-eslint/typescript-estree": "8.72.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1345,13 +1743,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.1.tgz", - "integrity": "sha512-0GxiUGqMU0qXJt58cBsiG3DP8lUmBaFo2vChtUX+CT7PnR3v/VGLLrzVP4K9r1lNiZXjHYefMBbPunplr09v6w==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.0.tgz", + "integrity": "sha512-E2mroviasaWecDzTGiGMtuEguuLVOeRggnrIn93CJuxYJzQBHbyymlT08aVQydbBal5538o+JkBKXh2sRuCyIA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/types": "8.72.0", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -1362,21 +1760,111 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@whatwg-node/promise-helpers": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@whatwg-node/promise-helpers/-/promise-helpers-1.3.2.tgz", - "integrity": "sha512-Nst5JdK47VIl9UcGwtv2Rcgyn5lWtZ0/mhRQ4G8NN2isxpq2TO30iqHzmwoJycjWuyUfg3GFXqP/gFHXeV57IA==", + "node_modules/@vitest/coverage-v8": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.5.tgz", + "integrity": "sha512-4KpkGdIrSqBihx/JyP/e+S+IKB98etg1XDQiLAxksLfcShnwi1VReGeOT9NI43hLHbknosKp/1CCLn9Zgcs8mg==", + "dev": true, "license": "MIT", "dependencies": { - "tslib": "^2.6.3" + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/istanbul-lib-coverage": "^1.0.2", + "@vitest/istanbul-lib-report": "^1.0.2", + "ast-v8-to-istanbul": "^1.0.7", + "magicast": "^0.5.5", + "obug": "^3.0.0", + "std-env": "^4.3.0", + "tinyrainbow": "^3.2.0" }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/acorn": { - "version": "8.19.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "5.0.5", + "vitest": "5.0.5" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/istanbul-lib-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.2.tgz", + "integrity": "sha512-9J/JMwOf9AoJhAywhrn7ScKTL38hsWQP/qPG60OtaAFcQ5OXPwKsxZFlbnuCKmZ61m8/lGgHYnFpdyQZUvG/iA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22" + } + }, + "node_modules/@vitest/istanbul-lib-report": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@vitest/istanbul-lib-report/-/istanbul-lib-report-1.0.2.tgz", + "integrity": "sha512-gUsfXZJbzPamoIY5TvHFiMMoXESBrUMo+xqaj+rYrWI69+EnvRlYBlP96ZnHPY4vX8kyUpgAnFUCg5wZG/HkDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/istanbul-lib-coverage": "1.0.2" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@vitest/mocker": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.5.tgz", + "integrity": "sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.0.5", + "estree-walker": "^3.0.3", + "magic-string": "^1.4.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9 || ^3.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/spy": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.5.tgz", + "integrity": "sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@whatwg-node/promise-helpers": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@whatwg-node/promise-helpers/-/promise-helpers-2.0.1.tgz", + "integrity": "sha512-ziVgm01A9irPLVBaUFei64qp771BrDXldbv5pY6kgFgNtA+7zq8ux6nj/6w8bELGH/+Ttnc76ox04HIjU8nqvg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.6.3" + }, + "engines": { + "node": ">=22.15.0" + } + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", "dev": true, "license": "MIT", @@ -1397,6 +1885,16 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, "node_modules/ajv": { "version": "6.15.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", @@ -1414,6 +1912,38 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.7.tgz", + "integrity": "sha512-kFL68AG6ajd8fg248zwM9GQrUWEp79gsmjum34OEXjs4yHuUMZfYKwOLW9GMmB4oNvVrj+EAGxsP7ye2UR9UlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, + "node_modules/async-mutex": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", + "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/async-retry": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/async-retry/-/async-retry-1.3.3.tgz", @@ -1438,6 +1968,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/b4a": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.9.0.tgz", + "integrity": "sha512-dpfcF9fDNR6++cthXR67iyhgqWy9CBouAvIWhIntzBG6cvK/cnIPiZQjBwi/ZqjjBEDGfoNDtmB0kTjroOJ3pQ==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "react-native-b4a": "*" + }, + "peerDependenciesMeta": { + "react-native-b4a": { + "optional": true + } + } + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -1448,19 +1993,104 @@ "node": "18 || 20 || >=22" } }, + "node_modules/bare-events": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz", + "integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==", + "dev": true, + "license": "Apache-2.0", + "peerDependencies": { + "bare-abort-controller": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + } + } + }, + "node_modules/bare-fs": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.8.4.tgz", + "integrity": "sha512-MPC2eyrpbk3A873sK4y6rk+Iv4o2enxTjHZ8zH3HO0mjrpm5XjnguY2XmfidIsDV6vnjpbMBKUAJpV0ISD2SsQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.5.4", + "bare-path": "^3.0.0", + "bare-stream": "^2.6.4", + "bare-url": "^2.2.2", + "fast-fifo": "^1.3.2" + }, + "engines": { + "bare": ">=1.28.0" + }, + "peerDependencies": { + "bare-buffer": "*" + }, + "peerDependenciesMeta": { + "bare-buffer": { + "optional": true + } + } + }, + "node_modules/bare-path": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.2.tgz", + "integrity": "sha512-ZyKbsuuqK6Ag0K8pX6V5Txq6XeJRvY+wXucnFGRjiyVYP9YWDpIQugk/b+enRYrEYBJaqLzghRQpXPMR7341Nw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/bare-stream": { + "version": "2.13.4", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.4.tgz", + "integrity": "sha512-PcrQ8lVLbiJscNm1Kez+Yp4Gy4AHGcN1lzwjvf5NybWen7VvEgUfyfnXYJ2zNqWnzOfCb1Abq6lH8ti0syQszA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.8.1", + "streamx": "^2.25.0", + "teex": "^1.0.1" + }, + "peerDependencies": { + "bare-abort-controller": "*", + "bare-buffer": "*", + "bare-events": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + }, + "bare-buffer": { + "optional": true + }, + "bare-events": { + "optional": true + } + } + }, + "node_modules/bare-url": { + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.5.tgz", + "integrity": "sha512-iM9qJCruvpt2rPaLsrumVDru9pogI7PHziHIa9kTNRFt8C8HuSa+kI9kFezK+NvHEFnnz71rKGZ1EAilq/3V/Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-path": "^3.0.0" + } + }, "node_modules/body-parser": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", - "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", + "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==", "license": "MIT", "dependencies": { "bytes": "^3.1.2", - "content-type": "^2.0.0", + "content-type": "^2.1.0", "debug": "^4.4.3", "http-errors": "^2.0.1", - "iconv-lite": "^0.7.2", + "iconv-lite": "^0.7.3", "on-finished": "^2.4.1", - "qs": "^6.15.2", + "qs": "^6.16.1", "raw-body": "^3.0.2", "type-is": "^2.1.0" }, @@ -1577,6 +2207,36 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, "node_modules/content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", @@ -1680,10 +2340,21 @@ "node": ">= 0.8" } }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "engines": { + "node": ">=8" + } + }, "node_modules/dotenv": { - "version": "18.0.5", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.5.tgz", - "integrity": "sha512-aBrGvt6KhjxbEnatqMWOMidftwsrCiCvqh1yNIGB9QyF0J+VcWkKDMsvYOEm7ZS82oiV+BT1sTOtIlAmUlTpwQ==", + "version": "18.0.9", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.9.tgz", + "integrity": "sha512-3fVOW4cB02R066PUSwn8O4TJyz9NckQl7F81blIbaq9jKBm2tSmOKky7ZHIXzGvkVPXCSn6jkpziBPZdGFs8Tw==", "license": "BSD-2-Clause", "bin": { "dotenv": "dist/index.cjs" @@ -1742,6 +2413,13 @@ "node": ">= 0.4" } }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, "node_modules/es-object-atoms": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", @@ -1816,9 +2494,9 @@ } }, "node_modules/eslint": { - "version": "10.12.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.12.0.tgz", - "integrity": "sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==", + "version": "10.13.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.13.0.tgz", + "integrity": "sha512-UohDjD4zSzEwhf58M3O7vc/ycc8O1I7dNlhtD0WxE8Px8EHNJKtUwzBqrzeGhisRuv2ag4sAYswszCJRgKXYUg==", "dev": true, "license": "MIT", "workspaces": [ @@ -1976,6 +2654,16 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1986,6 +2674,26 @@ "node": ">=0.10.0" } }, + "node_modules/events-universal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz", + "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.7.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1993,6 +2701,13 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-fifo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", + "dev": true, + "license": "MIT" + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2056,6 +2771,24 @@ "url": "https://opencollective.com/express" } }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2092,6 +2825,27 @@ "dev": true, "license": "ISC" }, + "node_modules/follow-redirects": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.2.tgz", + "integrity": "sha512-/kVP2U8z596Ia0gwFrwyIeo74ta5aVmSeU1FfAUMAmcEP5EP7zydmag3SLiN64NaRKef3lxsq7i/g7ltJQDGow==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", @@ -2306,6 +3060,20 @@ "url": "https://opencollective.com/express" } }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/iconv-lite": { "version": "0.7.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", @@ -2411,6 +3179,13 @@ "dev": true, "license": "ISC" }, + "node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -2449,35 +3224,308 @@ "node": ">= 0.8.0" } }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", "dev": true, - "license": "MIT", + "license": "MPL-2.0", + "peer": true, "dependencies": { - "p-locate": "^5.0.0" + "detect-libc": "^2.0.3" }, "engines": { - "node": ">=10" + "node": ">= 12.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", - "license": "MIT" - }, - "node_modules/loglevel": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.2.tgz", - "integrity": "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==", - "license": "MIT", + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "peer": true, "engines": { - "node": ">= 0.6.0" + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "license": "MIT" + }, + "node_modules/loglevel": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.2.tgz", + "integrity": "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" }, "funding": { "type": "tidelift", @@ -2499,6 +3547,54 @@ "node": "20 || >=22" } }, + "node_modules/magic-string": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.4.tgz", + "integrity": "sha512-jQz9sVhrZuphH4NrAIHSgkDJCluQO7Ioi4KGRLa7aTUjAODQ13hENX0YIytqYE/rIkO485gQG2LeBxJaW53kkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/magicast": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.5.tgz", + "integrity": "sha512-UicdXN8zQ3JHlxVq+28afMXPr1z7WNY6+7EJnzTdQWkTAlMLF5fNCCKxJHBQwGaNGR11581EiQmQzx73+MvszA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "source-map-js": "^1.2.1" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -2627,12 +3723,118 @@ "node": ">=20.19.0" } }, + "node_modules/mongodb-memory-server": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-11.3.0.tgz", + "integrity": "sha512-8ZCDrraqKqmAikoeKuEq+16jeWdVKwjtEAuMxxeQctHiGSGYt17W9LmoRzV1Nwnz7owyxwDKMhow4IVkNYYRKw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "mongodb-memory-server-core": "11.3.0", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/mongodb-memory-server-core": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-11.3.0.tgz", + "integrity": "sha512-QBu/RsRpBfcNd5CrBDfCzqcaFPaYpivUzGYUy9YgVc3up78ff0gIHQVD9PLmBLOOxFX6BM9hU6YT0HocZH+s1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-mutex": "^0.5.0", + "camelcase": "^6.3.0", + "debug": "^4.4.3", + "find-cache-dir": "^3.3.2", + "follow-redirects": "^1.16.0", + "https-proxy-agent": "^7.0.6", + "mongodb": "~7.5.0", + "new-find-package-json": "^2.0.0", + "semver": "^7.8.5", + "tar-stream": "^3.2.1", + "tslib": "^2.8.1", + "yauzl": "^3.4.0" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/mongodb": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.5.0.tgz", + "integrity": "sha512-5FnrEDLnvp6ycUOGLNLLU33BfCx2qmp2mJjGPDwKLruYsVzXVSK5fsGpoDXvsXJwBfBsD7ebMRdawbDxC2814g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.4.11", + "bson": "^7.2.0", + "mongodb-connection-string-url": "^7.0.1" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.806.0", + "@mongodb-js/zstd": "^7.0.0", + "gcp-metadata": "^7.0.1", + "kerberos": "^7.0.0", + "mongodb-client-encryption": "^7.2.0", + "snappy": "^7.3.2", + "socks": "^2.8.6" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -2669,6 +3871,19 @@ "url": "https://opencollective.com/express" } }, + "node_modules/new-find-package-json": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/new-find-package-json/-/new-find-package-json-2.0.0.tgz", + "integrity": "sha512-lDcBsjBSMlj3LXH2v/FW3txlh2pYTjmbOXPYJD93HI5EwuLzI11tdHSIpUMmfq/IOsldj4Ps8M8flhm+pCK4Ew==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">=12.22.0" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2690,16 +3905,34 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz", + "integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==", "license": "MIT", "dependencies": { "ee-first": "1.1.1" }, "engines": { "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/optionator": { @@ -2752,6 +3985,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -2781,6 +4024,21 @@ "node": ">=8" } }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC", + "peer": true + }, "node_modules/picomatch": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", @@ -2794,6 +4052,75 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/possible-typed-array-names": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", @@ -2803,6 +4130,36 @@ "node": ">= 0.4" } }, + "node_modules/postcss": { + "version": "8.5.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz", + "integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -2843,9 +4200,9 @@ "license": "MIT" }, "node_modules/qs": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", - "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", + "version": "6.16.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz", + "integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==", "license": "BSD-3-Clause", "dependencies": { "es-define-property": "^1.0.1", @@ -2882,6 +4239,41 @@ "node": ">= 4" } }, + "node_modules/rolldown": { + "version": "1.2.15", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.15.tgz", + "integrity": "sha512-6odND+fel5zVw3I4Yc2e69gvguDnX0CAAGiNDZSq4ik5WUcaLrkD2GLuog0XcODbor31hZ5ayEMgVDno+KPV5g==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@oxc-project/types": "=0.155.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.15", + "@rolldown/binding-android-arm64": "1.2.15", + "@rolldown/binding-darwin-arm64": "1.2.15", + "@rolldown/binding-darwin-x64": "1.2.15", + "@rolldown/binding-freebsd-x64": "1.2.15", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.15", + "@rolldown/binding-linux-arm64-gnu": "1.2.15", + "@rolldown/binding-linux-arm64-musl": "1.2.15", + "@rolldown/binding-linux-ppc64-gnu": "1.2.15", + "@rolldown/binding-linux-s390x-gnu": "1.2.15", + "@rolldown/binding-linux-x64-gnu": "1.2.15", + "@rolldown/binding-linux-x64-musl": "1.2.15", + "@rolldown/binding-openharmony-arm64": "1.2.15", + "@rolldown/binding-win32-arm64-msvc": "1.2.15", + "@rolldown/binding-win32-x64-msvc": "1.2.15" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -3059,6 +4451,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", @@ -3077,6 +4479,78 @@ "node": ">= 0.8" } }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, + "node_modules/streamx": { + "version": "2.28.1", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz", + "integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==", + "dev": true, + "license": "MIT", + "dependencies": { + "events-universal": "^1.0.0", + "fast-fifo": "^1.3.2", + "text-decoder": "^1.1.0" + } + }, + "node_modules/tar-stream": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.2.2.tgz", + "integrity": "sha512-+8NeqHRjQWH9nYlwo2gamAMImZCVzI4UoEgDpWorBt9OEfppiZn+uSkskzQKPWIZyji/C8fpWO7u69G0DX0tbg==", + "dev": true, + "license": "MIT", + "dependencies": { + "b4a": "^1.9.0", + "bare-fs": "^4.8.2", + "fast-fifo": "^1.3.2", + "streamx": "^2.28.1" + } + }, + "node_modules/teex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz", + "integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "streamx": "^2.12.5" + } + }, + "node_modules/text-decoder": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz", + "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.6.4" + } + }, + "node_modules/tinybench": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.2.tgz", + "integrity": "sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/tinyglobby": { "version": "0.2.17", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", @@ -3094,6 +4568,16 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tinyrainbow": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.2.0.tgz", + "integrity": "sha512-LgO3D9yZJjApUiuUfl9iFAwrtaX4+lok3wJIqttGoKCHlWUqHqbQpnxCf82L8FjgKsh4iGo78hqJwgL8F6To2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/to-buffer": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.2.tgz", @@ -3240,16 +4724,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.1.tgz", - "integrity": "sha512-oiNVPC3/NbV1FpaHU07l8O6ynqG9v4PAiW2WvTrAmZdR0f2HI/gE668ElMLCK7Xbsu5k2fK5C4fXNiq05j7/nQ==", + "version": "8.72.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.0.tgz", + "integrity": "sha512-r26Fkc8As+mZvqp7SLsMmNFyYUup/6CjK7/eHBHmhOw6GH6n6YFxHVFrG0jN1c5CMpDzelLPxvgeCOzx7BjN+A==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.71.1", - "@typescript-eslint/parser": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1", - "@typescript-eslint/utils": "8.71.1" + "@typescript-eslint/eslint-plugin": "8.72.0", + "@typescript-eslint/parser": "8.72.0", + "@typescript-eslint/typescript-estree": "8.72.0", + "@typescript-eslint/utils": "8.72.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3298,6 +4782,168 @@ "node": ">= 0.8" } }, + "node_modules/vite": { + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz", + "integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.30", + "rolldown": "~1.2.14", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.5.tgz", + "integrity": "sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.0.5", + "chai": "^6.3.0", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.4.3", + "obug": "^3.0.0", + "picomatch": "^4.0.7", + "std-env": "^4.3.0", + "tinybench": "^6.2.2", + "tinyexec": "^1.3.1", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.0.5", + "@vitest/browser-preview": "5.0.5", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.0.5", + "@vitest/coverage-v8": "5.0.5", + "@vitest/ui": "5.0.5", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, "node_modules/webidl-conversions": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", @@ -3366,6 +5012,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -3376,6 +5035,19 @@ "node": ">=0.10.0" } }, + "node_modules/yauzl": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-3.4.0.tgz", + "integrity": "sha512-jIH9yLR9wqr0wOS0TpBvo/g/2UgZH5qePVbjgRliiF0BYvOZyaBknKsF+x9Iht0O6sqgnB93rCICdOZFecJuDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pend": "~1.2.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/backend/package.json b/backend/package.json index 3cc36030..bf38285e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -14,7 +14,8 @@ "start": "node dist/server.js", "seed": "tsx seedDataFetch.js", "seed:reset": "tsx seedDataFetch.js --reset", - "lint": "eslint ." + "lint": "eslint .", + "test": "vitest" }, "dependencies": { "@apollo/server": "^5.5.1", @@ -25,11 +26,14 @@ "devDependencies": { "@eslint/js": "^10.0.1", "@types/node": "^26.6.3", + "@vitest/coverage-v8": "^5.0.5", "eslint": "^10.12.0", "eslint-config-prettier": "^10.1.8", "globals": "^17.13.0", + "mongodb-memory-server": "^11.3.0", "tsx": "^4.23.15", "typescript": "~6.0.2", - "typescript-eslint": "^8.71.0" + "typescript-eslint": "^8.71.0", + "vitest": "^5.0.5" } } diff --git a/backend/src/updatePlantImages.ts b/backend/src/updatePlantImages.ts deleted file mode 100644 index f4745709..00000000 --- a/backend/src/updatePlantImages.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { db } from "./db.js"; -import { getWikimediaImage } from "./wikimedia.js"; - -interface PlantDoc { - commonName: string; - scientificName?: string[]; - imageURL?: string | null; -} - -const plants = db.collection("plants"); - -async function updatePlantImages() { - const docs = await plants.find({}).toArray(); - - console.log(`Fant ${docs.length} planter`); - - for (const doc of docs) { - const scientificName = doc.scientificName?.[0]; - - if (!scientificName) { - console.log(`Mangler scientificName: ${doc.commonName}`); - continue; - } - - try { - console.log(`Søker etter: ${scientificName}`); - - const imageURL = await getWikimediaImage(scientificName); - - if (!imageURL) { - console.log(`Fant ikke bilde for ${scientificName}`); - - await plants.updateOne( - { _id: doc._id }, - { - $set: { - imageURL: null, - }, - }, - ); - - continue; - } - - await plants.updateOne( - { _id: doc._id }, - { - $set: { - imageURL, - }, - }, - ); - - console.log(`✓ Oppdaterte ${doc.commonName}`); - } catch (error) { - console.error(`Feil ved henting av bilde for ${scientificName}:`, error); - } - } - - console.log("Ferdig!"); - process.exit(0); -} - -updatePlantImages(); diff --git a/backend/src/wikimedia.ts b/backend/src/wikimedia.ts deleted file mode 100644 index 1a7146e1..00000000 --- a/backend/src/wikimedia.ts +++ /dev/null @@ -1,47 +0,0 @@ -export async function getWikimediaImage(scientificName: string) { - const params = new URLSearchParams({ - action: "query", - generator: "search", - gsrsearch: scientificName, - gsrnamespace: "6", - gsrlimit: "10", - prop: "imageinfo", - iiprop: "url|mime|extmetadata", - format: "json", - origin: "*", - }); - - const response = await fetch( - `https://commons.wikimedia.org/w/api.php?${params}`, - ); - - if (!response.ok) { - throw new Error(`Wikimedia svarte med status ${response.status}`); - } - - const data = await response.json(); - - const pages = data.query?.pages; - - if (!pages) { - return null; - } - - const results = Object.values(pages) as { - imageinfo?: { url?: string; mime?: string }[]; - }[]; - - const allowedMimeTypes = ["image/jpeg", "image/png", "image/webp"]; - - const image = results.find((page) => { - const info = page.imageinfo?.[0]; - - if (!info?.url || !info?.mime) { - return false; - } - - return allowedMimeTypes.includes(info.mime); - }); - - return image?.imageinfo?.[0]?.url ?? null; -} diff --git a/backend/tests/db.test.ts b/backend/tests/db.test.ts new file mode 100644 index 00000000..435245a0 --- /dev/null +++ b/backend/tests/db.test.ts @@ -0,0 +1,92 @@ +import type { MongoClient } from "mongodb"; +import { + afterEach, + beforeEach, + describe, + expect, + inject, + it, + vi, +} from "vitest"; + +vi.mock("dotenv/config", () => ({})); + +// db.ts connects as soon as it is imported, so every test imports a fresh copy +async function importDb() { + vi.resetModules(); + return import("../src/db.js"); +} + +let client: MongoClient | undefined; + +beforeEach(() => { + vi.spyOn(console, "log").mockImplementation(() => {}); +}); + +afterEach(async () => { + await client?.close(); + client = undefined; + vi.unstubAllEnvs(); + vi.restoreAllMocks(); +}); + +describe("db", () => { + it("connects to the database in MONGODB_URI and DB_NAME", async () => { + vi.stubEnv("MONGODB_URI", inject("mongoUri")); + vi.stubEnv("DB_NAME", "test-db"); + + const db = await importDb(); + client = db.client; + + expect(db.db.databaseName).toBe("test-db"); + // The connection really works + await expect(db.db.command({ ping: 1 })).resolves.toMatchObject({ ok: 1 }); + expect(console.log).toHaveBeenCalledWith("Connected to MongoDB"); + }); + + it("uses the iloveplants database when DB_NAME is not set", async () => { + vi.stubEnv("MONGODB_URI", inject("mongoUri")); + vi.stubEnv("DB_NAME", undefined); + + const db = await importDb(); + client = db.client; + + expect(db.db.databaseName).toBe("iloveplants"); + }); + + describe("when things fail", () => { + it.each([ + ["missing", undefined], + ["empty", ""], + ])( + "stops with a message about .env when MONGODB_URI is %s", + async (_, uri) => { + vi.stubEnv("MONGODB_URI", uri); + + await expect(importDb()).rejects.toThrow( + "MONGODB_URI mangler. Kopier .env.example til .env og fyll inn.", + ); + }, + ); + + it("stops with the driver's message when MONGODB_URI is not a MongoDB address", async () => { + vi.stubEnv("MONGODB_URI", "http://localhost:27017"); + + await expect(importDb()).rejects.toThrow(/Invalid scheme/); + }); + + it("stops with a connection error when MongoDB can't be reached", async () => { + // Nothing listens on port 1. This is what happens when the SSH tunnel is down. + vi.stubEnv( + "MONGODB_URI", + "mongodb://127.0.0.1:1/?serverSelectionTimeoutMS=500", + ); + + await expect(importDb()).rejects.toMatchObject({ + name: "MongoServerSelectionError", + message: expect.stringContaining("ECONNREFUSED"), + }); + expect(console.log).not.toHaveBeenCalledWith("Connected to MongoDB"); + }); + }); +}); diff --git a/backend/tests/globalSetup.ts b/backend/tests/globalSetup.ts new file mode 100644 index 00000000..ed217d12 --- /dev/null +++ b/backend/tests/globalSetup.ts @@ -0,0 +1,19 @@ +import { MongoMemoryServer } from "mongodb-memory-server"; +import type { TestProject } from "vitest/node"; + +declare module "vitest" { + export interface ProvidedContext { + mongoUri: string; + } +} + +// Starts one real MongoDB in memory before the tests run, so the tests never +// touch the database on the VM. Test files read its address with inject("mongoUri"). +export default async function setup(project: TestProject) { + const mongo = await MongoMemoryServer.create(); + project.provide("mongoUri", mongo.getUri()); + + return async () => { + await mongo.stop(); + }; +} diff --git a/backend/tests/server.test.ts b/backend/tests/server.test.ts new file mode 100644 index 00000000..42286a7a --- /dev/null +++ b/backend/tests/server.test.ts @@ -0,0 +1,562 @@ +import type { ApolloServer } from "@apollo/server"; +import { Collection, ObjectId, type Db, type MongoClient } from "mongodb"; +import { + afterAll, + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, + vi, +} from "vitest"; + +// The real db.ts connects to the VM. Here it connects to the in-memory MongoDB +// from globalSetup.ts instead, with its own database for this file. +vi.mock("../src/db.js", async () => { + const { MongoClient } = await import("mongodb"); + const { inject } = await import("vitest"); + const client = await MongoClient.connect(inject("mongoUri")); + return { client, db: client.db("server-test") }; +}); + +// Instead of opening a port, remember the server so the tests can send it requests +const { startStandaloneServer } = vi.hoisted(() => ({ + startStandaloneServer: vi.fn(), +})); +vi.mock("@apollo/server/standalone", () => ({ startStandaloneServer })); + +type StartOptions = { listen: { port: number } }; + +// server.ts starts as soon as it is imported, so each call imports a fresh copy. +// Returns the server it started, the options it started with, and the database. +async function importServer() { + vi.resetModules(); + startStandaloneServer.mockClear(); + try { + await import("../src/server.js"); + } finally { + const { client } = await import("../src/db.js"); + clients.push(client); + } + const [server, options] = startStandaloneServer.mock.calls[0] as [ + ApolloServer, + StartOptions, + ]; + const { db } = await import("../src/db.js"); + return { server, options, db }; +} + +const clients: MongoClient[] = []; +let server: ApolloServer; +let db: Db; + +beforeAll(async () => { + vi.spyOn(console, "log").mockImplementation(() => {}); + startStandaloneServer.mockResolvedValue({ url: "http://localhost:3001/" }); + ({ server, db } = await importServer()); +}); + +afterAll(async () => { + await db.dropDatabase(); + await Promise.all(clients.map((client) => client.close())); +}); + +beforeEach(async () => { + await db.collection("plants").deleteMany({}); + await db.collection("users").deleteMany({}); +}); + +afterEach(() => { + vi.unstubAllEnvs(); +}); + +// Sends a GraphQL request like the frontend does, and returns data and errors +async function execute>( + query: string, + variables?: Record, +) { + const response = await server.executeOperation({ query, variables }); + if (response.body.kind !== "single") throw new Error("Expected one result"); + return response.body.singleResult; +} + +// The first error's message and code, which is what the frontend gets to see +const firstError = (result: { + errors?: readonly { message: string; extensions?: Record }[]; +}) => ({ + message: result.errors?.[0]?.message, + code: result.errors?.[0]?.extensions?.code, +}); + +const USER_FIELDS = ` + id + name + description + profilePicture + preferences + matchedPlants { id name } + createdAt +`; + +type User = { + id: string; + name: string | null; + description: string | null; + profilePicture: string; + preferences: string[]; + matchedPlants: { id: string; name: string }[]; + createdAt: string; +}; + +async function createUser(): Promise { + const result = await execute<{ createUser: User }>( + `mutation { createUser { ${USER_FIELDS} } }`, + ); + return result.data!.createUser; +} + +// Adds plants straight to the database and returns their ids +async function insertPlants( + ...plants: Record[] +): Promise { + const { insertedIds } = await db.collection("plants").insertMany(plants); + return Object.values(insertedIds).map((id) => id.toString()); +} + +const getUser = (userId: string) => + execute<{ getUser: User | null }>( + `query ($userId: ID!) { getUser(userId: $userId) { ${USER_FIELDS} } }`, + { userId }, + ); + +const updateProfile = (variables: Record) => + execute<{ updateUserProfile: User | null }>( + `mutation ($userId: ID!, $name: String, $description: String, $profilePicture: String) { + updateUserProfile(userId: $userId, name: $name, description: $description, profilePicture: $profilePicture) { + ${USER_FIELDS} + } + }`, + variables, + ); + +const updatePreferences = (userId: string, preferences: string[]) => + execute<{ updateUserPreferences: User | null }>( + `mutation ($userId: ID!, $preferences: [String!]!) { + updateUserPreferences(userId: $userId, preferences: $preferences) { ${USER_FIELDS} } + }`, + { userId, preferences }, + ); + +const addMatch = (userId: string, plantId: string) => + execute<{ addUserMatch: User | null }>( + `mutation ($userId: ID!, $plantId: ID!) { + addUserMatch(userId: $userId, plantId: $plantId) { ${USER_FIELDS} } + }`, + { userId, plantId }, + ); + +const removeMatch = (userId: string, plantId: string) => + execute<{ removeUserMatch: User | null }>( + `mutation ($userId: ID!, $plantId: ID!) { + removeUserMatch(userId: $userId, plantId: $plantId) { ${USER_FIELDS} } + }`, + { userId, plantId }, + ); + +describe("starting the server", () => { + it("listens on port 3001 and logs the address", async () => { + vi.stubEnv("PORT", undefined); + + const { options } = await importServer(); + + expect(options.listen.port).toBe(3001); + expect(console.log).toHaveBeenCalledWith( + "Server Running at:http://localhost:3001/", + ); + }); + + it("listens on the port in PORT", async () => { + vi.stubEnv("PORT", "4000"); + + const { options } = await importServer(); + + expect(options.listen.port).toBe(4000); + }); + + it("stops with the error when the port is already in use", async () => { + startStandaloneServer.mockRejectedValueOnce( + new Error("listen EADDRINUSE: address already in use :::3001"), + ); + + await expect(importServer()).rejects.toThrow("EADDRINUSE"); + }); +}); + +describe("plants", () => { + // Made-up plants with the same spellings as the real data, e.g. both "Medium" and "Moderate" + const PLANTS = [ + { commonName: "Aloe", watering: "Minimum", careLevel: "Low" }, + { commonName: "Basil", watering: "Frequent", careLevel: "Moderate" }, + { commonName: "Cactus", watering: "minimum", careLevel: "High" }, + { commonName: "Daisy", watering: "Average", careLevel: "Medium" }, + { commonName: "Fern", watering: null, careLevel: null }, + { commonName: "Fern (giant)", watering: "Average", careLevel: "Medium" }, + ]; + + const EXPLORE = ` + query ($search: String, $watering: String, $careLevel: String, $sort: String, $limit: Int, $offset: Int) { + explorePlants(search: $search, watering: $watering, careLevel: $careLevel, sort: $sort, limit: $limit, offset: $offset) { + totalCount + plants { name } + } + } + `; + + type Page = { totalCount: number; plants: { name: string }[] }; + + // The names on one page of results, and the total number of matches + async function explore(variables: Record = {}) { + const result = await execute<{ explorePlants: Page }>(EXPLORE, variables); + expect(result.errors).toBeUndefined(); + const page = result.data!.explorePlants; + return { + names: page.plants.map((p) => p.name), + totalCount: page.totalCount, + }; + } + + beforeEach(async () => { + await insertPlants(...PLANTS.map((p) => ({ ...p }))); + }); + + it("getPlants returns the asked number of different plants", async () => { + const result = await execute<{ getPlants: { id: string }[] }>( + "query { getPlants(limit: 3) { id } }", + ); + + const ids = result.data!.getPlants.map((p) => p.id); + expect(new Set(ids).size).toBe(3); + }); + + it("uses the stored image data before the image URL", async () => { + await db.collection("plants").deleteMany({}); + await insertPlants( + { + commonName: "Both", + imageData: "data:image/png;base64,AAA", + imageURL: "a.png", + }, + { commonName: "Only URL", imageURL: "b.png" }, + { commonName: "No image" }, + ); + + const result = await execute<{ + getPlants: { name: string; imageURL: string | null }[]; + }>("query { getPlants { name imageURL } }"); + + expect( + Object.fromEntries( + result.data!.getPlants.map((p) => [p.name, p.imageURL]), + ), + ).toEqual({ + Both: "data:image/png;base64,AAA", + "Only URL": "b.png", + "No image": null, + }); + }); + + it("explorePlants sorts by name and counts all plants by default", async () => { + expect(await explore()).toEqual({ + names: ["Aloe", "Basil", "Cactus", "Daisy", "Fern", "Fern (giant)"], + totalCount: 6, + }); + }); + + it("searches without caring about case, and reads special characters as text", async () => { + expect((await explore({ search: " fERN " })).names).toEqual([ + "Fern", + "Fern (giant)", + ]); + expect((await explore({ search: "(giant)" })).names).toEqual([ + "Fern (giant)", + ]); + expect((await explore({ search: ".*" })).totalCount).toBe(0); + }); + + it("filters on watering and care level, with Medium and Moderate as the same", async () => { + expect((await explore({ watering: "minimum" })).names).toEqual([ + "Aloe", + "Cactus", + ]); + expect((await explore({ careLevel: "medium" })).names).toEqual([ + "Basil", + "Daisy", + "Fern (giant)", + ]); + expect((await explore({ careLevel: "high" })).names).toEqual(["Cactus"]); + }); + + it("returns one page at a time with the total count", async () => { + expect(await explore({ limit: 2, offset: 2 })).toEqual({ + names: ["Cactus", "Daisy"], + totalCount: 6, + }); + }); + + it.each([ + ["name_desc", ["Fern (giant)", "Fern", "Daisy", "Cactus", "Basil", "Aloe"]], + // Unknown values go last + [ + "watering_asc", + ["Aloe", "Cactus", "Daisy", "Fern (giant)", "Basil", "Fern"], + ], + [ + "careLevel_asc", + ["Aloe", "Basil", "Daisy", "Fern (giant)", "Cactus", "Fern"], + ], + ])("sorts with %s", async (sort, expected) => { + expect((await explore({ sort })).names).toEqual(expected); + }); +}); + +describe("users", () => { + it("createUser makes an empty user and getUser finds it again", async () => { + const user = await createUser(); + + expect(user).toMatchObject({ + name: null, + description: null, + profilePicture: "default", + preferences: [], + matchedPlants: [], + }); + expect((await getUser(user.id)).data?.getUser).toEqual(user); + }); + + it("updateUserProfile trims text, stores empty text as null and only changes sent fields", async () => { + const { id } = await createUser(); + + await updateProfile({ userId: id, name: " Nina ", description: "Hi" }); + const result = await updateProfile({ + userId: id, + description: " ", + profilePicture: "fern", + }); + + expect(result.data?.updateUserProfile).toMatchObject({ + name: "Nina", + description: null, + profilePicture: "fern", + }); + }); + + it("goes back to the default picture when the picture is null", async () => { + const { id } = await createUser(); + await updateProfile({ userId: id, profilePicture: "orchid" }); + + const result = await updateProfile({ userId: id, profilePicture: null }); + + expect(result.data?.updateUserProfile?.profilePicture).toBe("default"); + }); + + it("updateUserPreferences saves preferences without duplicates", async () => { + const { id } = await createUser(); + + const result = await updatePreferences(id, [ + "fullSun", + "easyCare", + "fullSun", + ]); + + expect(result.data?.updateUserPreferences?.preferences).toEqual([ + "fullSun", + "easyCare", + ]); + }); + + it("adds matches once each, in order, and removes them", async () => { + const { id } = await createUser(); + const [orchid, fern] = await insertPlants( + { commonName: "Orchid" }, + { commonName: "Fern" }, + ); + + await addMatch(id, fern); + await addMatch(id, orchid); + const added = await addMatch(id, orchid); + expect(added.data?.addUserMatch?.matchedPlants).toEqual([ + { id: fern, name: "Fern" }, + { id: orchid, name: "Orchid" }, + ]); + + const removed = await removeMatch(id, fern); + expect(removed.data?.removeUserMatch?.matchedPlants).toEqual([ + { id: orchid, name: "Orchid" }, + ]); + }); + + it("skips matched plants that were deleted from the database", async () => { + const { id } = await createUser(); + const [orchid, fern] = await insertPlants( + { commonName: "Orchid" }, + { commonName: "Fern" }, + ); + await addMatch(id, orchid); + await addMatch(id, fern); + await db.collection("plants").deleteOne({ _id: new ObjectId(orchid) }); + + const result = await getUser(id); + + expect(result.data?.getUser?.matchedPlants).toEqual([ + { id: fern, name: "Fern" }, + ]); + }); + + it.each([ + ["an id that does not exist", new ObjectId().toString()], + ["a malformed id", "not-an-id"], + ])("returns null without an error for %s", async (_, userId) => { + expect(await getUser(userId)).toEqual({ data: { getUser: null } }); + expect((await updateProfile({ userId, name: "Nina" })).data).toEqual({ + updateUserProfile: null, + }); + }); +}); + +describe("error messages", () => { + it.each([ + [ + "a name over 40 characters", + { name: "a".repeat(41) }, + "Name can be at most 40 characters", + ], + [ + "a description over 100 characters", + { description: "a".repeat(101) }, + "Description can be at most 100 characters", + ], + [ + "an unknown profile picture", + { profilePicture: "cactus" }, + "Unknown profile picture: cactus", + ], + ])("rejects %s and saves nothing", async (_, changes, message) => { + const { id } = await createUser(); + + const result = await updateProfile({ userId: id, ...changes }); + + expect(firstError(result)).toEqual({ message, code: "BAD_USER_INPUT" }); + expect(result.data?.updateUserProfile).toBeNull(); + expect((await getUser(id)).data?.getUser).toMatchObject({ + name: null, + description: null, + profilePicture: "default", + }); + }); + + it("accepts a name of exactly 40 characters", async () => { + const { id } = await createUser(); + + const result = await updateProfile({ userId: id, name: "a".repeat(40) }); + + expect(result.errors).toBeUndefined(); + }); + + it("lists every unknown preference and saves nothing", async () => { + const { id } = await createUser(); + + const result = await updatePreferences(id, ["fullSun", "rain", "snow"]); + + expect(firstError(result)).toEqual({ + message: "Unknown preferences: rain, snow", + code: "BAD_USER_INPUT", + }); + expect((await getUser(id)).data?.getUser?.preferences).toEqual([]); + }); + + it.each([ + ["a plant that does not exist", new ObjectId().toString()], + ["a malformed plant id", "not-an-id"], + ])("rejects matching %s", async (_, plantId) => { + const { id } = await createUser(); + + const result = await addMatch(id, plantId); + + expect(firstError(result)).toEqual({ + message: `Unknown plant: ${plantId}`, + code: "BAD_USER_INPUT", + }); + expect((await getUser(id)).data?.getUser?.matchedPlants).toEqual([]); + }); + + it("rejects removing a malformed plant id", async () => { + const { id } = await createUser(); + + const result = await removeMatch(id, "not-an-id"); + + expect(firstError(result)).toEqual({ + message: "Unknown plant: not-an-id", + code: "BAD_USER_INPUT", + }); + }); + + it("explains a request for a field that does not exist", async () => { + const result = await execute("query { getPlants { id colour } }"); + + expect(firstError(result)).toEqual({ + message: 'Cannot query field "colour" on type "Plant".', + code: "GRAPHQL_VALIDATION_FAILED", + }); + }); + + it("explains a missing required argument", async () => { + const result = await execute("query { getUser { id } }"); + + expect(firstError(result)).toEqual({ + message: + 'Field "getUser" argument "userId" of type "ID!" is required, but it was not provided.', + code: "GRAPHQL_VALIDATION_FAILED", + }); + }); + + it("explains a variable with the wrong type", async () => { + const result = await execute( + "query ($limit: Int) { getPlants(limit: $limit) { id } }", + { limit: "ten" }, + ); + + expect(firstError(result)).toEqual({ + message: expect.stringContaining( + 'Variable "$limit" got invalid value "ten"', + ), + code: "BAD_USER_INPUT", + }); + }); + + it("explains a request that is not valid GraphQL", async () => { + const result = await execute("query { getPlants { id }"); + + expect(firstError(result)).toEqual({ + message: expect.stringContaining("Syntax Error"), + code: "GRAPHQL_PARSE_FAILED", + }); + }); + + it("passes on the error when the database fails, and keeps running", async () => { + const { id } = await createUser(); + vi.spyOn(Collection.prototype, "findOne").mockRejectedValueOnce( + new Error("connection to MongoDB lost"), + ); + + const failed = await getUser(id); + + expect(firstError(failed)).toEqual({ + message: "connection to MongoDB lost", + code: "INTERNAL_SERVER_ERROR", + }); + expect(failed.data?.getUser).toBeNull(); + // The next request works again + expect((await getUser(id)).data?.getUser?.id).toBe(id); + }); +}); diff --git a/backend/vitest.config.ts b/backend/vitest.config.ts new file mode 100644 index 00000000..9c7598da --- /dev/null +++ b/backend/vitest.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + include: ["tests/**/*.test.ts"], + globalSetup: "./tests/globalSetup.ts", + // Starting MongoDB can be slow, and the first run also downloads it + hookTimeout: 120_000, + coverage: { + include: ["src/**/*.ts"], + }, + }, +}); diff --git a/docs/media/testCoverage.png b/docs/media/testCoverage.png deleted file mode 100644 index 7d4ef0f6..00000000 Binary files a/docs/media/testCoverage.png and /dev/null differ diff --git a/docs/tests.md b/docs/tests.md index f2ba4706..2bee8e63 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -1,7 +1,12 @@ # Tests The application is tested using **Vitest** and **React Testing Library**. We test pages, components and hooks, including rendering, user interactions and functionality. -**Snapshot tests** are also used to ensure that the rendered UI remains consistent when changes are made. +**Snapshot tests** are also used to ensure that the rendered UI remains consistent when changes are made. Both the frontend and backend code was tested as specified below. The test coverage was found to be --- (TODO fyll inn). + + + + +**end-to-end tests** TODO: skriv her The tests cover the following areas: @@ -11,6 +16,9 @@ The tests cover the following areas: - Reusable hooks, including debouncing and storing state in `sessionStorage`. - Accessibility, such as the sidebar navigation landmark and accessible names. +## Test coverage +TODO! Sett inn bilde + ## Overview of test files ### Tests in frontend @@ -42,24 +50,46 @@ The following tests are located in the folder `frontend/src/tests`. ### Tests in backend -TODO! +The following tests are located in the folder `backend/tests`. + +The test in backend uses a mongodb-memory-server that is setup in the `tests/globalSetup.ts`. It keeps its data in memory and is shut down when the tests finish. This is a real in-memory MongoDB, not the database on the VM. The database starts empty, and each test adds the plants and users it needs, so the results are predictable and the real data is never changed. The tests therefore do not need the VPN or the SSH tunnel. The first time the tests run, MongoDB is downloaded once. + +- `globalSetup.ts` + - Not a test file. Starts the in-memory MongoDB before the tests run and stops it afterwards. +- `db.test.ts` + - Tests the database connection in `db.ts`, including that it connects to the database in `MONGODB_URI` and `DB_NAME`, and uses `iloveplants` when `DB_NAME` is not set. Also verifies the error messages when the connection fails: when `MONGODB_URI` is missing or empty, when it is not a MongoDB address, and when MongoDB cannot be reached (for example when the SSH tunnel is down). +- `server.test.ts` + - Tests the GraphQL server in `server.ts`. The database connection is replaced by the in-memory MongoDB, and the server does not open a port, so the tests send their requests directly to the server. + - Plants: random plants from `getPlants`, and search, filters, sorting and pagination in `explorePlants`, including that "Medium" and "Moderate" count as the same care level and that special characters in the search are treated as plain text. + - Users: creating and fetching users, updating the profile and preferences, and adding and removing matched plants. + - Error messages: that invalid input gives the right message and code (`BAD_USER_INPUT`) and saves nothing, for example a name over 40 characters, an unknown profile picture, unknown preferences or an unknown plant. Also verifies the errors for invalid GraphQL requests, and that the server passes on the error and keeps running when the database fails. ## Run tests -- `npm run test` +`npm run test` in the root folder runs both the backend and the frontend tests, and `npm run test:coverage` runs them with test coverage. The same tests run in GitHub Actions on every pull request. To run the tests with coverage for only one part: -### To run tests with test coverage +Frontend: - `cd frontend` - `npm run test -- --coverage` +Backend: + +- `cd backend` +- `npm run test -- --run --coverage` + + +The coverage report is shown in the terminal. A more detailed report is saved in `frontend/coverage/index.html` or `backend/coverage/index.html`, which can be opened in a browser to see which lines are not tested. + ### To run tests with test coverage if not all tests are running - `npx vitest run --coverage --coverage.reportOnFailure=true` -## Test coverage -The table below shows the test coverage for the application. Overall statement and line coverage is above 80%, while branch (66%) and function (74%) coverage is lower. -Files with coverage below 80% will be prioritized for further testing to bring their coverage up. -![Test coverage](media/testCoverage.png) +End-to-end testing: +TODO! fyll inn + + + + diff --git a/frontend/src/tests/App.test.tsx b/frontend/src/tests/App.test.tsx new file mode 100644 index 00000000..05003239 --- /dev/null +++ b/frontend/src/tests/App.test.tsx @@ -0,0 +1,63 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { MemoryRouter } from "react-router-dom"; +import { describe, it, expect, vi } from "vitest"; +import App from "../App"; +import { ROUTES } from "../AppRoutes"; + +vi.mock("react-i18next", () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +// The pages have their own tests, so they are replaced by stand-ins here. +// This keeps the test about which page each route shows. +vi.mock("../pages/plantMatch/PlantMatchPage.tsx", () => ({ + default: () =>

plant match page

, +})); +vi.mock("../pages/explorePlants/ExplorePlants.tsx", () => ({ + default: () =>

explore page

, +})); +vi.mock("../pages/myMatches/MyMatchesPage.tsx", () => ({ + default: () =>

my matches page

, +})); +vi.mock("../pages/profile/Profile.tsx", () => ({ + default: () =>

profile page

, +})); +vi.mock("../components/sidebarButtons/LanguageSwitcher", () => ({ + default: () => null, +})); + +function renderApp(route: string) { + render( + + + , + ); +} + +describe("App", () => { + it.each([ + [ROUTES.plantMatch, "plant match page"], + [ROUTES.explore, "explore page"], + [ROUTES.myMatches, "my matches page"], + [ROUTES.profile, "profile page"], + ])("shows the right page for %s", async (route, page) => { + renderApp(route); + + expect(await screen.findByText(page)).toBeInTheDocument(); + }); + + it("opens the sidebar from the header and closes it again", async () => { + const user = userEvent.setup(); + renderApp(ROUTES.plantMatch); + const header = document.querySelector(".header"); + + expect(header).toHaveAttribute("data-sidebar-open", "false"); + await user.click(screen.getByRole("button", { name: "Open sidebar" })); + expect(header).toHaveAttribute("data-sidebar-open", "true"); + + await user.click(screen.getByRole("link", { name: "sidebar.profile" })); + expect(await screen.findByText("profile page")).toBeInTheDocument(); + expect(header).toHaveAttribute("data-sidebar-open", "false"); + }); +}); diff --git a/frontend/src/tests/Header.test.tsx b/frontend/src/tests/Header.test.tsx new file mode 100644 index 00000000..7293b4c3 --- /dev/null +++ b/frontend/src/tests/Header.test.tsx @@ -0,0 +1,41 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { MemoryRouter } from "react-router-dom"; +import { describe, it, expect, vi } from "vitest"; +import Header from "../components/header/Header"; +import { ROUTES } from "../AppRoutes"; + +vi.mock("react-i18next", () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +function renderHeader(route: string, onOpenSidebar = vi.fn()) { + render( + +
+ , + ); + return onOpenSidebar; +} + +describe("Header", () => { + it.each([ + [ROUTES.plantMatch, "sidebar.plantMatch"], + [ROUTES.explore, "sidebar.explorePlants"], + [ROUTES.myMatches, "sidebar.myMatches"], + [ROUTES.profile, "sidebar.profile"], + ["/unknown-page", "sidebar.plantMatch"], + ])("shows the title for %s", (route, title) => { + renderHeader(route); + + expect(screen.getByRole("heading", { name: title })).toBeInTheDocument(); + }); + + it("opens the sidebar with the menu button", async () => { + const onOpenSidebar = renderHeader(ROUTES.plantMatch); + + await userEvent.click(screen.getByRole("button", { name: "Open sidebar" })); + + expect(onOpenSidebar).toHaveBeenCalledTimes(1); + }); +}); diff --git a/frontend/src/tests/MyMatchesPage.test.tsx b/frontend/src/tests/MyMatchesPage.test.tsx index 47b2d2c8..553be19d 100644 --- a/frontend/src/tests/MyMatchesPage.test.tsx +++ b/frontend/src/tests/MyMatchesPage.test.tsx @@ -1,24 +1,80 @@ -import { cleanup, render, screen } from "@testing-library/react"; -import { afterEach } from "vitest"; -import { describe, it, expect, vi } from "vitest"; +import { fireEvent, render, screen } from "@testing-library/react"; +import { beforeEach, describe, it, expect, vi } from "vitest"; import MyMatchesPage from "../pages/myMatches/MyMatchesPage"; +import type { Plant } from "../types/Plant"; +const { removeUserMatch, useUser } = vi.hoisted(() => ({ + removeUserMatch: vi.fn(), + useUser: vi.fn(), +})); +vi.mock("@apollo/client/react", () => ({ + useMutation: () => [removeUserMatch], +})); +vi.mock("../context/UserContext", () => ({ useUser })); vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key, }), })); -afterEach(() => { - cleanup(); +const orchid: Plant = { + id: "1", + name: "Orchid", + imageURL: null, + scientificName: null, + description: null, + watering: "Average", + sunlight: ["Full sun"], + careLevel: "Easy", +}; + +function mockUser(matchedPlants: Plant[], loading = false) { + useUser.mockReturnValue({ + userId: "user-1", + user: { + id: "user-1", + name: null, + description: null, + profilePicture: "default", + preferences: [], + matchedPlants, + }, + loading, + }); +} + +beforeEach(() => { + removeUserMatch.mockClear(); }); describe("myMatchesPage", () => { it("shows a message when there are no matches", () => { + mockUser([]); render(); + expect(screen.getByText("myMatchesPage.noMatches")).toBeInTheDocument(); + }); + + it("shows the loading state instead of the no matches message", () => { + mockUser([], true); + render(); + + expect(screen.getByText("myMatchesPage.loading")).toBeInTheDocument(); expect( - screen.getByRole("heading", { name: "myMatchesPage.noMatches" }), - ).toBeInTheDocument(); + screen.queryByText("myMatchesPage.noMatches"), + ).not.toBeInTheDocument(); + }); + + it("shows the saved matches and removes one", () => { + mockUser([orchid]); + render(); + + expect(screen.getAllByText("Orchid").length).toBeGreaterThan(0); + fireEvent.click( + screen.getByRole("button", { name: "myMatchesPage.removeMatch" }), + ); + expect(removeUserMatch).toHaveBeenCalledWith({ + variables: { userId: "user-1", plantId: "1" }, + }); }); }); diff --git a/frontend/src/tests/PlantCard.test.tsx b/frontend/src/tests/PlantCard.test.tsx new file mode 100644 index 00000000..75b957da --- /dev/null +++ b/frontend/src/tests/PlantCard.test.tsx @@ -0,0 +1,90 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, it, expect, vi } from "vitest"; +import PlantCard from "../components/plantCard/PlantCard"; + +const { useUser } = vi.hoisted(() => ({ useUser: vi.fn() })); +vi.mock("../context/UserContext", () => ({ useUser })); +vi.mock("react-i18next", () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +useUser.mockReturnValue({ userId: null, user: null, loading: false }); + +// The text of every preference chip on the card +const chips = () => + Array.from(document.querySelectorAll(".plant-preference-chip")).map( + (chip) => chip.textContent, + ); + +describe("PlantCard", () => { + it("shows the full plant on the back after clicking information", async () => { + const user = userEvent.setup(); + const onInfo = vi.fn(); + const { container } = render( + , + ); + + expect(screen.getByRole("img", { name: "Orchid" })).toHaveAttribute( + "src", + "orchid.png", + ); + + await user.click( + screen.getByRole("button", { name: "plantCard.information" }), + ); + + expect(onInfo).toHaveBeenCalledTimes(1); + expect(container.firstChild).toHaveClass("is-flipped"); + expect(screen.getByText("Orchidaceae, Phalaenopsis")).toBeInTheDocument(); + expect(screen.getByText("A flowering plant")).toBeInTheDocument(); + expect(screen.getByText("Full sun, Part shade")).toBeInTheDocument(); + + await user.click(screen.getByRole("button", { name: "plantCard.back" })); + + expect(container.firstChild).not.toHaveClass("is-flipped"); + }); + + it("shows unknown for missing facts and no image", () => { + const { container } = render(); + + expect(screen.queryByRole("img")).not.toBeInTheDocument(); + expect(container.querySelector(".plant-card-image-missing")).not.toBeNull(); + expect(screen.getAllByText("plantCard.unknown")).toHaveLength(3); + expect(screen.queryByRole("group")).not.toBeInTheDocument(); + }); + + it.each([ + ["Minimum", [], null, ["preferences.minimumWater"]], + ["Frequent", [], null, ["preferences.frequentWater"]], + [null, ["Filtered shade"], null, ["preferences.filteredShade"]], + [null, ["Part sun/part shade"], null, ["preferences.partShade"]], + [null, [], "Moderate", ["preferences.mediumCare"]], + [null, [], "Medium", ["preferences.mediumCare"]], + [null, [], "High", ["preferences.hardCare"]], + ])( + "turns watering %s, sunlight %j and care %s into preference chips", + (watering, sunlight, careLevel, expected) => { + render( + , + ); + + expect(chips()).toEqual(expected); + }, + ); +}); diff --git a/frontend/src/tests/PlantMatchPage.test.tsx b/frontend/src/tests/PlantMatchPage.test.tsx index 7ea3d390..a5792aaf 100644 --- a/frontend/src/tests/PlantMatchPage.test.tsx +++ b/frontend/src/tests/PlantMatchPage.test.tsx @@ -2,8 +2,16 @@ import { fireEvent, render, screen } from "@testing-library/react"; import { beforeEach, describe, it, expect, vi } from "vitest"; import PlantMatchPage from "../pages/plantMatch/PlantMatchPage"; -const { useQuery } = vi.hoisted(() => ({ useQuery: vi.fn() })); -vi.mock("@apollo/client/react", () => ({ useQuery })); +const { useQuery, addUserMatch, useUser } = vi.hoisted(() => ({ + useQuery: vi.fn(), + addUserMatch: vi.fn(), + useUser: vi.fn(), +})); +vi.mock("@apollo/client/react", () => ({ + useQuery, + useMutation: () => [addUserMatch], +})); +vi.mock("../context/UserContext", () => ({ useUser })); vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key }), })); @@ -19,8 +27,25 @@ const plants = ["Hydrangea", "Orchid"].map((name, id) => ({ careLevel: "Easy", })); +// A user with the given saved preferences and no matches yet +function mockUser(preferences: string[] = []) { + useUser.mockReturnValue({ + userId: "user-1", + user: { + id: "user-1", + name: null, + description: null, + profilePicture: "default", + preferences, + matchedPlants: [], + }, + loading: false, + }); +} + beforeEach(() => { - localStorage.clear(); + addUserMatch.mockClear(); + mockUser(); useQuery.mockReturnValue({ data: { getPlants: plants }, loading: false, @@ -53,6 +78,20 @@ describe("PlantMatchPage", () => { }, ); + it("saves a liked plant as a match, but not a skipped one", () => { + render(); + fireEvent.click( + screen.getByRole("button", { name: "plantMatchPage.skipPlant" }), + ); + expect(addUserMatch).not.toHaveBeenCalled(); + fireEvent.click( + screen.getByRole("button", { name: "plantMatchPage.likePlant" }), + ); + expect(addUserMatch).toHaveBeenCalledWith({ + variables: { userId: "user-1", plantId: "1" }, + }); + }); + it("shows the loading state", () => { useQuery.mockReturnValue({ loading: true }); render(); @@ -68,7 +107,7 @@ describe("PlantMatchPage", () => { }); it("highlights card preferences saved on the profile", () => { - localStorage.setItem("plantPreferences", JSON.stringify(["averageWater"])); + mockUser(["averageWater"]); render(); expect(screen.getByText("preferences.averageWater")).toHaveClass( "is-match", diff --git a/frontend/src/tests/PlantPreferences.test.tsx b/frontend/src/tests/PlantPreferences.test.tsx new file mode 100644 index 00000000..7e96ec91 --- /dev/null +++ b/frontend/src/tests/PlantPreferences.test.tsx @@ -0,0 +1,106 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { beforeEach, describe, it, expect, vi } from "vitest"; +import PlantPreferences from "../components/plantPreferences/PlantPreferences"; +import type { Preference } from "../types/Preference"; + +const { updatePreferences, useUser } = vi.hoisted(() => ({ + updatePreferences: vi.fn(), + useUser: vi.fn(), +})); +vi.mock("@apollo/client/react", () => ({ + useMutation: () => [updatePreferences], +})); +vi.mock("../context/UserContext", () => ({ useUser })); +vi.mock("react-i18next", () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +const preferences: Preference[] = [ + { id: "averageWater", translationKey: "preferences.averageWater" }, + { id: "fullSun", translationKey: "preferences.fullSun" }, +]; + +function mockUser(selected: string[], userId: string | null = "user-1") { + useUser.mockReturnValue({ + userId, + user: userId ? { id: userId, preferences: selected } : null, + loading: false, + }); +} + +// The preferences sent in the last save +const savedPreferences = () => + updatePreferences.mock.lastCall?.[0].variables.preferences; + +describe("PlantPreferences", () => { + beforeEach(() => { + updatePreferences.mockReset(); + updatePreferences.mockResolvedValue({}); + }); + + it("marks the preferences saved on the user", () => { + mockUser(["fullSun"]); + render(); + + expect( + screen.getByRole("button", { name: "preferences.fullSun" }), + ).toHaveClass("selected"); + expect( + screen.getByRole("button", { name: "preferences.averageWater" }), + ).not.toHaveClass("selected"); + }); + + it("adds a preference that is not selected", async () => { + mockUser(["fullSun"]); + render(); + + await userEvent.click( + screen.getByRole("button", { name: "preferences.averageWater" }), + ); + + expect(savedPreferences()).toEqual(["fullSun", "averageWater"]); + // The buttons change right away instead of waiting for the server + expect(updatePreferences.mock.lastCall?.[0].optimisticResponse).toEqual({ + updateUserPreferences: { + __typename: "User", + id: "user-1", + preferences: ["fullSun", "averageWater"], + }, + }); + }); + + it("removes a preference that is already selected", async () => { + mockUser(["fullSun", "averageWater"]); + render(); + + await userEvent.click( + screen.getByRole("button", { name: "preferences.fullSun" }), + ); + + expect(savedPreferences()).toEqual(["averageWater"]); + }); + + it("does not crash when saving fails", async () => { + mockUser([]); + updatePreferences.mockRejectedValue(new Error("Offline")); + render(); + + await userEvent.click( + screen.getByRole("button", { name: "preferences.fullSun" }), + ); + + expect(updatePreferences).toHaveBeenCalledTimes(1); + }); + + it("saves nothing before the user exists", async () => { + mockUser([], null); + render(); + + await userEvent.click( + screen.getByRole("button", { name: "preferences.fullSun" }), + ); + + expect(updatePreferences).not.toHaveBeenCalled(); + }); +}); diff --git a/frontend/src/tests/Profile.test.tsx b/frontend/src/tests/Profile.test.tsx index 23fc8847..0f0b32d7 100644 --- a/frontend/src/tests/Profile.test.tsx +++ b/frontend/src/tests/Profile.test.tsx @@ -1,9 +1,18 @@ -import { render, screen } from "@testing-library/react"; +import { render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { beforeEach, describe, it, expect, vi } from "vitest"; import Profile from "../pages/profile/Profile"; +const { updateProfile, useUser } = vi.hoisted(() => ({ + updateProfile: vi.fn(), + useUser: vi.fn(), +})); +vi.mock("@apollo/client/react", () => ({ + useMutation: () => [updateProfile], +})); +vi.mock("../context/UserContext", () => ({ useUser })); + vi.mock("react-i18next", () => ({ useTranslation: () => ({ t: (key: string) => key, @@ -12,9 +21,27 @@ vi.mock("react-i18next", () => ({ describe("Profile page", () => { beforeEach(() => { - localStorage.clear(); + updateProfile.mockReset(); + updateProfile.mockResolvedValue({}); + mockUser(); }); + // A user who has not filled in their profile yet + function mockUser(profilePicture = "default") { + useUser.mockReturnValue({ + userId: "user-1", + user: { + id: "user-1", + name: null, + description: null, + profilePicture, + preferences: [], + matchedPlants: [], + }, + loading: false, + }); + } + it("renders profile name", () => { render(); @@ -90,7 +117,9 @@ describe("Profile page", () => { await user.click( screen.getByRole("button", { name: "profile.editProfile" }), ); - const nameInput = screen.getByRole("textbox", { name: "profile.enterName" }); + const nameInput = screen.getByRole("textbox", { + name: "profile.enterName", + }); const descriptionInput = screen.getByRole("textbox", { name: "profile.aboutYou", }); @@ -99,19 +128,54 @@ describe("Profile page", () => { await user.clear(descriptionInput); await user.type(descriptionInput, "I love plants"); - const avatar = screen.getByRole("button", { name: "Choose profile.monstera" }); - const avatarSrc = screen.getByAltText("profile.monstera").getAttribute("src"); - await user.click(avatar); + await user.click( + screen.getByRole("button", { name: "Choose profile.monstera" }), + ); + // The typed text is shown right away expect(screen.getByRole("heading", { name: "Nina" })).toBeInTheDocument(); expect(screen.getByText("I love plants")).toBeInTheDocument(); - expect(avatar).toHaveAttribute("aria-pressed", "true"); expect( screen.getByRole("img", { name: "profile.imageAlt: Nina" }), - ).toHaveAttribute("src", avatarSrc); - expect(localStorage.getItem("profileName")).toBe("Nina"); - expect(localStorage.getItem("description")).toBe("I love plants"); - expect(localStorage.getItem("profileAvatar")).toBe("monstera"); + ).toBeInTheDocument(); + + // The avatar is saved at once, with an optimistic response + expect(updateProfile).toHaveBeenCalledWith( + expect.objectContaining({ + variables: { userId: "user-1", profilePicture: "monstera" }, + }), + ); + + // Name and description are saved after the user stops typing + await waitFor(() => + expect(updateProfile).toHaveBeenCalledWith({ + variables: { + userId: "user-1", + name: "Nina", + description: "I love plants", + }, + }), + ); + }); + + it("shows the avatar saved on the user", async () => { + const user = userEvent.setup(); + mockUser("monstera"); + + render(); + await user.click( + screen.getByRole("button", { name: "profile.editProfile" }), + ); + + expect( + screen.getByRole("button", { name: "Choose profile.monstera" }), + ).toHaveAttribute("aria-pressed", "true"); + expect( + screen.getByRole("img", { name: "profile.imageAlt: profile.name" }), + ).toHaveAttribute( + "src", + screen.getByAltText("profile.monstera").getAttribute("src"), + ); }); it("matches snapshot", () => { diff --git a/frontend/src/tests/ThemeToggle.test.tsx b/frontend/src/tests/ThemeToggle.test.tsx new file mode 100644 index 00000000..c20cf06e --- /dev/null +++ b/frontend/src/tests/ThemeToggle.test.tsx @@ -0,0 +1,32 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { afterEach, describe, it, expect, vi } from "vitest"; +import ThemeToggle from "../components/sidebarButtons/ThemeToggle"; + +vi.mock("react-i18next", () => ({ + useTranslation: () => ({ t: (key: string) => key }), +})); + +describe("ThemeToggle", () => { + afterEach(() => { + document.documentElement.removeAttribute("data-theme"); + }); + + it("switches between dark and light mode", async () => { + const user = userEvent.setup(); + render(); + + await user.click( + screen.getByRole("button", { name: "sidebar.switchToDarkMode" }), + ); + expect(document.documentElement).toHaveAttribute("data-theme", "dark"); + + await user.click( + screen.getByRole("button", { name: "sidebar.switchToLightMode" }), + ); + expect(document.documentElement).toHaveAttribute("data-theme", "light"); + expect( + screen.getByRole("button", { name: "sidebar.switchToDarkMode" }), + ).toBeInTheDocument(); + }); +}); diff --git a/frontend/src/tests/UserContext.test.tsx b/frontend/src/tests/UserContext.test.tsx new file mode 100644 index 00000000..969ad942 --- /dev/null +++ b/frontend/src/tests/UserContext.test.tsx @@ -0,0 +1,146 @@ +import type { ComponentProps } from "react"; +import { render, screen, waitFor } from "@testing-library/react"; +import { MockedProvider } from "@apollo/client/testing/react"; +import { beforeEach, describe, it, expect, vi } from "vitest"; +import { UserProvider, useUser } from "../context/UserContext"; +import { CREATE_USER, GET_USER } from "../context/userQueries"; + +type Mocks = ComponentProps["mocks"]; + +// A user as the backend returns it +function makeUser(id: string, name: string | null = null) { + return { + __typename: "User", + id, + name, + description: null, + profilePicture: "default", + preferences: [], + matchedPlants: [], + }; +} + +function getUserMock(userId: string, user: ReturnType | null) { + return { + request: { query: GET_USER, variables: { userId } }, + result: { data: { getUser: user } }, + }; +} + +// `result` is a spy, so tests can check whether a user was created +function createUserMock(user: ReturnType) { + return { + request: { query: CREATE_USER }, + result: vi.fn(() => ({ data: { createUser: user } })), + }; +} + +// Shows what the context gives its children +function UserInfo() { + const { userId, user, loading } = useUser(); + return ( +
+

{userId ?? "none"}

+

{user?.name ?? "none"}

+

{String(loading)}

+
+ ); +} + +function setup(mocks: Mocks) { + return render( + + + + + , + ); +} + +describe("UserContext", () => { + beforeEach(() => { + localStorage.clear(); + }); + + it("gives no user without a UserProvider", () => { + render(); + + expect(screen.getByTestId("user-id")).toHaveTextContent("none"); + expect(screen.getByTestId("user-name")).toHaveTextContent("none"); + expect(screen.getByTestId("loading")).toHaveTextContent("false"); + }); + + it("loads the user saved in the browser", async () => { + localStorage.setItem("userId", "user-1"); + const create = createUserMock(makeUser("new-user")); + setup([getUserMock("user-1", makeUser("user-1", "Nina")), create]); + + expect(screen.getByTestId("loading")).toHaveTextContent("true"); + expect(await screen.findByText("Nina")).toBeInTheDocument(); + expect(screen.getByTestId("user-id")).toHaveTextContent("user-1"); + expect(create.result).not.toHaveBeenCalled(); + }); + + it("creates and saves a new user on the first visit", async () => { + const create = createUserMock(makeUser("new-user", "New")); + setup([create, getUserMock("new-user", makeUser("new-user", "New"))]); + + expect(await screen.findByText("New")).toBeInTheDocument(); + expect(screen.getByTestId("user-id")).toHaveTextContent("new-user"); + expect(localStorage.getItem("userId")).toBe("new-user"); + expect(create.result).toHaveBeenCalledTimes(1); + }); + + it("creates a new user when the saved one no longer exists", async () => { + localStorage.setItem("userId", "deleted-user"); + const create = createUserMock(makeUser("new-user", "New")); + setup([ + getUserMock("deleted-user", null), + create, + getUserMock("new-user", makeUser("new-user", "New")), + ]); + + expect(await screen.findByText("New")).toBeInTheDocument(); + expect(localStorage.getItem("userId")).toBe("new-user"); + }); + + it("keeps the saved user when the backend is down", async () => { + localStorage.setItem("userId", "user-1"); + const create = createUserMock(makeUser("new-user")); + setup([ + { + request: { query: GET_USER, variables: { userId: "user-1" } }, + error: new Error("Offline"), + }, + create, + ]); + + await waitFor(() => + expect(screen.getByTestId("loading")).toHaveTextContent("false"), + ); + expect(screen.getByTestId("user-id")).toHaveTextContent("user-1"); + expect(create.result).not.toHaveBeenCalled(); + expect(localStorage.getItem("userId")).toBe("user-1"); + }); + + it("keeps working when creating a user fails", async () => { + setup([{ request: { query: CREATE_USER }, error: new Error("Offline") }]); + + await waitFor(() => + expect(screen.getByTestId("loading")).toHaveTextContent("false"), + ); + expect(screen.getByTestId("user-id")).toHaveTextContent("none"); + expect(localStorage.getItem("userId")).toBeNull(); + }); + + it("removes user data left in the browser from before the database", () => { + localStorage.setItem("userId", "user-1"); + localStorage.setItem("matchedPlants", "[]"); + localStorage.setItem("profileName", "Nina"); + setup([getUserMock("user-1", makeUser("user-1"))]); + + expect(localStorage.getItem("matchedPlants")).toBeNull(); + expect(localStorage.getItem("profileName")).toBeNull(); + expect(localStorage.getItem("userId")).toBe("user-1"); + }); +}); diff --git a/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap b/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap index 63f475c9..35f7af01 100644 --- a/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap +++ b/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap @@ -22,6 +22,21 @@ exports[`ExplorePlants > snapshots > matches the snapshot of the page with no re > ExplorePlants.search + snapshots > matches the snapshot of the page with resul > ExplorePlants.search + snapshots > matches the snapshot of the page with resul > Testplante 1 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 2 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 3 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 4 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 5 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 6 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 7 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 8 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 9 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 10 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 11 + + + +
  • snapshots > matches the snapshot of the page with resul > Testplante 12 + + + +