From 95c6743b2ca842ea0606a331ef5f7fa20bf6a36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Duran?= Date: Sun, 7 Sep 2025 15:29:01 +0200 Subject: [PATCH] Tests: Remove Karma / Mocha and switch to Vitest #4995 #5014 #5087 * Tests: Remove unused Karma configuration and test files This commit deletes the Karma configuration file and test files that are no longer needed * Tests: Refactor setup file for Vitest and remove legacy vue-setup.js * Tests: Update truncate test case to use Vitest string * Tests: Add unit tests for PLocationInput component using Vitest * Tests: Improve unit tests for PLoadingBar component * Tests: Move karma test to vitest * Frontend: Update deps in package-lock.json * Tests: Adapt test to vitest * Tests: Refactor Makefile and package.json for test commands --- Makefile | 14 +- frontend/package-lock.json | 1209 +---------- frontend/package.json | 34 +- frontend/tests/unit/common/api_test.js | 104 - frontend/tests/unit/common/can_test.js | 59 - frontend/tests/unit/common/clipboard_test.js | 197 -- frontend/tests/unit/common/config_test.js | 322 --- frontend/tests/unit/common/form_test.js | 132 -- frontend/tests/unit/common/notify_test.js | 24 - frontend/tests/unit/common/session_test.js | 271 --- frontend/tests/unit/common/util_test.js | 223 -- frontend/tests/unit/common/view_test.js | 25 - frontend/tests/unit/config.js | 518 ----- frontend/tests/unit/fixtures.js | 379 ---- frontend/tests/unit/model/album_test.js | 345 --- .../tests/unit/model/config-options_test.js | 52 - frontend/tests/unit/model/face_test.js | 177 -- frontend/tests/unit/model/file_test.js | 461 ---- frontend/tests/unit/model/folder_test.js | 247 --- frontend/tests/unit/model/label_test.js | 141 -- frontend/tests/unit/model/link_test.js | 103 - frontend/tests/unit/model/marker_test.js | 221 -- frontend/tests/unit/model/photo_test.js | 1862 ----------------- frontend/tests/unit/model/rest_test.js | 238 --- frontend/tests/unit/model/service_test.js | 75 - frontend/tests/unit/model/settings_test.js | 41 - frontend/tests/unit/model/subject_test.js | 255 --- frontend/tests/unit/model/thumb_test.js | 326 --- frontend/tests/unit/model/user_test.js | 325 --- frontend/tests/unit/options/options_test.js | 252 --- frontend/tests/vitest/common/util.test.js | 26 +- .../vitest/component/loading-bar.test.js | 138 +- .../vitest/component/location/input.test.js | 246 +++ .../vitest/component/sidebar/info.test.js | 2 +- frontend/tests/vitest/options/options.test.js | 40 +- frontend/tests/vitest/setup.js | 60 +- frontend/tests/vitest/vue-setup.js | 63 - 37 files changed, 466 insertions(+), 8741 deletions(-) delete mode 100644 frontend/tests/unit/common/api_test.js delete mode 100644 frontend/tests/unit/common/can_test.js delete mode 100644 frontend/tests/unit/common/clipboard_test.js delete mode 100644 frontend/tests/unit/common/config_test.js delete mode 100644 frontend/tests/unit/common/form_test.js delete mode 100644 frontend/tests/unit/common/notify_test.js delete mode 100644 frontend/tests/unit/common/session_test.js delete mode 100644 frontend/tests/unit/common/util_test.js delete mode 100644 frontend/tests/unit/common/view_test.js delete mode 100644 frontend/tests/unit/config.js delete mode 100644 frontend/tests/unit/fixtures.js delete mode 100644 frontend/tests/unit/model/album_test.js delete mode 100644 frontend/tests/unit/model/config-options_test.js delete mode 100644 frontend/tests/unit/model/face_test.js delete mode 100644 frontend/tests/unit/model/file_test.js delete mode 100644 frontend/tests/unit/model/folder_test.js delete mode 100644 frontend/tests/unit/model/label_test.js delete mode 100644 frontend/tests/unit/model/link_test.js delete mode 100644 frontend/tests/unit/model/marker_test.js delete mode 100644 frontend/tests/unit/model/photo_test.js delete mode 100644 frontend/tests/unit/model/rest_test.js delete mode 100644 frontend/tests/unit/model/service_test.js delete mode 100644 frontend/tests/unit/model/settings_test.js delete mode 100644 frontend/tests/unit/model/subject_test.js delete mode 100644 frontend/tests/unit/model/thumb_test.js delete mode 100644 frontend/tests/unit/model/user_test.js delete mode 100644 frontend/tests/unit/options/options_test.js create mode 100644 frontend/tests/vitest/component/location/input.test.js delete mode 100644 frontend/tests/vitest/vue-setup.js diff --git a/Makefile b/Makefile index 8a18b854a..d86488077 100644 --- a/Makefile +++ b/Makefile @@ -334,7 +334,7 @@ watch-js: (cd frontend && env BUILD_ENV=development NODE_ENV=production npm run watch) test-js: $(info Running JS unit tests...) - (cd frontend && env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test npm run test) + (cd frontend && npm run test) acceptance: $(info Running public-mode tests in Chrome...) (cd frontend && npm run testcafe -- "chrome --headless=new" --test-grep "^(Multi-Window)\:*" --test-meta mode=public --config-file ./testcaferc.json --experimental-multiple-windows "tests/acceptance" && npm run testcafe -- "chrome --headless=new" --test-grep "^(Common|Core)\:*" --test-meta mode=public --config-file ./testcaferc.json "tests/acceptance") @@ -353,21 +353,15 @@ acceptance-auth-short: acceptance-auth-firefox: $(info Running JS acceptance-auth tests in Firefox...) (cd frontend && npm run testcafe -- firefox:headless --test-grep "^(Common|Core)\:*" --test-meta mode=auth --config-file ./testcaferc.json --disable-native-automation "tests/acceptance") -vitest: - $(info Running Vitest unit tests...) - (cd frontend && npm run vitest) vitest-watch: $(info Running Vitest unit tests in watch mode...) - (cd frontend && npm run vitest-watch) + (cd frontend && npm run test-watch) vitest-coverage: $(info Running Vitest unit tests with coverage...) - (cd frontend && npm run vitest-coverage) + (cd frontend && npm run test-coverage) vitest-component: $(info Running Vitest component tests...) - (cd frontend && npm run vitest-component) -vitest-ui: - $(info Opening Vitest UI...) - (cd frontend && npm run vitest-ui) + (cd frontend && npm run test-component) reset-mariadb: $(info Resetting photoprism database...) mysql < scripts/sql/reset-photoprism.sql diff --git a/frontend/package-lock.json b/frontend/package-lock.json index d5e10b2a7..c71da3ba2 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -35,12 +35,10 @@ "babel-loader": "^10.0.0", "babel-plugin-istanbul": "^7.0.0", "babel-plugin-polyfill-corejs3": "^0.13.0", - "browserslist": "^4.25.4", - "chai": "^5.3.3", + "browserslist": "^4.25.0", "cheerio": "1.0.0-rc.12", - "chrome-finder": "^1.0.7", - "core-js": "^3.45.1", - "cross-env": "^10.0.0", + "core-js": "^3.43.0", + "cross-env": "^7.0.3", "css-loader": "^7.1.2", "cssnano": "^7.1.1", "easygettext": "^2.17.0", @@ -62,19 +60,11 @@ "hls.js": "^1.6.11", "i": "^0.3.7", "jsdom": "^26.1.0", - "karma": "^6.4.4", - "karma-chrome-launcher": "^3.2.0", - "karma-coverage-istanbul-reporter": "^3.0.3", - "karma-htmlfile-reporter": "^0.3.8", - "karma-mocha": "^2.0.1", - "karma-verbose-reporter": "^0.0.8", - "karma-webpack": "^5.0.1", - "luxon": "^3.7.1", - "maplibre-gl": "^5.7.0", + "luxon": "^3.6.1", + "maplibre-gl": "^5.6.1", "memoize-one": "^6.0.0", - "mini-css-extract-plugin": "^2.9.4", - "minimist": "^1.2.8", - "mocha": "^11.7.2", + "mini-css-extract-plugin": "^2.9.2", + "minimist": ">=1.2.8", "node-storage-shim": "^2.0.1", "passive-events-support": "^1.1.0", "photoswipe": "^5.4.4", @@ -1705,15 +1695,6 @@ "node": ">=18" } }, - "node_modules/@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "license": "MIT", - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/@csstools/cascade-layer-name-parser": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@csstools/cascade-layer-name-parser/-/cascade-layer-name-parser-2.0.5.tgz", @@ -2965,12 +2946,6 @@ "integrity": "sha512-ZsZ2I9Vzso3Ho/pjZFsmmZ++FWeEd/txqybHTm4OgaZzdS8V9V/YYWQwg5TC38Z7uLWUV1vavpLLbjJtKubR1A==", "license": "MIT" }, - "node_modules/@epic-web/invariant": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz", - "integrity": "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==", - "license": "MIT" - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz", @@ -6169,6 +6144,7 @@ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "license": "ISC", + "optional": true, "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -6182,6 +6158,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "license": "MIT", + "optional": true, "engines": { "node": ">=8.6" }, @@ -7510,6 +7487,7 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", "license": "MIT", + "optional": true, "engines": { "node": ">=8" }, @@ -7606,12 +7584,6 @@ "integrity": "sha512-+ityJqcjhozQNrezzTd2dtH/lkIXmE52HL+FohK2TOLQDl3QURTNkim+2C0xcso4Zehq/HM4Wkumcdz7Ue+XmA==", "license": "MIT" }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "license": "ISC" - }, "node_modules/browserslist": { "version": "4.25.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.4.tgz", @@ -7914,6 +7886,7 @@ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "license": "MIT", + "optional": true, "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -7942,15 +7915,6 @@ "node": ">=18" } }, - "node_modules/chrome-finder": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/chrome-finder/-/chrome-finder-1.0.7.tgz", - "integrity": "sha512-Cxdl9ns86sXKMU5jIWy7rb0jX0SlWBNVV30/eBvtYCSx+GfLOM+MyODWd6gv72QONFWPbEmere8VL/xVIrTzmA==", - "license": "ISC", - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/chrome-trace-event": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz", @@ -8015,58 +7979,6 @@ "node": ">= 0.4" } }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/cliui/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==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "license": "MIT" - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/clone-deep": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", @@ -8142,15 +8054,6 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "license": "MIT" }, - "node_modules/colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "license": "MIT", - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -8352,21 +8255,6 @@ "proto-list": "~1.2.1" } }, - "node_modules/connect": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", - "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", - "license": "MIT", - "dependencies": { - "debug": "2.6.9", - "finalhandler": "1.1.2", - "parseurl": "~1.3.3", - "utils-merge": "1.0.1" - }, - "engines": { - "node": ">= 0.10.0" - } - }, "node_modules/connect-redis": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/connect-redis/-/connect-redis-7.1.1.tgz", @@ -8379,21 +8267,6 @@ "express-session": ">=1" } }, - "node_modules/connect/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "license": "MIT", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/connect/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "license": "MIT" - }, "node_modules/console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -8544,20 +8417,21 @@ } }, "node_modules/cross-env": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-10.0.0.tgz", - "integrity": "sha512-aU8qlEK/nHYtVuN4p7UQgAwVljzMg8hB4YK5ThRqD2l/ziSnryncPNn7bMLt5cFYsKVKBh8HqLqyCoTupEUu7Q==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", "license": "MIT", "dependencies": { - "@epic-web/invariant": "^1.0.0", - "cross-spawn": "^7.0.6" + "cross-spawn": "^7.0.1" }, "bin": { - "cross-env": "dist/bin/cross-env.js", - "cross-env-shell": "dist/bin/cross-env-shell.js" + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" }, "engines": { - "node": ">=20" + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" } }, "node_modules/cross-spawn": { @@ -9058,12 +8932,6 @@ "integrity": "sha512-d4ZVpCW31eWwCMe1YT3ur7mUDnTXbgwyzaL320DrcRT45rfjYxkt5QWLrmOJ+/UEAI2+fQgKe/fCjR8l4TpRgw==", "license": "MIT" }, - "node_modules/custom-event": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "integrity": "sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg==", - "license": "MIT" - }, "node_modules/data-urls": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", @@ -9128,15 +8996,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/date-format": { - "version": "4.0.14", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", - "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", - "license": "MIT", - "engines": { - "node": ">=4.0" - } - }, "node_modules/de-indent": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", @@ -9175,18 +9034,6 @@ "callsite": "^1.0.0" } }, - "node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/decimal.js": { "version": "10.6.0", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", @@ -9479,21 +9326,6 @@ "wrappy": "1" } }, - "node_modules/di": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "integrity": "sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA==", - "license": "MIT" - }, - "node_modules/diff": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", - "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", @@ -9518,18 +9350,6 @@ "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "license": "MIT" }, - "node_modules/dom-serialize": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "integrity": "sha512-Yra4DbvoW7/Z6LBN560ZwXMjoNOSAN2wRsKFGc4iBeso+mpIA6qj1vfdf9HpMaKAqG6wXTy+1SYEzmNpKXOSsQ==", - "license": "MIT", - "dependencies": { - "custom-event": "~1.0.0", - "ent": "~2.2.0", - "extend": "^3.0.0", - "void-elements": "^2.0.0" - } - }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -9874,21 +9694,6 @@ "node": ">=10.13.0" } }, - "node_modules/ent": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.2.tgz", - "integrity": "sha512-kKvD1tO6BM+oK9HzCPpUdRb4vKFQY/FPTFmurMvh6LlN68VMrdj77w8yp51/kDbpkFOS9J8w5W6zIzgM2H8/hw==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.3", - "es-errors": "^1.3.0", - "punycode": "^1.4.1", - "safe-regex-test": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -10780,12 +10585,6 @@ "node": ">= 0.6" } }, - "node_modules/eventemitter3": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", - "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", - "license": "MIT" - }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -11320,51 +11119,6 @@ "node": ">=8" } }, - "node_modules/finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "license": "MIT", - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "statuses": "~1.5.0", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/finalhandler/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "license": "MIT", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/finalhandler/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "license": "MIT" - }, - "node_modules/finalhandler/node_modules/on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/find-cache-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", @@ -11645,20 +11399,6 @@ "node": ">= 0.6" } }, - "node_modules/fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, "node_modules/fs-readdir-recursive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", @@ -11799,15 +11539,6 @@ "integrity": "sha512-AV9ROqlNqoZEIJGfm1ncNjEXfkz2hdFlZf0qkVfmkwdKa8vj7H16YUOT81rJw1rdFhyEDlN2Tds91p/glzbl5A==", "license": "ISC" }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, "node_modules/get-east-asian-width": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.1.tgz", @@ -12017,6 +11748,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "license": "ISC", + "optional": true, "dependencies": { "is-glob": "^4.0.1" }, @@ -12451,20 +12183,6 @@ "node": ">= 0.8" } }, - "node_modules/http-proxy": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", - "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", - "license": "MIT", - "dependencies": { - "eventemitter3": "^4.0.0", - "follow-redirects": "^1.0.0", - "requires-port": "^1.0.0" - }, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", @@ -12860,6 +12578,7 @@ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", "license": "MIT", + "optional": true, "dependencies": { "binary-extensions": "^2.0.0" }, @@ -13164,15 +12883,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -13378,18 +13088,6 @@ "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", "license": "MIT" }, - "node_modules/isbinaryfile": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", - "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", - "license": "MIT", - "engines": { - "node": ">= 8.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/gjtorikian/" - } - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -13871,15 +13569,6 @@ "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==", "license": "MIT" }, - "node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/jstransformer": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz", @@ -13890,232 +13579,6 @@ "promise": "^7.0.1" } }, - "node_modules/karma": { - "version": "6.4.4", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.4.tgz", - "integrity": "sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w==", - "license": "MIT", - "dependencies": { - "@colors/colors": "1.5.0", - "body-parser": "^1.19.0", - "braces": "^3.0.2", - "chokidar": "^3.5.1", - "connect": "^3.7.0", - "di": "^0.0.1", - "dom-serialize": "^2.2.1", - "glob": "^7.1.7", - "graceful-fs": "^4.2.6", - "http-proxy": "^1.18.1", - "isbinaryfile": "^4.0.8", - "lodash": "^4.17.21", - "log4js": "^6.4.1", - "mime": "^2.5.2", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.5", - "qjobs": "^1.2.0", - "range-parser": "^1.2.1", - "rimraf": "^3.0.2", - "socket.io": "^4.7.2", - "source-map": "^0.6.1", - "tmp": "^0.2.1", - "ua-parser-js": "^0.7.30", - "yargs": "^16.1.1" - }, - "bin": { - "karma": "bin/karma" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/karma-chrome-launcher": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz", - "integrity": "sha512-rE9RkUPI7I9mAxByQWkGJFXfFD6lE4gC5nPuZdobf/QdTEJI6EU4yIay/cfU/xV4ZxlM5JiTv7zWYgA64NpS5Q==", - "license": "MIT", - "dependencies": { - "which": "^1.2.1" - } - }, - "node_modules/karma-chrome-launcher/node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, - "node_modules/karma-coverage-istanbul-reporter": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/karma-coverage-istanbul-reporter/-/karma-coverage-istanbul-reporter-3.0.3.tgz", - "integrity": "sha512-wE4VFhG/QZv2Y4CdAYWDbMmcAHeS926ZIji4z+FkB2aF/EposRb6DP6G5ncT/wXhqUfAb/d7kZrNKPonbvsATw==", - "license": "MIT", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-report": "^3.0.0", - "istanbul-lib-source-maps": "^3.0.6", - "istanbul-reports": "^3.0.2", - "minimatch": "^3.0.4" - }, - "funding": { - "url": "https://github.com/sponsors/mattlewis92" - } - }, - "node_modules/karma-coverage-istanbul-reporter/node_modules/istanbul-lib-source-maps": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz", - "integrity": "sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw==", - "license": "BSD-3-Clause", - "dependencies": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^2.0.5", - "make-dir": "^2.1.0", - "rimraf": "^2.6.3", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/karma-coverage-istanbul-reporter/node_modules/istanbul-lib-source-maps/node_modules/istanbul-lib-coverage": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", - "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=6" - } - }, - "node_modules/karma-coverage-istanbul-reporter/node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "license": "ISC", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/karma-coverage-istanbul-reporter/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/karma-htmlfile-reporter": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/karma-htmlfile-reporter/-/karma-htmlfile-reporter-0.3.8.tgz", - "integrity": "sha512-Hd4c/vqPXYjdNYXeDJRMMq2DMMxPxqOR+TPeiLz2qbqO0qCCQMeXwFGhNDFr+GsvYhcOyn7maTbWusUFchS/4A==", - "license": "MIT", - "dependencies": { - "xmlbuilder": "^10.0.0" - }, - "peerDependencies": { - "karma": ">=0.10" - } - }, - "node_modules/karma-mocha": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz", - "integrity": "sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ==", - "license": "MIT", - "dependencies": { - "minimist": "^1.2.3" - } - }, - "node_modules/karma-verbose-reporter": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/karma-verbose-reporter/-/karma-verbose-reporter-0.0.8.tgz", - "integrity": "sha512-wHgevIcEpfgKwR3CnWd8t1ErzWeVlctO7ZtXkKFR1inb006ogz+7ZKg95eIVOnHCYWL3Gdy1dRMOGjVP0n4MlA==", - "license": "MIT", - "dependencies": { - "colors": "1.4.0" - }, - "peerDependencies": { - "karma": ">=0.12" - } - }, - "node_modules/karma-webpack": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-5.0.1.tgz", - "integrity": "sha512-oo38O+P3W2mSPCSUrQdySSPv1LvPpXP+f+bBimNomS5sW+1V4SuhCuW8TfJzV+rDv921w2fDSDw0xJbPe6U+kQ==", - "license": "MIT", - "dependencies": { - "glob": "^7.1.3", - "minimatch": "^9.0.3", - "webpack-merge": "^4.1.5" - }, - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "webpack": "^5.0.0" - } - }, - "node_modules/karma-webpack/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/karma-webpack/node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "license": "MIT" - }, - "node_modules/karma-webpack/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/karma-webpack/node_modules/webpack-merge": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", - "integrity": "sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g==", - "license": "MIT", - "dependencies": { - "lodash": "^4.17.15" - } - }, - "node_modules/karma/node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "license": "MIT" - }, - "node_modules/karma/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/kdbush": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-4.0.2.tgz", @@ -14334,22 +13797,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/log4js": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.9.1.tgz", - "integrity": "sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g==", - "license": "Apache-2.0", - "dependencies": { - "date-format": "^4.0.14", - "debug": "^4.3.4", - "flatted": "^3.2.7", - "rfdc": "^1.3.0", - "streamroller": "^3.1.5" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -14624,18 +14071,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/mime": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", - "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", - "license": "MIT", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -14765,284 +14200,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/mocha": { - "version": "11.7.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.7.2.tgz", - "integrity": "sha512-lkqVJPmqqG/w5jmmFtiRvtA2jkDyNVUcefFJKb2uyX4dekk8Okgqop3cgbFiaIvj8uCRJVTP5x9dfxGyXm2jvQ==", - "license": "MIT", - "dependencies": { - "browser-stdout": "^1.3.1", - "chokidar": "^4.0.1", - "debug": "^4.3.5", - "diff": "^7.0.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^10.4.5", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^9.0.5", - "ms": "^2.1.3", - "picocolors": "^1.1.1", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^9.2.0", - "yargs": "^17.7.2", - "yargs-parser": "^21.1.1", - "yargs-unparser": "^2.0.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha.js" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/mocha/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==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/mocha/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/mocha/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/mocha/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/mocha/node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/mocha/node_modules/chokidar": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", - "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", - "license": "MIT", - "dependencies": { - "readdirp": "^4.0.1" - }, - "engines": { - "node": ">= 14.16.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/mocha/node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/mocha/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "license": "MIT" - }, - "node_modules/mocha/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/mocha/node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/mocha/node_modules/readdirp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", - "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", - "license": "MIT", - "engines": { - "node": ">= 14.18.0" - }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/mocha/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/mocha/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/mocha/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/mocha/node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "license": "MIT", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/mrmime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", @@ -17971,12 +17128,6 @@ "integrity": "sha512-yYELe9Q5q9IQhuvqsZNwA5hfPkMJ8u92bQLIMcsMxf/VADjNtEYptU+inlufAFYcWdHlwNfZOEnOOQrZrcyJCQ==", "license": "MIT" }, - "node_modules/punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", - "license": "MIT" - }, "node_modules/q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", @@ -17988,15 +17139,6 @@ "teleport": ">=0.2.0" } }, - "node_modules/qjobs": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", - "integrity": "sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg==", - "license": "MIT", - "engines": { - "node": ">=0.9" - } - }, "node_modules/qs": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", @@ -18171,6 +17313,7 @@ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "license": "MIT", + "optional": true, "dependencies": { "picomatch": "^2.2.1" }, @@ -18183,6 +17326,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "license": "MIT", + "optional": true, "engines": { "node": ">=8.6" }, @@ -18514,15 +17658,6 @@ "integrity": "sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==", "license": "MIT" }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -18541,12 +17676,6 @@ "node": ">=0.10.5" } }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", - "license": "MIT" - }, "node_modules/resolve": { "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", @@ -18689,12 +17818,6 @@ "node": ">=0.12" } }, - "node_modules/rfdc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", - "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", - "license": "MIT" - }, "node_modules/right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", @@ -18707,22 +17830,6 @@ "node": ">=0.10.0" } }, - "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "license": "ISC", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/rndm": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/rndm/-/rndm-1.2.0.tgz", @@ -19958,20 +19065,6 @@ "node": ">= 0.4" } }, - "node_modules/streamroller": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.5.tgz", - "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", - "license": "MIT", - "dependencies": { - "date-format": "^4.0.14", - "debug": "^4.3.4", - "fs-extra": "^8.1.0" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -20722,15 +19815,6 @@ "integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==", "license": "MIT" }, - "node_modules/tmp": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", - "integrity": "sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==", - "license": "MIT", - "engines": { - "node": ">=14.14" - } - }, "node_modules/to-fast-properties": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", @@ -21077,32 +20161,6 @@ "node": ">=8" } }, - "node_modules/ua-parser-js": { - "version": "0.7.41", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.41.tgz", - "integrity": "sha512-O3oYyCMPYgNNHuO7Jjk3uacJWZF8loBgwrfd/5LE/HyZ3lUIOdniQ7DNXJcIgZbwioZxk0fLfI4EVnetdiX5jg==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/ua-parser-js" - }, - { - "type": "paypal", - "url": "https://paypal.me/faisalman" - }, - { - "type": "github", - "url": "https://github.com/sponsors/faisalman" - } - ], - "license": "MIT", - "bin": { - "ua-parser-js": "script/cli.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/uglify-js": { "version": "3.19.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", @@ -21207,15 +20265,6 @@ "node": ">=0.10.0" } }, - "node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -21684,15 +20733,6 @@ "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", "license": "MIT" }, - "node_modules/void-elements": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/volar-service-css": { "version": "0.0.65", "resolved": "https://registry.npmjs.org/volar-service-css/-/volar-service-css-0.0.65.tgz", @@ -23173,29 +22213,6 @@ "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", "license": "MIT" }, - "node_modules/workerpool": { - "version": "9.3.3", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-9.3.3.tgz", - "integrity": "sha512-slxCaKbYjEdFT/o2rH9xS1hf4uRDch1w7Uo+apxhZ+sf/1d9e0ZVkn42kPNGP2dgjIx6YFvSevj0zHvbWe2jdw==", - "license": "Apache-2.0" - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", @@ -23270,62 +22287,6 @@ "node": ">=8" } }, - "node_modules/wrap-ansi/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==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "license": "MIT" - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -23362,15 +22323,6 @@ "node": ">=12" } }, - "node_modules/xmlbuilder": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-10.1.1.tgz", - "integrity": "sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==", - "license": "MIT", - "engines": { - "node": ">=4.0" - } - }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", @@ -23386,125 +22338,12 @@ "cuint": "^0.2.2" } }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "license": "ISC", - "engines": { - "node": ">=10" - } - }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "license": "ISC" }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "license": "MIT", - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "license": "MIT", - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-unparser/node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yargs/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==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "license": "MIT" - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "license": "ISC", - "engines": { - "node": ">=10" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index eb02a719b..92706b689 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,12 +17,10 @@ "gettext-compile": "vue-gettext-compile", "gettext-extract": "gettext-extract --output src/locales/translations.pot $(find ${SRC:-src} -type f \\( -iname \\*.vue -o -iname \\*.js \\) -not -path src/common/gettext.js)", "lint": "eslint --cache src/ *.js", - "test": "karma start", - "vitest": "env TZ=UTC vitest run", - "vitest-watch": "env TZ=UTC vitest --watch", - "vitest-coverage": "env TZ=UTC vitest run --coverage", - "vitest-component": "env TZ=UTC vitest run tests/vitest/component", - "vitest-ui": "env TZ=UTC vitest --ui --watch", + "test": "cross-env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test vitest run", + "test-watch": "cross-env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test vitest --watch", + "test-coverage": "cross-env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test vitest run --coverage", + "test-component": "cross-env TZ=UTC BUILD_ENV=development NODE_ENV=development BABEL_ENV=test vitest run tests/vitest/component", "testcafe": "testcafe", "trace": "webpack --stats-children", "update": "npm update --save --package-lock && npm install --no-update-notifier --no-audit", @@ -58,12 +56,10 @@ "babel-loader": "^10.0.0", "babel-plugin-istanbul": "^7.0.0", "babel-plugin-polyfill-corejs3": "^0.13.0", - "browserslist": "^4.25.4", - "chai": "^5.3.3", + "browserslist": "^4.25.0", "cheerio": "1.0.0-rc.12", - "chrome-finder": "^1.0.7", - "core-js": "^3.45.1", - "cross-env": "^10.0.0", + "core-js": "^3.43.0", + "cross-env": "^7.0.3", "css-loader": "^7.1.2", "cssnano": "^7.1.1", "easygettext": "^2.17.0", @@ -85,19 +81,11 @@ "hls.js": "^1.6.11", "i": "^0.3.7", "jsdom": "^26.1.0", - "karma": "^6.4.4", - "karma-chrome-launcher": "^3.2.0", - "karma-coverage-istanbul-reporter": "^3.0.3", - "karma-htmlfile-reporter": "^0.3.8", - "karma-mocha": "^2.0.1", - "karma-verbose-reporter": "^0.0.8", - "karma-webpack": "^5.0.1", - "luxon": "^3.7.1", - "maplibre-gl": "^5.7.0", + "luxon": "^3.6.1", + "maplibre-gl": "^5.6.1", "memoize-one": "^6.0.0", - "mini-css-extract-plugin": "^2.9.4", - "minimist": "^1.2.8", - "mocha": "^11.7.2", + "mini-css-extract-plugin": "^2.9.2", + "minimist": ">=1.2.8", "node-storage-shim": "^2.0.1", "passive-events-support": "^1.1.0", "photoswipe": "^5.4.4", diff --git a/frontend/tests/unit/common/api_test.js b/frontend/tests/unit/common/api_test.js deleted file mode 100644 index 9717403fb..000000000 --- a/frontend/tests/unit/common/api_test.js +++ /dev/null @@ -1,104 +0,0 @@ -import { $api } from "../fixtures"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/api", () => { - const getCollectionResponse = [ - { id: 1, name: "John Smith" }, - { id: 1, name: "John Smith" }, - ]; - - const getEntityResponse = { - id: 1, - name: "John Smith", - }; - - const postEntityResponse = { - users: [{ id: 1, name: "John Smith" }], - }; - - const putEntityResponse = { - users: [{ id: 2, name: "John Foo" }], - }; - - const deleteEntityResponse = null; - - it("get should return a list of results and return with HTTP code 200", (done) => { - $api - .get("foo") - .then((response) => { - assert.equal(200, response.status); - assert.deepEqual(getCollectionResponse, response.data); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("get should return one item and return with HTTP code 200", (done) => { - $api - .get("foo/123") - .then((response) => { - assert.equal(200, response.status); - assert.deepEqual(getEntityResponse, response.data); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("post should create one item and return with HTTP code 201", (done) => { - $api - .post("foo", postEntityResponse) - .then((response) => { - assert.equal(201, response.status); - assert.deepEqual(postEntityResponse, response.data); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("put should update one item and return with HTTP code 200", (done) => { - $api - .put("foo/2", putEntityResponse) - .then((response) => { - assert.equal(200, response.status); - assert.deepEqual(putEntityResponse, response.data); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("delete should delete one item and return with HTTP code 204", (done) => { - $api - .delete("foo/2", deleteEntityResponse) - .then((response) => { - assert.equal(204, response.status); - assert.deepEqual(deleteEntityResponse, response.data); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - /* - it("get error", function () { - return Api.get("error") - .then(function (m) { - return Promise.reject("error expected"); - }) - .catch(function (m) { - assert.equal(m.message, "Request failed with status code 401"); - return Promise.resolve(); - }); - }); - */ -}); diff --git a/frontend/tests/unit/common/can_test.js b/frontend/tests/unit/common/can_test.js deleted file mode 100644 index cd2a956da..000000000 --- a/frontend/tests/unit/common/can_test.js +++ /dev/null @@ -1,59 +0,0 @@ -import "../fixtures"; -import * as can from "common/can"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/can", () => { - it("useVideo", () => { - assert.equal(can.useVideo, true); - }); - - it("useMp4Avc", () => { - assert.equal(can.useMp4Avc, true); - }); - - it("useMp4Hvc", () => { - assert.equal(can.useMp4Hvc, false); - }); - - it("useMp4Hev", () => { - assert.equal(can.useMp4Hev, false); - }); - - it("useMp4Vvc", () => { - assert.equal(can.useMp4Vvc, false); - }); - - it("useMp4Evc", () => { - assert.equal(can.useMp4Evc, false); - }); - - it("useMp4Av1", () => { - assert.equal(can.useMp4Av1, true); - }); - - it("useVP8", () => { - assert.equal(can.useVP8, true); - }); - - it("useVP9", () => { - assert.equal(can.useVP9, true); - }); - - it("useWebmAv1", () => { - assert.equal(can.useWebmAv1, true); - }); - - it("useMkvAv1", () => { - assert.equal(can.useMkvAv1, false); - }); - - it("useWebM", () => { - assert.equal(can.useWebM, true); - }); - - it("useTheora", () => { - assert.equal(can.useTheora, true); - }); -}); diff --git a/frontend/tests/unit/common/clipboard_test.js b/frontend/tests/unit/common/clipboard_test.js deleted file mode 100644 index 8616a533e..000000000 --- a/frontend/tests/unit/common/clipboard_test.js +++ /dev/null @@ -1,197 +0,0 @@ -import "../fixtures"; -import { Clipboard } from "common/clipboard"; -import Photo from "model/photo"; -import Album from "model/album"; -import StorageShim from "node-storage-shim"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/clipboard", () => { - it("should construct clipboard", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - assert.equal(clipboard.storageKey, "clipboard"); - assert.equal(clipboard.selection, ""); - }); - - it("should toggle model", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.toggle(); - assert.equal(clipboard.storageKey, "clipboard"); - assert.equal(clipboard.selection, ""); - - const values = { ID: 5, UID: "ABC123", Title: "Crazy Cat" }; - const photo = new Photo(values); - clipboard.toggle(photo); - assert.equal(clipboard.selection[0], "ABC123"); - const values2 = { ID: 8, UID: "ABC124", Title: "Crazy Cat" }; - const photo2 = new Photo(values2); - clipboard.toggle(photo2); - assert.equal(clipboard.selection[0], "ABC123"); - assert.equal(clipboard.selection[1], "ABC124"); - clipboard.toggle(photo); - assert.equal(clipboard.selection[0], "ABC124"); - }); - - it("should toggle id", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.toggleId(3); - assert.equal(clipboard.selection[0], 3); - clipboard.toggleId(3); - assert.equal(clipboard.selection, ""); - }); - - it("should add model", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.add(); - assert.equal(clipboard.storageKey, "clipboard"); - assert.equal(clipboard.selection, ""); - - const values = { ID: 5, UID: "ABC124", Title: "Crazy Cat" }; - const photo = new Photo(values); - clipboard.add(photo); - assert.equal(clipboard.selection[0], "ABC124"); - clipboard.add(photo); - assert.equal(clipboard.selection[0], "ABC124"); - }); - - it("should add id", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.addId(99); - assert.equal(clipboard.selection[0], 99); - }); - - it("should test whether clipboard has model", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.has(); - assert.equal(clipboard.storageKey, "clipboard"); - assert.equal(clipboard.selection, ""); - - const values = { ID: 5, UID: "ABC124", Title: "Crazy Cat" }; - const photo = new Photo(values); - clipboard.add(photo); - assert.equal(clipboard.selection[0], "ABC124"); - const result = clipboard.has(photo); - assert.equal(result, true); - const values2 = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values2); - const result2 = clipboard.has(album); - assert.equal(result2, false); - }); - - it("should test whether clipboard has id", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.addId(77); - assert.equal(clipboard.hasId(77), true); - assert.equal(clipboard.hasId(78), false); - }); - - it("should remove model", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.remove(); - assert.equal(clipboard.storageKey, "clipboard"); - assert.equal(clipboard.selection, ""); - - const values = { ID: 5, UID: "ABC123", Title: "Crazy Cat" }; - const photo = new Photo(values); - clipboard.add(photo); - assert.equal(clipboard.selection[0], "ABC123"); - - clipboard.remove(photo); - assert.equal(clipboard.selection, ""); - const values2 = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values2); - clipboard.remove(album); - assert.equal(clipboard.selection, ""); - }); - - it("should set and get ids", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.setIds(8); - assert.equal(clipboard.selection, ""); - clipboard.setIds([5, 6, 9]); - assert.equal(clipboard.selection[0], 5); - assert.equal(clipboard.selection[2], 9); - const result = clipboard.getIds(); - assert.equal(result[1], 6); - assert.equal(result.length, 3); - }); - - it("should clear", () => { - const storage = new StorageShim(); - const key = "clipboard"; - - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - clipboard.setIds([5, 6, 9]); - assert.equal(clipboard.selection[0], 5); - clipboard.clear(); - assert.equal(clipboard.selection, ""); - }); - - it("should add range", () => { - const storage = new StorageShim(); - const key = "clipboard"; - const clipboard = new Clipboard(storage, key); - clipboard.clear(); - const values = { ID: 5, UID: "ABC124", Title: "Crazy Cat" }; - const photo = new Photo(values); - const values2 = { ID: 6, UID: "ABC125", Title: "Crazy Dog" }; - const photo2 = new Photo(values2); - const values3 = { ID: 7, UID: "ABC128", Title: "Cute Dog" }; - const photo3 = new Photo(values3); - const values4 = { ID: 8, UID: "ABC129", Title: "Turtle" }; - const photo4 = new Photo(values4); - const Photos = [photo, photo2, photo3, photo4]; - clipboard.addRange(2); - assert.equal(clipboard.selection.length, 0); - clipboard.clear(); - clipboard.addRange(2, Photos); - assert.equal(clipboard.selection[0], "ABC128"); - assert.equal(clipboard.selection.length, 1); - clipboard.addRange(1, Photos); - assert.equal(clipboard.selection.length, 2); - assert.equal(clipboard.selection[0], "ABC128"); - assert.equal(clipboard.selection[1], "ABC125"); - clipboard.clear(); - clipboard.add(photo); - assert.equal(clipboard.selection.length, 1); - clipboard.addRange(3, Photos); - assert.equal(clipboard.selection.length, 4); - }); -}); diff --git a/frontend/tests/unit/common/config_test.js b/frontend/tests/unit/common/config_test.js deleted file mode 100644 index 7f600ea3d..000000000 --- a/frontend/tests/unit/common/config_test.js +++ /dev/null @@ -1,322 +0,0 @@ -import "../fixtures"; -import Config from "common/config"; -import StorageShim from "node-storage-shim"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -const defaultConfig = new Config(new StorageShim(), window.__CONFIG__); - -describe("common/config", () => { - it("should get all config values", () => { - const storage = new StorageShim(); - const values = { siteTitle: "Foo", name: "testConfig", year: "2300" }; - - const cfg = new Config(storage, values); - const result = cfg.getValues(); - assert.equal(result.name, "testConfig"); - }); - - it("should set multiple config values", () => { - const storage = new StorageShim(); - const values = { - siteTitle: "Foo", - country: "Germany", - city: "Hamburg", - settings: { ui: { language: "de", theme: "default" } }, - }; - const newValues = { - siteTitle: "Foo", - new: "xxx", - city: "Berlin", - debug: true, - settings: { ui: { language: "en", theme: "lavender" } }, - }; - const cfg = new Config(storage, values); - assert.equal(cfg.values.settings.ui.theme, "default"); - assert.equal(cfg.values.settings.ui.language, "de"); - assert.equal(cfg.values.new, undefined); - assert.equal(cfg.values.city, "Hamburg"); - cfg.setValues(); - assert.equal(cfg.values.new, undefined); - assert.equal(cfg.values.city, "Hamburg"); - cfg.setValues(newValues); - const result = cfg.getValues(); - assert.equal(result.city, "Berlin"); - assert.equal(result.new, "xxx"); - assert.equal(result.country, "Germany"); - assert.equal(cfg.values.settings.ui.theme, "lavender"); - assert.equal(cfg.values.settings.ui.language, "en"); - }); - - it("should test constructor with empty values", () => { - const storage = new StorageShim(); - const values = {}; - const config = new Config(storage, values); - assert.equal(config.debug, true); - assert.equal(config.demo, false); - assert.equal(config.apiUri, "/api/v1"); - }); - - it("should store values", () => { - const storage = new StorageShim(); - const values = { siteTitle: "Foo", country: "Germany", city: "Hamburg" }; - const config = new Config(storage, values); - assert.equal(config.storage["config"], undefined); - config.storeValues(); - const expected = '{"siteTitle":"Foo","country":"Germany","city":"Hamburg"}'; - assert.equal(config.storage["config"], expected); - }); - - it("should return the develop feature flag value", () => { - assert.equal(defaultConfig.featDevelop(), true); - }); - - it("should return the experimental feature flag value", () => { - assert.equal(defaultConfig.featExperimental(), true); - }); - - it("should return the preview feature flag value", () => { - assert.equal(defaultConfig.featPreview(), true); - }); - - it("should set and get single config value", () => { - const storage = new StorageShim(); - const values = { siteTitle: "Foo", country: "Germany", city: "Hamburg" }; - - const config = new Config(storage, values); - config.set("city", "Berlin"); - const result = config.get("city"); - assert.equal(result, "Berlin"); - }); - - it("should return app about", () => { - assert.equal(defaultConfig.getAbout(), "PhotoPrism® CE"); - }); - - it("should return app edition", () => { - assert.equal(defaultConfig.getEdition(), "ce"); - }); - - it("should return settings", () => { - const result = defaultConfig.getSettings(); - assert.equal(result.ui.theme, "default"); - assert.equal(result.ui.language, "en"); - }); - - it("should return feature", () => { - assert.equal(defaultConfig.feature("places"), true); - assert.equal(defaultConfig.feature("download"), true); - }); - - it("should test get name", () => { - const result = defaultConfig.getPerson("a"); - assert.equal(result, null); - - const result2 = defaultConfig.getPerson("Andrea Sander"); - assert.equal(result2.UID, "jr0jgyx2viicdnf7"); - - const result3 = defaultConfig.getPerson("Otto Sander"); - assert.equal(result3.UID, "jr0jgyx2viicdn88"); - }); - - it("should create, update and delete people", () => { - const storage = new StorageShim(); - const values = { Debug: true, siteTitle: "Foo", country: "Germany", city: "Hamburg" }; - - const cfg = new Config(storage, values); - cfg.onPeople("people.created", { entities: {} }); - assert.empty(cfg.values.people); - cfg.onPeople("people.created", { - entities: [ - { - UID: "abc123", - Name: "Test Name", - Keywords: ["Test", "Name"], - }, - ], - }); - assert.equal(cfg.values.people[0].Name, "Test Name"); - cfg.onPeople("people.updated", { - entities: [ - { - UID: "abc123", - Name: "New Name", - Keywords: ["New", "Name"], - }, - ], - }); - assert.equal(cfg.values.people[0].Name, "New Name"); - cfg.onPeople("people.deleted", { - entities: ["abc123"], - }); - assert.empty(cfg.values.people); - }); - - it("should return language locale", () => { - const cfg = new Config(new StorageShim(), Object.assign({}, window.__CONFIG__)); - assert.equal(cfg.getLanguageLocale(), "en"); - }); - - it("should return user time zone", () => { - const cfg = new Config(new StorageShim(), Object.assign({}, window.__CONFIG__)); - assert.equal(cfg.getTimeZone(), "Local"); - }); - - it("should return if language is rtl", () => { - const cfg = new Config(new StorageShim(), Object.assign({}, window.__CONFIG__)); - const result = cfg.isRtl(); - assert.equal(result, false); - const newValues = { - Debug: true, - siteTitle: "Foo", - country: "Germany", - city: "Hamburg", - settings: { - ui: { - language: "he", - }, - }, - }; - cfg.setValues(newValues); - const result2 = cfg.isRtl(); - assert.equal(result2, true); - const values2 = { siteTitle: "Foo" }; - const storage = new StorageShim(); - const config3 = new Config(storage, values2); - const result3 = config3.isRtl(); - assert.equal(result3, false); - cfg.setLanguage("en"); - }); - - it("should return album categories", () => { - const cfg = new Config(new StorageShim(), Object.assign({}, window.__CONFIG__)); - const result = cfg.albumCategories(); - assert.equal(result[0], "Animal"); - const newValues = { - albumCategories: ["Mouse"], - }; - cfg.setValues(newValues); - const result2 = cfg.albumCategories(); - assert.equal(result2[0], "Mouse"); - }); - - it("should update counts", () => { - const cfg = new Config(new StorageShim(), Object.assign({}, window.__CONFIG__)); - assert.equal(cfg.values.count.all, 133); - assert.equal(cfg.values.count.photos, 132); - cfg.onCount("add.photos", { - count: 2, - }); - assert.equal(cfg.values.count.all, 135); - assert.equal(cfg.values.count.photos, 134); - assert.equal(cfg.values.count.videos, 1); - cfg.onCount("add.videos", { - count: 1, - }); - assert.equal(cfg.values.count.all, 136); - assert.equal(cfg.values.count.videos, 2); - assert.equal(cfg.values.count.cameras, 6); - cfg.onCount("add.cameras", { - count: 3, - }); - assert.equal(cfg.values.count.all, 136); - assert.equal(cfg.values.count.cameras, 9); - assert.equal(cfg.values.count.lenses, 5); - cfg.onCount("add.lenses", { - count: 1, - }); - assert.equal(cfg.values.count.lenses, 6); - assert.equal(cfg.values.count.countries, 6); - cfg.onCount("add.countries", { - count: 2, - }); - assert.equal(cfg.values.count.countries, 8); - assert.equal(cfg.values.count.states, 8); - cfg.onCount("add.states", { - count: 1, - }); - assert.equal(cfg.values.count.states, 9); - assert.equal(cfg.values.count.people, 5); - cfg.onCount("add.people", { - count: 4, - }); - assert.equal(cfg.values.count.people, 9); - assert.equal(cfg.values.count.places, 17); - cfg.onCount("add.places", { - count: 1, - }); - assert.equal(cfg.values.count.places, 18); - assert.equal(cfg.values.count.labels, 22); - cfg.onCount("add.labels", { - count: 2, - }); - assert.equal(cfg.values.count.labels, 24); - assert.equal(cfg.values.count.albums, 2); - cfg.onCount("add.albums", { - count: 3, - }); - assert.equal(cfg.values.count.albums, 5); - assert.equal(cfg.values.count.moments, 4); - cfg.onCount("add.moments", { - count: 1, - }); - assert.equal(cfg.values.count.moments, 5); - assert.equal(cfg.values.count.months, 27); - cfg.onCount("add.months", { - count: 4, - }); - assert.equal(cfg.values.count.months, 31); - assert.equal(cfg.values.count.folders, 23); - cfg.onCount("add.folders", { - count: 2, - }); - assert.equal(cfg.values.count.folders, 25); - assert.equal(cfg.values.count.files, 136); - cfg.onCount("add.files", { - count: 14, - }); - assert.equal(cfg.values.count.files, 150); - assert.equal(cfg.values.count.favorites, 1); - cfg.onCount("add.favorites", { - count: 4, - }); - assert.equal(cfg.values.count.favorites, 5); - assert.equal(cfg.values.count.review, 22); - cfg.onCount("add.review", { - count: 1, - }); - assert.equal(cfg.values.count.all, 135); - assert.equal(cfg.values.count.review, 23); - assert.equal(cfg.values.count.private, 0); - cfg.onCount("add.private", { - count: 3, - }); - assert.equal(cfg.values.count.private, 3); - assert.equal(cfg.values.count.all, 135); - cfg.onCount("add.photos", { - count: 4, - }); - assert.equal(cfg.values.count.all, 139); - }); - - it("should return user interface direction string", async () => { - const cfg = new Config(new StorageShim(), Object.assign({}, window.__CONFIG__)); - await cfg.setLanguage("en", true); - assert.equal(document.dir, "ltr", "document.dir should be ltr"); - assert.equal(cfg.dir(), "ltr"); - assert.equal(cfg.dir(true), "rtl"); - assert.equal(cfg.dir(false), "ltr"); - await cfg.setLanguage("he", false); - assert.equal(document.dir, "ltr", "document.dir should still be ltr"); - await cfg.setLanguage("he", true); - assert.equal(cfg.dir(), "rtl"); - assert.equal(document.dir, "rtl", "document.dir should now be rtl"); - assert.equal(cfg.dir(), "rtl"); - assert.equal(cfg.dir(true), "rtl"); - assert.equal(cfg.dir(false), "ltr"); - await cfg.setLanguage("en", true); - assert.equal(document.dir, "ltr", "document.dir should be ltr again"); - assert.equal(cfg.dir(), "ltr"); - }); -}); diff --git a/frontend/tests/unit/common/form_test.js b/frontend/tests/unit/common/form_test.js deleted file mode 100644 index c5b1f2e3f..000000000 --- a/frontend/tests/unit/common/form_test.js +++ /dev/null @@ -1,132 +0,0 @@ -import "../fixtures"; -import { Form, FormPropertyType } from "common/form"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/form", () => { - it("setting and getting definition", () => { - const def = { foo: { type: FormPropertyType.String, caption: "Foo" } }; - const form = new Form(); - - form.setDefinition(def); - - const result = form.getDefinition(); - assert.equal(result, def); - }); - - it("setting and getting a value according to type", () => { - const def = { - foo: { type: FormPropertyType.String, caption: "Foo" }, - }; - const form = new Form(); - - form.setDefinition(def); - form.setValue("foo", "test"); - - const result = form.getValue("foo"); - assert.equal(result, "test"); - }); - - it("setting a value not according to type", () => { - const def = { - foo: { type: FormPropertyType.String, caption: "Foo" }, - }; - const form = new Form(); - - form.setDefinition(def); - - assert.throws(() => { - form.setValue("foo", 3); - }); - }); - - it("setting and getting a value for missing property throws exception", () => { - const def = { - foo: { type: FormPropertyType.String, caption: "Foo" }, - }; - const form = new Form(); - - form.setDefinition(def); - - assert.throws(() => { - form.setValue("bar", 3); - }); - - assert.throws(() => { - form.getValue("bar"); - }); - }); - - it("setting and getting a complex value", () => { - const complexValue = { - something: "abc", - another: "def", - }; - const def = { - foo: { - type: FormPropertyType.Object, - caption: "Foo", - }, - }; - const form = new Form(); - - form.setDefinition(def); - form.setValue("foo", complexValue); - - const result = form.getValue("foo"); - assert.deepEqual(result, complexValue); - }); - - it("setting and getting more values at once", () => { - const def = { - foo: { type: FormPropertyType.String, caption: "Foo" }, - baz: { type: FormPropertyType.String, caption: "XX" }, - }; - const form = new Form(); - - form.setDefinition(def); - form.setValues({ foo: "test", baz: "yyy" }); - - const result = form.getValues(); - assert.equal(result.foo, "test"); - assert.equal(result.baz, "yyy"); - }); - - it("getting options of fieldname", () => { - const def = { - search: { - type: FormPropertyType.String, - caption: "Search", - label: { options: "tiles", text: "Tiles" }, - options: [ - { value: "tiles", text: "Tiles" }, - { value: "mosaic", text: "Mosaic" }, - ], - }, - }; - const form = new Form(); - - form.setDefinition(def); - - const result = form.getOptions("search"); - assert.equal(result[0].value, "tiles"); - assert.equal(result[1].text, "Mosaic"); - }); - - it("getting not existing options returns empty object", () => { - const def = { - foo: { - type: FormPropertyType.Object, - caption: "Foo", - }, - }; - const form = new Form(); - - form.setDefinition(def); - - const result = form.getOptions("foo"); - assert.equal(result[0].option, ""); - assert.equal(result[0].label, ""); - }); -}); diff --git a/frontend/tests/unit/common/notify_test.js b/frontend/tests/unit/common/notify_test.js deleted file mode 100644 index 86b6e06bc..000000000 --- a/frontend/tests/unit/common/notify_test.js +++ /dev/null @@ -1,24 +0,0 @@ -import "../fixtures"; -import $notify from "common/notify"; - -describe("common/alert", () => { - it("should call alert.info", () => { - $notify.info("message"); - }); - - it("should call alert.warning", () => { - $notify.warn("message"); - }); - - it("should call alert.error", () => { - $notify.error("message"); - }); - - it("should call alert.success", () => { - $notify.success("message"); - }); - - it("should call wait", () => { - $notify.wait(); - }); -}); diff --git a/frontend/tests/unit/common/session_test.js b/frontend/tests/unit/common/session_test.js deleted file mode 100644 index 62a231448..000000000 --- a/frontend/tests/unit/common/session_test.js +++ /dev/null @@ -1,271 +0,0 @@ -import "../fixtures"; -import { $config } from "app/session"; -import Session from "common/session"; -import StorageShim from "node-storage-shim"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/session", () => { - beforeEach(() => { - window.onbeforeunload = () => "Oh no!"; - }); - - it("should construct session", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - assert.equal(session.authToken, null); - }); - - it("should set, get and delete token", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - assert.equal(session.hasToken("2lbh9x09"), false); - session.setAuthToken("999900000000000000000000000000000000000000000000"); - assert.equal(session.authToken, "999900000000000000000000000000000000000000000000"); - const result = session.getAuthToken(); - assert.equal(result, "999900000000000000000000000000000000000000000000"); - session.reset(); - assert.equal(session.authToken, null); - }); - - it("should set, get and delete user", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - assert.isFalse(session.user.hasId()); - - const user = { - ID: 5, - NickName: "Foo", - GivenName: "Max", - DisplayName: "Max Example", - Email: "test@test.com", - SuperAdmin: true, - Role: "admin", - }; - - const data = { - user, - }; - - assert.equal(session.hasId(), false); - assert.equal(session.hasAuthToken(), false); - assert.equal(session.isAuthenticated(), false); - assert.equal(session.hasProvider(), false); - session.setData(); - assert.equal(session.user.DisplayName, ""); - session.setData(data); - assert.equal(session.hasId(), false); - assert.equal(session.hasAuthToken(), false); - assert.equal(session.hasProvider(), false); - session.setId("a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f"); - session.setAuthToken("234200000000000000000000000000000000000000000000"); - session.setProvider("public"); - assert.equal(session.hasId(), true); - assert.equal(session.hasAuthToken(), true); - assert.equal(session.isAuthenticated(), true); - assert.equal(session.hasProvider(), true); - assert.equal(session.user.DisplayName, "Max Example"); - assert.equal(session.user.SuperAdmin, true); - assert.equal(session.user.Role, "admin"); - session.reset(); - assert.equal(session.user.DisplayName, ""); - assert.equal(session.user.SuperAdmin, false); - assert.equal(session.user.Role, ""); - session.setUser(user); - assert.equal(session.user.DisplayName, "Max Example"); - assert.equal(session.user.SuperAdmin, true); - assert.equal(session.user.Role, "admin"); - - const result = session.getUser(); - - assert.equal(result.DisplayName, "Max Example"); - assert.equal(result.SuperAdmin, true); - assert.equal(result.Role, "admin"); - assert.equal(result.Email, "test@test.com"); - assert.equal(result.ID, 5); - session.deleteData(); - assert.isTrue(session.user.hasId()); - session.deleteUser(); - assert.isFalse(session.user.hasId()); - }); - - it("should get user email", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - - session.setId("a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f"); - session.setAuthToken("234200000000000000000000000000000000000000000000"); - session.setProvider("public"); - - const values = { - user: { - ID: 5, - Name: "foo", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - - session.setData(values); - const result = session.getEmail(); - assert.equal(result, "test@test.com"); - const values2 = { - user: { - Name: "foo", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values2); - const result2 = session.getEmail(); - assert.equal(result2, ""); - session.deleteData(); - }); - - it("should get user display name", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - const values = { - user: { - ID: 5, - Name: "foo", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values); - const result = session.getDisplayName(); - assert.equal(result, "Max Last"); - const values2 = { - id: "a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f", - access_token: "234200000000000000000000000000000000000000000000", - provider: "public", - data: {}, - user: { - ID: 5, - Name: "bar", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values2); - const result2 = session.getDisplayName(); - assert.equal(result2, "Bar"); - session.deleteData(); - }); - - it("should get user full name", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - const values = { - user: { - ID: 5, - Name: "foo", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values); - const result = session.getDisplayName(); - assert.equal(result, "Max Last"); - const values2 = { - user: { - Name: "bar", - DisplayName: "Max New", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values2); - const result2 = session.getDisplayName(); - assert.equal(result2, ""); - session.deleteData(); - }); - - it("should test whether user is set", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - const values = { - user: { - ID: 5, - Name: "foo", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values); - const result = session.isUser(); - assert.equal(result, true); - session.deleteData(); - }); - - it("should test whether user is admin", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - const values = { - user: { - ID: 5, - Name: "foo", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values); - const result = session.isAdmin(); - assert.equal(result, true); - session.deleteData(); - }); - - it("should test whether user is anonymous", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - const values = { - user: { - ID: 5, - DisplayName: "Foo", - FullName: "Max Last", - Email: "test@test.com", - Role: "admin", - }, - }; - session.setData(values); - const result = session.isAnonymous(); - assert.equal(result, false); - session.deleteData(); - }); - - it("should use session storage", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - assert.equal(storage.getItem("session"), null); - session.useSessionStorage(); - assert.equal(storage.getItem("session"), "true"); - session.deleteData(); - }); - - it("should use local storage", () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - assert.equal(storage.getItem("session"), null); - session.useLocalStorage(); - assert.equal(storage.getItem("session"), "false"); - session.deleteData(); - }); - - it("should test redeem token", async () => { - const storage = new StorageShim(); - const session = new Session(storage, $config); - assert.equal(session.data, null); - await session.redeemToken("token123"); - assert.equal(session.data.token, "123token"); - session.deleteData(); - }); -}); diff --git a/frontend/tests/unit/common/util_test.js b/frontend/tests/unit/common/util_test.js deleted file mode 100644 index 3b214a7e4..000000000 --- a/frontend/tests/unit/common/util_test.js +++ /dev/null @@ -1,223 +0,0 @@ -import "../fixtures"; -import $util from "common/util"; -import { tokenRegexp, tokenLength } from "common/util"; -import * as can from "common/can"; -import { ContentTypeMp4AvcMain, ContentTypeMp4HvcMain } from "common/media"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/util", () => { - it("should return size in KB", () => { - const s = $util.formatBytes(10 * 1024); - assert.equal(s, "10 KB"); - }); - it("should return size in GB", () => { - const s = $util.formatBytes(10 * 1024 * 1024 * 1024); - assert.equal(s, "10.0 GB"); - }); - it("should convert bytes in GB", () => { - const b = $util.gigaBytes(10 * 1024 * 1024 * 1024); - assert.equal(b, 10); - }); - it("should return duration 3ns", () => { - const duration = $util.formatDuration(-3); - assert.equal(duration, "3ns"); - }); - it("should return duration 0s", () => { - const duration = $util.formatDuration(0); - assert.equal(duration, "0s"); - }); - it("should return duration 2µs", () => { - const duration = $util.formatDuration(2000); - assert.equal(duration, "2µs"); - }); - it("should return duration 4ms", () => { - const duration = $util.formatDuration(4000000); - assert.equal(duration, "4ms"); - }); - it("should return duration 6s", () => { - const duration = $util.formatDuration(6000000000); - assert.equal(duration, "0:06"); - }); - it("should return duration 10min", () => { - const duration = $util.formatDuration(600000000000); - assert.equal(duration, "10:00"); - }); - it("should return formatted seconds", () => { - const floor = $util.formatSeconds(Math.floor(65.4)); - assert.equal(floor, "1:05"); - const ceil = $util.formatSeconds(Math.ceil(65.4)); - assert.equal(ceil, "1:06"); - const unknown = $util.formatSeconds(0); - assert.equal(unknown, "0:00"); - const negative = $util.formatSeconds(-1); - assert.equal(negative, "0:00"); - }); - it("should return remaining seconds", () => { - const t = 23.3; - const d = 42.6; - const time = $util.formatSeconds(Math.floor(t)); - assert.equal(time, "0:23"); - const duration = $util.formatRemainingSeconds(0.0, d); - assert.equal(duration, "0:43"); - const difference = $util.formatRemainingSeconds(t, d); - assert.equal(difference, "0:20"); - const dotTime = $util.formatSeconds(Math.floor(9.5)); - assert.equal(dotTime, "0:09"); - const dotDiff = $util.formatRemainingSeconds(9.5, 12); - assert.equal(dotDiff, "0:03"); - const smallDiff = $util.formatRemainingSeconds(7.959863, 8.033); - assert.equal(smallDiff, "0:02"); - }); - it("should return formatted milliseconds", () => { - const short = $util.formatNs(45065875); - assert.equal(short, "45 ms"); - const long = $util.formatNs(45065875453454); - assert.equal(long, "45,065,875 ms"); - }); - it("should return formatted camera name", () => { - const iPhone15Pro = $util.formatCamera( - { Make: "Apple", Model: "iPhone 15 Pro" }, - 23, - "Apple", - "iPhone 15 Pro", - false - ); - assert.equal(iPhone15Pro, "iPhone 15 Pro"); - - const iPhone15ProLong = $util.formatCamera( - { Make: "Apple", Model: "iPhone 15 Pro" }, - 23, - "Apple", - "iPhone 15 Pro", - true - ); - assert.equal(iPhone15ProLong, "Apple iPhone 15 Pro"); - - const iPhone14 = $util.formatCamera({ Make: "Apple", Model: "iPhone 14" }, 22, "Apple", "iPhone 14", false); - assert.equal(iPhone14, "iPhone 14"); - - const iPhone13 = $util.formatCamera(null, 21, "Apple", "iPhone 13", false); - assert.equal(iPhone13, "iPhone 13"); - }); - it("should return best matching thumbnail", () => { - const thumbs = { - fit_720: { - w: 720, - h: 481, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_720", - }, - fit_1280: { - w: 1280, - h: 854, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_1280", - }, - fit_1920: { - w: 1800, - h: 1200, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_1920", - }, - fit_2560: { - w: 2400, - h: 1600, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_2560", - }, - fit_4096: { - w: 4096, - h: 2732, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_4096", - }, - fit_5120: { - w: 5120, - h: 3415, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_5120", - }, - fit_7680: { - w: 5120, - h: 3415, - src: "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_5120", - }, - }; - assert.equal($util.thumb(thumbs, 1200, 900).size, "fit_1280"); - assert.equal($util.thumb(thumbs, 1300, 900).size, "fit_1920"); - assert.equal($util.thumb(thumbs, 1300, 900).w, 1800); - assert.equal($util.thumb(thumbs, 1300, 900).h, 1200); - assert.equal( - $util.thumb(thumbs, 1300, 900).src, - "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_1920" - ); - assert.equal($util.thumb(thumbs, 1400, 1200).size, "fit_1920"); - assert.equal($util.thumb(thumbs, 100000, 120000).size, "fit_7680"); - }); - it("should return the approximate best thumbnail size name", () => { - assert.equal($util.thumbSize(1300, 900), "fit_1280"); - assert.equal($util.thumbSize(1400, 1200), "fit_1920"); - assert.equal($util.thumbSize(100000, 120000), "fit_7680"); - }); - it("should return matching video format name", () => { - const avc = $util.videoFormat("avc1", ContentTypeMp4AvcMain); - assert.equal(avc, "avc"); - - const hevc = $util.videoFormat("hvc1", ContentTypeMp4HvcMain); - if (can.useMp4Hvc) { - assert.equal(hevc, "hevc"); - } else { - assert.equal(hevc, "avc"); - } - - const webm = $util.videoFormat("", "video/webm"); - if (can.useWebM) { - assert.equal(webm, "webm"); - } else { - assert.equal(webm, "avc"); - } - }); - it("should convert -1 to roman", () => { - const roman = $util.arabicToRoman(-1); - assert.equal(roman, ""); - }); - it("should convert 2500 to roman", () => { - const roman = $util.arabicToRoman(2500); - assert.equal(roman, "MMD"); - }); - it("should convert 112 to roman", () => { - const roman = $util.arabicToRoman(112); - assert.equal(roman, "CXII"); - }); - it("should convert 9 to roman", () => { - const roman = $util.arabicToRoman(9); - assert.equal(roman, "IX"); - }); - it("should truncate xxx", () => { - const result = $util.truncate("teststring"); - assert.equal(result, "teststring"); - }); - it("should truncate xxx", () => { - const result = $util.truncate("teststring for mocha", 5, "ng"); - assert.equal(result, "tesng"); - }); - it("should encode html", () => { - const result = $util.encodeHTML("Micha & Theresa > < 'Lilly'"); - assert.equal(result, "Micha & Theresa > < 'Lilly'"); - }); - it("should encode link", () => { - const result = $util.encodeHTML("Try this: https://photoswipe.com/options/?foo=bar&bar=baz. It's a link!"); - assert.equal( - result, - `Try this: https://photoswipe.com/options/ It's a link!` - ); - }); - it("should generate tokens reliably", () => { - const tokens = new Set(); - const numTokens = 100; - for (let i = 0; i < numTokens; i++) { - const token = $util.generateToken(); - assert.lengthOf(token, tokenLength); - assert.match(token, tokenRegexp); - tokens.add(token); - } - // Check they are all unique - assert.lengthOf(tokens, numTokens); - }); -}); diff --git a/frontend/tests/unit/common/view_test.js b/frontend/tests/unit/common/view_test.js deleted file mode 100644 index 2ce4925ee..000000000 --- a/frontend/tests/unit/common/view_test.js +++ /dev/null @@ -1,25 +0,0 @@ -import { $view } from "common/view"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("common/view", () => { - it("should return parent", () => { - assert.equal($view.getParent(), null); - }); - it("should return parent name", () => { - assert.equal($view.getParentName(), ""); - }); - it("should return data", () => { - assert.containsSubset($view.getData(), {}); - }); - it("should return number of layers", () => { - assert.containsSubset($view.len(), 0); - }); - it("should return if root view is active", () => { - assert.equal($view.isRoot(), true); - }); - it("should return if view is app", () => { - assert.equal($view.isApp(), true); - }); -}); diff --git a/frontend/tests/unit/config.js b/frontend/tests/unit/config.js deleted file mode 100644 index b7f9e9aa6..000000000 --- a/frontend/tests/unit/config.js +++ /dev/null @@ -1,518 +0,0 @@ -const clientConfig = { - mode: "user", - name: "PhotoPrism", - about: "PhotoPrism® CE", - edition: "ce", - version: "210710-bae1f2d7-Linux-x86_64-DEBUG", - copyright: "(c) 2018-2025 PhotoPrism UG. All rights reserved.", - flags: "public debug develop experimental settings", - baseUri: "", - staticUri: "/static", - apiUri: "/api/v1", - contentUri: "/api/v1", - siteUrl: "http://localhost:2342/", - sitePreview: "http://localhost:2342/static/img/preview.jpg", - siteTitle: "PhotoPrism", - siteCaption: "AI-Powered Photos App", - siteDescription: "Open-Source Photo Management", - siteAuthor: "@photoprism_app", - debug: false, - readonly: false, - uploadNSFW: false, - public: false, - develop: true, - experimental: true, - disableSettings: false, - test: true, - demo: false, - sponsor: true, - albumCategories: ["Animal", "Holiday"], - albums: [ - { - ID: 69, - UID: "aqw0vmr32zb4560f", - CoverUID: "", - FolderUID: "", - Slug: "test-album-1", - Path: "", - Type: "album", - Title: "Test Album 1", - Location: "", - Category: "", - Caption: "", - Description: "", - Notes: "", - Filter: "", - Order: "oldest", - Template: "", - Country: "zz", - Year: 0, - Month: 0, - Day: 0, - Favorite: true, - Private: false, - CreatedAt: "2021-07-10T09:28:03Z", - UpdatedAt: "2021-07-10T09:28:03Z", - DeletedAt: null, - }, - { - ID: 70, - UID: "aqw0vmzrkc202vty", - CoverUID: "", - FolderUID: "", - Slug: "test-album-2", - Path: "", - Type: "album", - Title: "Test Album 2", - Location: "", - Category: "", - Caption: "", - Description: "", - Notes: "", - Filter: "", - Order: "oldest", - Template: "", - Country: "zz", - Year: 0, - Month: 0, - Day: 0, - Favorite: true, - Private: false, - CreatedAt: "2021-07-10T09:28:12Z", - UpdatedAt: "2021-07-10T09:28:12Z", - DeletedAt: null, - }, - ], - cameras: [ - { - ID: 7, - Slug: "apple-iphone-se", - Name: "Apple iPhone SE", - Make: "Apple", - Model: "iPhone SE", - }, - { - ID: 2, - Slug: "canon-eos-6d", - Name: "Canon EOS 6D", - Make: "Canon", - Model: "EOS 6D", - }, - { - ID: 3, - Slug: "canon-eos-7d", - Name: "Canon EOS 7D", - Make: "Canon", - Model: "EOS 7D", - }, - { - ID: 6, - Slug: "hmd-global-nokia-x71", - Name: "HMD Global Nokia X71", - Make: "HMD Global", - Model: "Nokia X71", - }, - { - ID: 4, - Slug: "huawei-mate-20-lite", - Name: "HUAWEI Mate 20 lite", - Make: "HUAWEI", - Model: "Mate 20 lite", - }, - { - ID: 5, - Slug: "huawei-p30", - Name: "HUAWEI P30", - Make: "HUAWEI", - Model: "P30", - }, - { - ID: 1, - Slug: "zz", - Name: "Unknown", - Make: "", - Model: "Unknown", - }, - ], - lenses: [ - { - ID: 6, - Slug: "apple-iphone-se-back-camera-4-15mm-f-2-2", - Name: "Apple iPhone SE back camera 4.15mm f/2.2", - Make: "Apple", - Model: "iPhone SE back camera 4.15mm f/2.2", - Type: "", - }, - { - ID: 3, - Slug: "ef100mm-f-2-8l-macro-is-usm", - Name: "EF100mm f/2.8L Macro IS USM", - Make: "", - Model: "EF100mm f/2.8L Macro IS USM", - Type: "", - }, - { - ID: 5, - Slug: "ef16-35mm-f-2-8l-ii-usm", - Name: "EF16-35mm f/2.8L II USM", - Make: "", - Model: "EF16-35mm f/2.8L II USM", - Type: "", - }, - { - ID: 2, - Slug: "ef24-105mm-f-4l-is-usm", - Name: "EF24-105mm f/4L IS USM", - Make: "", - Model: "EF24-105mm f/4L IS USM", - Type: "", - }, - { - ID: 4, - Slug: "ef70-200mm-f-4l-is-usm", - Name: "EF70-200mm f/4L IS USM", - Make: "", - Model: "EF70-200mm f/4L IS USM", - Type: "", - }, - { - ID: 1, - Slug: "zz", - Name: "Unknown", - Make: "", - Model: "Unknown", - Type: "", - }, - ], - countries: [ - { - ID: "bw", - Slug: "botswana", - Name: "Botswana", - }, - { - ID: "fr", - Slug: "france", - Name: "France", - }, - { - ID: "de", - Slug: "germany", - Name: "Germany", - }, - { - ID: "gr", - Slug: "greece", - Name: "Greece", - }, - { - ID: "za", - Slug: "south-africa", - Name: "South Africa", - }, - { - ID: "gb", - Slug: "united-kingdom", - Name: "United Kingdom", - }, - { - ID: "zz", - Slug: "zz", - Name: "Unknown", - }, - ], - people: [ - { - UID: "jr0jgyx2viicdnf7", - Name: "Andrea Sander", - Keywords: ["andrea"], - }, - { - UID: "jr0jgyx2viicdn88", - Name: "Otto Sander", - Keywords: ["andrea"], - }, - { - UID: "jr0jgzi2qmp5wt97", - Name: "Otto Sander", - Keywords: ["otto", "sander"], - }, - ], - thumbs: [ - { size: "fit_720", usage: "SD TV, Mobile", w: 720, h: 720 }, - { size: "fit_1280", usage: "HD TV, SXGA", w: 1280, h: 1024 }, - { size: "fit_1920", usage: "Full HD", w: 1920, h: 1200 }, - { size: "fit_2560", usage: "Quad HD, Notebooks", w: 2560, h: 1600 }, - { size: "fit_4096", usage: "DCI 4K, Retina 4K", w: 4096, h: 4096 }, - { size: "fit_7680", usage: "8K Ultra HD 2", w: 7680, h: 4320 }, - ], - status: "unregistered", - mapKey: "D9ve6edlcVR2mEsNvCXa", - downloadToken: "2lbh9x09", - previewToken: "public", - cssUri: "/static/build/app.2259c0edcc020e7af593.css", - jsUri: "/static/build/app.9bd7132eaee8e4c7c7e3.js", - manifestUri: "/manifest.json", - settings: { - ui: { - scrollbar: true, - zoom: false, - theme: "default", - language: "en", - }, - search: { - batchSize: 90, - }, - maps: { - animate: 0, - style: "streets", - }, - features: { - upload: true, - download: true, - private: true, - review: false, - files: true, - videos: true, - folders: true, - albums: true, - moments: true, - estimates: true, - people: true, - labels: true, - places: true, - edit: true, - archive: true, - delete: false, - share: true, - library: true, - import: true, - logs: true, - }, - import: { - path: "/", - move: false, - }, - index: { - path: "/", - convert: true, - rescan: false, - }, - stack: { - uuid: true, - meta: true, - name: false, - }, - share: { - title: "", - }, - download: { - name: "file", - }, - templates: { - default: "index.gohtml", - }, - }, - disable: { - backups: false, - webdav: false, - settings: false, - places: false, - exiftool: false, - darktable: false, - rawtherapee: false, - sips: true, - heifconvert: false, - ffmpeg: false, - tensorflow: false, - }, - count: { - all: 133, - photos: 132, - videos: 1, - cameras: 6, - lenses: 5, - countries: 6, - hidden: 0, - favorites: 1, - private: 0, - private_albums: 0, - private_folders: 0, - private_moments: 0, - private_months: 0, - private_states: 0, - review: 22, - stories: 0, - albums: 2, - moments: 4, - months: 27, - folders: 23, - files: 136, - places: 17, - states: 8, - people: 5, - labels: 22, - labelMaxPhotos: 118, - }, - pos: { - uid: "pqu0xswtrlixbcjp", - cid: "s2:149c947fca4c", - utc: "2021-06-01T09:46:52Z", - lat: 35.2847, - lng: 23.8122, - }, - years: [2021, 2020, 2019, 2018, 2017, 2015, 2013, 2012], - colors: [ - { - Example: "#AB47BC", - Name: "Purple", - Slug: "purple", - }, - { - Example: "#FF00FF", - Name: "Magenta", - Slug: "magenta", - }, - { - Example: "#EC407A", - Name: "Pink", - Slug: "pink", - }, - { - Example: "#EF5350", - Name: "Red", - Slug: "red", - }, - { - Example: "#FFA726", - Name: "Orange", - Slug: "orange", - }, - { - Example: "#D4AF37", - Name: "Gold", - Slug: "gold", - }, - { - Example: "#FDD835", - Name: "Yellow", - Slug: "yellow", - }, - { - Example: "#CDDC39", - Name: "Lime", - Slug: "lime", - }, - { - Example: "#66BB6A", - Name: "Green", - Slug: "green", - }, - { - Example: "#009688", - Name: "Teal", - Slug: "teal", - }, - { - Example: "#00BCD4", - Name: "Cyan", - Slug: "cyan", - }, - { - Example: "#2196F3", - Name: "Blue", - Slug: "blue", - }, - { - Example: "#A1887F", - Name: "Brown", - Slug: "brown", - }, - { - Example: "#F5F5F5", - Name: "White", - Slug: "white", - }, - { - Example: "#9E9E9E", - Name: "Grey", - Slug: "grey", - }, - { - Example: "#212121", - Name: "Black", - Slug: "black", - }, - ], - categories: [ - { - UID: "lqw0teu1kndplci9", - Slug: "animal", - Name: "Animal", - }, - { - UID: "lqw0tfrbx6e6flcx", - Slug: "bird", - Name: "Bird", - }, - { - UID: "lqw0tfw28lz7hcpq", - Slug: "food", - Name: "Food", - }, - { - UID: "lqw0tfqhgq2fr0ga", - Slug: "insect", - Name: "Insect", - }, - { - UID: "lqw0tfr144mh3jrd", - Slug: "nature", - Name: "Nature", - }, - { - UID: "lqw0tf72t04mgecr", - Slug: "outdoor", - Name: "Outdoor", - }, - { - UID: "lqw0teu1jpuk8310", - Slug: "people", - Name: "People", - }, - { - UID: "lqw0teufc81nxvqt", - Slug: "portrait", - Name: "Portrait", - }, - { - UID: "lqw0tft3e5qjlfcz", - Slug: "vehicle", - Name: "Vehicle", - }, - { - UID: "lqw0tft315xza8bk", - Slug: "water", - Name: "Water", - }, - { - UID: "lqw0tfs1dfgra72o", - Slug: "wildlife", - Name: "Wildlife", - }, - ], - clip: 160, - server: { - cores: 16, - routines: 26, - memory: { - used: 81586008, - reserved: 148459544, - info: "Used 82 MB / Reserved 148 MB", - }, - }, -}; - -window.__CONFIG__ = clientConfig; - -export default clientConfig; diff --git a/frontend/tests/unit/fixtures.js b/frontend/tests/unit/fixtures.js deleted file mode 100644 index 99acc7e02..000000000 --- a/frontend/tests/unit/fixtures.js +++ /dev/null @@ -1,379 +0,0 @@ -import { Settings } from "luxon"; - -Settings.defaultLocale = "en"; -Settings.defaultZoneName = "UTC"; - -import clientConfig from "./config"; -import { $config } from "app/session"; - -$config.setValues(clientConfig); - -import MockAdapter from "axios-mock-adapter"; -import $api from "common/api"; - -const Mock = new MockAdapter($api, { onNoMatch: "throwException" }); - -const mockHeaders = { - "Content-Type": "application/json; charset=utf-8", -}; - -const getCollectionResponse = [ - { id: 1, name: "John Smith" }, - { id: 1, name: "John Smith" }, -]; - -const getEntityResponse = { - id: 1, - name: "John Smith", -}; - -const postEntityResponse = { - users: [{ id: 1, name: "John Smith" }], -}; - -const putEntityResponse = { - users: [{ id: 2, name: "John Foo" }], -}; - -const deleteEntityResponse = null; -Mock.onPost("api/v1/users/urii20d30w2wqzjf/profile").reply(200, { DisplayName: "Max New" }, mockHeaders); -Mock.onPost("api/v1/users/52/avatar").reply(200, { Thumb: "abc", ThumbSrc: "manual" }, mockHeaders); -Mock.onGet("api/v1/foo").reply(200, getCollectionResponse, mockHeaders); -Mock.onGet("api/v1/foo/123").reply(200, getEntityResponse, mockHeaders); -Mock.onPost("api/v1/foo").reply(201, postEntityResponse, mockHeaders); -Mock.onPut("api/v1/foo/2").reply(200, putEntityResponse, mockHeaders); -Mock.onDelete("api/v1/foo/2").reply(204, deleteEntityResponse, mockHeaders); -Mock.onGet("api/v1/error").reply(401, "custom error cat", mockHeaders); - -Mock.onPost("api/v1/batch/photos/archive").reply(200, { photos: [1, 3] }, mockHeaders); -Mock.onPost("api/v1/photos/pqbemz8276mhtobh/approve").reply(200, {}, mockHeaders); -Mock.onPost("api/v1/photos/pqbemz8276mhtobh/files/fqbfk181n4ca5sud/primary").reply( - 200, - { - ID: 10, - UID: "pqbemz8276mhtobh", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: true, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - }, - mockHeaders -); - -Mock.onPut("api/v1/photos/pqbemz8276mhtobh").reply( - 200, - { - ID: 10, - UID: "pqbemz8276mhtobh", - TitleSrc: "manual", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - }, - mockHeaders -); - -Mock.onDelete("api/v1/photos/abc123/unlike").reply(200); -Mock.onDelete("api/v1/photos/pqbemz8276mhtobh/files/fqbfk181n4ca5sud").reply( - 200, - { - success: "successfully deleted", - }, - mockHeaders -); -Mock.onPost("api/v1/photos/pqbemz8276mhtobh/files/fqbfk181n4ca5sud/unstack").reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPost("api/v1/photos/pqbemz8276mhtobh/label", { Name: "Cat", Priority: 10 }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPut("api/v1/photos/pqbemz8276mhtobh/label/12345", { Uncertainty: 0 }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPut("api/v1/photos/pqbemz8276mhtobh/label/12345", { Label: { Name: "Sommer" } }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onDelete("api/v1/photos/pqbemz8276mhtobh/label/12345").reply(200, { success: "ok" }, mockHeaders); - -Mock.onPost("api/v1/session").reply( - 200, - { - session_id: "5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683", - access_token: "999900000000000000000000000000000000000000000000", - token_type: "Bearer", - provider: "test", - data: { token: "123token" }, - user: { ID: 1, UID: "urjysof3b9v7lgex", Name: "test", Email: "test@test.com" }, - }, - mockHeaders -); - -Mock.onGet("api/v1/session/a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f").reply( - 200, - { - session_id: "a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f", - access_token: "234200000000000000000000000000000000000000000000", - token_type: "Bearer", - provider: "public", - data: { token: "123token" }, - user: { ID: 1, UID: "urjysof3b9v7lgex", Name: "test", Email: "test@test.com" }, - }, - mockHeaders -); - -Mock.onGet("api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683").reply( - 200, - { - session_id: "5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683", - access_token: "999900000000000000000000000000000000000000000000", - token_type: "Bearer", - provider: "test", - data: { token: "123token" }, - user: { ID: 1, UID: "urjysof3b9v7lgex", Name: "test", Email: "test@test.com" }, - }, - mockHeaders -); - -Mock.onDelete("api/v1/session/5aa770f2a1ef431628d9f17bdf82a0d16865e99d4a1ddd9356e1aabfe6464683").reply(200); - -Mock.onDelete("api/v1/session/a9b8ff820bf40ab451910f8bbfe401b2432446693aa539538fbd2399560a722f").reply(200); - -Mock.onGet("api/v1/settings").reply(200, { download: true, language: "de" }, mockHeaders); -Mock.onPost("api/v1/settings").reply(200, { download: true, language: "en" }, mockHeaders); - -Mock.onGet("api/v1/services/123/folders").reply(200, { foo: "folders" }, mockHeaders); -Mock.onPost("api/v1/services/123/upload").reply(200, { foo: "upload" }, mockHeaders); - -Mock.onGet("api/v1/folders/2011/10-Halloween", { - params: { recursive: true, uncached: true }, -}).reply( - 200, - { folders: [1, 2], files: [1] }, - { - "Content-Type": "application/json; charset=utf-8", - "x-count": "3", - "x-limit": "100", - "x-offset": "0", - } -); -Mock.onGet("api/v1/folders/2011/10-Halloween", { params: { recursive: true } }).reply( - 200, - { - folders: [1, 2, 3], - files: [1], - }, - mockHeaders -); -Mock.onGet("api/v1/folders/originals/2011/10-Halloween", { params: { recursive: true } }).reply( - 200, - { - folders: [1, 2, 3], - files: [1], - }, - mockHeaders -); - -Mock.onPut("albums/66/links/5").reply( - 200, - { - UID: 5, - Slug: "friends", - Expires: 80000, - UpdatedAt: "2012-07-08T14:45:39Z", - }, - mockHeaders -); - -Mock.onGet("api/v1/albums/66").reply(200, { Success: "ok" }, mockHeaders); -Mock.onPost("api/v1/albums/66/links").reply( - 200, - { - Password: "passwd", - Expires: 8000, - Slug: "christmas-2019", - Comment: "", - Perm: 0, - }, - mockHeaders -); -Mock.onDelete("api/v1/albums/66/links/5").reply(200, { Success: "ok" }, mockHeaders); -Mock.onGet("api/v1/albums/66/links").reply( - 200, - [ - { UID: "sqcwh80ifesw74ht", ShareUID: "aqcwh7weohhk49q2", Slug: "july-2020" }, - { UID: "sqcwhxh1h58rf3c2", ShareUID: "aqcwh7weohhk49q2" }, - ], - mockHeaders -); -Mock.onPut("/api/v1/albums/66").reply( - 200, - { - Description: "Test description", - }, - mockHeaders -); - -Mock.onGet("api/v1/albums").reply( - 200, - { - ID: 51, - CreatedAt: "2019-07-03T18:48:07Z", - UpdatedAt: "2019-07-25T01:04:44Z", - DeletedAt: "0001-01-01T00:00:00Z", - Slug: "tabby-cat", - Name: "tabby cat", - Priority: 5, - LabelCount: 9, - Favorite: false, - Description: "", - Notes: "", - }, - { - "Content-Type": "application/json; charset=utf-8", - "x-count": "3", - "x-limit": "100", - "x-offset": "0", - } -); - -Mock.onOptions("api/v1/albums").reply( - 200, - { - foo: "bar", - }, - mockHeaders -); -Mock.onOptions("api/v1/albums/abc").reply( - 200, - { - foo: "edit", - }, - mockHeaders -); -Mock.onDelete("api/v1/albums/abc").reply( - 200, - { - status: "ok", - }, - mockHeaders -); -Mock.onPut("api/v1/albums/abc").reply( - 200, - { - Description: "Test description", - }, - mockHeaders -); - -//Mock.onPost("api/v1/users/55/profile").reply(200, { DisplayName: "Max New" }, mockHeaders); -//Mock.onPost("users/55/profile").reply(200, { DisplayName: "Max New" }, mockHeaders); -//Mock.onPost("api/v1/users/55/profile").reply(200, { DisplayName: "Max New" }, mockHeaders); - -Mock.onAny("api/v1/users/52/register").reply(200, { foo: "register" }, mockHeaders); - -Mock.onAny("api/v1/users/53/profile").reply(200, { foo: "profile" }, mockHeaders); - -Mock.onPut("api/v1/users/54/password").reply(200, { password: "old", new_password: "new" }, mockHeaders); - -Mock.onGet("api/v1/link/5").reply(200, "get success", mockHeaders); -Mock.onPut("api/v1/link/5").reply(200, "put success", mockHeaders); -Mock.onDelete("api/v1/link/5").reply(200, "delete success", mockHeaders); - -Mock.onPost("api/v1/photos/55/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onDelete("api/v1/photos/55/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onGet("api/v1/albums/5").reply(200, { UID: "5" }, mockHeaders); -Mock.onPut("api/v1/photos/5").reply(200, { UID: "5" }, mockHeaders); -Mock.onDelete("api/v1/photos/abc123/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onPost("api/v1/photos/5/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onPost("api/v1/labels/ABC123/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onDelete("api/v1/labels/ABC123/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onPost("api/v1/folders/dqbevau2zlhxrxww/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onDelete("api/v1/folders/dqbevau2zlhxrxww/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onPost("api/v1/photos/undefined/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onDelete("api/v1/photos/undefined/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onPost("api/v1/albums/5/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onDelete("api/v1/albums/5/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onGet("api/v1/config").reply(200, clientConfig, mockHeaders); -Mock.onPut("api/v1/markers/mBC123ghytr", { Review: false, Invalid: false }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPut("api/v1/markers/mCC123ghytr", { Review: false, Invalid: true }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPut("api/v1/markers/mDC123ghytr", { SubjSrc: "manual", Name: "testname" }).reply( - 200, - { - success: "ok", - Name: "testname", - }, - mockHeaders -); -Mock.onDelete("api/v1/markers/mEC123ghytr/subject").reply(200, { success: "ok" }, mockHeaders); -Mock.onPut("api/v1/faces/f123ghytrfggd", { Hidden: false }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPut("api/v1/faces/f123ghytrfggd", { Hidden: true }).reply( - 200, - { - success: "ok", - }, - mockHeaders -); -Mock.onPost("api/v1/subjects/s123ghytrfggd/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onPut("api/v1/subjects/s123ghytrfggd").reply(200, { status: "ok" }, mockHeaders); -Mock.onDelete("api/v1/subjects/s123ghytrfggd/like").reply(200, { status: "ok" }, mockHeaders); -Mock.onGet("api/v1/config/options").reply(200, { success: "ok" }, mockHeaders); -Mock.onPost("api/v1/config/options").reply(200, { success: "ok" }, mockHeaders); -Mock.onPost("api/v1/albums").reply(200, { success: "ok" }, mockHeaders); - -//Mock.onPost().reply(200); -//Mock.onDelete().reply(200); -/* -Mock.onPost().reply(200).onDelete().reply(200); -Mock.onDelete().reply(200); -Mock.onAny().reply(200, "editForm"); -Mock.onPut().reply(200, { Description: "Test description" }); -Mock.onPut().reply(200, { Description: "Test description" }); -Mock.onPost().reply(200, { Description: "Test description" }); -*/ - -export { $api, Mock }; diff --git a/frontend/tests/unit/model/album_test.js b/frontend/tests/unit/model/album_test.js deleted file mode 100644 index d5067de4c..000000000 --- a/frontend/tests/unit/model/album_test.js +++ /dev/null @@ -1,345 +0,0 @@ -import "../fixtures"; -import { Album, BatchSize } from "model/album"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/album", () => { - it("should get route view", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019" }; - const album = new Album(values); - const result = album.route("test"); - assert.equal(result.name, "test"); - assert.equal(result.params.slug, "view"); - }); - - it("should return classes", () => { - const values = { - UID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - Type: "moment", - Favorite: true, - Private: true, - }; - const album = new Album(values); - const result = album.classes(true); - assert.include(result, "is-album"); - assert.include(result, "uid-5"); - assert.include(result, "type-moment"); - assert.include(result, "is-selected"); - assert.include(result, "is-favorite"); - assert.include(result, "is-private"); - }); - - it("should get album entity name", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019" }; - const album = new Album(values); - const result = album.getEntityName(); - assert.equal(result, "christmas-2019"); - }); - - it("should get album id", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.getId(); - assert.equal(result, "66"); - }); - - it("should get album title", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019" }; - const album = new Album(values); - const result = album.getTitle(); - assert.equal(result, "Christmas 2019"); - }); - - it("should get album country", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Country: "at" }; - const album = new Album(values); - const result = album.getCountry(); - assert.equal(result, "Austria"); - - const values2 = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Country: "zz" }; - const album2 = new Album(values2); - const result2 = album2.getCountry(); - assert.equal(result2, ""); - - const values3 = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Country: "xx" }; - const album3 = new Album(values3); - const result3 = album3.getCountry(); - assert.equal(result3, ""); - }); - - it("should check if album has location", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - Country: "zz", - State: "", - Location: "", - }; - const album = new Album(values); - const result = album.hasLocation(); - assert.equal(result, false); - - const values2 = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Country: "at" }; - const album2 = new Album(values2); - const result2 = album2.hasLocation(); - assert.equal(result2, true); - }); - - it("should get album location", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - Country: "at", - State: "Salzburg", - Location: "", - }; - const album = new Album(values); - const result = album.getLocation(); - assert.equal(result, "Salzburg, Austria"); - - const values2 = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - Country: "zz", - State: "", - Location: "", - }; - const album2 = new Album(values2); - const result2 = album2.getLocation(); - assert.equal(result2, ""); - - const values3 = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - Country: "zz", - State: "", - Location: "Austria", - }; - const album3 = new Album(values3); - const result3 = album3.getLocation(); - assert.equal(result3, "Austria"); - - const values5 = { - ID: 5, - Title: "Salzburg", - Slug: "salzburg", - Country: "at", - State: "Salzburg", - Location: "", - }; - const album5 = new Album(values5); - const result5 = album5.getLocation(); - assert.equal(result5, "Austria"); - - const values6 = { - ID: 5, - Title: "Austria", - Slug: "austria", - Country: "at", - State: "Salzburg", - Location: "", - }; - const album6 = new Album(values6); - const result6 = album6.getLocation(); - assert.equal(result6, "Salzburg"); - }); - - it("should get thumbnail url", () => { - const values = { - ID: 5, - Thumb: "d6b24d688564f7ddc7b245a414f003a8d8ff5a67", - Title: "Christmas 2019", - Slug: "christmas-2019", - UID: 66, - }; - const album = new Album(values); - const result = album.thumbnailUrl("xyz"); - assert.equal(result, "/api/v1/t/d6b24d688564f7ddc7b245a414f003a8d8ff5a67/public/xyz"); - - const values2 = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - UID: 66, - }; - const album2 = new Album(values2); - const result2 = album2.thumbnailUrl("xyz"); - assert.equal(result2, "/api/v1/albums/66/t/public/xyz"); - - const values3 = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - }; - const album3 = new Album(values3); - const result3 = album3.thumbnailUrl("xyz"); - assert.equal(result3, "/api/v1/svg/album"); - }); - - it("should get created date string", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - }; - const album = new Album(values); - const result = album.getCreatedString(); - assert.equal(result.replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("should get album date string with invalid day", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: -1, - Month: 5, - Year: 2019, - }; - const album = new Album(values); - const result = album.getDateString(); - assert.equal(result, "May 2019"); - }); - - it("should get album date string with invalid month", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: 1, - Month: -5, - Year: 2000, - }; - const album = new Album(values); - const result = album.getDateString(); - assert.equal(result, "2000"); - }); - - it("should get album date string with invalid year", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: 1, - Month: 5, - Year: 800, - }; - const album = new Album(values); - const result = album.getDateString(); - assert.equal(result, "Unknown"); - }); - - it("should get album date string", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: 1, - Month: 5, - Year: 2000, - }; - const album = new Album(values); - const result = album.getDateString(); - assert.equal(result, "Monday, May 1, 2000"); - }); - - it("should get day string", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: 8, - Month: 5, - Year: 2019, - }; - const album = new Album(values); - const result = album.dayString(); - assert.equal(result, "08"); - }); - - it("should get month string", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: 8, - Month: -5, - Year: 2019, - }; - const album = new Album(values); - const result = album.monthString(); - assert.equal(result, "01"); - }); - - it("should get year string", () => { - const values = { - ID: 5, - Title: "Christmas 2019", - Slug: "christmas-2019", - CreatedAt: "2012-07-08T14:45:39Z", - Day: 8, - Month: -5, - Year: 800, - }; - const album = new Album(values); - const result = album.yearString(); - assert.equal(result, new Date().getFullYear().toString().padStart(4, "0")); - }); - - it("should get model name", () => { - const result = Album.getModelName(); - assert.equal(result, "Album"); - }); - - it("should get collection resource", () => { - const result = Album.getCollectionResource(); - assert.equal(result, "albums"); - }); - - it("should return batch size", () => { - assert.equal(Album.batchSize(), BatchSize); - Album.setBatchSize(30); - assert.equal(Album.batchSize(), 30); - Album.setBatchSize(BatchSize); - }); - - it("should like album", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Favorite: false }; - const album = new Album(values); - assert.equal(album.Favorite, false); - album.like(); - assert.equal(album.Favorite, true); - }); - - it("should unlike album", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Favorite: true }; - const album = new Album(values); - assert.equal(album.Favorite, true); - album.unlike(); - assert.equal(album.Favorite, false); - }); - - it("should toggle like", () => { - const values = { ID: 5, Title: "Christmas 2019", Slug: "christmas-2019", Favorite: true }; - const album = new Album(values); - assert.equal(album.Favorite, true); - album.toggleLike(); - assert.equal(album.Favorite, false); - album.toggleLike(); - assert.equal(album.Favorite, true); - }); -}); diff --git a/frontend/tests/unit/model/config-options_test.js b/frontend/tests/unit/model/config-options_test.js deleted file mode 100644 index 8b9f00131..000000000 --- a/frontend/tests/unit/model/config-options_test.js +++ /dev/null @@ -1,52 +0,0 @@ -import "../fixtures"; -import ConfigOptions from "model/config-options"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/config-options", () => { - it("should get options defaults", () => { - const values = {}; - const options = new ConfigOptions(values); - const result = options.getDefaults(); - assert.equal(result.Debug, false); - assert.equal(result.ReadOnly, false); - assert.equal(result.ThumbSize, 0); - }); - - it("should test changed", () => { - const values = {}; - const options = new ConfigOptions(values); - assert.equal(options.changed(), false); - }); - - it("should load options", (done) => { - const values = {}; - const options = new ConfigOptions(values); - options - .load() - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - assert.equal(options.changed(), false); - }); - - it("should save options", (done) => { - const values = { Debug: true }; - const options = new ConfigOptions(values); - options - .save() - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - assert.equal(options.changed(), false); - }); -}); diff --git a/frontend/tests/unit/model/face_test.js b/frontend/tests/unit/model/face_test.js deleted file mode 100644 index e9dcd8c51..000000000 --- a/frontend/tests/unit/model/face_test.js +++ /dev/null @@ -1,177 +0,0 @@ -import "../fixtures"; -import { Face, BatchSize } from "model/face"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/face", () => { - it("should get face defaults", () => { - const values = {}; - const face = new Face(values); - const result = face.getDefaults(); - assert.equal(result.ID, ""); - assert.equal(result.SampleRadius, 0.0); - }); - - it("should get route view", () => { - const values = { ID: "f123ghytrfggd", Samples: 5 }; - const face = new Face(values); - const result = face.route("test"); - assert.equal(result.name, "test"); - assert.equal(result.query.q, "face:f123ghytrfggd"); - }); - - it("should return classes", () => { - const values = { ID: "f123ghytrfggd", Samples: 5 }; - const face = new Face(values); - const result = face.classes(true); - assert.include(result, "is-face"); - assert.include(result, "uid-f123ghytrfggd"); - assert.include(result, "is-selected"); - assert.notInclude(result, "is-hidden"); - const result2 = face.classes(false); - assert.include(result2, "is-face"); - assert.include(result2, "uid-f123ghytrfggd"); - assert.notInclude(result2, "is-selected"); - assert.notInclude(result2, "is-hidden"); - const values2 = { ID: "f123ghytrfggd", Samples: 5, Hidden: true }; - const face2 = new Face(values2); - const result3 = face2.classes(true); - assert.include(result3, "is-face"); - assert.include(result3, "uid-f123ghytrfggd"); - assert.include(result3, "is-selected"); - assert.include(result3, "is-hidden"); - }); - - it("should get face entity name", () => { - const values = { ID: "f123ghytrfggd", Samples: 5 }; - const face = new Face(values); - const result = face.getEntityName(); - assert.equal(result, "f123ghytrfggd"); - }); - - it("should get face title", () => { - const values = { ID: "f123ghytrfggd", Samples: 5 }; - const face = new Face(values); - const result = face.getTitle(); - assert.equal(result, undefined); - }); - - it("should get thumbnail url", () => { - const values = { - ID: "f123ghytrfggd", - Samples: 5, - MarkerUID: "ABC123ghytr", - FileUID: "fhjouohnnmnd", - Name: "", - Thumb: "7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1", - }; - - const face = new Face(values); - const result = face.thumbnailUrl("xyz"); - - assert.equal(result, "/api/v1/t/7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1/public/xyz"); - - const values2 = { - ID: "f123ghytrfggd", - Samples: 5, - Thumb: "7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1", - }; - const face2 = new Face(values2); - const result2 = face2.thumbnailUrl(); - - assert.equal(result2, "/api/v1/t/7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1/public/tile_160"); - - const values3 = { - ID: "f123ghytrfggd", - Samples: 5, - Thumb: "", - }; - const face3 = new Face(values3); - const result3 = face3.thumbnailUrl("tile_240"); - - assert.equal(result3, "/api/v1/svg/portrait"); - }); - - it("should get date string", () => { - const values = { - ID: "f123ghytrfggd", - Samples: 5, - CreatedAt: "2012-07-08T14:45:39Z", - }; - const face = new Face(values); - const result = face.getDateString(); - assert.equal(result.replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("show and hide face", () => { - const values = { - ID: "f123ghytrfggd", - Samples: 5, - CreatedAt: "2012-07-08T14:45:39Z", - Hidden: true, - }; - const face = new Face(values); - assert.equal(face.Hidden, true); - face.show(); - assert.equal(face.Hidden, false); - face.hide(); - assert.equal(face.Hidden, true); - }); - - it("should toggle hidden", () => { - const values = { - ID: "f123ghytrfggd", - Samples: 5, - CreatedAt: "2012-07-08T14:45:39Z", - Hidden: true, - }; - const face = new Face(values); - assert.equal(face.Hidden, true); - face.toggleHidden(); - assert.equal(face.Hidden, false); - face.toggleHidden(); - assert.equal(face.Hidden, true); - }); - - it("should set name", (done) => { - const values = { ID: "f123ghytrfggd", Samples: 5, MarkerUID: "mDC123ghytr", Name: "Jane" }; - const face = new Face(values); - face - .setName("testname") - .then((response) => { - assert.equal(response.Name, "testname"); - done(); - }) - .catch((error) => { - done(error); - }); - - face - .setName("") - .then((response) => { - assert.equal(response.Name, "Jane"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should return batch size", () => { - assert.equal(Face.batchSize(), BatchSize); - Face.setBatchSize(30); - assert.equal(Face.batchSize(), 30); - Face.setBatchSize(BatchSize); - }); - - it("should get collection resource", () => { - const result = Face.getCollectionResource(); - assert.equal(result, "faces"); - }); - - it("should get model name", () => { - const result = Face.getModelName(); - assert.equal(result, "Face"); - }); -}); diff --git a/frontend/tests/unit/model/file_test.js b/frontend/tests/unit/model/file_test.js deleted file mode 100644 index c542c26e5..000000000 --- a/frontend/tests/unit/model/file_test.js +++ /dev/null @@ -1,461 +0,0 @@ -import "../fixtures"; -import File from "model/file"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/file", () => { - it("should return classes", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Name: "1/2/IMG123.jpg", - Primary: true, - Sidecar: true, - Video: true, - }; - const file = new File(values); - const result = file.classes(true); - assert.include(result, "is-file"); - assert.include(result, "uid-ABC123"); - assert.include(result, "is-primary"); - assert.include(result, "is-sidecar"); - assert.include(result, "is-video"); - assert.include(result, "is-selected"); - }); - - it("should get file defaults", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - }; - const file = new File(values); - const result = file.getDefaults(); - assert.equal(result.UID, ""); - assert.equal(result.Size, 0); - }); - - it("should get file base name", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - const result = file.baseName(); - assert.equal(result, "IMG123.jpg"); - const result2 = file.baseName(8); - assert.equal(result2, "IMG123.…"); - }); - - it("should return true", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(file.isFile(), true); - }); - - it("should return entity name", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Root: "", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(file.getEntityName(), "/1/2/IMG123.jpg"); - }); - - it("should return thumbnail url", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(file.thumbnailUrl("tile_224"), "/api/v1/t/54ghtfd/public/tile_224"); - const values2 = { - InstanceID: 5, - UID: "ABC123", - Name: "1/2/IMG123.jpg", - Error: true, - }; - const file2 = new File(values2); - assert.equal(file2.thumbnailUrl("tile_224"), "/api/v1/svg/broken"); - const values3 = { - InstanceID: 5, - UID: "ABC123", - Hash: "bd66bd2c304f45f6c160df375f34b49eb7aef321", - Name: "1/2/IMG123.jpg", - FileType: "raw", - }; - const file3 = new File(values3); - assert.equal(file3.thumbnailUrl("tile_224"), "/api/v1/t/bd66bd2c304f45f6c160df375f34b49eb7aef321/public/tile_224"); - const values4 = { - InstanceID: 5, - UID: "ABC123", - Hash: "0e437256ec20da874318b64027750b320548378c", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - Sidecar: true, - }; - const file4 = new File(values4); - assert.equal(file4.thumbnailUrl("tile_224"), "/api/v1/svg/file"); - }); - - it("should return download url", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(file.getDownloadUrl("abc"), "/api/v1/dl/54ghtfd?t=2lbh9x09"); - }); - - it("should not download as hash is missing", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(file.download(), undefined); - }); - - it("should calculate size", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Width: 500, - Height: 700, - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(file.calculateSize(600, 800).width, 500); - assert.equal(file.calculateSize(600, 800).height, 700); - const values2 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Width: 900, - Height: 850, - Name: "1/2/IMG123.jpg", - }; - const file2 = new File(values2); - assert.equal(file2.calculateSize(600, 800).width, 600); - assert.equal(file2.calculateSize(600, 800).height, 567); - const values3 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Width: 750, - Height: 850, - Name: "1/2/IMG123.jpg", - }; - const file3 = new File(values3); - assert.equal(file3.calculateSize(900, 450).width, 398); - assert.equal(file3.calculateSize(900, 450).height, 450); - }); - - it("should get date string", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.getDateString().replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("should get info", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.getInfo(), "JPG"); - - const values2 = { - InstanceID: 6, - UID: "ABC124", - Hash: "54ghtfd", - FileType: "mp4", - Duration: 8009, - FPS: 60, - Name: "1/2/IMG123.mp4", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file2 = new File(values2); - assert.equal(file2.getInfo(), "MP4, 8µs, 60.0 FPS"); - }); - - it("should return storage location", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - Root: "sidecar", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.storageInfo(), "Sidecar"); - - const values2 = { - InstanceID: 6, - UID: "ABC124", - Hash: "54ghtfd", - FileType: "mp4", - Duration: 8009, - FPS: 60, - Root: "/", - Name: "1/2/IMG123.mp4", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file2 = new File(values2); - assert.equal(file2.storageInfo(), "Originals"); - - const values3 = { - InstanceID: 6, - UID: "ABC124", - Hash: "54ghtfd", - FileType: "mp4", - Duration: 8009, - FPS: 60, - Root: "", - Name: "1/2/IMG123.mp4", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file3 = new File(values3); - assert.equal(file3.storageInfo(), ""); - }); - - it("should return whether file is animated", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - MediaType: "image", - Duration: 500, - }; - const file = new File(values); - assert.equal(file.isAnimated(), true); - }); - - it("should get type info", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Primary: true, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.typeInfo(), "Image"); - const values2 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "mp4", - Duration: 8009, - FPS: 60, - Name: "1/2/IMG123.mp4", - Video: true, - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file2 = new File(values2); - assert.equal(file2.typeInfo(), "Video"); - const values3 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - Sidecar: true, - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file3 = new File(values3); - assert.equal(file3.typeInfo(), "Sidecar JPEG"); - const values4 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "gif", - MediaType: "image", - Duration: 8009, - Name: "1/2/IMG123.jpg", - Sidecar: true, - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file4 = new File(values4); - assert.equal(file4.typeInfo(), "Sidecar GIF Image"); - const values5 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "svg", - MediaType: "vector", - Name: "1/2/IMG123.svg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file5 = new File(values5); - assert.equal(file5.typeInfo(), "SVG"); - }); - - it("should get size info", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Size: 8009, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.sizeInfo(), "8 KB"); - const values2 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Size: 8009999987, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file2 = new File(values2); - assert.equal(file2.sizeInfo(), "7.5 GB"); - const values3 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Size: 8009999987, - Name: "1/2/IMG123.jpg", - Width: 500, - Height: 800, - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file3 = new File(values3); - assert.equal(file3.sizeInfo(), "500 × 800, 7.5 GB"); - }); - - it("should like file", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Duration: 8009, - Favorite: false, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.Favorite, false); - file.like(); - assert.equal(file.Favorite, true); - }); - - it("should unlike file", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Duration: 8009, - Favorite: true, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.Favorite, true); - file.unlike(); - assert.equal(file.Favorite, false); - }); - - it("should toggle like", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Duration: 8009, - Favorite: true, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.Favorite, true); - file.toggleLike(); - assert.equal(file.Favorite, false); - file.toggleLike(); - assert.equal(file.Favorite, true); - }); - - it("should get photo resource", () => { - const values = { - InstanceID: 5, - PhotoUID: "bgad457", - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Duration: 8009, - Favorite: true, - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values); - assert.equal(file.getPhotoResource(), "photos/bgad457"); - }); - - it("should get collection resource", () => { - const result = File.getCollectionResource(); - assert.equal(result, "files"); - }); - - it("should get model name", () => { - const result = File.getModelName(); - assert.equal(result, "File"); - }); -}); diff --git a/frontend/tests/unit/model/folder_test.js b/frontend/tests/unit/model/folder_test.js deleted file mode 100644 index 738f1eac1..000000000 --- a/frontend/tests/unit/model/folder_test.js +++ /dev/null @@ -1,247 +0,0 @@ -import "../fixtures"; -import Folder from "model/folder"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/folder", () => { - it("should return classes", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - Favorite: true, - Private: true, - Ignore: false, - Watch: false, - FileCount: 0, - }; - const folder = new Folder(values); - const result = folder.classes(true); - assert.include(result, "is-folder"); - assert.include(result, "uid-dqbevau2zlhxrxww"); - assert.include(result, "is-favorite"); - assert.include(result, "is-private"); - assert.include(result, "is-selected"); - }); - - it("should get folder defaults", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Type: "", - Title: "Halloween Party", - Category: "", - Description: "", - Order: "", - Country: "", - Year: "", - Month: "", - Favorite: false, - Private: false, - Ignore: false, - Watch: false, - FileCount: 0, - CreatedAt: "", - UpdatedAt: "", - }; - const model = new Folder(values); - const result = model.getDefaults(); - assert.equal(result.Folder, true); - assert.equal(result.Path, ""); - assert.equal(result.Favorite, false); - }); - - it("should get folder base name", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Type: "", - Title: "Halloween Party", - Category: "", - Description: "", - Order: "", - Country: "", - Year: "", - Month: "", - Favorite: false, - Private: false, - Ignore: false, - Watch: false, - FileCount: 0, - CreatedAt: "", - UpdatedAt: "", - }; - const folder = new Folder(values); - const result = folder.baseName(); - assert.equal(result, "10-Halloween"); - const result2 = folder.baseName(8); - assert.equal(result2, "10-Hall…"); - }); - - it("should return false", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - }; - const folder = new Folder(values); - assert.equal(folder.isFile(), false); - }); - - it("should return entity name", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - }; - const folder = new Folder(values); - assert.equal(folder.getEntityName(), "/2011/10-Halloween"); - }); - - it("should return thumbnail url", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - }; - const folder = new Folder(values); - assert.equal(folder.thumbnailUrl("tile_224"), "/api/v1/folders/t/dqbevau2zlhxrxww/public/tile_224"); - }); - - it("should get date string", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const folder = new Folder(values); - assert.equal(folder.getDateString().replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("should toggle like", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - Favorite: true, - Private: true, - }; - const folder = new Folder(values); - assert.equal(folder.Favorite, true); - folder.toggleLike(); - assert.equal(folder.Favorite, false); - folder.toggleLike(); - assert.equal(folder.Favorite, true); - }); - - it("should like folder", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - Favorite: false, - Private: true, - }; - const folder = new Folder(values); - assert.equal(folder.Favorite, false); - folder.like(); - assert.equal(folder.Favorite, true); - }); - - it("should unlike folder", () => { - const values = { - Folder: true, - Path: "2011/10-Halloween", - Root: "", - UID: "dqbevau2zlhxrxww", - Title: "Halloween Party", - Favorite: true, - Private: true, - }; - const folder = new Folder(values); - assert.equal(folder.Favorite, true); - folder.unlike(); - assert.equal(folder.Favorite, false); - }); - - it("should get collection resource", () => { - const result = Folder.getCollectionResource(); - assert.equal(result, "folders"); - }); - - it("should get model name", () => { - const result = Folder.getModelName(); - assert.equal(result, "Folder"); - }); - - it("should test find all", (done) => { - Folder.findAll("2011/10-Halloween") - .then((response) => { - assert.equal(response.status, 200); - assert.equal(response.count, 4); - assert.equal(response.folders, 3); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should test find all uncached", (done) => { - Folder.findAllUncached("2011/10-Halloween") - .then((response) => { - assert.equal(response.status, 200); - assert.equal(response.count, 3); - assert.equal(response.folders, 2); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should test find in originals", (done) => { - Folder.originals("2011/10-Halloween", { recursive: true }) - .then((response) => { - assert.equal(response.status, 200); - assert.equal(response.count, 4); - assert.equal(response.folders, 3); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should test search", (done) => { - Folder.search("2011/10-Halloween", { recursive: true, uncached: true }) - .then((response) => { - assert.equal(response.status, 200); - assert.equal(response.count, 3); - assert.equal(response.folders, 2); - done(); - }) - .catch((error) => { - done(error); - }); - }); -}); diff --git a/frontend/tests/unit/model/label_test.js b/frontend/tests/unit/model/label_test.js deleted file mode 100644 index 5fb528e12..000000000 --- a/frontend/tests/unit/model/label_test.js +++ /dev/null @@ -1,141 +0,0 @@ -import "../fixtures"; -import { Label, BatchSize } from "model/label"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/label", () => { - it("should get route view", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat" }; - const label = new Label(values); - const result = label.route("test"); - assert.equal(result.name, "test"); - assert.equal(result.query.q, "label:black-cat"); - }); - - it("should return batch size", () => { - assert.equal(Label.batchSize(), BatchSize); - Label.setBatchSize(30); - assert.equal(Label.batchSize(), 30); - Label.setBatchSize(BatchSize); - }); - - it("should return classes", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat", Favorite: true }; - const label = new Label(values); - const result = label.classes(true); - assert.include(result, "is-label"); - assert.include(result, "uid-ABC123"); - assert.include(result, "is-selected"); - assert.include(result, "is-favorite"); - }); - - it("should get label entity name", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat" }; - const label = new Label(values); - const result = label.getEntityName(); - assert.equal(result, "black-cat"); - }); - - it("should get label id", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat" }; - const label = new Label(values); - const result = label.getId(); - assert.equal(result, "ABC123"); - }); - - it("should get label title", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat" }; - const label = new Label(values); - const result = label.getTitle(); - assert.equal(result, "Black Cat"); - }); - - it("should get thumbnail url", () => { - const values = { - ID: 5, - UID: "ABC123", - Thumb: "c6b24d688564f7ddc7b245a414f003a8d8ff5a67", - Name: "Black Cat", - Slug: "black-cat", - }; - const label = new Label(values); - const result = label.thumbnailUrl("xyz"); - assert.equal(result, "/api/v1/t/c6b24d688564f7ddc7b245a414f003a8d8ff5a67/public/xyz"); - - const values2 = { - ID: 5, - UID: "ABC123", - Name: "Black Cat", - Slug: "black-cat", - }; - const label2 = new Label(values2); - const result2 = label2.thumbnailUrl("xyz"); - assert.equal(result2, "/api/v1/labels/ABC123/t/public/xyz"); - - const values3 = { - ID: 5, - Name: "Black Cat", - Slug: "black-cat", - }; - const label3 = new Label(values3); - const result3 = label3.thumbnailUrl("xyz"); - assert.equal(result3, "/api/v1/svg/label"); - }); - - it("should get date string", () => { - const values = { - ID: 5, - UID: "ABC123", - Name: "Black Cat", - Slug: "black-cat", - CreatedAt: "2012-07-08T14:45:39Z", - }; - const label = new Label(values); - const result = label.getDateString(); - assert.equal(result.replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("should get model name", () => { - const result = Label.getModelName(); - assert.equal(result, "Label"); - }); - - it("should get collection resource", () => { - const result = Label.getCollectionResource(); - assert.equal(result, "labels"); - }); - - it("should like label", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat", Favorite: false }; - const label = new Label(values); - assert.equal(label.Favorite, false); - label.like(); - assert.equal(label.Favorite, true); - }); - - it("should unlike label", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat", Favorite: true }; - const label = new Label(values); - assert.equal(label.Favorite, true); - label.unlike(); - assert.equal(label.Favorite, false); - }); - - it("should toggle like", () => { - const values = { ID: 5, UID: "ABC123", Name: "Black Cat", Slug: "black-cat", Favorite: true }; - const label = new Label(values); - assert.equal(label.Favorite, true); - label.toggleLike(); - assert.equal(label.Favorite, false); - label.toggleLike(); - assert.equal(label.Favorite, true); - }); - - it("should get label defaults", () => { - const values = { ID: 5, UID: "ABC123" }; - const label = new Label(values); - const result = label.getDefaults(); - assert.equal(result.ID, 0); - }); -}); diff --git a/frontend/tests/unit/model/link_test.js b/frontend/tests/unit/model/link_test.js deleted file mode 100644 index e85975fdc..000000000 --- a/frontend/tests/unit/model/link_test.js +++ /dev/null @@ -1,103 +0,0 @@ -import "../fixtures"; -import Link from "model/link"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/link", () => { - it("should get link defaults", () => { - const values = { UID: 5 }; - const link = new Link(values); - const result = link.getDefaults(); - assert.equal(result.UID, 0); - assert.equal(result.Perm, 0); - assert.equal(result.Comment, ""); - assert.equal(result.ShareUID, ""); - }); - - it("should get link url", () => { - const values = { UID: 5, Token: "1234hhtbbt", Slug: "friends", ShareUID: "family" }; - const link = new Link(values); - const result = link.url(); - assert.equal(result, "http://localhost:2342/s/1234hhtbbt/friends"); - const values2 = { UID: 5, Token: "", ShareUID: "family" }; - const link2 = new Link(values2); - const result2 = link2.url(); - assert.equal(result2, "http://localhost:2342/s/…/family"); - }); - - it("should get link caption", () => { - const values = { UID: 5, Token: "AcfgbTTh", Slug: "friends", ShareUID: "family" }; - const link = new Link(values); - const result = link.caption(); - assert.equal(result, "/s/acfgbtth"); - }); - - it("should get link id", () => { - const values = { UID: 5 }; - const link = new Link(values); - const result = link.getId(); - assert.equal(result, 5); - const values2 = {}; - const link2 = new Link(values2); - const result2 = link2.getId(); - assert.equal(result2, false); - }); - - it("should test has id", () => { - const values = { UID: 5 }; - const link = new Link(values); - const result = link.hasId(); - assert.equal(result, true); - }); - - it("should get link slug", () => { - const values = { UID: 5, Token: "AcfgbTTh", Slug: "friends", ShareUID: "family" }; - const link = new Link(values); - const result = link.getSlug(); - assert.equal(result, "friends"); - }); - - it("should test has slug", () => { - const values = { UID: 5, Token: "AcfgbTTh", Slug: "friends", ShareUID: "family" }; - const link = new Link(values); - const result = link.hasSlug(); - assert.equal(result, true); - const values2 = { UID: 5, Token: "AcfgbTTh", ShareUID: "family" }; - const link2 = new Link(values2); - const result2 = link2.hasSlug(); - assert.equal(result2, false); - }); - - it("should clone link", () => { - const values = { UID: 5, Token: "AcfgbTTh", Slug: "friends", ShareUID: "family" }; - const link = new Link(values); - const result = link.clone(); - assert.equal(result.Slug, "friends"); - assert.equal(result.Token, "AcfgbTTh"); - }); - - it("should test expire", () => { - const values = { - UID: 5, - Token: "AcfgbTTh", - Slug: "friends", - ShareUID: "family", - Expires: 80000, - ModifiedAt: "2012-07-08T14:45:39Z", - }; - const link = new Link(values); - const result = link.expires(); - assert.equal(result, "Jul 9, 2012"); - }); - - it("should get collection resource", () => { - const result = Link.getCollectionResource(); - assert.equal(result, "links"); - }); - - it("should get model name", () => { - const result = Link.getModelName(); - assert.equal(result, "Link"); - }); -}); diff --git a/frontend/tests/unit/model/marker_test.js b/frontend/tests/unit/model/marker_test.js deleted file mode 100644 index 5fa0eebc0..000000000 --- a/frontend/tests/unit/model/marker_test.js +++ /dev/null @@ -1,221 +0,0 @@ -import "../fixtures"; -import { Marker, BatchSize } from "model/marker"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/marker", () => { - it("should get marker defaults", () => { - const values = { FileUID: "fghjojp" }; - const marker = new Marker(values); - const result = marker.getDefaults(); - assert.equal(result.UID, ""); - assert.equal(result.FileUID, ""); - }); - - it("should get route view", () => { - const values = { UID: "ABC123ghytr", FileUID: "fhjouohnnmnd", Type: "face", Src: "image" }; - const marker = new Marker(values); - const result = marker.route("test"); - assert.equal(result.name, "test"); - assert.equal(result.query.q, "marker:ABC123ghytr"); - }); - - it("should return classes", () => { - const values = { UID: "ABC123ghytr", FileUID: "fhjouohnnmnd", Type: "face", Src: "image" }; - const marker = new Marker(values); - const result = marker.classes(true); - assert.include(result, "is-marker"); - assert.include(result, "uid-ABC123ghytr"); - assert.include(result, "is-selected"); - assert.notInclude(result, "is-review"); - assert.notInclude(result, "is-invalid"); - const result2 = marker.classes(false); - assert.include(result2, "is-marker"); - assert.include(result2, "uid-ABC123ghytr"); - assert.notInclude(result2, "is-selected"); - assert.notInclude(result2, "is-review"); - assert.notInclude(result2, "is-invalid"); - const values2 = { - UID: "mBC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Invalid: true, - Review: true, - }; - const marker2 = new Marker(values2); - const result3 = marker2.classes(true); - assert.include(result3, "is-marker"); - assert.include(result3, "uid-mBC123ghytr"); - assert.include(result3, "is-selected"); - assert.include(result3, "is-review"); - assert.include(result3, "is-invalid"); - }); - - it("should get marker entity name", () => { - const values = { - UID: "ABC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Name: "test", - }; - const marker = new Marker(values); - const result = marker.getEntityName(); - assert.equal(result, "test"); - }); - - it("should get marker title", () => { - const values = { - UID: "ABC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Name: "test", - }; - const marker = new Marker(values); - const result = marker.getTitle(); - assert.equal(result, "test"); - }); - - it("should get thumbnail url", () => { - const values = { UID: "ABC123ghytr", FileUID: "fhjouohnnmnd", Type: "face", Src: "image" }; - const marker = new Marker(values); - const result = marker.thumbnailUrl("xyz"); - assert.equal(result, "/api/v1/svg/portrait"); - - const values2 = { - UID: "ABC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Thumb: "nicethumbuid", - }; - const marker2 = new Marker(values2); - const result2 = marker2.thumbnailUrl(); - assert.equal(result2, "/api/v1/t/nicethumbuid/public/tile_160"); - }); - - it("should get date string", () => { - const values = { - UID: "ABC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - CreatedAt: "2012-07-08T14:45:39Z", - }; - const marker = new Marker(values); - const result = marker.getDateString(); - assert.equal(result.replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("should approve marker", () => { - const values = { - UID: "mBC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Invalid: true, - Review: true, - }; - const marker = new Marker(values); - assert.equal(marker.Review, true); - assert.equal(marker.Invalid, true); - marker.approve(); - assert.equal(marker.Review, false); - assert.equal(marker.Invalid, false); - }); - - it("should reject marker", () => { - const values = { - UID: "mCC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Invalid: false, - Review: true, - }; - const marker = new Marker(values); - assert.equal(marker.Review, true); - assert.equal(marker.Invalid, false); - marker.reject(); - assert.equal(marker.Review, false); - assert.equal(marker.Invalid, true); - }); - - it("should rename marker", (done) => { - const values = { - UID: "mDC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Subject: "skhljkpigh", - Name: "", - SubjSrc: "manual", - }; - const marker = new Marker(values); - assert.equal(marker.Name, ""); - marker.setName(); - assert.equal(marker.Name, ""); - const values2 = { - UID: "mDC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Subject: "skhljkpigh", - Name: "testname", - SubjSrc: "manual", - }; - const marker2 = new Marker(values2); - assert.equal(marker2.Name, "testname"); - marker2 - .setName() - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should clear subject", (done) => { - const values = { - UID: "mEC123ghytr", - FileUID: "fhjouohnnmnd", - Type: "face", - Src: "image", - Subject: "skhljkpigh", - Name: "testname", - SubjSrc: "manual", - }; - const marker = new Marker(values); - marker - .clearSubject() - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should return batch size", () => { - assert.equal(Marker.batchSize(), BatchSize); - Marker.setBatchSize(30); - assert.equal(Marker.batchSize(), 30); - Marker.setBatchSize(BatchSize); - }); - - it("should get collection resource", () => { - const result = Marker.getCollectionResource(); - assert.equal(result, "markers"); - }); - - it("should get model name", () => { - const result = Marker.getModelName(); - assert.equal(result, "Marker"); - }); -}); diff --git a/frontend/tests/unit/model/photo_test.js b/frontend/tests/unit/model/photo_test.js deleted file mode 100644 index 66b982955..000000000 --- a/frontend/tests/unit/model/photo_test.js +++ /dev/null @@ -1,1862 +0,0 @@ -import "../fixtures"; -import * as media from "common/media"; -import { Photo, BatchSize } from "model/photo"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/photo", () => { - it("should get photo entity name", () => { - const values = { UID: 5, Title: "Crazy Cat" }; - const photo = new Photo(values); - const result = photo.getEntityName(); - assert.equal(result, "Crazy Cat"); - }); - - it("should get photo uuid", () => { - const values = { ID: 5, Title: "Crazy Cat", UID: 789 }; - const photo = new Photo(values); - const result = photo.getId(); - assert.equal(result, 789); - }); - - it("should get photo title", () => { - const values = { ID: 5, Title: "Crazy Cat", UID: 789 }; - const photo = new Photo(values); - const result = photo.getTitle(); - assert.equal(result, "Crazy Cat"); - }); - - it("should get photo maps link", () => { - const values = { ID: 5, Title: "Crazy Cat", Lat: 36.442881666666665, Lng: 28.229493333333334 }; - const photo = new Photo(values); - const result = photo.getGoogleMapsLink(); - assert.equal(result, "https://www.google.com/maps/place/36.442881666666665,28.229493333333334"); - }); - - it("should get photo thumbnail url", () => { - const values = { ID: 5, Title: "Crazy Cat", Hash: "97b8cf7b3710bec95f6609487bbdd62489b95fb2" }; - const photo = new Photo(values); - const result = photo.thumbnailUrl("tile500"); - assert.equal(result, "/api/v1/t/97b8cf7b3710bec95f6609487bbdd62489b95fb2/public/tile500"); - const values2 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "be651a4fffd699196cfd5dd14b6ec9cb10a8531a", - }, - ], - }; - const photo2 = new Photo(values2); - const result2 = photo2.thumbnailUrl("tile500"); - assert.equal(result2, "/api/v1/t/be651a4fffd699196cfd5dd14b6ec9cb10a8531a/public/tile500"); - const values3 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - }, - ], - }; - const photo3 = new Photo(values3); - const result3 = photo3.thumbnailUrl("tile500"); - assert.equal(result3, "/static/img/404.jpg"); - }); - - it("should get classes", () => { - const values2 = { - ID: 10, - UID: "ABC127", - Type: "video", - Portrait: true, - Favorite: true, - Private: true, - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Video: true, - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - }, - { - UID: "123fde", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdkkk", - }, - ], - }; - const photo2 = new Photo(values2); - const result2 = photo2.classes(); - assert.include(result2, "is-photo"); - assert.include(result2, "uid-ABC127"); - assert.include(result2, "type-video"); - assert.include(result2, "is-portrait"); - assert.include(result2, "is-favorite"); - assert.include(result2, "is-private"); - assert.notInclude(result2, "is-stack"); - assert.include(result2, "is-playable"); - }); - - it("should get photo download url", () => { - const values = { ID: 5, Title: "Crazy Cat", Hash: "97b8cf7b3710bec95f6609487bbdd62489b95fb2" }; - const photo = new Photo(values); - const result = photo.getDownloadUrl(); - assert.equal(result, "/api/v1/dl/97b8cf7b3710bec95f6609487bbdd62489b95fb2?t=2lbh9x09"); - }); - - it("should calculate photo size", () => { - const values = { ID: 5, Title: "Crazy Cat", Width: 500, Height: 200 }; - const photo = new Photo(values); - const result = photo.calculateSize(500, 200); - assert.equal(result.width, 500); - assert.equal(result.height, 200); - }); - - it("should calculate photo size with srcAspectRatio < maxAspectRatio", () => { - const values = { ID: 5, Title: "Crazy Cat", Width: 500, Height: 200 }; - const photo = new Photo(values); - const result = photo.calculateSize(300, 50); - assert.equal(result.width, 125); - assert.equal(result.height, 50); - }); - - it("should calculate photo size with srcAspectRatio > maxAspectRatio", () => { - const values = { ID: 5, Title: "Crazy Cat", Width: 500, Height: 200 }; - const photo = new Photo(values); - const result = photo.calculateSize(400, 300); - assert.equal(result.width, 400); - assert.equal(result.height, 160); - }); - - it("should get local day string", () => { - const values = { ID: 5, Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TimeZone: "UTC" }; - const photo = new Photo(values); - const result = photo.localDayString(); - // Current day of the month (changes): - assert.equal(result.length, 2); - const values2 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - TimeZone: "UTC", - Day: 8, - }; - const photo2 = new Photo(values2); - const result2 = photo2.localDayString(); - assert.equal(result2, "08"); - }); - - it("should get local month string", () => { - const values = { ID: 5, Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TimeZone: "UTC" }; - const photo = new Photo(values); - const result = photo.localMonthString(); - assert.equal(result, (new Date().getMonth() + 1).toString().padStart(2, "0")); - const values2 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - TimeZone: "UTC", - Month: 8, - }; - const photo2 = new Photo(values2); - const result2 = photo2.localMonthString(); - assert.equal(result2, "08"); - }); - - it("should get local year string", () => { - const values = { ID: 5, Title: "Crazy Cat", TakenAt: "2012-07-08T14:45:39Z", TimeZone: "UTC" }; - const photo = new Photo(values); - const result = photo.localYearString(); - assert.equal(result, new Date().getFullYear().toString().padStart(4, "0")); - const values2 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - TimeZone: "UTC", - Year: 2010, - }; - const photo2 = new Photo(values2); - const result2 = photo2.localYearString(); - assert.equal(result2, "2010"); - }); - - it("should get local date string", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - TimeZone: "UTC", - }; - const photo = new Photo(values); - const result = photo.localDateString(); - assert.equal(result, "2012-07-08T14:45:39Z"); - }); - - it("should get local date", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - TakenAt: "2012-07-08T14:45:39Z", - TimeZone: "Indian/Reunion", - }; - const photo = new Photo(values); - const result = photo.localDate(); - assert.equal(String(result), "2012-07-08T14:45:39.000Z"); - }); - - it("UTC", () => { - const values = { - ID: 9999, - Title: "Video", - TakenAt: "2012-07-08T14:45:39Z", - TakenAtLocal: "2012-07-08T14:45:39Z", - TimeZone: "UTC", - }; - const photo = new Photo(values); - assert.equal(String(photo.localDateString("10:00:00")), "2012-07-08T10:00:00Z"); - const result = photo.localDate(); - assert.equal(String(result), "2012-07-08T14:45:39.000Z"); - }); - - it("should get date string", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T12:45:39Z", - TimeZone: "Europe/Berlin", - }; - const photo = new Photo(values); - const result = photo.getDateString(false).replaceAll("\u202f", " "); - assert.isTrue(result.startsWith("Sunday, July 8, 2012")); - assert.isTrue(result.endsWith("2:45 PM")); - const values2 = { ID: 5, Title: "Crazy Cat", TakenAtLocal: "", TakenAt: "", TimeZone: "UTC" }; - const photo2 = new Photo(values2); - const result2 = photo2.getDateString(); - assert.equal(result2, "Unknown"); - const values3 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - }; - const photo3 = new Photo(values3); - const result3 = photo3.getDateString(); - assert.equal(result3, "Sunday, July 8, 2012"); - const values4 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - Month: -1, - }; - const photo4 = new Photo(values4); - const result4 = photo4.getDateString(); - assert.equal(result4, "2012"); - const values5 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - Day: -1, - }; - const photo5 = new Photo(values5); - const result5 = photo5.getDateString(); - assert.equal(result5, "July 2012"); - }); - - it("should get short date string", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - TimeZone: "UTC", - }; - const photo = new Photo(values); - const result = photo.shortDateString(); - assert.equal(result, "7/8/2012"); - const values2 = { ID: 5, Title: "Crazy Cat", TakenAtLocal: "", TakenAt: "", TimeZone: "UTC" }; - const photo2 = new Photo(values2); - const result2 = photo2.shortDateString(); - assert.equal(result2, "Unknown"); - const values3 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - }; - const photo3 = new Photo(values3); - const result3 = photo3.shortDateString(); - assert.equal(result3, "7/8/2012"); - const values4 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - Month: -1, - }; - const photo4 = new Photo(values4); - const result4 = photo4.shortDateString(); - assert.equal(result4, "2012"); - const values5 = { - ID: 5, - Title: "Crazy Cat", - TakenAtLocal: "2012-07-08T14:45:39Z", - TakenAt: "2012-07-08T14:45:39Z", - Day: -1, - }; - const photo5 = new Photo(values5); - const result5 = photo5.shortDateString(); - assert.equal(result5, "July 2012"); - }); - - it("should test whether photo has location", () => { - const values = { ID: 5, Title: "Crazy Cat", Lat: 36.442881666666665, Lng: 28.229493333333334 }; - const photo = new Photo(values); - const result = photo.hasLocation(); - assert.equal(result, true); - }); - - it("should test whether photo has location", () => { - const values = { ID: 5, Title: "Crazy Cat", Lat: 0, Lng: 0 }; - const photo = new Photo(values); - const result = photo.hasLocation(); - assert.equal(result, false); - }); - - it("should get location", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - CellID: 6, - CellCategory: "viewpoint", - PlaceLabel: "Cape Point, South Africa", - PlaceCountry: "South Africa", - }; - const photo = new Photo(values); - const result = photo.locationInfo(); - assert.equal(result, "Cape Point, South Africa"); - }); - - it("should get location", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - CellID: 6, - CellCategory: "viewpoint", - PlaceLabel: "Cape Point, State, South Africa", - PlaceCountry: "South Africa", - PlaceCity: "Cape Town", - PlaceCounty: "County", - PlaceState: "State", - }; - const photo = new Photo(values); - const result = photo.locationInfo(); - assert.equal(result, "Cape Point, State, South Africa"); - }); - - it("should get location", () => { - const values = { - ID: 5, - Title: "Crazy Cat", - CellCategory: "viewpoint", - CellName: "Cape Point", - PlaceCountry: "Africa", - PlaceCity: "Cape Town", - PlaceCounty: "County", - PlaceState: "State", - }; - const photo = new Photo(values); - const result = photo.locationInfo(); - assert.equal(result, "Unknown"); - }); - - it("should get location", () => { - const values = { ID: 5, Title: "Crazy Cat", CountryName: "Africa", PlaceCity: "Cape Town" }; - const photo = new Photo(values); - const result = photo.locationInfo(); - assert.equal(result, "Unknown"); - }); - - it("should get camera", () => { - const values = { ID: 5, Title: "Crazy Cat", CameraModel: "EOSD10", CameraMake: "Canon" }; - const photo = new Photo(values); - const result = photo.getCamera(); - assert.equal(result, "Canon EOSD10"); - const values2 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Hash: "1xxbgdt55", - }, - ], - Camera: { - Make: "Canon", - Model: "abc", - }, - }; - const photo2 = new Photo(values2); - assert.equal(photo2.getCamera(), "Canon abc"); - }); - - it("should get camera", () => { - const values = { ID: 5, Title: "Crazy Cat" }; - const photo = new Photo(values); - const result = photo.getCamera(); - assert.equal(result, "Unknown"); - }); - - it("should get collection resource", () => { - const result = Photo.getCollectionResource(); - assert.equal(result, "photos"); - }); - - it("should return batch size", () => { - assert.equal(Photo.batchSize(), BatchSize); - }); - - it("should get model name", () => { - const result = Photo.getModelName(); - assert.equal(result, "Photo"); - }); - - it("should like photo", () => { - const values = { ID: 5, Title: "Crazy Cat", CountryName: "Africa", Favorite: false }; - const photo = new Photo(values); - assert.equal(photo.Favorite, false); - photo.like(); - assert.equal(photo.Favorite, true); - }); - - it("should unlike photo", () => { - const values = { - ID: 5, - UID: "abc123", - Title: "Crazy Cat", - CountryName: "Africa", - Favorite: true, - }; - const photo = new Photo(values); - assert.equal(photo.Favorite, true); - photo.unlike(); - assert.equal(photo.Favorite, false); - }); - - /* TODO - it("should toggle like", () => { - const values = {ID: 5, Title: "Crazy Cat", CountryName: "Africa", Favorite: true}; - const photo = new Photo(values); - assert.equal(photo.Favorite, true); - photo.toggleLike(); - assert.equal(photo.Favorite, false); - photo.toggleLike(); - assert.equal(photo.Favorite, true); - }); - */ - - it("should get photo defaults", () => { - const values = { ID: 5, UID: "ABC123" }; - const photo = new Photo(values); - const result = photo.getDefaults(); - assert.equal(result.UID, ""); - }); - - it("should get photos base name", () => { - const values = { - ID: 8, - UID: "ABC123", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "TypeJpeg", - Width: 500, - Height: 600, - Hash: "ca3e60b9825bd61ee6369fcefe22f4eb92631bb5", - }, - ], - }; - const photo = new Photo(values); - const result = photo.baseName(); - assert.equal(result, "superCuteKitten.jpg"); - const result2 = photo.baseName(5); - assert.equal(result2, "supe…"); - }); - - it("should refresh file attributes", () => { - const values2 = { ID: 5, UID: "ABC123" }; - const photo2 = new Photo(values2); - photo2.refreshFileAttr(); - assert.equal(photo2.Width, undefined); - assert.equal(photo2.Height, undefined); - assert.equal(photo2.Hash, undefined); - const values = { - ID: 8, - UID: "ABC123", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "TypeJpeg", - Width: 500, - Height: 600, - Hash: "ca3e60b9825bd61ee6369fcefe22f4eb92631bb5", - }, - ], - }; - const photo = new Photo(values); - assert.equal(photo.Width, undefined); - assert.equal(photo.Height, undefined); - assert.equal(photo.Hash, undefined); - photo.refreshFileAttr(); - assert.equal(photo.Width, 500); - assert.equal(photo.Height, 600); - assert.equal(photo.Hash, "ca3e60b9825bd61ee6369fcefe22f4eb92631bb5"); - }); - - it("should return is playable", () => { - const values = { - ID: 8, - UID: "ABC123", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "TypeJpeg", - Width: 500, - Height: 600, - Hash: "ca3e60b9825bd61ee6369fcefe22f4eb92631bb5", - }, - ], - }; - const photo = new Photo(values); - assert.equal(photo.isPlayable(), false); - const values2 = { ID: 9, UID: "ABC163" }; - const photo2 = new Photo(values2); - assert.equal(photo2.isPlayable(), false); - const values3 = { - ID: 10, - UID: "ABC127", - Filename: "1980/01/superCuteKitten.mp4", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - Video: true, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "c1e30d265eab968155082c8e86d85815a8389479", - }, - ], - }; - const photo3 = new Photo(values3); - assert.equal(photo3.isPlayable(), true); - const values4 = { - ID: 1, - UID: "ABC128", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - Video: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "ca3e60b9825bd61ee6369fcefe22f4eb92631bb5", - Codec: "avc1", - }, - ], - }; - const photo4 = new Photo(values4); - assert.equal(photo4.isPlayable(), true); - }); - - it("should return video params", () => { - const values3 = { - ID: 10, - UID: "ABC127", - Filename: "1980/01/superCuteKitten.mp4", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - Video: true, - FileType: "mp4", - Width: 900, - Height: 600, - Hash: "c1e30d265eab968155082c8e86d85815a8389479", - }, - ], - }; - const photo3 = new Photo(values3); - const result = photo3.videoParams(); - assert.isAbove(result.height, 340); - assert.isAbove(result.width, 510); - assert.equal(result.loop, false); - assert.equal(result.uri, "/api/v1/videos/c1e30d265eab968155082c8e86d85815a8389479/public/avc"); - const values = { - ID: 11, - UID: "ABC127", - Filename: "1980/01/superCuteKitten.mp4", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - Video: true, - FileType: "mp4", - Width: 0, - Height: 0, - Hash: "c1e30d265eab968155082c8e86d85815a8389479", - }, - { - UID: "123fpp", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - Width: 5000, - Height: 5000, - Hash: "ca3e60b9825bd61ee6369fcefe22f4eb92631bb5", - }, - ], - }; - const photo = new Photo(values); - const result2 = photo.videoParams(); - assert.isAbove(result2.height, 340); - assert.isAbove(result2.width, 340); - assert.equal(result2.loop, false); - assert.equal(result2.uri, "/api/v1/videos/c1e30d265eab968155082c8e86d85815a8389479/public/avc"); - }); - - it("should return videofile", () => { - const values = { - ID: 8, - UID: "ABC123", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "c1e30d265eab968155082c8e86d85815a8389479", - }, - ], - }; - const photo = new Photo(values); - assert.equal(photo.videoFile(), undefined); - const values2 = { ID: 9, UID: "ABC163" }; - const photo2 = new Photo(values2); - assert.equal(photo2.videoFile(), false); - const values3 = { - ID: 10, - UID: "ABC127", - Filename: "1980/01/superCuteKitten.mp4", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "c1e30d265eab968155082c8e86d85815a8389479", - }, - ], - }; - const photo3 = new Photo(values3); - const file = photo3.videoFile(); - assert.equal(photo3.videoFile().Name, "1980/01/superCuteKitten.mp4"); - const values4 = { - ID: 1, - UID: "ABC128", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - Codec: "avc1", - }, - ], - }; - const photo4 = new Photo(values4); - assert.equal(photo4.videoFile().Name, "1980/01/superCuteKitten.jpg"); - const file2 = photo4.videoFile(); - }); - - it("should return video url", () => { - const values = { - ID: 8, - UID: "ABC123", - Filename: "1980/01/superCuteKitten.jpg", - Hash: "703cf8f274fbb265d49c6262825780e1", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - }, - ], - }; - const photo = new Photo(values); - assert.equal(photo.videoContentType(), media.ContentTypeMp4AvcMain); - assert.equal(photo.videoUrl(), "/api/v1/videos/703cf8f274fbb265d49c6262825780e1/public/avc"); - const values2 = { ID: 9, UID: "ABC163", Hash: "2305e512e3b183ec982d60a8b608a8ca501973ba" }; - const photo2 = new Photo(values2); - assert.equal(photo2.videoUrl(), "/api/v1/videos/2305e512e3b183ec982d60a8b608a8ca501973ba/public/avc"); - const values3 = { - ID: 10, - UID: "ABC127", - Filename: "1980/01/superCuteKitten.mp4", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - }, - ], - }; - const photo3 = new Photo(values3); - - assert.equal(photo3.videoUrl(), "/api/v1/videos/1xxbgdt55/public/avc"); - const values4 = { - ID: 1, - UID: "ABC128", - Filename: "1980/01/superCuteKitten.jpg", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - Codec: "avc1", - }, - ], - }; - - const photo4 = new Photo(values4); - assert.equal(photo4.videoUrl(), "/api/v1/videos/1xxbgdt53/public/avc"); - }); - - it("should return main file", () => { - const values = { ID: 9, UID: "ABC163", Width: 111, Height: 222 }; - const photo = new Photo(values); - assert.equal(photo.primaryFile(), photo); - const values2 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - }, - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt56", - }, - ], - }; - const photo2 = new Photo(values2); - const file = photo2.primaryFile(); - assert.equal(file.Name, "1980/01/superCuteKitten.jpg"); - const values3 = { - ID: 1, - UID: "ABC128", - Files: [ - { - UID: "123fgb", - Name: "1980/01/NotMainKitten.jpg", - Primary: false, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - }, - { - UID: "123fgb", - Name: "1980/01/MainKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt54", - }, - ], - }; - const photo3 = new Photo(values3); - const file2 = photo3.primaryFile(); - assert.equal(file2.Name, "1980/01/MainKitten.jpg"); - }); - - it("should return jpeg files", () => { - const values = { ID: 8, UID: "ABC123", Filename: "1980/01/superCuteKitten.jpg" }; - const photo = new Photo(values); - const result = photo.jpegFiles(); - assert.equal(result[0].Filename, "1980/01/superCuteKitten.jpg"); - const values3 = { - ID: 10, - UID: "ABC127", - Filename: "1980/01/superCuteKitten.mp4", - FileUID: "123fgb", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - FileType: media.FormatJpeg, - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - }, - { - UID: "123fgz", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdt66", - }, - ], - }; - const photo3 = new Photo(values3); - const file = photo3.jpegFiles(); - assert.equal(file[0].Name, "1980/01/superCuteKitten.jpg"); - }); - - it("should return file hash", () => { - // If the picture has no Hash property, an empty string should be returned: - const values = { ID: 9, UID: "ABC163" }; - const photo = new Photo(values); - assert.equal(photo.fileHash(), ""); - // If the picture has a Hash property but no Files, its value should be returned: - photo.Hash = "123693d2c2b9afdba19f97d1c92963953e1d2cfe"; - assert.equal(photo.fileHash(), "123693d2c2b9afdba19f97d1c92963953e1d2cfe"); - // If there is a non-primary JPEG or PNG image, its Hash should be returned: - const values2 = { - ID: 10, - UID: "ABC127", - Type: "video", - Hash: "123693d2c2b9afdba19f97d1c92963953e1d2cfe", - Files: [ - { - UID: "fsr3uh0u30trle4l", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - Root: "/", - MediaType: "video", - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "617693d2c2b9afdba19f97d1c92963953e1d2cfe", - }, - { - UID: "fsr3uh0g2us6cwg4", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - Root: "/", - MediaType: "image", - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "9249cee32bc8adc6ba996a6b78dd84c03b5a0153", - }, - ], - }; - const photo2 = new Photo(values2); - assert.equal(photo2.fileHash(), "9249cee32bc8adc6ba996a6b78dd84c03b5a0153"); - // If the FileType of the image is "invalid", the video Hash should be returned: - photo2.Files = [ - { - UID: "fsr3uh0u30trle4l", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - Root: "/", - MediaType: "video", - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "617693d2c2b9afdba19f97d1c92963953e1d2cfe", - }, - { - UID: "fsr3uh0g2us6cwg4", - Name: "1980/01/superCuteKitten.jpg", - Primary: false, - Root: "/", - MediaType: "image", - FileType: "invalid", - Width: 500, - Height: 600, - Hash: "9249cee32bc8adc6ba996a6b78dd84c03b5a0153", - }, - ]; - assert.equal(photo2.fileHash(), "617693d2c2b9afdba19f97d1c92963953e1d2cfe"); - }); - - it("should return file models", () => { - const values = { ID: 9, UID: "ABC163" }; - const photo = new Photo(values); - assert.empty(photo.fileModels()); - const values2 = { - ID: 10, - UID: "ABC127", - Type: "video", - Files: [ - { - UID: "fsr3uh0u30trle4l", - Name: "1980/01/cat.jpg", - Primary: false, - Root: "/", - FileType: "jpg", - MediaType: "image", - Width: 500, - Height: 600, - Hash: "35c905d21486b400814bd2d8479ed2e780440b1a", - }, - { - UID: "fsr3uh0g2us6cwg4", - Name: "1999/01/dog.jpg", - Primary: true, - Root: "/", - FileType: "jpg", - MediaType: "image", - Width: 500, - Height: 600, - Hash: "617693d2c2b9afdba19f97d1c92963953e1d2cfe", - }, - { - UID: "fsr3uh10nrgs63a2", - Name: "1999/01/dog.mov", - Video: true, - Root: "/", - FileType: "mov", - MediaType: "video", - Width: 500, - Height: 600, - Hash: "9249cee32bc8adc6ba996a6b78dd84c03b5a0153", - }, - ], - }; - const photo2 = new Photo(values2); - assert.equal(photo2.fileModels()[0].Name, "1999/01/dog.mov"); - const values3 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "fsr3uh0u30trle4l", - Name: "1980/01/cat.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "35c905d21486b400814bd2d8479ed2e780440b1a", - }, - { - UID: "fsr3uh0g2us6cwg4", - Name: "1999/01/dog.jpg", - Primary: false, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "617693d2c2b9afdba19f97d1c92963953e1d2cfe", - }, - ], - }; - const photo3 = new Photo(values3); - assert.equal(photo3.fileModels()[0].Name, "1980/01/cat.jpg"); - const values4 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "fsr3uh0u30trle4l", - Name: "1980/01/cat.jpg", - Primary: true, - Root: "/", - FileType: "jpg", - MediaType: "image", - Width: 500, - Height: 600, - Hash: "35c905d21486b400814bd2d8479ed2e780440b1a", - }, - ], - }; - const photo4 = new Photo(values4); - assert.equal(photo4.fileModels()[0].Name, "1980/01/cat.jpg"); - }); - - it("should get country name", () => { - const values = { ID: 5, UID: "ABC123", Country: "zz" }; - const photo = new Photo(values); - assert.equal(photo.countryName(), "Unknown"); - const values2 = { ID: 5, UID: "ABC123", Country: "es" }; - const photo2 = new Photo(values2); - assert.equal(photo2.countryName(), "Spain"); - }); - - it("should get location info", () => { - const values = { ID: 5, UID: "ABC123", Country: "zz", PlaceID: "zz", PlaceLabel: "Nice beach" }; - const photo = new Photo(values); - assert.equal(photo.locationInfo(), "Nice beach"); - const values2 = { ID: 5, UID: "ABC123", Country: "es", PlaceID: "zz" }; - const photo2 = new Photo(values2); - assert.equal(photo2.locationInfo(), "Spain"); - }); - - it("should return video info", () => { - const values = { - ID: 9, - UID: "ABC163", - }; - const photo = new Photo(values); - assert.equal(photo.getVideoInfo(), "Video"); - const values2 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - }; - const photo2 = new Photo(values2); - assert.equal(photo2.getVideoInfo(), "MP4"); - const values3 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - Duration: 6000, - Size: 222897, - Codec: "avc1", - }, - ], - }; - const photo3 = new Photo(values3); - assert.equal(photo3.getVideoInfo(), "6µs, AVC, 500 × 600, 218 KB"); - const values4 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - Duration: 6000, - Size: 10240, - Codec: "avc1", - }, - { - UID: "345fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Hash: "1xxbgjhu5", - Width: 300, - Height: 500, - }, - ], - }; - const photo4 = new Photo(values4); - assert.equal(photo4.getVideoInfo(), "6µs, AVC, 300 × 500, 10 KB"); - assert.equal(photo4.getDurationInfo(), "6µs"); - }); - - it("should return photo info", () => { - const values = { - ID: 9, - UID: "ABC163", - }; - const photo = new Photo(values); - assert.equal(photo.getCameraInfo(), "Unknown"); - const values2 = { - ID: 10, - UID: "ABC127", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Hash: "1xxbgdt55", - }, - ], - Size: "300", - Camera: { - Make: "Canon", - Model: "abc", - }, - }; - const photo2 = new Photo(values2); - assert.equal(photo2.getCameraInfo(), "Canon abc"); - const values3 = { - ID: 10, - UID: "ABC127", - CameraMake: "Canon", - CameraModel: "EOS 6D", - Iso: 100, - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - Duration: 6000, - Codec: "avc1", - }, - ], - }; - const photo3 = new Photo(values3); - assert.equal(photo3.getCameraInfo(), "Canon EOS 6D, ISO 100"); - const values4 = { - ID: 10, - UID: "ABC127", - CameraID: 2, - CameraMake: "Canon", - Iso: 200, - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Width: 500, - Height: 600, - Hash: "1xxbgdt55", - Duration: 6000, - Size: 300, - Codec: "avc1", - }, - { - UID: "123fgx", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 800, - Height: 600, - Hash: "1xxbgdt55", - Duration: 6000, - Size: 200, - Codec: "avc1", - }, - ], - }; - const photo4 = new Photo(values4); - assert.equal(photo4.getCameraInfo(), "Canon, ISO 200"); - }); - - it("should return lens info", () => { - const values = { - ID: "674-860", - UID: "ps22wlskqtcmu9l3", - Type: "raw", - TypeSrc: "", - TakenAt: "2018-10-05T08:47:32Z", - TakenAtLocal: "2018-10-05T08:47:32Z", - TakenSrc: "meta", - TimeZone: "Local", - Path: "raw images/Canon EOS 700 D", - Name: "_MG_9509", - OriginalName: "", - Title: "Unknown / 2018", - Caption: "", - Year: 2018, - Month: 10, - Day: 5, - Country: "zz", - Stack: 0, - Favorite: false, - Private: false, - Iso: 100, - FocalLength: 50, - FNumber: 2.8, - Exposure: "1/1600", - Quality: 3, - Resolution: 18, - Color: 0, - Scan: false, - Panorama: false, - CameraID: 47, - CameraSrc: "meta", - CameraSerial: "338075021697", - CameraModel: "EOS 700D", - CameraMake: "Canon", - LensID: 47, - LensModel: "EF50mm f/1.8 II", - CellID: "zz", - PlaceID: "zz", - PlaceSrc: "", - PlaceLabel: "Unknown", - PlaceCity: "Unknown", - PlaceState: "Unknown", - PlaceCountry: "zz", - InstanceID: "", - FileUID: "fs25jsa22w9g851o", - FileRoot: "sidecar", - FileName: "raw images/Canon EOS 700 D/_MG_9509.CR2.jpg", - Hash: "7dc01e8cb588f3cfe31694ac2fece10167d88eec", - Width: 5198, - Height: 3462, - Portrait: false, - Files: [], - }; - const photo = new Photo(values); - assert.equal(photo.getLensInfo(), "EF50mm ƒ/1.8 II, 50mm, ƒ/2.8"); - }); - - it("should archive photo", () => { - const values = { ID: 5, Title: "Crazy Cat", CountryName: "Africa", Favorite: false }; - const photo = new Photo(values); - return photo - .archive() - .then((response) => { - assert.equal(200, response.status); - assert.deepEqual({ photos: [1, 3] }, response.data); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should approve photo", () => { - const values = { - ID: 5, - UID: "pqbemz8276mhtobh", - Title: "Crazy Cat", - CountryName: "Africa", - Favorite: false, - }; - const photo = new Photo(values); - return photo - .approve() - .then((response) => { - assert.equal(200, response.status); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should toggle private", () => { - const values = { ID: 5, Title: "Crazy Cat", CountryName: "Africa", Private: true }; - const photo = new Photo(values); - assert.equal(photo.Private, true); - photo.togglePrivate(); - assert.equal(photo.Private, false); - photo.togglePrivate(); - assert.equal(photo.Private, true); - }); - - it("should mark photo as primary", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - }; - const photo = new Photo(values); - photo - .setPrimaryFile("fqbfk181n4ca5sud") - .then((response) => { - assert.equal(response.Files[0].Primary, true); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should unstack", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - }; - const photo = new Photo(values); - photo - .unstackFile("fqbfk181n4ca5sud") - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should delete file", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - { - UID: "fqbfk181n4ca5abc", - Name: "1980/01/superCuteKitten.mp4", - Primary: true, - FileType: "mp4", - Hash: "1xxbgdt89", - }, - ], - }; - const photo = new Photo(values); - photo - .deleteFile("fqbfk181n4ca5sud") - .then((response) => { - assert.equal(response.success, "successfully deleted"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should add label", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - }; - const photo = new Photo(values); - photo - .addLabel("Cat") - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should activate label", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - }; - const photo = new Photo(values); - photo - .activateLabel(12345) - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should rename label", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - }; - const photo = new Photo(values); - photo - .renameLabel(12345, "Sommer") - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should remove label", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - }; - const photo = new Photo(values); - photo - .removeLabel(12345) - .then((response) => { - assert.equal(response.success, "ok"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should test update", (done) => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - Lat: 1.1, - Lng: 3.3, - CameraID: 123, - Title: "Test Titel", - Caption: "Super nice video", - Day: 10, - Country: "es", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - Details: [ - { - Keywords: "old", - Notes: "old notes", - Subject: "old subject", - Artist: "Old Artist", - Copyright: "ABC", - License: "test", - }, - ], - }; - const photo = new Photo(values); - photo.Title = "New Title"; - photo.Type = "newtype"; - photo.Caption = "New description"; - photo.Day = 21; - photo.Country = "de"; - photo.CameraID = "newcameraid"; - photo.Details.Keywords = "newkeyword"; - photo.Details.Notes = "New Notes"; - photo.Details.Subject = "New Photo Subject"; - photo.Details.Artist = "New Artist"; - photo.Details.Copyright = "New Copyright"; - photo.Details.License = "New License"; - photo - .update() - .then((response) => { - assert.equal(response.TitleSrc, "manual"); - done(); - }) - .catch((error) => { - done(error); - }); - assert.equal(photo.Title, "New Title"); - assert.equal(photo.Type, "newtype"); - assert.equal(photo.Caption, "New description"); - assert.equal(photo.Day, 21); - assert.equal(photo.Country, "de"); - assert.equal(photo.CameraID, "newcameraid"); - assert.equal(photo.Details.Keywords, "newkeyword"); - assert.equal(photo.Details.Notes, "New Notes"); - assert.equal(photo.Details.Subject, "New Photo Subject"); - assert.equal(photo.Details.Artist, "New Artist"); - assert.equal(photo.Details.Copyright, "New Copyright"); - assert.equal(photo.Details.License, "New License"); - }); - - it("should test get Markers", () => { - const values = { - ID: 10, - UID: "pqbemz8276mhtobh", - Lat: 1.1, - Lng: 3.3, - CameraID: 123, - Title: "Test Titel", - Caption: "Super nice video", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: false, - FileType: "mp4", - Hash: "1xxbgdt55", - }, - ], - }; - const photo = new Photo(values); - const result = photo.getMarkers(true); - assert.empty(result); - const values2 = { - ID: 10, - UID: "pqbemz8276mhtobh", - Lat: 1.1, - Lng: 3.3, - CameraID: 123, - Title: "Test Titel", - Caption: "Super nice video", - Files: [ - { - UID: "fqbfk181n4ca5sud", - Name: "1980/01/superCuteKitten.mp4", - Primary: true, - FileType: "mp4", - Hash: "1xxbgdt55", - Markers: [ - { - UID: "aaa123", - Invalid: false, - }, - { - UID: "bbb123", - Invalid: true, - }, - ], - }, - ], - }; - const photo2 = new Photo(values2); - const result2 = photo2.getMarkers(true); - assert.equal(result2.length, 1); - const result3 = photo2.getMarkers(false); - assert.equal(result3.length, 2); - }); - - it("should determine if photo is a stack", () => { - // Not a stack: Type is not image - const values1 = { - UID: "stack1", - Type: "video", - Files: [{ FileType: media.FormatJpeg }, { FileType: media.FormatJpeg }], - }; - const photo1 = new Photo(values1); - assert.isFalse(photo1.isStack(), "Should not be stack if type is not image"); - - // Not a stack: No files - const values2 = { UID: "stack2", Type: media.Image, Files: [] }; - const photo2 = new Photo(values2); - assert.isFalse(photo2.isStack(), "Should not be stack if no files"); - - // Not a stack: Only one file - const values3 = { UID: "stack3", Type: media.Image, Files: [{ FileType: media.FormatJpeg }] }; - const photo3 = new Photo(values3); - assert.isFalse(photo3.isStack(), "Should not be stack if only one file"); - - // Not a stack: Less than two JPEGs - const values4 = { UID: "stack4", Type: media.Image, Files: [{ FileType: media.FormatJpeg }, { FileType: "raw" }] }; - const photo4 = new Photo(values4); - assert.isFalse(photo4.isStack(), "Should not be stack if less than two JPEGs"); - - // Is a stack: Two JPEGs - const values5 = { - UID: "stack5", - Type: media.Image, - Files: [{ FileType: media.FormatJpeg }, { FileType: media.FormatJpeg }], - }; - const photo5 = new Photo(values5); - assert.isTrue(photo5.isStack(), "Should be stack if two JPEGs"); - - // Is a stack: More than two JPEGs - const values6 = { - UID: "stack6", - Type: media.Image, - Files: [{ FileType: media.FormatJpeg }, { FileType: "raw" }, { FileType: media.FormatJpeg }], - }; - const photo6 = new Photo(values6); - assert.isTrue(photo6.isStack(), "Should be stack if more than two JPEGs"); - }); - - it("should return the original file based on type", () => { - // Test for Live type - const liveFiles = [ - { UID: "live_jpg", Name: "live.jpg", FileType: media.FormatJpeg, Root: "/", Primary: true }, - { UID: "live_mov", Name: "live.mov", FileType: "mov", MediaType: media.Video, Root: "/", Video: true }, - { UID: "live_sidecar", Name: "live.xmp", FileType: "xmp", Root: "sidecar", Sidecar: true }, - ]; - const photoLive = new Photo({ UID: "livePhoto", Type: media.Live, Files: liveFiles }); - assert.strictEqual(photoLive.originalFile().UID, "live_mov", "Original file for Live should be video"); - - // Test for Video type - const videoFiles = [ - { UID: "video_jpg", Name: "video.jpg", FileType: media.FormatJpeg, Root: "/", Primary: true }, - { - UID: "video_mp4", - Name: "video.mp4", - FileType: media.FormatMp4, - MediaType: media.Video, - Root: "/", - Video: true, - }, - ]; - const photoVideo = new Photo({ UID: "videoPhoto", Type: media.Video, Files: videoFiles }); - assert.strictEqual(photoVideo.originalFile().UID, "video_mp4", "Original file for Video should be video"); - - // Test for Raw type - const rawFiles = [ - { UID: "raw_jpg", Name: "raw.jpg", FileType: media.FormatJpeg, Root: "/", Primary: true }, - { UID: "raw_cr2", Name: "raw.cr2", FileType: "cr2", MediaType: media.Raw, Root: "/" }, - ]; - const photoRaw = new Photo({ UID: "rawPhoto", Type: media.Raw, Files: rawFiles }); - assert.strictEqual(photoRaw.originalFile().UID, "raw_cr2", "Original file for Raw should be raw"); - - // Test for Animated type - const animatedFiles = [ - { - UID: "anim_gif", - Name: "anim.gif", - FileType: media.FormatGif, - MediaType: media.Image, - Root: "/", - Primary: true, - }, - { UID: "anim_sidecar", Name: "anim.xmp", FileType: "xmp", Root: "sidecar", Sidecar: true }, - ]; - const photoAnimated = new Photo({ UID: "animatedPhoto", Type: media.Animated, Files: animatedFiles }); - assert.strictEqual(photoAnimated.originalFile().UID, "anim_gif", "Original file for Animated should be image"); - - // Test for non-specific type - const otherFiles = [ - { UID: "other_jpg", Name: "other.jpg", FileType: media.FormatJpeg, Root: "/", Primary: true }, - { UID: "other_png", Name: "other.png", FileType: media.FormatPng, Root: "/" }, - ]; - const photoOther = new Photo({ UID: "otherPhoto", Type: media.Image, Files: otherFiles }); - assert.strictEqual( - photoOther.originalFile().UID, - "other_png", - "Original file should be first non-JPEG original if no type match" - ); - - // Test for JPEG only - const jpegFiles = [ - { UID: "jpeg_1", Name: "jpeg1.jpg", FileType: media.FormatJpeg, Root: "/" }, - { UID: "jpeg_2", Name: "jpeg2.jpg", FileType: media.FormatJpeg, Root: "/", Primary: true }, - ]; - const photoJpeg = new Photo({ UID: "jpegPhoto", Type: media.Image, Files: jpegFiles }); - assert.strictEqual(photoJpeg.originalFile().UID, "jpeg_2", "Original file should be primary JPEG if only JPEGs"); - - // Test for single file - const singleFile = [ - { UID: "single_jpg", Name: "single.jpg", FileType: media.FormatJpeg, Root: "/", Primary: true }, - ]; - const photoSingle = new Photo({ UID: "singlePhoto", Type: media.Image, Files: singleFile }); - assert.strictEqual( - photoSingle.originalFile().UID, - "single_jpg", - "Original file should be the only file if length < 2" - ); - - // Test for no Files array - const noFilesPhoto = new Photo({ - UID: "noFiles", - Type: media.Image, - OriginalName: "no_files_original.jpg", - Name: "no_files_name.jpg", - FileName: "no_files_filename.jpg", - }); - assert.strictEqual( - noFilesPhoto.originalFile(), - noFilesPhoto, - "Original file should be the photo instance if Files is empty" - ); - }); - - it("should return the correct original name", () => { - // Test with original name in file - const files1 = [ - { UID: "f1_orig", Name: "file1.raw", OriginalName: "original_raw_name.raw", Root: "/", MediaType: media.Raw }, - { - UID: "f1_jpg", - Name: "file1.jpg", - OriginalName: "original_jpg_name.jpg", - Root: "/", - FileType: media.FormatJpeg, - Primary: true, - }, - ]; - const photo1 = new Photo({ UID: "origName1", Type: media.Raw, Files: files1 }); - assert.strictEqual(photo1.getOriginalName(), "original_raw_name.raw", "Should use OriginalName from original file"); - - // Test with file name only - const files2 = [ - { UID: "f2_orig", Name: "file2_actual.raw", Root: "/", MediaType: media.Raw }, - { UID: "f2_jpg", Name: "file2_actual.jpg", Root: "/", FileType: media.FormatJpeg, Primary: true }, - ]; - const photo2 = new Photo({ UID: "origName2", Type: media.Raw, Files: files2 }); - assert.strictEqual( - photo2.getOriginalName(), - "file2_actual.raw", - "Should use Name from original file if OriginalName is missing" - ); - - // Test with photo original name - const photo3 = new Photo({ - UID: "origName3", - Type: media.Image, - OriginalName: "photo_original.jpg", - Name: "photo_name.jpg", - FileName: "photo_filename.jpg", - }); - assert.strictEqual(photo3.getOriginalName(), "photo_original.jpg", "Should use photo.OriginalName if no files"); - - // Test with photo file name - const photo4 = new Photo({ - UID: "origName4", - Type: media.Image, - Name: "photo_name.jpg", - FileName: "photo_filename.jpg", - }); - assert.strictEqual( - photo4.getOriginalName(), - "photo_name.jpg", - "Should use photo.FileName if photo.OriginalName is missing" - ); - - // Test with photo name only - const photo5 = new Photo({ UID: "origName5", Type: media.Image, Name: "photo_name.jpg" }); - assert.strictEqual( - photo5.getOriginalName(), - "photo_name.jpg", - "Should use photo.Name if FileName and OriginalName are missing" - ); - - // Test with no names - const photo6 = new Photo({ UID: "origName6", Type: media.Image }); - assert.strictEqual(photo6.getOriginalName(), "Unknown", "Should return Unknown if no name is available"); - - // Test with missing names in original file - const files7 = [ - { UID: "f7_orig", Root: "/", MediaType: media.Raw }, - { UID: "f7_jpg", Name: "file7.jpg", Root: "/", FileType: media.FormatJpeg, Primary: true }, - ]; - const photo7 = new Photo({ - UID: "origName7", - Type: media.Raw, - Files: files7, - OriginalName: "photo7_original.jpg", - FileName: "photo7_filename.jpg", - Name: "photo7_name.jpg", - }); - assert.strictEqual( - photo7.getOriginalName(), - "photo7_original.jpg", - "Should fallback to photo.OriginalName if original file lacks names" - ); - - // Test with path in name - const files8 = [ - { - UID: "f8_orig", - Name: "some/path/file8.raw", - OriginalName: "another/path/original_raw_name8.raw", - Root: "/", - MediaType: media.Raw, - }, - { UID: "f8_jpg", Name: "file8.jpg", Root: "/", FileType: media.FormatJpeg, Primary: true }, - ]; - const photo8 = new Photo({ UID: "origName8", Type: media.Raw, Files: files8 }); - assert.strictEqual(photo8.getOriginalName(), "original_raw_name8.raw", "Should return base name from OriginalName"); - }); -}); diff --git a/frontend/tests/unit/model/rest_test.js b/frontend/tests/unit/model/rest_test.js deleted file mode 100644 index 6c65e74d6..000000000 --- a/frontend/tests/unit/model/rest_test.js +++ /dev/null @@ -1,238 +0,0 @@ -import "../fixtures"; -import Rest from "model/rest"; -import Album from "model/album"; -import Label from "model/label"; -import Link from "model/link"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/abstract", () => { - it("should set values", () => { - const values = { ID: 5, Name: "Black Cat", Slug: "black-cat" }; - const label = new Label(values); - assert.equal(label.Name, "Black Cat"); - assert.equal(label.Slug, "black-cat"); - label.setValues(); - assert.equal(label.Name, "Black Cat"); - assert.equal(label.Slug, "black-cat"); - const values2 = { ID: 6, Name: "White Cat", Slug: "white-cat" }; - label.setValues(values2); - assert.equal(label.Name, "White Cat"); - assert.equal(label.Slug, "white-cat"); - }); - - it("should get values", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.getValues(); - assert.equal(result.Name, "Christmas 2019"); - assert.equal(result.UID, 66); - }); - - it("should get id", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.getId(); - assert.equal(result, 66); - }); - - it("should test if id exists", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.hasId(); - assert.equal(result, true); - }); - - it("should get model name", () => { - const result = Rest.getModelName(); - assert.equal(result, "Item"); - }); - - it("should update album", async () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - assert.equal(album.Description, undefined); - album.Name = "Christmas 2020"; - await album.update(); - assert.equal(album.Description, "Test description"); - }); - - it("should save album", async () => { - const values = { UID: "abc", Name: "Christmas 2019", Slug: "christmas-2019" }; - const album = new Album(values); - album.Name = "Christmas 2020"; - assert.equal(album.Description, undefined); - await album.save(); - assert.equal(album.Description, "Test description"); - - const values2 = { Name: "Christmas 2019", Slug: "christmas-2019" }; - const album2 = new Album(values2); - album.Name = "Christmas 2020"; - assert.equal(album2.Description, undefined); - await album2.save().then((response) => { - assert.equal(response.success, "ok"); - }); - assert.equal(album2.Description, undefined); - }); - - it("should remove album", async () => { - const values = { UID: "abc", Name: "Christmas 2019", Slug: "christmas-2019" }; - const album = new Album(values); - assert.equal(album.Name, "Christmas 2019"); - await album.remove(); - }); - - it("should get edit form", async () => { - const values = { UID: "abc", Name: "Christmas 2019", Slug: "christmas-2019" }; - const album = new Album(values); - const result = await album.getEditForm(); - assert.equal(result.definition.foo, "edit"); - }); - - it("should get create form", async () => { - const result = await Album.getCreateForm(); - assert.equal(result.definition.foo, "bar"); - }); - - it("should get search form", async () => { - const result = await Album.getSearchForm(); - assert.equal(result.definition.foo, "bar"); - }); - - it("should search label", async () => { - const result = await Album.search(); - assert.equal(result.data.ID, 51); - assert.equal(result.data.Name, "tabby cat"); - }); - - it("should get collection resource", () => { - assert.equal(Rest.getCollectionResource(), ""); - }); - - it("should get slug", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.getSlug(); - assert.equal(result, "christmas-2019"); - }); - - it("should get slug", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.clone(); - assert.equal(result.Slug, "christmas-2019"); - assert.equal(result.Name, "Christmas 2019"); - assert.equal(result.ID, 5); - }); - - it("should find album", async () => { - const values = { Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - return album - .find(5) - .then((response) => { - assert.equal(response.UID, "5"); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should get entity name", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.getEntityName(); - assert.equal(result, "christmas-2019"); - }); - - it("should return model name", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = album.modelName(); - assert.equal(result, "Album"); - }); - - it("should return limit", () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - const result = Rest.limit(); - assert.equal(result, 100000); - assert.equal(album.constructor.limit(), 100000); - }); - - it("should create link", async () => { - const values = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values); - album - .createLink("passwd", 8000) - .then((response) => { - assert.equal(response.Slug, "christmas-2019"); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should update link", async () => { - const values = { - UID: 5, - Password: "passwd", - Slug: "friends", - Expires: 80000, - UpdatedAt: "2012-07-08T14:45:39Z", - Token: "abchhgftryue2345", - }; - const link = new Link(values); - const values2 = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values2); - return album - .updateLink(link) - .then((response) => { - assert.equal(response.Slug, "friends"); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should remove link", async () => { - const values = { - UID: 5, - Password: "passwd", - Slug: "friends", - Expires: 80000, - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const link = new Link(values); - const values2 = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values2); - return album - .removeLink(link) - .then((response) => { - assert.equal(response.Success, "ok"); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should return links", async () => { - const values2 = { ID: 5, Name: "Christmas 2019", Slug: "christmas-2019", UID: 66 }; - const album = new Album(values2); - return album - .links() - .then((response) => { - assert.equal(response.count, 2); - assert.equal(response.models.length, 2); - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); -}); diff --git a/frontend/tests/unit/model/service_test.js b/frontend/tests/unit/model/service_test.js deleted file mode 100644 index cc9d7d75f..000000000 --- a/frontend/tests/unit/model/service_test.js +++ /dev/null @@ -1,75 +0,0 @@ -import "../fixtures"; - -import Service from "model/service"; -import Photo from "model/photo"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/service", () => { - it("should get service defaults", () => { - const values = { ID: 5 }; - const service = new Service(values); - const result = service.getDefaults(); - assert.equal(result.ID, 0); - assert.equal(result.AccShare, true); - assert.equal(result.AccName, ""); - }); - - it("should get service entity name", () => { - const values = { ID: 5, AccName: "Test Name" }; - const service = new Service(values); - const result = service.getEntityName(); - assert.equal(result, "Test Name"); - }); - - it("should get service id", () => { - const values = { ID: 5, AccName: "Test Name" }; - const service = new Service(values); - const result = service.getId(); - assert.equal(result, 5); - }); - - it("should get folders", (done) => { - const values = { ID: 123, AccName: "Test Name" }; - const service = new Service(values); - service - .Folders() - .then((response) => { - assert.equal(response.foo, "folders"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should get share photos", (done) => { - const values = { ID: 123, AccName: "Test Name" }; - const service = new Service(values); - const values1 = { ID: 5, Title: "Crazy Cat", UID: 789 }; - const photo = new Photo(values1); - const values2 = { ID: 6, Title: "Crazy Cat 2", UID: 783 }; - const photo2 = new Photo(values2); - const Photos = [photo, photo2]; - service - .Upload(Photos, "destination") - .then((response) => { - assert.equal(response.foo, "upload"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should get collection resource", () => { - const result = Service.getCollectionResource(); - assert.equal(result, "services"); - }); - - it("should get model name", () => { - const result = Service.getModelName(); - assert.equal(result, "Account"); - }); -}); diff --git a/frontend/tests/unit/model/settings_test.js b/frontend/tests/unit/model/settings_test.js deleted file mode 100644 index fc52a20b0..000000000 --- a/frontend/tests/unit/model/settings_test.js +++ /dev/null @@ -1,41 +0,0 @@ -import "../fixtures"; -import Settings from "model/settings"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/settings", () => { - it("should return if key was changed", () => { - const model = new Settings({ ui: { language: "de", scrollbar: false } }); - assert.equal(model.changed("ui", "scrollbar"), false); - assert.equal(model.changed("ui", "language"), false); - }); - - it("should load settings", (done) => { - const model = new Settings({ ui: { language: "de", scrollbar: false } }); - model - .load() - .then((response) => { - assert.equal(response["ui"]["scrollbar"], false); - assert.equal(response["ui"]["language"], "de"); - done(); - }) - .catch((error) => { - done(error); - }); - }); - - it("should save settings", (done) => { - const model = new Settings({ ui: { language: "de", scrollbar: false } }); - model - .save() - .then((response) => { - assert.equal(response["ui"]["scrollbar"], false); - assert.equal(response["ui"]["language"], "de"); - done(); - }) - .catch((error) => { - done(error); - }); - }); -}); diff --git a/frontend/tests/unit/model/subject_test.js b/frontend/tests/unit/model/subject_test.js deleted file mode 100644 index 90591dfa8..000000000 --- a/frontend/tests/unit/model/subject_test.js +++ /dev/null @@ -1,255 +0,0 @@ -import "../fixtures"; -import { Subject, BatchSize } from "model/subject"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/subject", () => { - it("should get face defaults", () => { - const values = {}; - const subject = new Subject(values); - const result = subject.getDefaults(); - assert.equal(result.UID, ""); - assert.equal(result.Favorite, false); - }); - - it("should get route view", () => { - const values = { UID: "s123ghytrfggd", Type: "person", Src: "manual" }; - const subject = new Subject(values); - const result = subject.route("test"); - assert.equal(result.name, "test"); - assert.equal(result.query.q, "subject:s123ghytrfggd"); - const values2 = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - }; - const subject2 = new Subject(values2); - const result2 = subject2.route("test"); - assert.equal(result2.name, "test"); - assert.equal(result2.query.q, "person:jane-doe"); - }); - - it("should return classes", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - Excluded: true, - Private: true, - Hidden: true, - }; - const subject = new Subject(values); - const result = subject.classes(true); - assert.include(result, "is-subject"); - assert.include(result, "uid-s123ghytrfggd"); - assert.include(result, "is-selected"); - assert.notInclude(result, "is-favorite"); - assert.include(result, "is-private"); - assert.include(result, "is-excluded"); - assert.include(result, "is-hidden"); - const values2 = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: true, - Excluded: false, - Private: false, - }; - const subject2 = new Subject(values2); - const result2 = subject2.classes(false); - assert.include(result2, "is-subject"); - assert.include(result2, "uid-s123ghytrfggd"); - assert.notInclude(result2, "is-selected"); - assert.include(result2, "is-favorite"); - assert.notInclude(result2, "is-private"); - assert.notInclude(result2, "is-excluded"); - }); - - it("should get subject entity name", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - Excluded: true, - Private: true, - }; - const subject = new Subject(values); - const result = subject.getEntityName(); - assert.equal(result, "jane-doe"); - }); - - it("should get subject title", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - Excluded: true, - Private: true, - }; - const subject = new Subject(values); - const result = subject.getTitle(); - assert.equal(result, "Jane Doe"); - }); - - it("should get thumbnail url", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - Excluded: true, - Private: true, - Thumb: "nicethumb", - }; - const subject = new Subject(values); - const result = subject.thumbnailUrl("xyz"); - assert.equal(result, "/api/v1/t/nicethumb/public/xyz"); - const result2 = subject.thumbnailUrl(); - assert.equal(result2, "/api/v1/t/nicethumb/public/tile_160"); - const values2 = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - Excluded: true, - Private: true, - }; - const subject2 = new Subject(values2); - const result3 = subject2.thumbnailUrl("xyz"); - assert.equal(result3, "/api/v1/svg/portrait"); - }); - - it("should get date string", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - Excluded: true, - Private: true, - Thumb: "nicethumb", - CreatedAt: "2012-07-08T14:45:39Z", - }; - const subject = new Subject(values); - const result = subject.getDateString(); - assert.equal(result.replaceAll("\u202f", " "), "Jul 8, 2012, 2:45 PM"); - }); - - it("should like subject", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: false, - }; - const subject = new Subject(values); - assert.equal(subject.Favorite, false); - subject.like(); - assert.equal(subject.Favorite, true); - }); - - it("should unlike subject", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: true, - }; - const subject = new Subject(values); - assert.equal(subject.Favorite, true); - subject.unlike(); - assert.equal(subject.Favorite, false); - }); - - it("should toggle like", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Favorite: true, - }; - const subject = new Subject(values); - assert.equal(subject.Favorite, true); - subject.toggleLike(); - assert.equal(subject.Favorite, false); - subject.toggleLike(); - assert.equal(subject.Favorite, true); - }); - - it("show and hide subject", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Hidden: true, - }; - const subject = new Subject(values); - assert.equal(subject.Hidden, true); - subject.show(); - assert.equal(subject.Hidden, false); - subject.hide(); - assert.equal(subject.Hidden, true); - }); - - it("should toggle hidden", () => { - const values = { - UID: "s123ghytrfggd", - Type: "person", - Src: "manual", - Name: "Jane Doe", - Slug: "jane-doe", - Hidden: true, - }; - const subject = new Subject(values); - assert.equal(subject.Hidden, true); - subject.toggleHidden(); - assert.equal(subject.Hidden, false); - subject.toggleHidden(); - assert.equal(subject.Hidden, true); - }); - - it("should return batch size", () => { - assert.equal(Subject.batchSize(), BatchSize); - Subject.setBatchSize(30); - assert.equal(Subject.batchSize(), 30); - Subject.setBatchSize(BatchSize); - }); - - it("should get collection resource", () => { - const result = Subject.getCollectionResource(); - assert.equal(result, "subjects"); - }); - - it("should get model name", () => { - const result = Subject.getModelName(); - assert.equal(result, "Person"); - }); -}); diff --git a/frontend/tests/unit/model/thumb_test.js b/frontend/tests/unit/model/thumb_test.js deleted file mode 100644 index 3a1cd8dfa..000000000 --- a/frontend/tests/unit/model/thumb_test.js +++ /dev/null @@ -1,326 +0,0 @@ -import "../fixtures"; -import Thumb from "model/thumb"; -import Photo from "model/photo"; -import File from "model/file"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/thumb", () => { - it("should get thumb defaults", () => { - const values = { - UID: "55", - Title: "", - TakenAtLocal: "", - Caption: "", - Favorite: false, - Playable: false, - Width: 0, - Height: 0, - DownloadUrl: "", - }; - const thumb = new Thumb(values); - const result = thumb.getDefaults(); - assert.equal(result.UID, ""); - }); - - it("should get id", () => { - const values = { - UID: "55", - }; - const thumb = new Thumb(values); - assert.equal(thumb.getId(), "55"); - }); - - it("should return hasId", () => { - const values = { - UID: "55", - }; - const thumb = new Thumb(values); - assert.equal(thumb.hasId(), true); - - const values2 = { - Title: "", - }; - const thumb2 = new Thumb(values2); - assert.equal(thumb2.hasId(), false); - }); - - it("should toggle like", () => { - const values = { - UID: "55", - Title: "", - TakenAtLocal: "", - Caption: "", - Favorite: true, - Playable: false, - Width: 0, - Height: 0, - DownloadUrl: "", - }; - const thumb = new Thumb(values); - assert.equal(thumb.Favorite, true); - thumb.toggleLike(); - assert.equal(thumb.Favorite, false); - thumb.toggleLike(); - assert.equal(thumb.Favorite, true); - }); - - it("should return thumb not found", () => { - const result = Thumb.notFound(); - assert.equal(result.UID, ""); - assert.equal(result.Favorite, false); - }); - - it("should test from file", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Name: "1/2/IMG123.jpg", - Hash: "abc123", - Width: 500, - Height: 900, - }; - const file = new File(values); - - const values2 = { - UID: "5", - Title: "Crazy Cat", - TakenAt: "2012-07-08T14:45:39Z", - TakenAtLocal: "2012-07-08T14:45:39Z", - Caption: "Nice description", - Favorite: true, - }; - const photo = new Photo(values2); - const result = Thumb.fromFile(photo, file); - assert.equal(result.UID, "5"); - assert.equal(result.Caption, "Nice description"); - assert.equal(result.Width, 500); - const result2 = Thumb.fromFile(); - assert.equal(result2.UID, ""); - }); - - it("should test from files", () => { - const values2 = { - UID: "5", - Title: "Crazy Cat", - TakenAt: "2012-07-08T14:45:39Z", - TakenAtLocal: "2012-07-08T14:45:39Z", - Caption: "Nice description", - Favorite: true, - }; - const photo = new Photo(values2); - - const values3 = { - UID: "5", - Title: "Crazy Cat", - TakenAt: "2012-07-08T14:45:39Z", - TakenAtLocal: "2012-07-08T14:45:39Z", - Caption: "Nice description", - Favorite: true, - }; - const photo2 = new Photo(values3); - const Photos = [photo, photo2]; - const result = Thumb.fromFiles(Photos); - assert.equal(result.length, 0); - const values4 = { - ID: 8, - UID: "ABC123", - Caption: "Nice description 2", - Hash: "abc345", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - }, - ], - }; - const photo3 = new Photo(values4); - const Photos2 = [photo, photo2, photo3]; - const result2 = Thumb.fromFiles(Photos2); - assert.equal(result2[0].UID, "ABC123"); - assert.equal(result2[0].Caption, "Nice description 2"); - assert.equal(result2[0].Width, 500); - assert.equal(result2.length, 1); - const values5 = { - ID: 8, - UID: "ABC123", - Caption: "Nice description 2", - Hash: "abc345", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "mov", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - }, - ], - }; - const photo4 = new Photo(values5); - const Photos3 = [photo3, photo2, photo4]; - const result3 = Thumb.fromFiles(Photos3); - assert.equal(result3.length, 1); - assert.equal(result3[0].UID, "ABC123"); - assert.equal(result3[0].Caption, "Nice description 2"); - assert.equal(result3[0].Width, 500); - }); - - it("should test from files", () => { - const Photos = []; - const result = Thumb.fromFiles(Photos); - assert.equal(result, ""); - }); - - it("should test from photo", () => { - const values = { - ID: 8, - UID: "ABC123", - Caption: "Nice description 3", - Hash: "345ggh", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - }, - ], - }; - const photo = new Photo(values); - const result = Thumb.fromPhoto(photo); - assert.equal(result.UID, "ABC123"); - assert.equal(result.Caption, "Nice description 3"); - assert.equal(result.Width, 500); - const values3 = { - ID: 8, - UID: "ABC124", - Caption: "Nice description 3", - }; - const photo3 = new Photo(values3); - const result2 = Thumb.fromPhoto(photo3); - assert.equal(result2.UID, ""); - const values2 = { - ID: 8, - UID: "ABC123", - Title: "Crazy Cat", - TakenAt: "2012-07-08T14:45:39Z", - TakenAtLocal: "2012-07-08T14:45:39Z", - Caption: "Nice description", - Favorite: true, - Hash: "xdf45m", - }; - const photo2 = new Photo(values2); - const result3 = Thumb.fromPhoto(photo2); - assert.equal(result3.UID, "ABC123"); - assert.equal(result3.Title, "Crazy Cat"); - assert.equal(result3.Caption, "Nice description"); - }); - - it("should test from photos", () => { - const values = { - ID: 8, - UID: "ABC123", - Caption: "Nice description 3", - Hash: "345ggh", - Files: [ - { - UID: "123fgb", - Name: "1980/01/superCuteKitten.jpg", - Primary: true, - FileType: "jpg", - Width: 500, - Height: 600, - Hash: "1xxbgdt53", - }, - ], - }; - const photo = new Photo(values); - const Photos = [photo]; - const result = Thumb.fromPhotos(Photos); - assert.equal(result[0].UID, "ABC123"); - assert.equal(result[0].Caption, "Nice description 3"); - assert.equal(result[0].Width, 500); - }); - - it("should return download url", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(Thumb.downloadUrl(file), "/api/v1/dl/54ghtfd?t=2lbh9x09"); - const values2 = { - InstanceID: 5, - UID: "ABC123", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - }; - const file2 = new File(values2); - assert.equal(Thumb.downloadUrl(file2), ""); - }); - - it("should return thumbnail url", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - assert.equal(Thumb.thumbnailUrl(file, "abc"), "/api/v1/t/54ghtfd/public/abc"); - const values2 = { - InstanceID: 5, - UID: "ABC123", - Name: "1/2/IMG123.jpg", - }; - const file2 = new File(values2); - assert.equal(Thumb.thumbnailUrl(file2, "bcd"), "/static/img/404.jpg"); - }); - - it("should calculate size", () => { - const values = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Width: 900, - Height: 850, - Name: "1/2/IMG123.jpg", - }; - const file = new File(values); - const result = Thumb.calculateSize(file, 600, 800); //max 0,75 - assert.equal(result.width, 600); - assert.equal(result.height, 567); - const values3 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - Width: 750, - Height: 850, - Name: "1/2/IMG123.jpg", - }; - const file3 = new File(values3); - const result2 = Thumb.calculateSize(file3, 900, 450); - assert.equal(result2.width, 398); - assert.equal(result2.height, 450); - const result4 = Thumb.calculateSize(file3, 900, 950); - assert.equal(result4.width, 750); - assert.equal(result4.height, 850); - }); -}); diff --git a/frontend/tests/unit/model/user_test.js b/frontend/tests/unit/model/user_test.js deleted file mode 100644 index 4081688bb..000000000 --- a/frontend/tests/unit/model/user_test.js +++ /dev/null @@ -1,325 +0,0 @@ -import "../fixtures"; -import User from "model/user"; -import File from "model/file"; -import Config from "common/config"; -import StorageShim from "node-storage-shim"; - -const defaultConfig = new Config(new StorageShim(), window.__CONFIG__); - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("model/user", () => { - it("should get handle", () => { - const values = { - ID: 5, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = user.getHandle(); - assert.equal(result, "max"); - - const values2 = { - ID: 6, - Name: "", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - }; - - const user2 = new User(values2); - const result2 = user2.getHandle(); - assert.equal(result2, ""); - }); - - it("should get default base path", () => { - const values = { - ID: 5, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = user.defaultBasePath(); - assert.equal(result, "users/max"); - - const values2 = { - ID: 6, - Name: "", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - }; - - const user2 = new User(values2); - const result2 = user2.defaultBasePath(); - assert.equal(result2, ""); - }); - - it("should get display name", () => { - const values = { - ID: 5, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = user.getDisplayName(); - assert.equal(result, "Max Last"); - - const values2 = { - ID: 6, - Name: "", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - }; - - const user2 = new User(values2); - const result2 = user2.getDisplayName(); - assert.equal(result2, "Unknown"); - - const values3 = { - ID: 7, - Name: "", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - Details: { - NickName: "maxi", - GivenName: "Maximilian", - }, - }; - - const user3 = new User(values3); - const result3 = user3.getDisplayName(); - assert.equal(result3, "maxi"); - - const values4 = { - ID: 8, - Name: "", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - Details: { - NickName: "", - GivenName: "Maximilian", - }, - }; - - const user4 = new User(values4); - const result4 = user4.getDisplayName(); - assert.equal(result4, "Maximilian"); - }); - - it("should get account info", () => { - const values = { - ID: 5, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = user.getAccountInfo(); - assert.equal(result, "max"); - - const values2 = { - ID: 6, - Name: "", - DisplayName: "", - Email: "test@test.com", - Role: "admin", - }; - - const user2 = new User(values2); - const result2 = user2.getAccountInfo(); - assert.equal(result2, "test@test.com"); - - const values3 = { - ID: 7, - Name: "", - DisplayName: "", - Email: "", - Role: "admin", - }; - - const user3 = new User(values3); - const result3 = user3.getAccountInfo(); - assert.equal(result3, "Admin"); - - const values4 = { - ID: 8, - Name: "", - DisplayName: "", - Email: "", - Role: "", - }; - - const user4 = new User(values4); - const result4 = user4.getAccountInfo(); - assert.equal(result4, "Account"); - - const values5 = { - ID: 9, - Name: "", - DisplayName: "", - Email: "", - Role: "admin", - Details: { - JobTitle: "Developer", - }, - }; - - const user5 = new User(values5); - const result5 = user5.getAccountInfo(); - assert.equal(result5, "Developer"); - }); - - it("should get entity name", () => { - const values = { - ID: 5, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = user.getEntityName(); - assert.equal(result, "Max Last"); - }); - - it("should get id", () => { - const values = { - ID: 5, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = user.getId(); - assert.equal(result, 5); - }); - - it("should get model name", () => { - const result = User.getModelName(); - assert.equal(result, "User"); - }); - - it("should get collection resource", () => { - const result = User.getCollectionResource(); - assert.equal(result, "users"); - }); - - it("should get register form", async () => { - const values = { ID: 52, Name: "max", DisplayName: "Max Last" }; - const user = new User(values); - const result = await user.getRegisterForm(); - assert.equal(result.definition.foo, "register"); - }); - - it("should get avatar url", async () => { - const values = { ID: 52, Name: "max", DisplayName: "Max Last" }; - const user = new User(values); - const result = await user.getAvatarURL(); - assert.equal(result, "/static/img/avatar/tile_500.jpg"); - - const values2 = { - ID: 53, - Name: "max", - DisplayName: "Max Last", - Thumb: "91e6c374afb78b28a52d7b4fd4fd2ea861b87123", - }; - const user2 = new User(values2); - const result2 = await user2.getAvatarURL("tile_500", defaultConfig); - assert.equal(result2, "/api/v1/t/91e6c374afb78b28a52d7b4fd4fd2ea861b87123/public/tile_500"); - }); - - it("should upload avatar", async () => { - const values = { ID: 52, Name: "max", DisplayName: "Max Last" }; - const user = new User(values); - - const values2 = { - InstanceID: 5, - UID: "ABC123", - Hash: "54ghtfd", - FileType: "jpg", - MediaType: "image", - Name: "1/2/IMG123.jpg", - CreatedAt: "2012-07-08T14:45:39Z", - UpdatedAt: "2012-07-08T14:45:39Z", - }; - const file = new File(values2); - - const Files = [file]; - - return user - .uploadAvatar(Files) - .then((response) => { - assert.equal("abc", response.Thumb); - assert.equal("manual", response.ThumbSrc); - - return Promise.resolve(); - }) - .catch((error) => { - return Promise.reject(error); - }); - }); - - it("should get profile form", async () => { - const values = { ID: 53, Name: "max", DisplayName: "Max Last" }; - const user = new User(values); - const result = await user.getProfileForm(); - assert.equal(result.definition.foo, "profile"); - }); - - it("should return whether user is remote", async () => { - const values = { ID: 52, Name: "max", DisplayName: "Max Last", AuthProvider: "local" }; - const user = new User(values); - const result = await user.isRemote(); - assert.equal(result, false); - - const values2 = { ID: 51, Name: "max", DisplayName: "Max Last", AuthProvider: "ldap" }; - const user2 = new User(values2); - const result2 = await user2.isRemote(); - assert.equal(result2, true); - }); - - it("should return auth info", async () => { - const values = { ID: 50, Name: "max", DisplayName: "Max Last", AuthProvider: "oidc" }; - const user = new User(values); - const result = await user.authInfo(); - assert.equal(result, "OIDC"); - - const values2 = { ID: 52, Name: "max", DisplayName: "Max Last", AuthProvider: "oidc", AuthMethod: "session" }; - const user2 = new User(values2); - const result2 = await user2.authInfo(); - assert.equal(result2, "OIDC (Session)"); - }); - - it("should get change password", async () => { - const values = { - ID: 54, - Name: "max", - DisplayName: "Max Last", - Email: "test@test.com", - Role: "admin", - }; - - const user = new User(values); - const result = await user.changePassword("old", "new"); - assert.equal(result.new_password, "new"); - }); -}); diff --git a/frontend/tests/unit/options/options_test.js b/frontend/tests/unit/options/options_test.js deleted file mode 100644 index 3c51f6a24..000000000 --- a/frontend/tests/unit/options/options_test.js +++ /dev/null @@ -1,252 +0,0 @@ -import "../fixtures"; -import * as options from "../../../src/options/options"; -import { - AccountTypes, - Colors, - DefaultLocale, - Expires, - FallbackLocale, - FeedbackCategories, - FindLanguage, - FindLocale, - Gender, - Intervals, - ItemsPerPage, - MapsAnimate, - MapsStyle, - Orientations, - PhotoTypes, - RetryLimits, - SetDefaultLocale, - StartPages, - ThumbFilters, - Thumbs, - ThumbSizes, - Timeouts, -} from "../../../src/options/options"; - -let chai = require("chai/chai"); -let assert = chai.assert; - -describe("options/options", () => { - it("should get timezones", () => { - const timezones = options.TimeZones(); - assert.equal(timezones[0].ID, "Local"); - assert.equal(timezones[0].Name, "Local"); - assert.equal(timezones[1].ID, "UTC"); - assert.equal(timezones[1].Name, "UTC"); - }); - - it("should get days", () => { - const Days = options.Days(); - assert.equal(Days[0].text, "01"); - assert.equal(Days[30].text, "31"); - }); - - it("should get years", () => { - const Years = options.Years(); - const currentYear = new Date().getUTCFullYear(); - assert.equal(Years[0].text, currentYear); - }); - - it("should get indexed years", () => { - const IndexedYears = options.IndexedYears(); - assert.equal(IndexedYears[0].text, "2021"); - }); - - it("should get months", () => { - const Months = options.Months(); - assert.equal(Months[5].text, "June"); - }); - - it("should get short months", () => { - const MonthsShort = options.MonthsShort(); - assert.equal(MonthsShort[5].text, "06"); - }); - - it("should get languages", () => { - const Languages = options.Languages(); - assert.equal(Languages[0].value, "en"); - }); - - it("should set default locale", () => { - assert.equal(DefaultLocale, "en"); - SetDefaultLocale("de"); - assert.equal(DefaultLocale, "de"); - SetDefaultLocale("en"); - }); - - it("should return default when no locale is provided", () => { - assert.equal(FindLanguage("").value, "en"); - }); - - it("should return default locale is smaller than 2", () => { - assert.equal(FindLanguage("d").value, "en"); - }); - - it("should return default locale", () => { - assert.equal(FindLanguage("xx").value, "en"); - }); - - it("should return correct locale", () => { - assert.equal(FindLanguage("de").value, "de"); - assert.equal(FindLanguage("de").text, "Deutsch"); - assert.equal(FindLanguage("de_AT").value, "de"); - assert.equal(FindLanguage("de_AT").text, "Deutsch"); - assert.equal(FindLanguage("zh-tw").value, "zh_TW"); - assert.equal(FindLanguage("zh-tw").text, "繁體中文"); - assert.equal(FindLanguage("zh+tw").value, "zh_TW"); - assert.equal(FindLanguage("zh+tw").text, "繁體中文"); - assert.equal(FindLanguage("zh_AT").value, "zh"); - assert.equal(FindLanguage("zh_AT").text, "简体中文"); - assert.equal(FindLanguage("ZH_TW").value, "zh_TW"); - assert.equal(FindLanguage("ZH_TW").text, "繁體中文"); - assert.equal(FindLanguage("zH-tW").value, "zh_TW"); - assert.equal(FindLanguage("zH-tW").text, "繁體中文"); - }); - - it("should return default locale", () => { - assert.equal(FindLocale("xx"), "en"); - assert.equal(FindLocale(""), "en"); - }); - - it("should return fallback locale", () => { - assert.equal(FallbackLocale(), "en"); - }); - - it("should return items per page", () => { - assert.equal(ItemsPerPage()[0].value, 10); - }); - - it("should return start page options", () => { - let features = { - account: true, - albums: true, - archive: true, - delete: true, - download: true, - edit: true, - estimates: true, - favorites: true, - files: true, - folders: true, - import: true, - labels: true, - library: true, - logs: true, - calendar: true, - moments: true, - people: true, - places: true, - private: true, - ratings: true, - reactions: true, - review: true, - search: true, - services: true, - settings: true, - share: true, - upload: true, - videos: true, - }; - assert.equal(StartPages(features).length, 12); - assert.equal(StartPages(features)[5].value, "people"); - assert.equal(StartPages(features)[5].props.disabled, false); - features = { - account: true, - albums: true, - archive: true, - delete: true, - download: true, - edit: true, - estimates: true, - favorites: true, - files: true, - folders: true, - import: true, - labels: true, - library: true, - logs: true, - calendar: false, - moments: true, - people: false, - places: true, - private: true, - ratings: true, - reactions: true, - review: true, - search: true, - services: true, - settings: true, - share: true, - upload: true, - videos: true, - }; - assert.equal(StartPages(features).length, 12); - assert.equal(StartPages(features)[5].value, "people"); - assert.equal(StartPages(features)[5].props.disabled, true); - }); - - it("should return animation options", () => { - assert.equal(MapsAnimate()[1].value, 2500); - }); - - it("should return photo types", () => { - assert.equal(PhotoTypes()[0].value, "image"); - assert.equal(PhotoTypes()[1].value, "raw"); - }); - - it("should return map styles", () => { - let styles = MapsStyle(true); - assert.include(styles[styles.length - 1].value, "low-resolution"); - styles = MapsStyle(false); - assert.notInclude(styles[styles.length - 1].value, "low-resolution"); - }); - - it("should return timeouts", () => { - assert.equal(Timeouts()[1].value, "high"); - }); - - it("should return retry limits", () => { - assert.equal(RetryLimits()[1].value, 1); - }); - - it("should return intervals", () => { - assert.equal(Intervals()[0].text, "Never"); - assert.equal(Intervals()[1].text, "1 hour"); - }); - - it("should return expiry options", () => { - assert.equal(Expires()[0].text, "Never"); - assert.equal(Expires()[1].text, "After 1 day"); - }); - - it("should return colors", () => { - assert.equal(Colors()[0].Slug, "purple"); - }); - - it("should return feedback categories", () => { - assert.equal(FeedbackCategories()[0].value, "feedback"); - }); - - it("should return thumb sizes", () => { - assert.equal(ThumbSizes()[1].value, "fit_720"); - }); - - it("should return thumb filters", () => { - assert.equal(ThumbFilters()[0].value, "blackman"); - }); - - it("should return gender", () => { - assert.equal(Gender()[2].value, "other"); - }); - - it("should return orientations", () => { - assert.equal(Orientations()[1].text, "90°"); - }); - - it("should return service account type options", () => { - assert.equal(AccountTypes()[0].value, "webdav"); - assert.equal(AccountTypes().length, 1); - }); -}); diff --git a/frontend/tests/vitest/common/util.test.js b/frontend/tests/vitest/common/util.test.js index e9d41892e..c30f21c34 100644 --- a/frontend/tests/vitest/common/util.test.js +++ b/frontend/tests/vitest/common/util.test.js @@ -80,7 +80,7 @@ describe("common/util", () => { 23, "Apple", "iPhone 15 Pro", - false + false, ); expect(iPhone15Pro).toBe("iPhone 15 Pro"); @@ -89,11 +89,17 @@ describe("common/util", () => { 23, "Apple", "iPhone 15 Pro", - true + true, ); expect(iPhone15ProLong).toBe("Apple iPhone 15 Pro"); - const iPhone14 = $util.formatCamera({ Make: "Apple", Model: "iPhone 14" }, 22, "Apple", "iPhone 14", false); + const iPhone14 = $util.formatCamera( + { Make: "Apple", Model: "iPhone 14" }, + 22, + "Apple", + "iPhone 14", + false, + ); expect(iPhone14).toBe("iPhone 14"); const iPhone13 = $util.formatCamera(null, 21, "Apple", "iPhone 13", false); @@ -142,7 +148,7 @@ describe("common/util", () => { expect($util.thumb(thumbs, 1300, 900).w).toBe(1800); expect($util.thumb(thumbs, 1300, 900).h).toBe(1200); expect($util.thumb(thumbs, 1300, 900).src).toBe( - "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_1920" + "/api/v1/t/bfdcf45e58b1978af66bbf6212c195851dc65814/174usyd0/fit_1920", ); expect($util.thumb(thumbs, 1400, 1200).size).toBe("fit_1920"); expect($util.thumb(thumbs, 100000, 120000).size).toBe("fit_7680"); @@ -191,17 +197,19 @@ describe("common/util", () => { expect(result).toBe("teststring"); }); it("should truncate xxx", () => { - const result = $util.truncate("teststring for mocha", 5, "ng"); + const result = $util.truncate("teststring for vitest", 5, "ng"); expect(result).toBe("tesng"); }); - it.skip("should encode html", () => { + it("should encode html", () => { const result = $util.encodeHTML("Micha & Theresa > < 'Lilly'"); - expect(result).toBe("Micha & Theresa > < 'Lilly'"); + expect(result).toBe("Micha & Theresa > < 'Lilly'"); }); it.skip("should encode link", () => { - const result = $util.encodeHTML("Try this: https://photoswipe.com/options/?foo=bar&bar=baz. It's a link!"); + const result = $util.encodeHTML( + "Try this: https://photoswipe.com/options/?foo=bar&bar=baz. It's a link!", + ); expect(result).toBe( - `Try this: https://photoswipe.com/options/ It's a link!` + `Try this: https://photoswipe.com/options/ It's a link!`, ); }); it("should generate tokens reliably", () => { diff --git a/frontend/tests/vitest/component/loading-bar.test.js b/frontend/tests/vitest/component/loading-bar.test.js index f013a2cbd..a4fdad8ee 100644 --- a/frontend/tests/vitest/component/loading-bar.test.js +++ b/frontend/tests/vitest/component/loading-bar.test.js @@ -1,5 +1,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; import { mount } from "@vue/test-utils"; +import { nextTick } from "vue"; import PLoadingBar from "component/loading-bar.vue"; // Mock $event subscription @@ -23,7 +24,6 @@ describe("PLoadingBar component", () => { beforeEach(() => { vi.clearAllMocks(); - vi.useFakeTimers(); wrapper = mount(PLoadingBar, { @@ -42,64 +42,120 @@ describe("PLoadingBar component", () => { afterEach(() => { vi.useRealTimers(); + if (wrapper) { + wrapper.unmount(); + } }); - it("should render correctly", () => { - expect(wrapper.vm).toBeTruthy(); - expect(wrapper.find("#p-loading-bar").exists()).toBe(true); - expect(wrapper.find(".top-progress").exists()).toBe(false); // Initially not visible + describe("Component Initialization", () => { + it("should render container element", () => { + const container = wrapper.find("#p-loading-bar"); + expect(container.exists()).toBe(true); + }); - // Check computed properties - expect(wrapper.vm.progressColor).toBe("#29d"); // Default color - expect(wrapper.vm.isStarted).toBe(false); + it("should not show progress bar initially", () => { + const progressBar = wrapper.find(".top-progress"); + expect(progressBar.exists()).toBe(false); + }); + + it("should subscribe to AJAX events on mount", () => { + expect(mockSubscribe).toHaveBeenCalledTimes(2); + expect(mockSubscribe.mock.calls[0][0]).toBe("ajax.start"); + expect(mockSubscribe.mock.calls[1][0]).toBe("ajax.end"); + }); }); - it("should subscribe to ajax events on mount", () => { - expect(mockSubscribe).toHaveBeenCalledTimes(2); - expect(mockSubscribe.mock.calls[0][0]).toBe("ajax.start"); - expect(mockSubscribe.mock.calls[1][0]).toBe("ajax.end"); + describe("Progress Bar Visibility", () => { + it("should show progress bar when started", async () => { + // Start the loading bar + wrapper.vm.start(); + await nextTick(); + + const progressBar = wrapper.find(".top-progress"); + expect(progressBar.exists()).toBe(true); + }); + + it("should hide progress bar when completed", async () => { + // Start and complete the loading bar + wrapper.vm.start(); + await nextTick(); + + wrapper.vm.done(); + await nextTick(); + + // Fast forward through completion animation + vi.advanceTimersByTime(1000); + await nextTick(); + + const progressBar = wrapper.find(".top-progress"); + expect(progressBar.exists()).toBe(false); + }); }); - it("should start the loading bar", async () => { - wrapper.vm.start(); + describe("Progress Bar Appearance", () => { + beforeEach(async () => { + wrapper.vm.start(); + await nextTick(); + }); - await wrapper.vm.$nextTick(); - expect(wrapper.vm.visible).toBe(true); + it("should display with default color", async () => { + const progressBar = wrapper.find(".top-progress"); + const barStyle = progressBar.attributes("style"); - // After transition, the bar should be displayed - wrapper.vm.afterEnter(); - expect(wrapper.vm.status).not.toBeNull(); + expect(barStyle).toContain("background-color: rgb(34, 153, 221)"); // #29d + }); + + it("should display with error color when failed", async () => { + wrapper.vm.fail(); + await nextTick(); + + const progressBar = wrapper.find(".top-progress"); + const barStyle = progressBar.attributes("style"); + + expect(barStyle).toContain("background-color: rgb(244, 67, 54)"); // #f44336 + }); + + it("should have peg element for styling", () => { + const peg = wrapper.find(".peg"); + expect(peg.exists()).toBe(true); + }); }); - it("should make progress visible when started", async () => { - expect(wrapper.vm.visible).toBe(false); + describe("Progress Bar Behavior", () => { + it("should show progress bar when started", async () => { + wrapper.vm.start(); + await nextTick(); - // Start the bar - wrapper.vm.start(); - await wrapper.vm.$nextTick(); + const progressBar = wrapper.find(".top-progress"); + expect(progressBar.exists()).toBe(true); + expect(progressBar.attributes("style")).toContain("width:"); + }); - // Should be visible now - expect(wrapper.vm.visible).toBe(true); - }); + it("should pause progress when paused", async () => { + wrapper.vm.start(); + wrapper.vm.pause(); + await nextTick(); - it("should handle error state", async () => { - wrapper.vm.fail(); - await wrapper.vm.$nextTick(); + // When paused, progress bar should still exist but not advance + const progressBar = wrapper.find(".top-progress"); + expect(progressBar.exists()).toBe(true); + }); - expect(wrapper.vm.error).toBe(true); - expect(wrapper.vm.progressColor).toBe("#f44336"); // Error color - }); + it("should complete progress when done is called", async () => { + wrapper.vm.start(); + await nextTick(); - it("should pause the loading bar", () => { - wrapper.vm.start(); - wrapper.vm.pause(); + const progressBar = wrapper.find(".top-progress"); + expect(progressBar.exists()).toBe(true); - expect(wrapper.vm.isPaused).toBe(true); - }); + wrapper.vm.done(); - it("should initialize progress to zero", () => { - expect(wrapper.vm.progress).toBe(0); + // Allow time for completion animation + vi.advanceTimersByTime(1000); + await nextTick(); - expect(wrapper.vm.getProgress()).toBe(0); + // Progress bar should disappear after completion + expect(wrapper.find(".top-progress").exists()).toBe(false); + }); }); }); diff --git a/frontend/tests/vitest/component/location/input.test.js b/frontend/tests/vitest/component/location/input.test.js new file mode 100644 index 000000000..87d137de6 --- /dev/null +++ b/frontend/tests/vitest/component/location/input.test.js @@ -0,0 +1,246 @@ +import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; +import { mount } from "@vue/test-utils"; +import { nextTick } from "vue"; +import PLocationInput from "component/location/input.vue"; + +describe("PLocationInput", () => { + let wrapper; + + const defaultProps = { + latlng: [null, null], + disabled: false, + hideDetails: true, + label: "Location", + placeholder: "37.75267, -122.543", + density: "comfortable", + validateOn: "input", + showMapButton: false, + icon: "mdi-map-marker", + mapButtonTitle: "Open Map", + mapButtonDisabled: false, + enableUndo: false, + autoApply: true, + debounceDelay: 1000, + }; + + beforeEach(() => { + vi.useFakeTimers(); + }); + + afterEach(() => { + if (wrapper) { + wrapper.unmount(); + } + vi.useRealTimers(); + vi.clearAllTimers(); + }); + + const createWrapper = (props = {}) => { + return mount(PLocationInput, { + props: { ...defaultProps, ...props }, + }); + }; + + describe("Component Rendering", () => { + it("should render input field with correct placeholder", () => { + const placeholder = "Custom placeholder"; + wrapper = createWrapper({ placeholder }); + + const input = wrapper.find("input"); + expect(input.exists()).toBe(true); + expect(input.attributes("placeholder")).toBe(placeholder); + }); + + it("should disable input when disabled prop is true", () => { + wrapper = createWrapper({ disabled: true }); + + const input = wrapper.find("input"); + expect(input.attributes("disabled")).toBeDefined(); + }); + + it("should show map button when showMapButton is true", () => { + wrapper = createWrapper({ showMapButton: true }); + + const mapButton = wrapper.find(".action-map"); + expect(mapButton.exists()).toBe(true); + }); + + it("should display existing coordinates in input field", async () => { + wrapper = createWrapper({ latlng: [37.7749, -122.4194] }); + + await nextTick(); + const input = wrapper.find("input"); + expect(input.element.value).toBe("37.7749, -122.4194"); + }); + }); + + describe("User Input and Validation", () => { + beforeEach(() => { + wrapper = createWrapper(); + }); + + it("should emit coordinates when valid input is entered and Enter is pressed", async () => { + const input = wrapper.find("input"); + + await input.setValue("37.7749, -122.4194"); + await input.trigger("keydown.enter"); + + expect(wrapper.emitted("update:latlng")).toEqual([[[37.7749, -122.4194]]]); + expect(wrapper.emitted("changed")).toEqual([[{ lat: 37.7749, lng: -122.4194 }]]); + }); + + it("should not emit coordinates for invalid input", async () => { + const input = wrapper.find("input"); + + await input.setValue("invalid coordinates"); + await input.trigger("keydown.enter"); + + expect(wrapper.emitted("update:latlng")).toBeFalsy(); + expect(wrapper.emitted("changed")).toBeFalsy(); + }); + + it("should handle various valid coordinate formats", async () => { + const input = wrapper.find("input"); + + // Test with spaces around comma + await input.setValue("90, 180"); + await input.trigger("keydown.enter"); + + expect(wrapper.emitted("update:latlng")[0]).toEqual([[90, 180]]); + }); + }); + + describe("Button Interactions", () => { + it("should emit open-map event when map button is clicked", async () => { + wrapper = createWrapper({ showMapButton: true }); + + const mapButton = wrapper.find(".action-map"); + await mapButton.trigger("click"); + + expect(wrapper.emitted("open-map")).toBeTruthy(); + }); + + it("should clear coordinates when clear button is clicked", async () => { + wrapper = createWrapper({ latlng: [37.7749, -122.4194] }); + + // Wait for component to initialize and coordinateInput to be set + await nextTick(); + + const clearButton = wrapper.find(".action-clear"); + expect(clearButton.exists()).toBe(true); + + await clearButton.trigger("click"); + + expect(wrapper.emitted("update:latlng")).toEqual([[[0, 0]]]); + expect(wrapper.emitted("changed")).toEqual([[{ lat: 0, lng: 0 }]]); + expect(wrapper.emitted("cleared")).toBeTruthy(); + }); + + it("should show and work with undo button when enabled", async () => { + wrapper = createWrapper({ enableUndo: true, latlng: [37.7749, -122.4194] }); + + // Wait for component to initialize and coordinateInput to be set + await nextTick(); + + // Clear coordinates first + const clearButton = wrapper.find(".action-clear"); + expect(clearButton.exists()).toBe(true); + await clearButton.trigger("click"); + await nextTick(); + + // Undo button should appear + const undoButton = wrapper.find(".action-undo"); + expect(undoButton.exists()).toBe(true); + + // Click undo to restore coordinates + await undoButton.trigger("click"); + + const latlngEmits = wrapper.emitted("update:latlng"); + + // Last emit should restore original coordinates + expect(latlngEmits[latlngEmits.length - 1]).toEqual([[37.7749, -122.4194]]); + }); + }); + + describe("Auto Apply Feature", () => { + it("should auto apply valid coordinates after debounce delay", async () => { + wrapper = createWrapper({ autoApply: true, debounceDelay: 500 }); + + const input = wrapper.find("input"); + await input.setValue("37.7749, -122.4194"); + + // Should not emit immediately + expect(wrapper.emitted("update:latlng")).toBeFalsy(); + + // Fast forward timer + vi.advanceTimersByTime(500); + await nextTick(); + + expect(wrapper.emitted("update:latlng")).toEqual([[[37.7749, -122.4194]]]); + }); + + it("should not auto apply when autoApply is disabled", async () => { + wrapper = createWrapper({ autoApply: false }); + + const input = wrapper.find("input"); + await input.setValue("37.7749, -122.4194"); + + vi.advanceTimersByTime(1000); + await nextTick(); + + expect(wrapper.emitted("update:latlng")).toBeFalsy(); + }); + }); + + describe("Paste Functionality", () => { + beforeEach(() => { + wrapper = createWrapper(); + }); + + it("should handle paste with valid coordinates", async () => { + const input = wrapper.find("input"); + + const pasteEvent = new Event("paste"); + pasteEvent.clipboardData = { + getData: vi.fn().mockReturnValue("40.7128, -74.0060"), + }; + + await input.trigger("paste", { clipboardData: pasteEvent.clipboardData }); + + expect(wrapper.emitted("update:latlng")).toEqual([[[40.7128, -74.006]]]); + expect(wrapper.emitted("changed")).toEqual([[{ lat: 40.7128, lng: -74.006 }]]); + }); + + it("should handle paste with space-separated coordinates", async () => { + const input = wrapper.find("input"); + + const pasteEvent = new Event("paste"); + pasteEvent.clipboardData = { + getData: vi.fn().mockReturnValue("40.7128 -74.0060"), + }; + + await input.trigger("paste", { clipboardData: pasteEvent.clipboardData }); + + expect(wrapper.emitted("update:latlng")).toEqual([[[40.7128, -74.006]]]); + }); + }); + + describe("Props Updates", () => { + it("should update input field when lat/lng props change", async () => { + wrapper = createWrapper(); + + await wrapper.setProps({ latlng: [40.7128, -74.006] }); + + const input = wrapper.find("input"); + expect(input.element.value).toBe("40.7128, -74.006"); + }); + + it("should clear input field when coordinates are invalid", async () => { + wrapper = createWrapper({ latlng: [0, 0] }); + + await nextTick(); + const input = wrapper.find("input"); + expect(input.element.value).toBe(""); + }); + }); +}); diff --git a/frontend/tests/vitest/component/sidebar/info.test.js b/frontend/tests/vitest/component/sidebar/info.test.js index 4c0f9a9b8..9af1c175a 100644 --- a/frontend/tests/vitest/component/sidebar/info.test.js +++ b/frontend/tests/vitest/component/sidebar/info.test.js @@ -80,7 +80,7 @@ describe("PSidebarInfo component", () => { expect(mockModel.getLatLng).toHaveBeenCalled(); }); - it.skip("should emit close event when close button is clicked", async () => { + it("should emit close event when close button is clicked", async () => { // Try finding close button by various selectors const closeButtonSelectors = [".close-button", "button[aria-label='Close']", "button[title='Close']"]; diff --git a/frontend/tests/vitest/options/options.test.js b/frontend/tests/vitest/options/options.test.js index 7f2a67511..7d3347d79 100644 --- a/frontend/tests/vitest/options/options.test.js +++ b/frontend/tests/vitest/options/options.test.js @@ -67,21 +67,24 @@ describe("options/options", () => { }); it("should set default locale", () => { - expect(DefaultLocale).toBe("en"); + // Assuming DefaultLocale is exported and mutable for testing purposes + // Initial state check might depend on test execution order, so we control it here. + SetDefaultLocale("en"); // Ensure starting state + expect(options.DefaultLocale).toBe("en"); SetDefaultLocale("de"); - expect(DefaultLocale).toBe("de"); - SetDefaultLocale("en"); + expect(options.DefaultLocale).toBe("de"); + SetDefaultLocale("en"); // Reset for other tests }); it("should return default when no locale is provided", () => { expect(FindLanguage("").value).toBe("en"); }); - it("should return default locale is smaller than 2", () => { + it("should return default if locale is smaller than 2", () => { expect(FindLanguage("d").value).toBe("en"); }); - it("should return default locale", () => { + it("should return default for unknown locale", () => { expect(FindLanguage("xx").value).toBe("en"); }); @@ -150,34 +153,9 @@ describe("options/options", () => { expect(StartPages(features)[5].value).toBe("people"); expect(StartPages(features)[5].props.disabled).toBe(false); features = { - account: true, - albums: true, - archive: true, - delete: true, - download: true, - edit: true, - estimates: true, - favorites: true, - files: true, - folders: true, - import: true, - labels: true, - library: true, - logs: true, + ...features, // copy previous settings calendar: false, - moments: true, people: false, - places: true, - private: true, - ratings: true, - reactions: true, - review: true, - search: true, - services: true, - settings: true, - share: true, - upload: true, - videos: true, }; expect(StartPages(features).length).toBe(12); expect(StartPages(features)[5].value).toBe("people"); diff --git a/frontend/tests/vitest/setup.js b/frontend/tests/vitest/setup.js index ba43c695c..f1610d630 100644 --- a/frontend/tests/vitest/setup.js +++ b/frontend/tests/vitest/setup.js @@ -1,8 +1,11 @@ import { afterEach, vi } from "vitest"; import "@testing-library/jest-dom"; -import "./vue-setup"; +import { config } from "@vue/test-utils"; +import { createVuetify } from "vuetify"; +import * as components from "vuetify/components"; +import * as directives from "vuetify/directives"; +import "vuetify/styles"; -// Import and set up global config import clientConfig from "./config"; import { $config } from "app/session"; @@ -11,7 +14,54 @@ $config.setValues(clientConfig); // Make config available in browser environment window.__CONFIG__ = clientConfig; -console.log("Running tests in real browser environment"); +// Create a proper Vuetify instance with all components and styles +const vuetify = createVuetify({ + components, + directives, + theme: { + defaultTheme: "light", + }, +}); + +// Configure Vue Test Utils global configuration +config.global.mocks = { + $gettext: (text) => text, + $isRtl: false, + $config: { + feature: (_name) => true, + }, +}; + +config.global.plugins = [vuetify]; + +config.global.stubs = { + transition: false, +}; + +config.global.directives = { + tooltip: { + mounted(el, binding) { + el.setAttribute("data-tooltip", binding.value); + }, + }, +}; + +const originalMount = config.global.mount; +config.global.mount = function (component, options = {}) { + options.global = options.global || {}; + options.global.config = options.global.config || {}; + options.global.config.globalProperties = options.global.config.globalProperties || {}; + options.global.config.globalProperties.$emit = vi.fn(); + + // Add vuetify to all mount calls + if (!options.global.plugins) { + options.global.plugins = [vuetify]; + } else if (Array.isArray(options.global.plugins)) { + options.global.plugins.push(vuetify); + } + + return originalMount(component, options); +}; // Clean up after each test afterEach(() => { @@ -20,3 +70,7 @@ afterEach(() => { // Export shared configuration export { clientConfig }; + +export default { + vuetify, +}; diff --git a/frontend/tests/vitest/vue-setup.js b/frontend/tests/vitest/vue-setup.js deleted file mode 100644 index 4b77c0dfb..000000000 --- a/frontend/tests/vitest/vue-setup.js +++ /dev/null @@ -1,63 +0,0 @@ -import { config } from "@vue/test-utils"; -import { vi } from "vitest"; -import { createVuetify } from "vuetify"; -import * as components from "vuetify/components"; -import * as directives from "vuetify/directives"; -import "vuetify/styles"; -import { Settings } from "luxon"; - -// Setup timezone to match test expectations (UTC+2/CEST) -Settings.defaultZoneName = "Europe/Berlin"; - -// Create a proper Vuetify instance with all components and styles -const vuetify = createVuetify({ - components, - directives, - theme: { - defaultTheme: "light", - }, -}); - -// Configure Vue Test Utils global configuration -config.global.mocks = { - $gettext: (text) => text, - $isRtl: false, - $config: { - feature: (_name) => true, - }, -}; - -config.global.plugins = [vuetify]; - -config.global.stubs = { - transition: false, -}; - -config.global.directives = { - tooltip: { - mounted(el, binding) { - el.setAttribute("data-tooltip", binding.value); - }, - }, -}; - -const originalMount = config.global.mount; -config.global.mount = function (component, options = {}) { - options.global = options.global || {}; - options.global.config = options.global.config || {}; - options.global.config.globalProperties = options.global.config.globalProperties || {}; - options.global.config.globalProperties.$emit = vi.fn(); - - // Add vuetify to all mount calls - if (!options.global.plugins) { - options.global.plugins = [vuetify]; - } else if (Array.isArray(options.global.plugins)) { - options.global.plugins.push(vuetify); - } - - return originalMount(component, options); -}; - -export default { - vuetify, -};