diff --git a/docs/ai-usage.md b/docs/ai-usage.md index 7b75d5e..30889bc 100644 --- a/docs/ai-usage.md +++ b/docs/ai-usage.md @@ -7,4 +7,17 @@ This file documents how we use AI tools in the project. | Tool | Used for | How we checked the output | | --- | --- | --- | | Claude (Anthropic) / Opus 5.5 (medium)| Refactoring our written specification into a structured README format. | The group wrote the content and made all decisions: app idea, dataset, data model, functionality and tech stack. We reviewed the result against our own notes and the project requirements, and corrected inconsistencies before committing. | -| Claude (Anthropic) / Sonnet 5 | Scaffolding the backend (`server/`): project setup, Mongoose schema/index design, the `averageScore`/`reviewCount` recompute strategy for ratings, the CSV ingestion script, GraphQL resolvers, and integration tests. Database choice (MongoDB) was decided by the group. | We reviewed the generated code against the README's data model and functionality requirements, checked proposed package versions for compatibility, and verified behavior by running the backend locally against Apollo Sandbox and the automated test suite before committing. | \ No newline at end of file +| Claude (Anthropic) / Sonnet 5 | Scaffolding the backend (`server/`): project setup, Mongoose schema/index design, the `averageScore`/`reviewCount` recompute strategy for ratings, the CSV ingestion script, GraphQL resolvers, and integration tests. Database choice (MongoDB) was decided by the group. | We reviewed the generated code against the README's data model and functionality requirements, checked proposed package versions for compatibility, and verified behavior by running the backend locally against Apollo Sandbox and the automated test suite before committing. | + +## Delivery 2 + +| Tool | Used for | How we checked the output | +| --- | --- | --- | +| Claude (Anthropic) / Sonnet 5 | Writing tests, keeping documentation in sync with new features and decisions, and assisting with debugging and error handling. | We reviewed and ran the tests locally, read through the documentation changes for accuracy, and verified fixes by reproducing the original issues before committing. | + +## Delivery 3 + +| Tool | Used for | How we checked the output | +| --- | --- | --- | +| Claude (Anthropic) / Sonnet 5 | Same as Delivery 2: writing tests, keeping documentation in sync with new features and decisions, and assisting with debugging and error handling. | We reviewed and ran the tests locally, read through the documentation changes for accuracy, and verified fixes by reproducing the original issues before committing. | +| Claude (Anthropic) / Opus 5.5 | Assisting with error handling during deployment to the VM. | We tested the deployment on the VM and confirmed the errors were resolved before committing. | \ No newline at end of file diff --git a/frontend/.gitignore b/frontend/.gitignore index a547bf3..0bced94 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -12,6 +12,9 @@ dist dist-ssr *.local +# Env +.env + # Editor directories and files .vscode/* !.vscode/extensions.json @@ -22,3 +25,6 @@ dist-ssr *.njsproj *.sln *.sw? + +# Vitest reports and artifacts +.vitest/ \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index d4263e3..b20be89 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - it2810-t33-p2 + NTNU GameShelf
diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 5a1d157..33da54e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -24,6 +24,9 @@ "@babel/core": "^7.29.7", "@eslint/js": "^10.0.1", "@rolldown/plugin-babel": "^0.2.3", + "@testing-library/jest-dom": "^7.0.1", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.12", "@types/babel__core": "^7.20.5", "@types/node": "^24.13.3", "@types/react": "^19.2.18", @@ -35,12 +38,21 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.6", "globals": "^17.12.0", + "jsdom": "^31.0.1", "prettier": "3.9.9", "typescript": "~6.0.2", "typescript-eslint": "^8.69.0", - "vite": "^8.3.0" + "vite": "^8.3.0", + "vitest": "^5.1.0" } }, + "node_modules/@adobe/css-tools": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.5.0.tgz", + "integrity": "sha512-6OzddxPio9UiWTCemp4N8cYLV2ZN1ncRnV1cVGtve7dhPOtRkleRyx32GQCYSwDYgaHU3USMm84tNsvKzRCa1Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@apollo/client": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/@apollo/client/-/client-4.3.1.tgz", @@ -479,6 +491,24 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, + "node_modules/@exodus/bytes": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz", + "integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, "node_modules/@graphql-typed-document-node/core": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", @@ -1041,6 +1071,113 @@ "tslib": "^2.8.0" } }, + "node_modules/@testing-library/dom": { + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.2.tgz", + "integrity": "sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "picocolors": "1.1.1", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/jest-dom": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-7.0.1.tgz", + "integrity": "sha512-oMDTC3oA+6CXSO2JZnvOI7CA6oVub6kij5ggk9ohwye5slmkwxYDXcPOVxgMw/RQlticjtO0C1RZkR97HgrWMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "picocolors": "^1.1.1", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=22", + "npm": ">=6", + "yarn": ">=1" + }, + "peerDependencies": { + "@testing-library/dom": ">=10 <11", + "vitest": ">= 0.32" + }, + "peerDependenciesMeta": { + "vitest": { + "optional": true + } + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/react": { + "version": "16.3.3", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.3.tgz", + "integrity": "sha512-Uo193NgQbPMz6lrrhtRQQFcMC6Re/ELLFbbuVL30WDlZxlpZf9/lMHTAVxPRLw1q1iu9OJmR1c2BLiENRstdBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0 || ^19.0.0", + "@types/react-dom": "^18.0.0 || ^19.0.0", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@testing-library/user-event": { + "version": "14.6.12", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.12.tgz", + "integrity": "sha512-8yQV8v+eToBhsUO4oYrZY7fzhpTEMZx4IDx0/iuER/x0Xuy0NdqQOhsaaUNlvXE03N7vQ+4RCXUieKC0NJty9w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "peerDependencies": { + "@testing-library/dom": ">=7.21.4" + } + }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -1086,6 +1223,24 @@ "@babel/types": "^7.28.2" } }, + "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", @@ -1430,6 +1585,44 @@ } } }, + "node_modules/@vitest/mocker": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.0.tgz", + "integrity": "sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.1.0", + "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.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.0.tgz", + "integrity": "sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/@wry/caches": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@wry/caches/-/caches-1.0.1.tgz", @@ -1518,6 +1711,31 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/aria-hidden": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/aria-hidden/-/aria-hidden-1.2.6.tgz", @@ -1530,6 +1748,26 @@ "node": ">=10" } }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "dequal": "^2.0.3" + } + }, + "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/babel-plugin-react-compiler": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-1.0.0.tgz", @@ -1563,6 +1801,33 @@ "node": ">=6.0.0" } }, + "node_modules/bcp-47": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.2.tgz", + "integrity": "sha512-wsv86UuNFuPnVieKLyECTT+CP1WSAHeoIg5P3xu2kA9Z+7fVPoKt7dxzSeEhtJel0AI+NW3fIW3KtTKQKUCngg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-match": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz", + "integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/bootstrap": { "version": "5.3.8", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz", @@ -1664,6 +1929,16 @@ ], "license": "CC-BY-4.0" }, + "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/classnames": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz", @@ -1720,12 +1995,33 @@ "integrity": "sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q==", "license": "BSD" }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true, + "license": "MIT" + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "license": "MIT" }, + "node_modules/data-urls": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz", + "integrity": "sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.1.2" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1744,6 +2040,13 @@ } } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1770,6 +2073,14 @@ "node": ">=8" } }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/dom-helpers": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", @@ -1787,6 +2098,26 @@ "dev": true, "license": "ISC" }, + "node_modules/entities": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "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/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -2001,6 +2332,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", @@ -2011,6 +2352,16 @@ "node": ">=0.10.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", @@ -2208,6 +2559,19 @@ "dev": true, "license": "MIT" }, + "node_modules/html-encoding-sniffer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz", + "integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.15.1" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" + } + }, "node_modules/hyphenate-style-name": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.1.0.tgz", @@ -2234,6 +2598,16 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -2243,6 +2617,43 @@ "loose-envify": "^1.0.0" } }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2266,6 +2677,13 @@ "node": ">=0.10.0" } }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -2279,6 +2697,54 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "license": "MIT" }, + "node_modules/jsdom": { + "version": "31.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz", + "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.16.0", + "bcp-47": "^2.1.2", + "bcp-47-match": "^2.0.3", + "data-urls": "^8.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^7.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.3", + "parse5": "^8.1.0", + "parse5-parser-stream": "^8.1.0", + "saxes": "^6.0.0", + "tough-cookie": "^6.0.2", + "undici": "^8.12.3", + "w3c-xmlserializer": "^6.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.3.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + }, + "peerDependencies": { + "@napi-rs/canvas": "^1.0.13" + }, + "peerDependenciesMeta": { + "@napi-rs/canvas": { + "optional": true + } + } + }, + "node_modules/jsdom/node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/jsesc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", @@ -2642,6 +3108,27 @@ "yallist": "^3.0.2" } }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "lz-string": "bin/bin.js" + } + }, + "node_modules/magic-string": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, "node_modules/matchmediaquery": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/matchmediaquery/-/matchmediaquery-0.4.2.tgz", @@ -2651,6 +3138,16 @@ "css-mediaquery": "^0.1.2" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/minimatch": { "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", @@ -2718,6 +3215,20 @@ "node": ">=0.10.0" } }, + "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/optimism": { "version": "0.18.1", "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.18.1.tgz", @@ -2780,6 +3291,32 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse5": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^9.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz", + "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parse5": "^8.1.1" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2874,6 +3411,30 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -3114,6 +3675,20 @@ "react-dom": ">=16.6.0" } }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/rolldown": { "version": "1.2.15", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.15.tgz", @@ -3156,6 +3731,19 @@ "tslib": "^2.1.0" } }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/scheduler": { "version": "0.28.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", @@ -3216,6 +3804,46 @@ "node": ">=0.10.0" } }, + "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/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tinybench": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.3.tgz", + "integrity": "sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==", + "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", @@ -3233,6 +3861,52 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tldts": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.4.tgz", + "integrity": "sha512-Rn2ABgjHZrA+jzqom5zhxA0hLohzYrIgfCPyhpTUxqsUrcsBYuab49LseR9waB9Jr8/MxdodvMHA91oRiGLO3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.5.4" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.4.tgz", + "integrity": "sha512-9+4zWtKEDZ3V3FoZ1B97rv+5z5oqp7yeXGVze3CxgQ+CJro9do9DCPD00wxstYZDXDMXsurkBerFfiB6GYtPbA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz", + "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz", + "integrity": "sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/ts-api-utils": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", @@ -3318,6 +3992,16 @@ "react": ">=15.0.0" } }, + "node_modules/undici": { + "version": "8.12.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.4.tgz", + "integrity": "sha512-8Mx+uNKKER2bA4AdtedkqRbwUCIJFr2nJckXRe5yrDqzePqwLP7VNcctN8/XdmDSbF7mS+jJKIszlL+vbam1VA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/undici-types": { "version": "7.24.6", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", @@ -3464,6 +4148,102 @@ } } }, + "node_modules/vitest": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.0.tgz", + "integrity": "sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.1.0", + "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.1.0", + "@vitest/browser-preview": "5.1.0", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.1.0", + "@vitest/coverage-v8": "5.1.0", + "@vitest/ui": "5.1.0", + "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/w3c-xmlserializer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz", + "integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, "node_modules/warning": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", @@ -3473,6 +4253,41 @@ "loose-envify": "^1.0.0" } }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "17.3.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz", + "integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.16.0", + "tr46": "^7.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -3489,6 +4304,19 @@ "node": ">= 8" } }, + "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", @@ -3499,6 +4327,23 @@ "node": ">=0.10.0" } }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 1fb9ebe..23d983e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", - "preview": "vite preview" + "preview": "vite preview", + "test": "vitest" }, "dependencies": { "@apollo/client": "^4.3.1", @@ -26,6 +27,9 @@ "@babel/core": "^7.29.7", "@eslint/js": "^10.0.1", "@rolldown/plugin-babel": "^0.2.3", + "@testing-library/jest-dom": "^7.0.1", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.12", "@types/babel__core": "^7.20.5", "@types/node": "^24.13.3", "@types/react": "^19.2.18", @@ -37,9 +41,11 @@ "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.6", "globals": "^17.12.0", + "jsdom": "^31.0.1", "prettier": "3.9.9", "typescript": "~6.0.2", "typescript-eslint": "^8.69.0", - "vite": "^8.3.0" + "vite": "^8.3.0", + "vitest": "^5.1.0" } } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index cc94a32..b430de1 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,6 @@ import "bootstrap/dist/css/bootstrap.min.css"; import { BrowserRouter, Route, Routes } from "react-router-dom"; -import GamesGrid from "./pages/GamesGrid/GamesGrid"; +import GamesGrid from "./pages/GamesGrid"; import GameDetails from "./pages/GameDetails"; import MyRatings from "./pages/MyRatings"; diff --git a/frontend/src/components/GameListItem.test.tsx b/frontend/src/components/GameListItem.test.tsx new file mode 100644 index 0000000..098c814 --- /dev/null +++ b/frontend/src/components/GameListItem.test.tsx @@ -0,0 +1,46 @@ +import { describe, expect, it } from "vitest"; +import { render, screen } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; +import GameListItem from "./GameListItem"; + +function renderItem(overrides: Partial[0]> = {}) { + return render( + + + , + ); +} + +describe("GameListItem", () => { + it("renders the title, year, tags and image", () => { + renderItem(); + expect(screen.getByText("Great Game")).toBeInTheDocument(); + expect(screen.getByText("2020")).toBeInTheDocument(); + expect(screen.getByText("Action, Adventure")).toBeInTheDocument(); + expect(screen.getByRole("img", { name: "Great Game" })).toHaveAttribute("src", "/game.png"); + }); + + it("falls back to N/A when year or tags are missing", () => { + renderItem({ year: null, tags: "" }); + expect(screen.getAllByText("N/A")).toHaveLength(2); + }); + + it("links to the game's detail page", () => { + renderItem({ id: "456" }); + expect(screen.getByRole("link")).toHaveAttribute("href", "/project2/games/456"); + }); + + it("renders the star rating for the given score", () => { + renderItem({ rating: 10 }); + expect(screen.getByText("5/5 stars")).toBeInTheDocument(); + }); +}); diff --git a/frontend/src/components/GameListItem.tsx b/frontend/src/components/GameListItem.tsx new file mode 100644 index 0000000..ca55737 --- /dev/null +++ b/frontend/src/components/GameListItem.tsx @@ -0,0 +1,45 @@ +import { Image } from "react-bootstrap"; +import { Link } from "react-router-dom"; +import { resizedImage } from "../utils/resizedImage"; +import StarRating from "./StarRating"; + +interface GameListItemProps { + id: string; + title: string; + year: number | null; + tags: string; + rating: number | null; + image: string; + striped: boolean; +} + +export default function GameListItem({ + id, + title, + year, + tags, + rating, + image, + striped, +}: GameListItemProps) { + return ( + + {title} +
+

{title}

+

{year ?? N/A}

+

{tags || N/A}

+ +
+ + ); +} diff --git a/frontend/src/components/GameListItem/GameListItem.module.css b/frontend/src/components/GameListItem/GameListItem.module.css deleted file mode 100644 index 7c5a6c5..0000000 --- a/frontend/src/components/GameListItem/GameListItem.module.css +++ /dev/null @@ -1,36 +0,0 @@ -.row { - display: flex; - align-items: center; - flex: 1 1 0; - min-height: var(--row-min-height); - gap: 1.5rem; - padding: 0 1.5rem; - color: inherit; - text-decoration: none; -} - -.odd { - background-color: var(--color-stripe-odd); -} - -.even { - background-color: var(--color-stripe-even); -} - -.image { - width: 95px; - height: 95px; - object-fit: cover; - background-color: #ddd; - flex-shrink: 0; -} - -.info p { - margin: 0; -} - -.title { - margin: 0 0 0.25rem; - font-size: 1.1rem; - font-weight: 700; -} diff --git a/frontend/src/components/GameListItem/GameListItem.tsx b/frontend/src/components/GameListItem/GameListItem.tsx deleted file mode 100644 index 9c6953a..0000000 --- a/frontend/src/components/GameListItem/GameListItem.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { Image } from "react-bootstrap"; -import { Link } from "react-router-dom"; -import styles from "./GameListItem.module.css"; -import StarRating from "../StarRating"; - -interface GameListItemProps { - id: string; - title: string; - year: number | null; - tags: string; - rating: number | null; - image: string; - striped: boolean; -} - -export default function GameListItem({ - id, - title, - year, - tags, - rating, - image, - striped, -}: GameListItemProps) { - return ( - - {title} -
-

{title}

-

{year ?? "—"}

-

{tags || "—"}

- {/*

{rating != null ? `${Number.isInteger(rating) ? rating.toFixed(0) : rating.toFixed(1)}/10` : "Not yet rated"}

*/} - -
- - ); -} diff --git a/frontend/src/components/Header.test.tsx b/frontend/src/components/Header.test.tsx new file mode 100644 index 0000000..31d4cf1 --- /dev/null +++ b/frontend/src/components/Header.test.tsx @@ -0,0 +1,80 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { MemoryRouter } from "react-router-dom"; +import Header from "./Header"; +import { GRID_QUERY_STORAGE_KEY } from "../constants/storageKeys"; + +const navigateMock = vi.fn(); + +vi.mock("react-router-dom", async (importOriginal) => { + const actual = await importOriginal(); + return { ...actual, useNavigate: () => navigateMock }; +}); + +function renderHeader(initialEntry: string) { + return render( + +
+ , + ); +} + +describe("Header", () => { + beforeEach(() => { + navigateMock.mockClear(); + sessionStorage.clear(); + }); + + it("renders the wordmark, search field and My Ratings link", () => { + renderHeader("/project2"); + expect(screen.getByText("NTNU GameShelf")).toBeInTheDocument(); + expect(screen.getByPlaceholderText("Search games...")).toHaveValue(""); + expect(screen.getByText("My Ratings")).toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "Clear" })).not.toBeInTheDocument(); + }); + + it("prefills the search field from the current search param", () => { + renderHeader("/project2?search=zelda"); + expect(screen.getByPlaceholderText("Search games...")).toHaveValue("zelda"); + expect(screen.getByRole("button", { name: "Clear" })).toBeInTheDocument(); + }); + + it("navigates with the trimmed search term on submit", async () => { + const user = userEvent.setup(); + renderHeader("/project2"); + await user.type(screen.getByPlaceholderText("Search games..."), " mario "); + await user.click(screen.getByRole("button", { name: "Search" })); + expect(navigateMock).toHaveBeenCalledWith("/project2/?search=mario"); + }); + + it("clears the search term and navigates without it", async () => { + const user = userEvent.setup(); + renderHeader("/project2?search=zelda"); + await user.click(screen.getByRole("button", { name: "Clear" })); + expect(screen.getByPlaceholderText("Search games...")).toHaveValue(""); + expect(navigateMock).toHaveBeenCalledWith("/project2/?"); + }); + + it("links home to the current query on the grid page", () => { + renderHeader("/project2?search=zelda"); + expect(screen.getByText("NTNU GameShelf").closest("a")).toHaveAttribute( + "href", + "/project2/?search=zelda", + ); + }); + + it("links home to the persisted grid query from other pages", () => { + sessionStorage.setItem(GRID_QUERY_STORAGE_KEY, "search=bar"); + renderHeader("/project2/my-ratings"); + expect(screen.getByText("NTNU GameShelf").closest("a")).toHaveAttribute( + "href", + "/project2/?search=bar", + ); + }); + + it("links home plainly when there is no persisted query", () => { + renderHeader("/project2/my-ratings"); + expect(screen.getByText("NTNU GameShelf").closest("a")).toHaveAttribute("href", "/project2"); + }); +}); diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header.tsx similarity index 69% rename from frontend/src/components/Header/Header.tsx rename to frontend/src/components/Header.tsx index fe38b96..26c4fd8 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header.tsx @@ -8,9 +8,8 @@ import { useNavigate, useSearchParams, } from "react-router-dom"; -import { GRID_QUERY_STORAGE_KEY } from "../../constants/storageKeys"; -import styles from "./Header.module.css"; -import { useIsMobile } from "../../constants/global"; +import { GRID_QUERY_STORAGE_KEY } from "../constants/storageKeys"; +import { useIsMobile } from "../utils/isMobile"; export default function Header() { const navigate = useNavigate(); @@ -54,14 +53,19 @@ export default function Header() { } return ( -
- - { isMobile ? : "Working Title" } - +
+ -
- + + - - { isMobile ? :"My Ratings" } - +
); } diff --git a/frontend/src/components/Header/Header.module.css b/frontend/src/components/Header/Header.module.css deleted file mode 100644 index 30c4aeb..0000000 --- a/frontend/src/components/Header/Header.module.css +++ /dev/null @@ -1,39 +0,0 @@ -.header { - display: flex; - align-items: center; - justify-content: space-between; - gap: 1rem; - height: var(--header-height); - padding: 0 1.5rem; - background-color: var(--color-brand); -} - -.brand, -.link { - font-weight: 700; - color: var(--color-text); - white-space: nowrap; - text-decoration: none; -} - -.search { - flex: 1; - max-width: 420px; -} - -.search :global(.input-group) { - border-radius: 999px; - overflow: hidden; -} - -.search :global(.form-control) { - border: none; -} - -.search :global(.form-control:focus) { - box-shadow: none; -} - -.search :global(.btn) { - border: none; -} diff --git a/frontend/src/components/Layout.test.tsx b/frontend/src/components/Layout.test.tsx new file mode 100644 index 0000000..4d2204c --- /dev/null +++ b/frontend/src/components/Layout.test.tsx @@ -0,0 +1,14 @@ +import { describe, expect, it } from "vitest"; +import { render, screen } from "@testing-library/react"; +import Layout from "./Layout"; + +describe("Layout", () => { + it("renders its children", () => { + render( + +

Page content

+
, + ); + expect(screen.getByText("Page content")).toBeInTheDocument(); + }); +}); diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx new file mode 100644 index 0000000..7b18c12 --- /dev/null +++ b/frontend/src/components/Layout.tsx @@ -0,0 +1,7 @@ +import type { ReactNode } from "react"; + +export default function Layout({ children }: { children: ReactNode }) { + return
+ {children} +
; +} diff --git a/frontend/src/components/Layout/Layout.module.css b/frontend/src/components/Layout/Layout.module.css deleted file mode 100644 index 52611a0..0000000 --- a/frontend/src/components/Layout/Layout.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.shell { - width: 100%; - max-width: var(--content-width); - margin: 0 auto; -} diff --git a/frontend/src/components/Layout/Layout.tsx b/frontend/src/components/Layout/Layout.tsx deleted file mode 100644 index ced9683..0000000 --- a/frontend/src/components/Layout/Layout.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import type { ReactNode } from "react"; -import styles from "./Layout.module.css"; - -export default function Layout({ children }: { children: ReactNode }) { - return
{children}
; -} diff --git a/frontend/src/components/Pagination.tsx b/frontend/src/components/Pagination.tsx new file mode 100644 index 0000000..a99869c --- /dev/null +++ b/frontend/src/components/Pagination.tsx @@ -0,0 +1,47 @@ +import { Button } from "react-bootstrap"; +import { ChevronLeft, ChevronRight } from "react-bootstrap-icons"; + +interface PaginationProps { + page: number; + totalPages: number; + onPrevPage: () => void; + onNextPage: () => void; +} + +export default function Pagination({ + page, + totalPages, + onPrevPage, + onNextPage, +}: PaginationProps) { + return ( +
+ + + Page {page} of {totalPages} + + +
+ ); +} diff --git a/frontend/src/components/StarRating.test.tsx b/frontend/src/components/StarRating.test.tsx new file mode 100644 index 0000000..7a990fa --- /dev/null +++ b/frontend/src/components/StarRating.test.tsx @@ -0,0 +1,79 @@ +import { describe, expect, it, vi } from "vitest"; +import { fireEvent, render, screen } from "@testing-library/react"; +import StarRating from "./StarRating"; + +function mockRowWidth(width: number) { + vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockReturnValue({ + left: 0, + top: 0, + right: width, + bottom: 0, + width, + height: 0, + x: 0, + y: 0, + toJSON: () => {}, + }); +} + +describe("StarRating", () => { + it("shows 'Not yet rated' when score is null", () => { + render(); + expect(screen.getByText("Not yet rated")).toBeInTheDocument(); + }); + + it("rounds a whole score to a clean X/5", () => { + render(); + expect(screen.getByText("5/5 stars")).toBeInTheDocument(); + }); + + it("rounds a repeating decimal down to 2 places", () => { + render(); + expect(screen.getByText("4.33/5 stars")).toBeInTheDocument(); + }); + + it("rounds a repeating decimal up to 2 places", () => { + render(); + expect(screen.getByText("4.67/5 stars")).toBeInTheDocument(); + }); + + it("does not render an interactive slider or delete button when readonly", () => { + render(); + expect(screen.queryByRole("slider")).not.toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "Remove your rating" })).not.toBeInTheDocument(); + }); + + it("calls onChange with the score for the clicked position", () => { + mockRowWidth(100); + const onChange = vi.fn(); + render(); + fireEvent.click(screen.getByRole("slider"), { clientX: 50 }); + expect(onChange).toHaveBeenCalledWith(5); + }); + + it("increments and decrements by arrow keys, clamped to 0-10", () => { + const onChange = vi.fn(); + render(); + const slider = screen.getByRole("slider"); + + fireEvent.keyDown(slider, { key: "ArrowRight" }); + expect(onChange).toHaveBeenLastCalledWith(10); + + fireEvent.keyDown(slider, { key: "ArrowLeft" }); + expect(onChange).toHaveBeenLastCalledWith(9); + }); + + it("calls onDelete without bubbling the click to a parent handler", () => { + const onDelete = vi.fn(); + const onParentClick = vi.fn(); + render( +
+ +
, + ); + + fireEvent.click(screen.getByRole("button", { name: "Remove your rating" })); + expect(onDelete).toHaveBeenCalledOnce(); + expect(onParentClick).not.toHaveBeenCalled(); + }); +}); diff --git a/frontend/src/components/StarRating.tsx b/frontend/src/components/StarRating.tsx index 2e56e7b..895444c 100644 --- a/frontend/src/components/StarRating.tsx +++ b/frontend/src/components/StarRating.tsx @@ -1,6 +1,6 @@ import { useRef, useState } from "react"; import type { KeyboardEvent, MouseEvent } from "react"; -import { Star, StarFill, StarHalf } from "react-bootstrap-icons"; +import { Star, StarFill, StarHalf, XCircle } from "react-bootstrap-icons"; const STAR_COUNT = 5; // Ratings are out of 10 server-side, so each star covers two points and a @@ -10,6 +10,7 @@ const POINTS_PER_STAR = 2; interface StarRatingProps { score: number | null; // 0-10, null when no rating exists yet onChange?: (score: number) => void; + onDelete?: () => void; disabled?: boolean; size?: number; scorePosition?: "bottom" | "right"; @@ -40,6 +41,7 @@ function starValueFromPointer(clientX: number, rect: DOMRect): number { export default function StarRating({ score, onChange, + onDelete, disabled = false, size = 2, scorePosition = "bottom", @@ -71,54 +73,71 @@ export default function StarRating({ return (
-
setHovered(scoreFromPointer(event)) : undefined - } - onMouseLeave={canInteract ? () => setHovered(null) : undefined} - onClick={ - canInteract - ? (event) => { - const value = scoreFromPointer(event); - if (value != null) onChange?.(value); - } - : undefined - } - onKeyDown={canInteract ? handleKeyDown : undefined} - > - {Array.from({ length: STAR_COUNT }, (_, i) => i + 1).map((starIndex) => { - const fill = fillFor(displayed, starIndex); - return ( - - ); - })} +
+
setHovered(scoreFromPointer(event)) : undefined + } + onMouseLeave={canInteract ? () => setHovered(null) : undefined} + onClick={ + canInteract + ? (event) => { + const value = scoreFromPointer(event); + if (value != null) onChange?.(value); + } + : undefined + } + onKeyDown={canInteract ? handleKeyDown : undefined} + > + {Array.from({ length: STAR_COUNT }, (_, i) => i + 1).map((starIndex) => { + const fill = fillFor(displayed, starIndex); + return ( + + ); + })} +
+ {onDelete && score != null && ( + + )}

- {score == null ? "Not yet rated" : `${Number.isInteger(score) ? score.toFixed(0) : score.toFixed(1)}/10`} + {score == null ? "Not yet rated" : `${Math.round((score / 2) * 100) / 100}/5 stars`}

); diff --git a/frontend/src/components/Toolbar/Toolbar.module.css b/frontend/src/components/Toolbar/Toolbar.module.css index 52d9fb7..d0f4173 100644 --- a/frontend/src/components/Toolbar/Toolbar.module.css +++ b/frontend/src/components/Toolbar/Toolbar.module.css @@ -38,21 +38,6 @@ background-color: var(--color-brand); } -.pagination { - display: inline-flex; - align-items: center; - justify-self: center; - gap: 0.75rem; -} - -.pageButton { - display: inline-flex; - align-items: center; - padding: 0; - color: inherit; - font: inherit; -} - .sort { display: inline-flex; align-items: center; @@ -133,6 +118,10 @@ white-space: nowrap; } +.checkOption :global(.form-check-input:not(:checked)) { + border-color: grey; +} + .panelRow { display: flex; flex-wrap: wrap; diff --git a/frontend/src/components/Toolbar/Toolbar.test.tsx b/frontend/src/components/Toolbar/Toolbar.test.tsx new file mode 100644 index 0000000..fec2985 --- /dev/null +++ b/frontend/src/components/Toolbar/Toolbar.test.tsx @@ -0,0 +1,142 @@ +import { describe, expect, it, vi } from "vitest"; +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import Toolbar from "./Toolbar"; +import { EMPTY_FILTERS } from "../../types/gameQuery"; +import type { GameFilters, SortState } from "../../types/gameQuery"; + +function renderToolbar(overrides: { + page?: number; + totalPages?: number; + filters?: GameFilters; + sort?: SortState; +} = {}) { + const onPrevPage = vi.fn(); + const onNextPage = vi.fn(); + const onFiltersChange = vi.fn(); + const onSortChange = vi.fn(); + + render( + , + ); + + return { onPrevPage, onNextPage, onFiltersChange, onSortChange }; +} + +describe("Toolbar pagination", () => { + it("shows the current page and total", () => { + renderToolbar({ page: 2, totalPages: 5 }); + expect(screen.getByText("Page 2 of 5")).toBeInTheDocument(); + }); + + it("disables previous on the first page and next on the last page", () => { + renderToolbar({ page: 1, totalPages: 1 }); + expect(screen.getByRole("button", { name: "Previous page" })).toBeDisabled(); + expect(screen.getByRole("button", { name: "Next page" })).toBeDisabled(); + }); + + it("calls onPrevPage and onNextPage when enabled", async () => { + const user = userEvent.setup(); + const { onPrevPage, onNextPage } = renderToolbar({ page: 2, totalPages: 5 }); + await user.click(screen.getByRole("button", { name: "Previous page" })); + await user.click(screen.getByRole("button", { name: "Next page" })); + expect(onPrevPage).toHaveBeenCalledOnce(); + expect(onNextPage).toHaveBeenCalledOnce(); + }); +}); + +describe("Toolbar sorting", () => { + it("shows the active sort field's label", () => { + renderToolbar({ sort: { field: "AVERAGE_SCORE", order: "ASC" } }); + expect(screen.getByText("Average score")).toBeInTheDocument(); + }); + + it("toggles sort order", async () => { + const user = userEvent.setup(); + const { onSortChange } = renderToolbar({ sort: { field: "NAME", order: "ASC" } }); + await user.click(screen.getByRole("button", { name: "Switch to descending order" })); + expect(onSortChange).toHaveBeenCalledWith({ field: "NAME", order: "DESC" }); + }); + + it("opens the sort menu and selects a field", async () => { + const user = userEvent.setup(); + const { onSortChange } = renderToolbar({ sort: { field: "NAME", order: "ASC" } }); + await user.click(screen.getByRole("button", { name: /Sort by/ })); + await user.click(screen.getByRole("menuitemradio", { name: "Number of reviews" })); + expect(onSortChange).toHaveBeenCalledWith({ field: "REVIEW_COUNT", order: "ASC" }); + expect(screen.queryByRole("menu")).not.toBeInTheDocument(); + }); +}); + +describe("Toolbar filtering", () => { + it("shows a badge only when filters are active", () => { + const { container, unmount } = render( + , + ); + expect(container.querySelector('[aria-hidden="true"]')).not.toBeInTheDocument(); + unmount(); + + render( + , + ); + expect(screen.getByRole("button", { name: "Filter by" }).querySelector('[aria-hidden="true"]')).toBeInTheDocument(); + }); + + it("toggles a tag, applies and reports the updated filters", async () => { + const user = userEvent.setup(); + const { onFiltersChange } = renderToolbar({ filters: EMPTY_FILTERS }); + await user.click(screen.getByRole("button", { name: "Filter by" })); + await user.click(screen.getByRole("checkbox", { name: "RPG" })); + await user.click(screen.getByRole("button", { name: "Apply" })); + + expect(onFiltersChange).toHaveBeenCalledWith({ ...EMPTY_FILTERS, tags: ["RPG"] }); + expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + }); + + it("clears all filters", async () => { + const user = userEvent.setup(); + const { onFiltersChange } = renderToolbar({ + filters: { ...EMPTY_FILTERS, tags: ["RPG"], platforms: ["PC"] }, + }); + await user.click(screen.getByRole("button", { name: "Filter by" })); + await user.click(screen.getByRole("button", { name: "Clear all" })); + + expect(onFiltersChange).toHaveBeenCalledWith(EMPTY_FILTERS); + }); + + it("closes the filter panel on Escape", async () => { + const user = userEvent.setup(); + renderToolbar(); + await user.click(screen.getByRole("button", { name: "Filter by" })); + expect(screen.getByRole("dialog")).toBeInTheDocument(); + await user.keyboard("{Escape}"); + expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + }); +}); diff --git a/frontend/src/components/Toolbar/Toolbar.tsx b/frontend/src/components/Toolbar/Toolbar.tsx index 29d9caa..c482e82 100644 --- a/frontend/src/components/Toolbar/Toolbar.tsx +++ b/frontend/src/components/Toolbar/Toolbar.tsx @@ -1,22 +1,17 @@ import { useEffect, useRef, useState } from "react"; import type { ChangeEvent } from "react"; import { Button, Form } from "react-bootstrap"; -import { - ArrowDownUp, - ChevronDown, - ChevronLeft, - ChevronRight, - Funnel, - X, -} from "react-bootstrap-icons"; +import { ArrowDownUp, ChevronDown, Funnel, X } from "react-bootstrap-icons"; import { ESRB_OPTIONS, PLATFORM_OPTIONS, SORT_FIELD_OPTIONS, TAG_OPTIONS, + YEAR_OPTIONS, } from "../../constants/filterOptions"; import type { GameFilters, SortField, SortState } from "../../types/gameQuery"; import { EMPTY_FILTERS, hasActiveFilters } from "../../types/gameQuery"; +import Pagination from "../Pagination"; import styles from "./Toolbar.module.css"; interface ToolbarProps { @@ -100,31 +95,12 @@ export default function Toolbar({ )}
-
- - - Page {page} of {totalPages} - - -
+
@@ -143,7 +119,8 @@ export default function Toolbar({