From 2174b3a2c8ff6879e6609ff875ef12318b335b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Thu, 9 Jan 2025 14:46:02 +0100 Subject: [PATCH] Added basic vitest test --- packages/frontend/eslint.config.js | 3 + packages/frontend/package-lock.json | 409 +++++++++++++++++- packages/frontend/package.json | 6 +- packages/frontend/tests/testData.ts | 226 ++++++++++ .../__snapshots__/getProject.test.ts.snap | 156 +++++++ .../utils/getProject.test.ts | 2 + packages/frontend/vite.config.js | 3 + 7 files changed, 795 insertions(+), 10 deletions(-) create mode 100644 packages/frontend/tests/testData.ts create mode 100644 packages/frontend/tests/utils/__snapshots__/getProject.test.ts.snap rename packages/frontend/{__tests__ => tests}/utils/getProject.test.ts (93%) diff --git a/packages/frontend/eslint.config.js b/packages/frontend/eslint.config.js index 42e1f19fd..9d738d78d 100644 --- a/packages/frontend/eslint.config.js +++ b/packages/frontend/eslint.config.js @@ -211,6 +211,9 @@ export default tseslint.config( }, }, }, + { + files: ["tests/**/*.test.ts", "tests/**/*.test.tsx"], + }, { ...jest.configs["flat/recommended"], ...jest.configs["flat/style"], diff --git a/packages/frontend/package-lock.json b/packages/frontend/package-lock.json index 919020f8a..3ca39f2a0 100644 --- a/packages/frontend/package-lock.json +++ b/packages/frontend/package-lock.json @@ -49,7 +49,8 @@ "ts-jest": "^29.2.5", "typescript": "^5.5.4", "typescript-eslint": "^8.19.1", - "vite": "^5.4.11" + "vite": "^5.4.11", + "vitest": "^2.1.8" } }, "node_modules/@adobe/css-tools": { @@ -4150,6 +4151,119 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0" } }, + "node_modules/@vitest/expect": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.8.tgz", + "integrity": "sha512-8ytZ/fFHq2g4PJVAtDX57mayemKgDR6X3Oa2Foro+EygiOJHUXhCqBAAKQYYajZpFoIfvBCF1j6R6IYRSIUFuw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.8", + "@vitest/utils": "2.1.8", + "chai": "^5.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.8.tgz", + "integrity": "sha512-7guJ/47I6uqfttp33mgo6ga5Gr1VnL58rcqYKyShoRK9ebu8T5Rs6HN3s1NABiBeVTdWNrwUMcHH54uXZBN4zA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.8", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.12" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.8.tgz", + "integrity": "sha512-9HiSZ9zpqNLKlbIDRWOnAWqgcA7xu+8YxXSekhr0Ykab7PAYFkhkwoqVArPOtJhPmYeE2YHgKZlj3CP36z2AJQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.8.tgz", + "integrity": "sha512-17ub8vQstRnRlIU5k50bG+QOMLHRhYPAna5tw8tYbj+jzjcspnwnwtPtiOlkuKC4+ixDPTuLZiqiWWQ2PSXHVg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "2.1.8", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.8.tgz", + "integrity": "sha512-20T7xRFbmnkfcmgVEz+z3AU/3b0cEzZOt/zmnvZEctg64/QZbSDJEVm9fLnnlSi74KibmRsO9/Qabi+t0vCRPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.8", + "magic-string": "^0.30.12", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.8.tgz", + "integrity": "sha512-5swjf2q95gXeYPevtW0BLk6H8+bPlMb4Vw/9Em4hFxDcaOxS+e0LOX4yqNxoHzMR2akEB2xfpnWUzkZokmgWDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^3.0.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.8.tgz", + "integrity": "sha512-dwSoui6djdwbfFmIgbIjX2ZhIoG7Ex/+xpxyiEgIGzjliY8xGkcpITKTlp6B4MgtGkF2ilvm97cPM96XZaAgcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.8", + "loupe": "^3.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -4440,6 +4554,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "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-metadata-inferer": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/ast-metadata-inferer/-/ast-metadata-inferer-0.8.1.tgz", @@ -4770,6 +4894,16 @@ "dev": true, "license": "MIT" }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", @@ -4866,6 +5000,23 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/chai": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.2.tgz", + "integrity": "sha512-aGtmf24DW6MLHHG5gCx4zaI3uBq3KRtxeVs0DjFH6Z0rDNbsvTxFASFvdj79pxjxZ8/5u3PIiN3IwEIQkiiuPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -4933,6 +5084,16 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, "node_modules/ci-info": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", @@ -5236,12 +5397,12 @@ } }, "node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -5287,6 +5448,16 @@ } } }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -5621,6 +5792,13 @@ "node": ">= 0.4" } }, + "node_modules/es-module-lexer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz", + "integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==", + "dev": true, + "license": "MIT" + }, "node_modules/es-object-atoms": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", @@ -6124,6 +6302,16 @@ "url": "https://opencollective.com/unified" } }, + "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", @@ -6184,6 +6372,16 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/expect-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.1.0.tgz", + "integrity": "sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -8854,6 +9052,13 @@ "loose-envify": "cli.js" } }, + "node_modules/loupe": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.2.tgz", + "integrity": "sha512-23I4pFZHmAemUnz8WZXbYRSKYj801VDaNv9ETuMh7IrMc7VuVVSo+Z9iLE3ni30+U48iDWfi30d3twAXBYmnCg==", + "dev": true, + "license": "MIT" + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -9911,9 +10116,9 @@ } }, "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "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": { @@ -10558,6 +10763,23 @@ "node": ">=8" } }, + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -11664,6 +11886,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -11814,6 +12043,20 @@ "node": ">=8" } }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", + "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", + "dev": true, + "license": "MIT" + }, "node_modules/string-length": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", @@ -12223,6 +12466,50 @@ "node": ">=8" } }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinypool": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz", + "integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", + "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -12860,6 +13147,95 @@ } } }, + "node_modules/vite-node": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.8.tgz", + "integrity": "sha512-uPAwSr57kYjAUux+8E2j0q0Fxpn8M9VoyfGiRI8Kfktz9NcYMCenwY5RnZxnF1WTu3TGiYipirIzacLL3VVGFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.7", + "es-module-lexer": "^1.5.4", + "pathe": "^1.1.2", + "vite": "^5.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.8.tgz", + "integrity": "sha512-1vBKTZskHw/aosXqQUlVWWlGUxSJR8YtiyZDJAFeW2kPAeX6S3Sool0mjspO+kXLuxVWlEDDowBAeqeAQefqLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "2.1.8", + "@vitest/mocker": "2.1.8", + "@vitest/pretty-format": "^2.1.8", + "@vitest/runner": "2.1.8", + "@vitest/snapshot": "2.1.8", + "@vitest/spy": "2.1.8", + "@vitest/utils": "2.1.8", + "chai": "^5.1.2", + "debug": "^4.3.7", + "expect-type": "^1.1.0", + "magic-string": "^0.30.12", + "pathe": "^1.1.2", + "std-env": "^3.8.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.1", + "tinypool": "^1.0.1", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.8", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.8", + "@vitest/ui": "2.1.8", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, "node_modules/w3c-xmlserializer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz", @@ -13043,6 +13419,23 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 8bb1bca9c..520e0b16e 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -20,12 +20,13 @@ "clean": "rimraf dist/*", "prebuild": "npm run clean", "build": "vite build", - "lint:ts:eslint": "eslint --color \"src/**/*\" \"__mocks__/**/*\" \"__tests__/**/*\" \"*.config.{js,ts}\"", + "lint:ts:eslint": "eslint --color \"src/**/*\" \"__mocks__/**/*\" \"tests/**/*\" \"__tests__/**/*\" \"*.config.{js,ts}\"", "lint:ts:typecheck": "tsc --noEmit", "lint:ts": "run-p -c --aggregate-output lint:ts:*", "lint": "run-p -c --aggregate-output lint:*", "start": "vite", "test": "jest", + "vitest": "vitest", "test-accept": "jest --updateSnapshot" }, "dependencies": { @@ -70,7 +71,8 @@ "ts-jest": "^29.2.5", "typescript": "^5.5.4", "typescript-eslint": "^8.19.1", - "vite": "^5.4.11" + "vite": "^5.4.11", + "vitest": "^2.1.8" }, "browserslist": { "production": [ diff --git a/packages/frontend/tests/testData.ts b/packages/frontend/tests/testData.ts new file mode 100644 index 000000000..5209737cf --- /dev/null +++ b/packages/frontend/tests/testData.ts @@ -0,0 +1,226 @@ +import type { ProjectListings } from "../src/interfaces/ProjectListings"; + +export const testData: ProjectListings = { + projects: [ + { + info: { + description: + 'Galerie obrázků a videí z Google Disku je plugin pro WordPress, který propojí web s Google Diskem. V pluginu se dá vybrat libovolná složku na Google Disku nebo ve Sdíleném disku a plugin z ní vytvoří galerii s obrázky a videi na libovolné stránce či příspěvku na webu. Ze všech složek a podsložek jsou navíc vytvořeny vnořené “podgalerie”. Plugin vzniknul primárně pro potřeby Junáka, oddílů a středisek, ale vyvíjíme ho tzv. Open-Source (otevřeně pro veřejnost) a nabízíme ho v oficiální databázi pluginů pro WordPress. V tuto chvíli (léto 2021) podle statistik WordPressu plugin běží na víc jak 4 000 webových stránek a z kontaktů s uživateli víme, že ho využívají jak oddíly a střediska v Junáku, tak i "náhodná veřejnost" - zvlášť oblíbený se zdá být u skautů z celého světa a profesionálních fotografů, prezentujících svoje fotky.', + links: [ + { + type: "email", + uri: "mailto:mlha@skaut.cz", + }, + { + type: "homepage", + uri: "https://wordpress.org/plugins/skaut-google-drive-gallery/", + }, + { + type: "demo", + uri: "https://demo-skaut-google-drive-gallery.skauting.cz/", + }, + { + type: "issue-tracker", + uri: "https://github.com/skaut/skaut-google-drive-gallery/issues", + }, + { + type: "docs", + uri: "https://napoveda.skaut.cz/dobryweb/cs-skaut-google-drive-gallery", + }, + { + name: "skaut/skaut-google-drive-gallery", + type: "github-repo", + uri: "https://github.com/skaut/skaut-google-drive-gallery", + }, + ], + maintainers: [ + { + email: "mlha@skaut.cz", + name: "Marek Dědič – Mlha", + }, + ], + name: "WordPress plugin: Galerie obrázků a videí z Google Disku", + "short-description": + "Plugin pro WordPress, který ze složek s fotkami na Google Disku dělá galerie na webu.", + tags: ["wordpress", "php", "javascript", "google"], + }, + issues: [ + { + description: + 'When editing and selecting a folder with videos, the editor could display a notice that setting videos to "Anyone can view" will speed them up.\r\n\r\nDepends on #792', + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/873", + number: 1, + title: "Add hint to set videos to public", + }, + { + description: + "When in a situation that there is a Google Drive shortcut somewhere in the gallery, the plugin displays the folder and it works for browsing. However, when looking at the shortcut as a member of its parent directory and when being inside the directory and looking at its name in the breadcrumbs, one uses the shortcut name, whereas the other uses the original folder name (when they differ).\r\n\r\nThis is a bug and both should show the shortcut name.", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/745", + number: 2, + title: + "If a shortcut name differs from the original, the name in gallery and breadcrumbs differs", + }, + { + description: + "When opening the editor which contains a gallery that is made from a folder that has been renamed or deleted, the editor breaks. It shows: `Directory "Galerie ODYWEB" wasn't found - it may have been deleted or renamed.` Instead, it should verify that the path is valid and if it's not, should display a warning (and possibly move you to either the root directory, or the closest valid ancestor - however, this should not lead to you accidentally changing the gallery!)\r\n\r\nLast tested on 36dc1a10a353ba5bf2b98f33b49b1135a36ae3d3", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/683", + number: 3, + title: "Editing doesn't check path validity", + }, + { + description: + "Ctrl+click on a gallery item (subfolder) or breadcrumbs should open in a new tab", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/571", + number: 4, + title: "Ctrl-click on folders does not work", + }, + { + description: + "https://wordpress.org/support/topic/folder-link-instead-of-folder-name/\r\n\r\nBasically, instead of searching for the folder in WP, you'd just paste the link to it into the editor and the plugin would figure out the path (Google Drive files now return a list of parents, so it could be done.)\r\n\r\nDepends on #111.", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/311", + number: 5, + title: "Add option to specify gallery by a Drive link", + }, + { + description: + "Currently, images aren't listed in the editor - both block and TinyMCE plugin. This often confuses users.", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/257", + number: 6, + title: "Add images to the block", + }, + { + description: + "In the image grid, we should add an overlay to signify that an item is a video (for example a big play icon).", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/235", + number: 7, + title: "Add video overlay", + }, + { + description: "https://codecov.io/gh/skaut/skaut-google-drive-gallery", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/164", + number: 8, + title: "Increase test coverage", + }, + { + description: + "If the active theme contains\r\n```php\r\nadd_theme_support( 'editor-styles' );\r\n```\r\nits styles are also applied to the block editor, which then looks weird. We should implement our own styles for the editor.\r\n\r\nExample of such theme is the Twenty Seventeen theme.", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/98", + number: 9, + title: + 'Themes with "editor-styles" support change the look of the block editor', + }, + { + description: + "https://napoveda.skaut.cz/dobryweb/en-skaut-google-drive-gallery/en-get-google-application\r\nhttps://napoveda.skaut.cz/dobryweb/cs-skaut-google-drive-gallery/cs-ziskani-google-aplikace\r\n\r\nGoogle changed the consent screen layout and require some form of verification.", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/92", + number: 10, + title: "Google app creation manual is outdated", + }, + { + description: + "Currently, the first image in a directory is used for its preview.", + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/54", + number: 11, + title: "Directory preview images", + }, + { + description: + 'Go over the design of:\r\n- [ ] gallery view https://github.com/skaut/skaut-google-drive-gallery/issues/36\r\n- [ ] preview\r\n- [ ] folder thumbnail - overlay, folder title and image count\r\n- [ ] svg folder icon\r\n- [ ] gallery breadcrumbs\r\n- [ ] options page\r\n- [ ] WP.org plugin page\r\n- [ ] TinyMCE & Gutenberg editor plugins\r\n- [ ] TinyMCE & Gutenberg "Authentication failed" dialogs\r\n\r\nEverything on the frontend needs to work at least with the default WP template and DSW templates.', + link: "https://github.com/skaut/skaut-google-drive-gallery/issues/33", + number: 12, + title: "UX & design audit", + }, + ], + owner: "skaut", + repo: "skaut-google-drive-gallery", + }, + { + info: { + description: + "Plugin zajišťuje propojení skautských webů se skautISem. Dá se přes plugin registrovat, přihlašovat. Dokáže u stránek nastavovat oprávnění podle roli a dalších nastavení ve skautISu. Skrývá obsah podle toho jaká pravidla na stránce jsou nastavená.", + links: [ + { + type: "email", + uri: "mailto:kalich@skaut.cz", + }, + { + type: "homepage", + uri: "https://wordpress.org/plugins/skautis-integration/", + }, + { + type: "issue-tracker", + uri: "https://github.com/skaut/skautis-integration/issues", + }, + { + type: "docs", + uri: "https://napoveda.skaut.cz/skautis/skautis-integration", + }, + { + name: "skaut/skautis-integration", + type: "github-repo", + uri: "https://github.com/skaut/skautis-integration", + }, + ], + maintainers: [ + { + email: "kalich@skaut.cz", + name: "Michal Janata – Kalich", + }, + { + email: "mlha@skaut.cz", + name: "Marek Dědič – Mlha", + }, + ], + name: "WordPress plugin: SkautIS integrace", + "short-description": + "Plugin pro WordPress, který napojuje přihlašování přes skautIS na skautské weby.", + tags: ["wordpress", "php", "javascript", "skautis"], + }, + issues: [ + { + description: "", + link: "https://github.com/skaut/skautis-integration/issues/115", + number: 1, + title: + "User management smart table is not smart when the registration module is enabled", + }, + { + description: + "![image](https://user-images.githubusercontent.com/8988898/130583907-9aaf6288-2129-42dd-88ef-0a27b0c7ddd1.png)\r\n", + link: "https://github.com/skaut/skautis-integration/issues/109", + number: 2, + title: "Chyba v zobrazení", + }, + { + description: + "Musíme pořešit, jak nejlépe integrovat náš plugin s WP 5.x a hlavně Gutenbergem.\r\n\r\nSkrývání bloků, celých stránek... atd", + link: "https://github.com/skaut/skautis-integration/issues/70", + number: 3, + title: "WordPress 5.x + Gutenberg", + }, + { + description: + "Co do WordPressu tahat i profilové fotky, co si lidi do skautISu přidávají. Aby u profilu nějakou fotku měli...", + link: "https://github.com/skaut/skautis-integration/issues/43", + number: 4, + title: "Profilové fotky", + }, + { + description: "Přidat Select2 do výběru pravidel v shortcode.", + link: "https://github.com/skaut/skautis-integration/issues/39", + number: 5, + title: "Výběry pravidel v shortcode", + }, + { + description: + "modul pro nábory se zobrazením náborové mapy\r\npříklad: http://is.skaut.cz/napoveda/programatori.Hotove-reseni-MapAdvertising-Interaktivni-mapa-naborovych-informaci-zakladni.ashx\r\n\r\nOtevírám k tomu diskuzi...", + link: "https://github.com/skaut/skautis-integration/issues/25", + number: 6, + title: 'Modul "Nábory"', + }, + ], + owner: "skaut", + repo: "skautis-integration", + }, + ], +}; diff --git a/packages/frontend/tests/utils/__snapshots__/getProject.test.ts.snap b/packages/frontend/tests/utils/__snapshots__/getProject.test.ts.snap new file mode 100644 index 000000000..ce85c352d --- /dev/null +++ b/packages/frontend/tests/utils/__snapshots__/getProject.test.ts.snap @@ -0,0 +1,156 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`should get project 1`] = ` +{ + "info": { + "description": "Galerie obrázků a videí z Google Disku je plugin pro WordPress, který propojí web s Google Diskem. V pluginu se dá vybrat libovolná složku na Google Disku nebo ve Sdíleném disku a plugin z ní vytvoří galerii s obrázky a videi na libovolné stránce či příspěvku na webu. Ze všech složek a podsložek jsou navíc vytvořeny vnořené “podgalerie”. Plugin vzniknul primárně pro potřeby Junáka, oddílů a středisek, ale vyvíjíme ho tzv. Open-Source (otevřeně pro veřejnost) a nabízíme ho v oficiální databázi pluginů pro WordPress. V tuto chvíli (léto 2021) podle statistik WordPressu plugin běží na víc jak 4 000 webových stránek a z kontaktů s uživateli víme, že ho využívají jak oddíly a střediska v Junáku, tak i "náhodná veřejnost" - zvlášť oblíbený se zdá být u skautů z celého světa a profesionálních fotografů, prezentujících svoje fotky.", + "links": [ + { + "type": "email", + "uri": "mailto:mlha@skaut.cz", + }, + { + "type": "homepage", + "uri": "https://wordpress.org/plugins/skaut-google-drive-gallery/", + }, + { + "type": "demo", + "uri": "https://demo-skaut-google-drive-gallery.skauting.cz/", + }, + { + "type": "issue-tracker", + "uri": "https://github.com/skaut/skaut-google-drive-gallery/issues", + }, + { + "type": "docs", + "uri": "https://napoveda.skaut.cz/dobryweb/cs-skaut-google-drive-gallery", + }, + { + "name": "skaut/skaut-google-drive-gallery", + "type": "github-repo", + "uri": "https://github.com/skaut/skaut-google-drive-gallery", + }, + ], + "maintainers": [ + { + "email": "mlha@skaut.cz", + "name": "Marek Dědič – Mlha", + }, + ], + "name": "WordPress plugin: Galerie obrázků a videí z Google Disku", + "short-description": "Plugin pro WordPress, který ze složek s fotkami na Google Disku dělá galerie na webu.", + "tags": [ + "wordpress", + "php", + "javascript", + "google", + ], + }, + "issues": [ + { + "description": "When editing and selecting a folder with videos, the editor could display a notice that setting videos to "Anyone can view" will speed them up. + +Depends on #792", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/873", + "number": 1, + "title": "Add hint to set videos to public", + }, + { + "description": "When in a situation that there is a Google Drive shortcut somewhere in the gallery, the plugin displays the folder and it works for browsing. However, when looking at the shortcut as a member of its parent directory and when being inside the directory and looking at its name in the breadcrumbs, one uses the shortcut name, whereas the other uses the original folder name (when they differ). + +This is a bug and both should show the shortcut name.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/745", + "number": 2, + "title": "If a shortcut name differs from the original, the name in gallery and breadcrumbs differs", + }, + { + "description": "When opening the editor which contains a gallery that is made from a folder that has been renamed or deleted, the editor breaks. It shows: \`Directory "Galerie ODYWEB" wasn't found - it may have been deleted or renamed.\` Instead, it should verify that the path is valid and if it's not, should display a warning (and possibly move you to either the root directory, or the closest valid ancestor - however, this should not lead to you accidentally changing the gallery!) + +Last tested on 36dc1a10a353ba5bf2b98f33b49b1135a36ae3d3", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/683", + "number": 3, + "title": "Editing doesn't check path validity", + }, + { + "description": "Ctrl+click on a gallery item (subfolder) or breadcrumbs should open in a new tab", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/571", + "number": 4, + "title": "Ctrl-click on folders does not work", + }, + { + "description": "https://wordpress.org/support/topic/folder-link-instead-of-folder-name/ + +Basically, instead of searching for the folder in WP, you'd just paste the link to it into the editor and the plugin would figure out the path (Google Drive files now return a list of parents, so it could be done.) + +Depends on #111.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/311", + "number": 5, + "title": "Add option to specify gallery by a Drive link", + }, + { + "description": "Currently, images aren't listed in the editor - both block and TinyMCE plugin. This often confuses users.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/257", + "number": 6, + "title": "Add images to the block", + }, + { + "description": "In the image grid, we should add an overlay to signify that an item is a video (for example a big play icon).", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/235", + "number": 7, + "title": "Add video overlay", + }, + { + "description": "https://codecov.io/gh/skaut/skaut-google-drive-gallery", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/164", + "number": 8, + "title": "Increase test coverage", + }, + { + "description": "If the active theme contains +\`\`\`php +add_theme_support( 'editor-styles' ); +\`\`\` +its styles are also applied to the block editor, which then looks weird. We should implement our own styles for the editor. + +Example of such theme is the Twenty Seventeen theme.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/98", + "number": 9, + "title": "Themes with "editor-styles" support change the look of the block editor", + }, + { + "description": "https://napoveda.skaut.cz/dobryweb/en-skaut-google-drive-gallery/en-get-google-application +https://napoveda.skaut.cz/dobryweb/cs-skaut-google-drive-gallery/cs-ziskani-google-aplikace + +Google changed the consent screen layout and require some form of verification.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/92", + "number": 10, + "title": "Google app creation manual is outdated", + }, + { + "description": "Currently, the first image in a directory is used for its preview.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/54", + "number": 11, + "title": "Directory preview images", + }, + { + "description": "Go over the design of: +- [ ] gallery view https://github.com/skaut/skaut-google-drive-gallery/issues/36 +- [ ] preview +- [ ] folder thumbnail - overlay, folder title and image count +- [ ] svg folder icon +- [ ] gallery breadcrumbs +- [ ] options page +- [ ] WP.org plugin page +- [ ] TinyMCE & Gutenberg editor plugins +- [ ] TinyMCE & Gutenberg "Authentication failed" dialogs + +Everything on the frontend needs to work at least with the default WP template and DSW templates.", + "link": "https://github.com/skaut/skaut-google-drive-gallery/issues/33", + "number": 12, + "title": "UX & design audit", + }, + ], + "owner": "skaut", + "repo": "skaut-google-drive-gallery", +} +`; diff --git a/packages/frontend/__tests__/utils/getProject.test.ts b/packages/frontend/tests/utils/getProject.test.ts similarity index 93% rename from packages/frontend/__tests__/utils/getProject.test.ts rename to packages/frontend/tests/utils/getProject.test.ts index 2794e9e83..62f021f5f 100644 --- a/packages/frontend/__tests__/utils/getProject.test.ts +++ b/packages/frontend/tests/utils/getProject.test.ts @@ -1,3 +1,5 @@ +import { expect, test } from "vitest"; + import { getProject } from "../../src/utils/getProject"; import { testData } from "../testData"; diff --git a/packages/frontend/vite.config.js b/packages/frontend/vite.config.js index dd5a891eb..013114972 100644 --- a/packages/frontend/vite.config.js +++ b/packages/frontend/vite.config.js @@ -8,4 +8,7 @@ export default defineConfig({ }, plugins: [legacy(), react()], root: "src", + test: { + root: ".", + }, });