diff --git a/.deployment.config.json b/.deployment.config.json index 342cb7e371c..a659869473b 100644 --- a/.deployment.config.json +++ b/.deployment.config.json @@ -9,7 +9,7 @@ "sequential": ["dev", "stg", "prd"] }, "team_jenkins": "searchuibuilds", - "start_environment_automatically": false, + "start_environment_automatically": true, "notifications": { "slack_channels": ["#searchuibuilds"] } diff --git a/.github/actions/e2e-atomic-insight-panel/action.yml b/.github/actions/e2e-atomic-insight-panel/action.yml index 4aaa6f6b7bb..04082a54fa8 100644 --- a/.github/actions/e2e-atomic-insight-panel/action.yml +++ b/.github/actions/e2e-atomic-insight-panel/action.yml @@ -13,7 +13,7 @@ runs: with: browser: chrome command-prefix: 'npx -w @coveo/atomic cypress-repeat run -n 3 --until-passes --rerun-failed-only --' - config-file: cypress-insight-panel.config.ts + config-file: cypress-insight-panel.config.mjs start: npm start -w @coveo/atomic wait-on: 'http://localhost:3333/ping' wait-on-timeout: 600000 diff --git a/.github/actions/e2e-atomic-screenshots/action.yml b/.github/actions/e2e-atomic-screenshots/action.yml index d5882bfed41..008bd258f63 100644 --- a/.github/actions/e2e-atomic-screenshots/action.yml +++ b/.github/actions/e2e-atomic-screenshots/action.yml @@ -15,7 +15,7 @@ runs: with: browser: chrome command-prefix: 'npx -w @coveo/atomic cypress-repeat run -n 3 --until-passes --rerun-failed-only --' - config-file: cypress-screenshots.config.ts + config-file: cypress-screenshots.config.mjs start: npm start -w @coveo/atomic wait-on: 'http://localhost:3333/ping' wait-on-timeout: 600000 diff --git a/.github/workflows/prbot.yml b/.github/workflows/prbot.yml index 08d32a043b9..2736a5771be 100644 --- a/.github/workflows/prbot.yml +++ b/.github/workflows/prbot.yml @@ -91,7 +91,6 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - uses: ./.github/actions/setup - run: npm run build - - run: cat packages/atomic/dist/atomic/atomic.esm.js - uses: ./.github/actions/playwright-atomic with: shardIndex: ${{ matrix.shardIndex }} @@ -107,7 +106,6 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - uses: ./.github/actions/setup - run: npm run build - - run: cat packages/atomic/dist/atomic/atomic.esm.js - uses: ./.github/actions/merge-playwright-reports - name: Generate a token if: ${{ always() && github.event_name == 'pull_request'}} diff --git a/.prettierignore b/.prettierignore index 26b8de76282..6603d0cf302 100644 --- a/.prettierignore +++ b/.prettierignore @@ -20,7 +20,8 @@ packages/atomic/dist-storybook/**/* packages/atomic/src/components/search/atomic-search-interface/lang/*.json packages/atomic/src/external-builds/**/* packages/atomic/src/generated/** +packages/headless/src/external-builds/**/* packages/quantic/docs/out/quantic-docs.json packages/samples/headless-react/build/**/* packages/samples/angular/src/lang/*.json -packages/samples/vuejs/public/lang/*.json \ No newline at end of file +packages/samples/vuejs/public/lang/*.json diff --git a/package-lock.json b/package-lock.json index 4840951bd1c..58c9d8ee55e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4935,6 +4935,12 @@ "resolved": "packages/bueno", "link": true }, + "node_modules/@coveo/explorer-messenger": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@coveo/explorer-messenger/-/explorer-messenger-0.4.0.tgz", + "integrity": "sha512-nVxwn+4Z+SZe6K94evxPaIeJWJq7hATNaUrTKznnauVptFMYcujts/nnhMplddm9ePg7NgZQjvcHwbi5kqw/EA==", + "license": "Apache-2.0" + }, "node_modules/@coveo/headless": { "resolved": "packages/headless", "link": true @@ -4975,6 +4981,29 @@ "resolved": "packages/quantic", "link": true }, + "node_modules/@coveo/relay": { + "version": "0.7.10", + "resolved": "https://registry.npmjs.org/@coveo/relay/-/relay-0.7.10.tgz", + "integrity": "sha512-d/4Vf8wwj746M0RV9xAek7SV/rZhv3ERoQoZo6I2IKAqzMxX8r0Vyrau+UZG1sdxybd6zzo8AVIzvRFHGXxvnA==", + "license": "Apache-2.0", + "dependencies": { + "@coveo/explorer-messenger": "^0.4.0", + "uuid": "^9.0.1" + } + }, + "node_modules/@coveo/relay/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@coveo/release": { "resolved": "utils/release", "link": true @@ -7166,9 +7195,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.25", @@ -10635,6 +10664,30 @@ } } }, + "node_modules/@reduxjs/toolkit": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.7.tgz", + "integrity": "sha512-faI3cZbSdFb8yv9dhDTmGwclW0vk0z5o1cia+kf7gCbaCwHI5e+7tP57mJUv22pNcNbeA62GSrPpfrUfdXcQ6g==", + "license": "MIT", + "dependencies": { + "immer": "^10.0.3", + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "reselect": "^5.1.0" + }, + "peerDependencies": { + "react": "^16.9.0 || ^17.0.0 || ^18", + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-redux": { + "optional": true + } + } + }, "node_modules/@remix-run/router": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.19.0.tgz", @@ -10938,9 +10991,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.18.0.tgz", - "integrity": "sha512-l3m9ewPgjQSXrUMHg93vt0hYCGnrMOcUpTz6FLtbwljo2HluS4zTXFy2571YQbisTnfTKPZ01u/ukJdQTLGh9A==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "cpu": [ "arm" ], @@ -21302,6 +21355,63 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/@vitest/mocker": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.1.tgz", + "integrity": "sha512-LNN5VwOEdJqCmJ/2XJBywB11DLlkbY0ooDJW3uRX5cZyYCrc4PI/ePX0iQhE3BiEGiQmK4GE7Q/PqCkkaiPnrA==", + "dev": true, + "dependencies": { + "@vitest/spy": "^2.1.0-beta.1", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.11" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/spy": "2.1.1", + "msw": "^2.3.5", + "vite": "^5.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/mocker/node_modules/@vitest/spy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.1.tgz", + "integrity": "sha512-ZM39BnZ9t/xZ/nF4UwRH5il0Sw93QnZXd9NAZGRpIgj0yvVwPpLd702s/Cx955rGaMlyBQkZJ2Ir7qyY48VZ+g==", + "dev": true, + "dependencies": { + "tinyspy": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker/node_modules/magic-string": { + "version": "0.30.11", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz", + "integrity": "sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/@vitest/mocker/node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@vitest/pretty-format": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.0.5.tgz", @@ -25410,6 +25520,17 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/core-js": { + "version": "3.37.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.1.tgz", + "integrity": "sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==", + "hasInstallScript": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-js-compat": { "version": "3.37.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.37.1.tgz", @@ -28514,6 +28635,36 @@ "integrity": "sha512-jyfL/pwPqaFXyKnj8lP8iLk6Z0m099uXR45aSN8Av1XD4vhvQutxxPzgA2bTcAwQpa1zCXDcWOlhFgyP3GKqhQ==", "dev": true }, + "node_modules/esbuild-plugin-alias-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esbuild-plugin-alias-path/-/esbuild-plugin-alias-path-2.0.2.tgz", + "integrity": "sha512-YK8H9bzx6/CG6YBV11XjoNLjRhNZP0Ta4xZ3ATHhPn7pN8ljQGg+zne4d47DpIzF8/sX2qM+xQWev0CvaD2rSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "5.0.0", + "fs-extra": "^10.1.0", + "jsonfile": "^6.1.0" + }, + "peerDependencies": { + "esbuild": ">= 0.14.0" + } + }, + "node_modules/esbuild-plugin-alias-path/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/esbuild-plugin-umd-wrapper": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esbuild-plugin-umd-wrapper/-/esbuild-plugin-umd-wrapper-2.0.3.tgz", @@ -31700,6 +31851,19 @@ "node": ">= 8" } }, + "node_modules/fix-esm-import-path": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/fix-esm-import-path/-/fix-esm-import-path-1.10.0.tgz", + "integrity": "sha512-c4BoKC4qA8GFAPrApmF4j0QNDWeeaGy51C9/QQw2z671sgfdDmOwUbGmPp/bdyQ4SoThB7CEjy97PJ3LlfuvfA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "debug": "^4.3.2" + }, + "bin": { + "fix-esm-import-path": "fix-esm-import-path.js" + } + }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -33917,6 +34081,38 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/i18next": { + "version": "23.12.2", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.12.2.tgz", + "integrity": "sha512-XIeh5V+bi8SJSWGL3jqbTEBW5oD6rbP5L+E7dVQh1MNTxxYef0x15rhJVcRb7oiuq4jLtgy2SD8eFlf6P2cmqg==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.23.2" + } + }, + "node_modules/i18next-http-backend": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.5.2.tgz", + "integrity": "sha512-+K8HbDfrvc1/2X8jpb7RLhI9ZxBDpx3xogYkQwGKlWAUXLSEGXzgdt3EcUjLlBCdMwdQY+K+EUF6oh8oB6rwHw==", + "license": "MIT", + "dependencies": { + "cross-fetch": "4.0.0" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -33979,6 +34175,16 @@ "node": ">=10" } }, + "node_modules/immer": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", + "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, "node_modules/immutable": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.5.tgz", @@ -45242,6 +45448,21 @@ "balanced-match": "^1.0.0" } }, + "node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==", + "license": "MIT" + }, + "node_modules/redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "license": "MIT", + "peerDependencies": { + "redux": "^5.0.0" + } + }, "node_modules/reflect-metadata": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.1.tgz", @@ -45637,6 +45858,12 @@ "lodash": "^4.17.21" } }, + "node_modules/reselect": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", + "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==", + "license": "MIT" + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", @@ -48864,6 +49091,12 @@ "integrity": "sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==", "dev": true }, + "node_modules/tinyexec": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.0.tgz", + "integrity": "sha512-tVGE0mVJPGb0chKhqmsoosjsS+qUnJVGJpZgsHYQcGoPlG3B51R3PouqTgEGH2Dc9jjFyOqOpix6ZHNMXp1FZg==", + "dev": true + }, "node_modules/tinypool": { "version": "0.8.4", "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.8.4.tgz", @@ -49017,6 +49250,12 @@ "typescript": ">=4.2.0" } }, + "node_modules/ts-debounce": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-4.0.0.tgz", + "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==", + "license": "MIT" + }, "node_modules/ts-dedent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", @@ -51882,11 +52121,11 @@ }, "packages/atomic": { "name": "@coveo/atomic", - "version": "3.1.1", + "version": "3.2.3", "license": "Apache-2.0", "dependencies": { - "@coveo/bueno": "1.0.0", - "@coveo/headless": "3.0.0", + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3", "@popperjs/core": "^2.11.6", "@salesforce-ux/design-system": "^2.16.1", "@stencil/store": "2.0.16", @@ -51904,7 +52143,7 @@ "devDependencies": { "@axe-core/playwright": "4.9.1", "@babel/core": "7.24.9", - "@coveo/atomic": "file:.", + "@coveo/atomic-storybook-utils": "file:./storybookUtils", "@coveo/release": "1.0.0", "@coveo/rollup-plugin-replace-with-ast": "1.0.0", "@custom-elements-manifest/analyzer": "0.10.3", @@ -51967,6 +52206,7 @@ "postcss-nested": "6.2.0", "puppeteer": "22.14.0", "react": "18.3.1", + "rollup": "4.22.4", "rollup-plugin-html": "0.2.1", "shadow-dom-testing-library": "1.11.2", "storybook": "8.1.2", @@ -51982,7 +52222,8 @@ "node": "^20.9.0" }, "peerDependencies": { - "@coveo/headless": "3.0.0" + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3" } }, "packages/atomic-angular": { @@ -51997,14 +52238,14 @@ "@angular/platform-browser": "17.3.12", "@angular/platform-browser-dynamic": "17.3.12", "@angular/router": "17.3.12", - "@coveo/atomic": "3.1.1", + "@coveo/atomic": "3.2.3", "rxjs": "7.8.1" }, "devDependencies": { "@angular-devkit/build-angular": "17.3.9", "@angular/cli": "17.3.9", "@angular/compiler-cli": "17.3.12", - "@coveo/headless": "3.0.0", + "@coveo/headless": "3.1.3", "@types/node": "20.14.12", "jasmine-core": "5.2.0", "karma": "6.4.3", @@ -52020,7 +52261,7 @@ "node": "^20.9.0" }, "peerDependencies": { - "@coveo/headless": "3.0.0" + "@coveo/headless": "3.1.3" } }, "packages/atomic-angular/node_modules/jasmine-core": { @@ -52049,10 +52290,10 @@ }, "packages/atomic-angular/projects/atomic-angular": { "name": "@coveo/atomic-angular", - "version": "3.0.2", + "version": "3.1.3", "license": "Apache-2.0", "dependencies": { - "@coveo/atomic": "3.1.1", + "@coveo/atomic": "3.2.3", "tslib": "2.6.3" }, "engines": { @@ -52061,16 +52302,16 @@ "peerDependencies": { "@angular/common": "14 - 17", "@angular/core": "14 - 17", - "@coveo/headless": "3.0.0" + "@coveo/headless": "3.1.3" } }, "packages/atomic-hosted-page": { "name": "@coveo/atomic-hosted-page", - "version": "1.0.0", + "version": "1.0.4", "license": "Apache-2.0", "dependencies": { - "@coveo/bueno": "1.0.0", - "@coveo/headless": "3.0.0", + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3", "@stencil/core": "4.20.0" }, "devDependencies": { @@ -52152,9 +52393,9 @@ }, "packages/atomic-react": { "name": "@coveo/atomic-react", - "version": "3.0.2", + "version": "3.1.3", "dependencies": { - "@coveo/atomic": "3.1.1" + "@coveo/atomic": "3.2.3" }, "devDependencies": { "@coveo/release": "1.0.0", @@ -52168,6 +52409,7 @@ "@types/node": "20.14.12", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", + "fix-esm-import-path": "1.10.0", "ncp": "2.0.0", "react": "18.3.1", "react-dom": "18.3.1", @@ -52178,7 +52420,7 @@ "node": "^20.9.0" }, "peerDependencies": { - "@coveo/headless": "3.0.0", + "@coveo/headless": "3.1.3", "react": ">=18.0.0", "react-dom": ">=18.0.0" } @@ -52384,6 +52626,10 @@ "node": ">=6.9.0" } }, + "packages/atomic/node_modules/@coveo/atomic-storybook-utils": { + "resolved": "packages/atomic/storybookUtils", + "link": true + }, "packages/atomic/node_modules/@custom-elements-manifest/analyzer": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/@custom-elements-manifest/analyzer/-/analyzer-0.10.3.tgz", @@ -52821,13 +53067,6 @@ "postcss": "^8.0.0" } }, - "packages/atomic/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true, - "license": "MIT" - }, "packages/atomic/node_modules/@lit/reactive-element": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.4.tgz", @@ -53239,195 +53478,210 @@ } }, "packages/atomic/node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz", - "integrity": "sha512-Tya6xypR10giZV1XzxmH5wr25VcZSncG0pZIjfePT0OVBvqNEurzValetGNarVrGiq66EBVAFn15iYX4w6FKgQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" ] }, "packages/atomic/node_modules/@rollup/rollup-android-arm64": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.0.tgz", - "integrity": "sha512-avCea0RAP03lTsDhEyfy+hpfr85KfyTctMADqHVhLAF3MlIkq83CP8UfAHUssgXTYd+6er6PaAhx/QGv4L1EiA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" ] }, "packages/atomic/node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.0.tgz", - "integrity": "sha512-IWfdwU7KDSm07Ty0PuA/W2JYoZ4iTj3TUQjkVsO/6U+4I1jN5lcR71ZEvRh52sDOERdnNhhHU57UITXz5jC1/w==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" ] }, "packages/atomic/node_modules/@rollup/rollup-darwin-x64": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.18.0.tgz", - "integrity": "sha512-n2LMsUz7Ynu7DoQrSQkBf8iNrjOGyPLrdSg802vk6XT3FtsgX6JbE8IHRvposskFm9SNxzkLYGSq9QdpLYpRNA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.18.0.tgz", - "integrity": "sha512-C/zbRYRXFjWvz9Z4haRxcTdnkPt1BtCkz+7RtBSuNmKzMzp3ZxdM28Mpccn6pt28/UWUCTXa+b0Mx1k3g6NOMA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.0.tgz", - "integrity": "sha512-rJ5D47d8WD7J+7STKdCUAgmQk49xuFrRi9pZkWoRD1UeSMakbcepWXPF8ycChBoAqs1pb2wzvbY6Q33WmN2ftw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.18.0.tgz", - "integrity": "sha512-be6Yx37b24ZwxQ+wOQXXLZqpq4jTckJhtGlWGZs68TgdKXJgw54lUUoFYrg6Zs/kjzAQwEwYbp8JxZVzZLRepQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.18.0.tgz", - "integrity": "sha512-hNVMQK+qrA9Todu9+wqrXOHxFiD5YmdEi3paj6vP02Kx1hjd2LLYR2eaN7DsEshg09+9uzWi2W18MJDlG0cxJA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", "cpu": [ "ppc64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.18.0.tgz", - "integrity": "sha512-ROCM7i+m1NfdrsmvwSzoxp9HFtmKGHEqu5NNDiZWQtXLA8S5HBCkVvKAxJ8U+CVctHwV2Gb5VUaK7UAkzhDjlg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", "cpu": [ "riscv64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.0.tgz", - "integrity": "sha512-0UyyRHyDN42QL+NbqevXIIUnKA47A+45WyasO+y2bGJ1mhQrfrtXUpTxCOrfxCR4esV3/RLYyucGVPiUsO8xjg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", "cpu": [ "s390x" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.0.tgz", - "integrity": "sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.18.0.tgz", - "integrity": "sha512-LKaqQL9osY/ir2geuLVvRRs+utWUNilzdE90TpyoX0eNqPzWjRm14oMEE+YLve4k/NAqCdPkGYDaDF5Sw+xBfg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ] }, "packages/atomic/node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.0.tgz", - "integrity": "sha512-7J6TkZQFGo9qBKH0pk2cEVSRhJbL6MtfWxth7Y5YmZs57Pi+4x6c2dStAUvaQkHQLnEQv1jzBUW43GvZW8OFqA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" ] }, "packages/atomic/node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.0.tgz", - "integrity": "sha512-Txjh+IxBPbkUB9+SXZMpv+b/vnTEtFyfWZgJ6iyCmt2tdx0OF5WhFowLmnh8ENGNpfUlUZkdI//4IEmhwPieNg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" ] }, "packages/atomic/node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.0.tgz", - "integrity": "sha512-UOo5FdvOL0+eIVTgS4tIdbW+TtnBLWg1YBCcU2KWM7nuNwRz9bksDX1bekJJCpu25N1DVWaCwnT39dVQxzqS8g==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -53651,16 +53905,6 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "packages/atomic/node_modules/core-js": { - "version": "3.37.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.1.tgz", - "integrity": "sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==", - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, "packages/atomic/node_modules/cosmiconfig": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz", @@ -53863,36 +54107,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/atomic/node_modules/i18next": { - "version": "23.12.2", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.12.2.tgz", - "integrity": "sha512-XIeh5V+bi8SJSWGL3jqbTEBW5oD6rbP5L+E7dVQh1MNTxxYef0x15rhJVcRb7oiuq4jLtgy2SD8eFlf6P2cmqg==", - "funding": [ - { - "type": "individual", - "url": "https://locize.com" - }, - { - "type": "individual", - "url": "https://locize.com/i18next.html" - }, - { - "type": "individual", - "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" - } - ], - "dependencies": { - "@babel/runtime": "^7.23.2" - } - }, - "packages/atomic/node_modules/i18next-http-backend": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.5.2.tgz", - "integrity": "sha512-+K8HbDfrvc1/2X8jpb7RLhI9ZxBDpx3xogYkQwGKlWAUXLSEGXzgdt3EcUjLlBCdMwdQY+K+EUF6oh8oB6rwHw==", - "dependencies": { - "cross-fetch": "4.0.0" - } - }, "packages/atomic/node_modules/js-yaml": { "name": "@zkochan/js-yaml", "version": "0.0.7", @@ -54270,10 +54484,11 @@ } }, "packages/atomic/node_modules/rollup": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", - "integrity": "sha512-QmJz14PX3rzbJCN1SG4Xe/bAAX2a6NpCP8ab2vfu2GiUr8AQcr2nCV/oEO3yneFarB67zk8ShlIyWb2LGTb3Sg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, + "license": "MIT", "dependencies": { "@types/estree": "1.0.5" }, @@ -54285,22 +54500,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.18.0", - "@rollup/rollup-android-arm64": "4.18.0", - "@rollup/rollup-darwin-arm64": "4.18.0", - "@rollup/rollup-darwin-x64": "4.18.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.18.0", - "@rollup/rollup-linux-arm-musleabihf": "4.18.0", - "@rollup/rollup-linux-arm64-gnu": "4.18.0", - "@rollup/rollup-linux-arm64-musl": "4.18.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.18.0", - "@rollup/rollup-linux-riscv64-gnu": "4.18.0", - "@rollup/rollup-linux-s390x-gnu": "4.18.0", - "@rollup/rollup-linux-x64-gnu": "4.18.0", - "@rollup/rollup-linux-x64-musl": "4.18.0", - "@rollup/rollup-win32-arm64-msvc": "4.18.0", - "@rollup/rollup-win32-ia32-msvc": "4.18.0", - "@rollup/rollup-win32-x64-msvc": "4.18.0", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } }, @@ -54481,11 +54696,6 @@ "streamx": "^2.15.0" } }, - "packages/atomic/node_modules/ts-debounce": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-4.0.0.tgz", - "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==" - }, "packages/atomic/node_modules/tsconfig-paths": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", @@ -54682,9 +54892,12 @@ "url": "https://github.com/sponsors/colinhacks" } }, + "packages/atomic/storybookUtils": { + "dev": true + }, "packages/auth": { "name": "@coveo/auth", - "version": "2.0.0", + "version": "2.0.1", "license": "Apache-2.0", "devDependencies": { "@coveo/release": "1.0.0", @@ -55284,7 +55497,7 @@ }, "packages/bueno": { "name": "@coveo/bueno", - "version": "1.0.0", + "version": "1.0.1", "license": "Apache-2.0", "devDependencies": { "@coveo/release": "1.0.0", @@ -55345,10 +55558,10 @@ }, "packages/headless": { "name": "@coveo/headless", - "version": "3.0.0", + "version": "3.1.3", "license": "Apache-2.0", "dependencies": { - "@coveo/bueno": "1.0.0", + "@coveo/bueno": "1.0.1", "@coveo/relay": "0.7.10", "@coveo/relay-event-types": "9.4.0", "@microsoft/fetch-event-source": "2.0.1", @@ -55369,12 +55582,12 @@ "@microsoft/api-extractor": "7.47.3", "@microsoft/api-extractor-model": "7.29.3", "@microsoft/tsdoc": "0.15.0", + "esbuild-plugin-alias-path": "2.0.2", "eslint-plugin-canonical": "4.18.0", "execa": "8.0.1", "install": "0.13.0", - "jest": "29.7.0", - "ts-jest": "29.2.3", - "ts-node": "10.9.2" + "ts-node": "10.9.2", + "vitest": "2.1.1" }, "engines": { "node": "^20.9.0" @@ -55386,10 +55599,10 @@ }, "packages/headless-react": { "name": "@coveo/headless-react", - "version": "2.0.0", + "version": "2.0.4", "license": "Apache-2.0", "dependencies": { - "@coveo/headless": "3.0.0" + "@coveo/headless": "3.1.3" }, "devDependencies": { "@coveo/release": "1.0.0", @@ -55402,12 +55615,11 @@ "eslint-plugin-react": "7.35.0", "eslint-plugin-testing-library": "6.2.2", "gts": "5.3.1", - "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "publint": "0.2.9", "rimraf": "5.0.9", - "ts-jest": "29.2.3", - "typescript": "5.4.5" + "typescript": "5.4.5", + "vitest": "2.1.1" }, "engines": { "node": "^20.9.0" @@ -55455,6 +55667,179 @@ "@types/react": "*" } }, + "packages/headless-react/node_modules/@vitest/expect": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.1.tgz", + "integrity": "sha512-YeueunS0HiHiQxk+KEOnq/QMzlUuOzbU1Go+PgAsHvvv3tUkJPm9xWt+6ITNTlzsMXUjmgm5T+U7KBPK2qQV6w==", + "dev": true, + "dependencies": { + "@vitest/spy": "2.1.1", + "@vitest/utils": "2.1.1", + "chai": "^5.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/@vitest/pretty-format": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.1.tgz", + "integrity": "sha512-SjxPFOtuINDUW8/UkElJYQSFtnWX7tMksSGW0vfjxMneFqxVr8YJ979QpMbDW7g+BIiq88RAGDjf7en6rvLPPQ==", + "dev": true, + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/@vitest/runner": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.1.tgz", + "integrity": "sha512-uTPuY6PWOYitIkLPidaY5L3t0JJITdGTSwBtwMjKzo5O6RCOEncz9PUN+0pDidX8kTHYjO0EwUIvhlGpnGpxmA==", + "dev": true, + "dependencies": { + "@vitest/utils": "2.1.1", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/@vitest/snapshot": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.1.tgz", + "integrity": "sha512-BnSku1WFy7r4mm96ha2FzN99AZJgpZOWrAhtQfoxjUU5YMRpq1zmHRq7a5K9/NjqonebO7iVDla+VvZS8BOWMw==", + "dev": true, + "dependencies": { + "@vitest/pretty-format": "2.1.1", + "magic-string": "^0.30.11", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/@vitest/spy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.1.tgz", + "integrity": "sha512-ZM39BnZ9t/xZ/nF4UwRH5il0Sw93QnZXd9NAZGRpIgj0yvVwPpLd702s/Cx955rGaMlyBQkZJ2Ir7qyY48VZ+g==", + "dev": true, + "dependencies": { + "tinyspy": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/@vitest/utils": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.1.tgz", + "integrity": "sha512-Y6Q9TsI+qJ2CC0ZKj6VBb+T8UPz593N113nnUykqwANqhgf3QkZeHFlusgKLTqrnVHbj/XDKZcDHol+dxVT+rQ==", + "dev": true, + "dependencies": { + "@vitest/pretty-format": "2.1.1", + "loupe": "^3.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "packages/headless-react/node_modules/chai": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", + "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", + "dev": true, + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "packages/headless-react/node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "engines": { + "node": ">= 16" + } + }, + "packages/headless-react/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "packages/headless-react/node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "packages/headless-react/node_modules/loupe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", + "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "packages/headless-react/node_modules/magic-string": { + "version": "0.30.11", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz", + "integrity": "sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "packages/headless-react/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "packages/headless-react/node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "engines": { + "node": ">= 14.16" + } + }, "packages/headless-react/node_modules/publint": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/publint/-/publint-0.2.9.tgz", @@ -55475,66 +55860,129 @@ "url": "https://bjornlu.com/sponsor" } }, - "packages/headless-react/node_modules/ts-jest": { - "version": "29.2.3", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.3.tgz", - "integrity": "sha512-yCcfVdiBFngVz9/keHin9EnsrQtQtEu3nRykNy9RVp+FiPFFbPJ3Sg6Qg4+TkmH0vMP5qsTKgXSsk80HRwvdgQ==", + "packages/headless-react/node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true + }, + "packages/headless-react/node_modules/tinypool": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.1.tgz", + "integrity": "sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==", + "dev": true, + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "packages/headless-react/node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "engines": { + "node": ">=14.0.0" + } + }, + "packages/headless-react/node_modules/vite-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.1.tgz", + "integrity": "sha512-N/mGckI1suG/5wQI35XeR9rsMsPqKXzq1CdUndzVstBj/HvyxxGctwnK6WX43NGt5L3Z5tcRf83g4TITKJhPrA==", "dev": true, "dependencies": { - "bs-logger": "0.x", - "ejs": "^3.1.10", - "fast-json-stable-stringify": "2.x", - "jest-util": "^29.0.0", - "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" + "cac": "^6.7.14", + "debug": "^4.3.6", + "pathe": "^1.1.2", + "vite": "^5.0.0" }, "bin": { - "ts-jest": "cli.js" + "vite-node": "vite-node.mjs" }, "engines": { - "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless-react/node_modules/vitest": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.1.tgz", + "integrity": "sha512-97We7/VC0e9X5zBVkvt7SGQMGrRtn3KtySFQG5fpaMlS+l62eeXRQO633AYhSTC3z7IMebnPPNjGXVGNRFlxBA==", + "dev": true, + "dependencies": { + "@vitest/expect": "2.1.1", + "@vitest/mocker": "2.1.1", + "@vitest/pretty-format": "^2.1.1", + "@vitest/runner": "2.1.1", + "@vitest/snapshot": "2.1.1", + "@vitest/spy": "2.1.1", + "@vitest/utils": "2.1.1", + "chai": "^5.1.1", + "debug": "^4.3.6", + "magic-string": "^0.30.11", + "pathe": "^1.1.2", + "std-env": "^3.7.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.0", + "tinypool": "^1.0.0", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.1", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@babel/core": ">=7.0.0-beta.0 <8", - "@jest/transform": "^29.0.0", - "@jest/types": "^29.0.0", - "babel-jest": "^29.0.0", - "jest": "^29.0.0", - "typescript": ">=4.3 <6" + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.1", + "@vitest/ui": "2.1.1", + "happy-dom": "*", + "jsdom": "*" }, "peerDependenciesMeta": { - "@babel/core": { + "@edge-runtime/vm": { "optional": true }, - "@jest/transform": { + "@types/node": { "optional": true }, - "@jest/types": { + "@vitest/browser": { "optional": true }, - "babel-jest": { + "@vitest/ui": { "optional": true }, - "esbuild": { + "happy-dom": { + "optional": true + }, + "jsdom": { "optional": true } } }, - "packages/headless/node_modules/@coveo/explorer-messenger": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@coveo/explorer-messenger/-/explorer-messenger-0.4.0.tgz", - "integrity": "sha512-nVxwn+4Z+SZe6K94evxPaIeJWJq7hATNaUrTKznnauVptFMYcujts/nnhMplddm9ePg7NgZQjvcHwbi5kqw/EA==" - }, - "packages/headless/node_modules/@coveo/relay": { - "version": "0.7.10", - "resolved": "https://registry.npmjs.org/@coveo/relay/-/relay-0.7.10.tgz", - "integrity": "sha512-d/4Vf8wwj746M0RV9xAek7SV/rZhv3ERoQoZo6I2IKAqzMxX8r0Vyrau+UZG1sdxybd6zzo8AVIzvRFHGXxvnA==", + "packages/headless-react/node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, "dependencies": { - "@coveo/explorer-messenger": "^0.4.0", - "uuid": "^9.0.1" + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" } }, "packages/headless/node_modules/@coveo/relay-event-types": { @@ -55595,30 +56043,6 @@ "resolve": "~1.22.2" } }, - "packages/headless/node_modules/@reduxjs/toolkit": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.7.tgz", - "integrity": "sha512-faI3cZbSdFb8yv9dhDTmGwclW0vk0z5o1cia+kf7gCbaCwHI5e+7tP57mJUv22pNcNbeA62GSrPpfrUfdXcQ6g==", - "license": "MIT", - "dependencies": { - "immer": "^10.0.3", - "redux": "^5.0.1", - "redux-thunk": "^3.1.0", - "reselect": "^5.1.0" - }, - "peerDependencies": { - "react": "^16.9.0 || ^17.0.0 || ^18", - "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" - }, - "peerDependenciesMeta": { - "react": { - "optional": true - }, - "react-redux": { - "optional": true - } - } - }, "packages/headless/node_modules/@rushstack/node-core-library": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-5.5.0.tgz", @@ -55703,6 +56127,86 @@ "string-argv": "~0.3.1" } }, + "packages/headless/node_modules/@vitest/expect": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.1.tgz", + "integrity": "sha512-YeueunS0HiHiQxk+KEOnq/QMzlUuOzbU1Go+PgAsHvvv3tUkJPm9xWt+6ITNTlzsMXUjmgm5T+U7KBPK2qQV6w==", + "dev": true, + "dependencies": { + "@vitest/spy": "2.1.1", + "@vitest/utils": "2.1.1", + "chai": "^5.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless/node_modules/@vitest/pretty-format": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.1.tgz", + "integrity": "sha512-SjxPFOtuINDUW8/UkElJYQSFtnWX7tMksSGW0vfjxMneFqxVr8YJ979QpMbDW7g+BIiq88RAGDjf7en6rvLPPQ==", + "dev": true, + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless/node_modules/@vitest/runner": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.1.tgz", + "integrity": "sha512-uTPuY6PWOYitIkLPidaY5L3t0JJITdGTSwBtwMjKzo5O6RCOEncz9PUN+0pDidX8kTHYjO0EwUIvhlGpnGpxmA==", + "dev": true, + "dependencies": { + "@vitest/utils": "2.1.1", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless/node_modules/@vitest/snapshot": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.1.tgz", + "integrity": "sha512-BnSku1WFy7r4mm96ha2FzN99AZJgpZOWrAhtQfoxjUU5YMRpq1zmHRq7a5K9/NjqonebO7iVDla+VvZS8BOWMw==", + "dev": true, + "dependencies": { + "@vitest/pretty-format": "2.1.1", + "magic-string": "^0.30.11", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless/node_modules/@vitest/spy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.1.tgz", + "integrity": "sha512-ZM39BnZ9t/xZ/nF4UwRH5il0Sw93QnZXd9NAZGRpIgj0yvVwPpLd702s/Cx955rGaMlyBQkZJ2Ir7qyY48VZ+g==", + "dev": true, + "dependencies": { + "tinyspy": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless/node_modules/@vitest/utils": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.1.tgz", + "integrity": "sha512-Y6Q9TsI+qJ2CC0ZKj6VBb+T8UPz593N113nnUykqwANqhgf3QkZeHFlusgKLTqrnVHbj/XDKZcDHol+dxVT+rQ==", + "dev": true, + "dependencies": { + "@vitest/pretty-format": "2.1.1", + "loupe": "^3.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "packages/headless/node_modules/ajv-formats": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", @@ -55720,11 +56224,71 @@ } } }, + "packages/headless/node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "packages/headless/node_modules/chai": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", + "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", + "dev": true, + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "packages/headless/node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "engines": { + "node": ">= 16" + } + }, "packages/headless/node_modules/dayjs": { "version": "1.11.12", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.12.tgz", "integrity": "sha512-Rt2g+nTbLlDWZTwwrIXjy9MeiZmSDI375FvZs72ngxx8PDC6YXOeR3q5LAuPzjZQxhiWdRKac7RKV+YyQYfYIg==" }, + "packages/headless/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "packages/headless/node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "packages/headless/node_modules/exponential-backoff": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.0.tgz", @@ -55744,15 +56308,6 @@ "node": ">=6 <7 || >=8" } }, - "packages/headless/node_modules/immer": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz", - "integrity": "sha512-pwupu3eWfouuaowscykeckFmVTpqbzW+rXFCX8rQLkZzM9ftBmU/++Ra+o+L27mz03zJTlyV4UUr+fdKNffo4A==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/immer" - } - }, "packages/headless/node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -55762,6 +56317,15 @@ "graceful-fs": "^4.1.6" } }, + "packages/headless/node_modules/loupe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", + "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.1" + } + }, "packages/headless/node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -55774,6 +56338,15 @@ "node": ">=10" } }, + "packages/headless/node_modules/magic-string": { + "version": "0.30.11", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz", + "integrity": "sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, "packages/headless/node_modules/minimatch": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", @@ -55796,24 +56369,21 @@ "concat-map": "0.0.1" } }, - "packages/headless/node_modules/redux": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", - "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + "packages/headless/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true }, - "packages/headless/node_modules/redux-thunk": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", - "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", - "peerDependencies": { - "redux": "^5.0.0" + "packages/headless/node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "engines": { + "node": ">= 14.16" } }, - "packages/headless/node_modules/reselect": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.0.tgz", - "integrity": "sha512-aw7jcGLDpSgNDyWBQLv2cedml85qd95/iszJjN988zX1t7AVRJi19d9kto5+W7oCfQ94gyo40dVbT6g2k4/kXg==" - }, "packages/headless/node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", @@ -55829,57 +56399,28 @@ "node": ">=10" } }, - "packages/headless/node_modules/ts-debounce": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/ts-debounce/-/ts-debounce-4.0.0.tgz", - "integrity": "sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==" + "packages/headless/node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true }, - "packages/headless/node_modules/ts-jest": { - "version": "29.2.3", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.3.tgz", - "integrity": "sha512-yCcfVdiBFngVz9/keHin9EnsrQtQtEu3nRykNy9RVp+FiPFFbPJ3Sg6Qg4+TkmH0vMP5qsTKgXSsk80HRwvdgQ==", + "packages/headless/node_modules/tinypool": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.1.tgz", + "integrity": "sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==", "dev": true, - "dependencies": { - "bs-logger": "0.x", - "ejs": "^3.1.10", - "fast-json-stable-stringify": "2.x", - "jest-util": "^29.0.0", - "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" - }, - "bin": { - "ts-jest": "cli.js" - }, "engines": { - "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" - }, - "peerDependencies": { - "@babel/core": ">=7.0.0-beta.0 <8", - "@jest/transform": "^29.0.0", - "@jest/types": "^29.0.0", - "babel-jest": "^29.0.0", - "jest": "^29.0.0", - "typescript": ">=4.3 <6" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "@jest/transform": { - "optional": true - }, - "@jest/types": { - "optional": true - }, - "babel-jest": { - "optional": true - }, - "esbuild": { - "optional": true - } + "node": "^18.0.0 || >=20.0.0" + } + }, + "packages/headless/node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "engines": { + "node": ">=14.0.0" } }, "packages/headless/node_modules/typescript": { @@ -55904,16 +56445,105 @@ "node": ">= 4.0.0" } }, - "packages/headless/node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], + "packages/headless/node_modules/vite-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.1.tgz", + "integrity": "sha512-N/mGckI1suG/5wQI35XeR9rsMsPqKXzq1CdUndzVstBj/HvyxxGctwnK6WX43NGt5L3Z5tcRf83g4TITKJhPrA==", + "dev": true, + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.6", + "pathe": "^1.1.2", + "vite": "^5.0.0" + }, "bin": { - "uuid": "dist/bin/uuid" + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "packages/headless/node_modules/vitest": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.1.tgz", + "integrity": "sha512-97We7/VC0e9X5zBVkvt7SGQMGrRtn3KtySFQG5fpaMlS+l62eeXRQO633AYhSTC3z7IMebnPPNjGXVGNRFlxBA==", + "dev": true, + "dependencies": { + "@vitest/expect": "2.1.1", + "@vitest/mocker": "2.1.1", + "@vitest/pretty-format": "^2.1.1", + "@vitest/runner": "2.1.1", + "@vitest/snapshot": "2.1.1", + "@vitest/spy": "2.1.1", + "@vitest/utils": "2.1.1", + "chai": "^5.1.1", + "debug": "^4.3.6", + "magic-string": "^0.30.11", + "pathe": "^1.1.2", + "std-env": "^3.7.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.0", + "tinypool": "^1.0.0", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.1", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.1", + "@vitest/ui": "2.1.1", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "packages/headless/node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" } }, "packages/headless/node_modules/yallist": { @@ -55924,12 +56554,12 @@ }, "packages/quantic": { "name": "@coveo/quantic", - "version": "3.0.0", + "version": "3.0.4", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@coveo/bueno": "1.0.0", - "@coveo/headless": "3.0.0", + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3", "dompurify": "3.1.6", "marked": "12.0.2" }, @@ -57638,13 +58268,6 @@ } } }, - "packages/rollup-plugin-replace-with-ast/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true, - "license": "MIT" - }, "packages/rollup-plugin-replace-with-ast/node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.0.0-24", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.0.0-24.tgz", @@ -57876,7 +58499,7 @@ "@angular/platform-browser": "17.3.12", "@angular/platform-browser-dynamic": "17.3.12", "@angular/router": "17.3.12", - "@coveo/atomic-angular": "3.0.2", + "@coveo/atomic-angular": "3.1.3", "rxjs": "7.8.1", "tslib": "2.6.3", "zone.js": "0.14.8" @@ -58176,9 +58799,9 @@ "name": "@coveo/atomic-next-samples", "version": "0.0.0", "dependencies": { - "@coveo/atomic": "3.1.1", - "@coveo/atomic-react": "3.0.2", - "@coveo/headless": "3.0.0", + "@coveo/atomic": "3.2.3", + "@coveo/atomic-react": "3.1.3", + "@coveo/headless": "3.1.3", "next": "14.2.5", "react": "18.3.1", "react-dom": "18.3.1" @@ -58241,9 +58864,9 @@ "name": "@coveo/atomic-react-samples", "version": "0.0.0", "dependencies": { - "@coveo/atomic": "3.1.1", - "@coveo/atomic-react": "3.0.2", - "@coveo/headless": "3.0.0", + "@coveo/atomic": "3.2.3", + "@coveo/atomic-react": "3.1.3", + "@coveo/headless": "3.1.3", "react": "18.3.1", "react-dom": "18.3.1" }, @@ -58731,7 +59354,7 @@ "name": "@coveo/headless-commerce-react-samples", "version": "0.1.0", "dependencies": { - "@coveo/headless": "3.0.0", + "@coveo/headless": "3.1.3", "react": "18.3.1", "react-dom": "18.3.1" }, @@ -59117,12 +59740,6 @@ "node": ">=12" } }, - "packages/samples/headless-commerce-react/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true - }, "packages/samples/headless-commerce-react/node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.21.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.1.tgz", @@ -59963,8 +60580,8 @@ "name": "@coveo/headless-react-samples", "version": "0.0.0", "dependencies": { - "@coveo/auth": "2.0.0", - "@coveo/headless": "3.0.0", + "@coveo/auth": "2.0.1", + "@coveo/headless": "3.1.3", "@testing-library/jest-dom": "6.4.8", "@testing-library/react": "14.3.1", "@testing-library/user-event": "14.5.2", @@ -61355,8 +61972,8 @@ "name": "@coveo/headless-ssr-samples-common", "version": "0.0.0", "dependencies": { - "@coveo/headless": "3.0.0", - "@coveo/headless-react": "2.0.0", + "@coveo/headless": "3.1.3", + "@coveo/headless-react": "2.0.4", "next": "14.2.5", "react": "^18.2.0", "react-dom": "^18.2.0" @@ -61377,7 +61994,7 @@ "name": "@coveo/headless-ssr-commerce-samples", "version": "0.0.0", "dependencies": { - "@coveo/headless": "3.0.0", + "@coveo/headless": "3.1.3", "next": "14.2.5", "react": "^18.2.0", "react-dom": "^18.2.0" @@ -61496,10 +62113,10 @@ "version": "0.1.0", "dependencies": { "@babel/standalone": "7.25.0", - "@coveo/atomic": "3.1.1", - "@coveo/atomic-hosted-page": "1.0.0", - "@coveo/atomic-react": "3.0.2", - "@coveo/headless": "3.0.0", + "@coveo/atomic": "3.2.3", + "@coveo/atomic-hosted-page": "1.0.4", + "@coveo/atomic-react": "3.1.3", + "@coveo/headless": "3.1.3", "react": "18.3.1", "react-dom": "18.3.1" }, @@ -61568,8 +62185,9 @@ "name": "@coveo/atomic-stencil-samples", "version": "0.0.0", "dependencies": { - "@coveo/atomic": "3.1.1", - "@coveo/headless": "3.0.0", + "@coveo/atomic": "3.2.3", + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3", "@stencil/core": "4.20.0", "stencil-router-v2": "0.6.0" }, @@ -61852,7 +62470,7 @@ "name": "@coveo/atomic-vuejs-samples", "version": "0.0.0", "dependencies": { - "@coveo/atomic": "3.1.1", + "@coveo/atomic": "3.2.3", "vue": "^3.4.15" }, "devDependencies": { diff --git a/packages/atomic-angular/package.json b/packages/atomic-angular/package.json index 1724aab8d20..8189d0e5cef 100644 --- a/packages/atomic-angular/package.json +++ b/packages/atomic-angular/package.json @@ -20,17 +20,17 @@ "@angular/platform-browser": "17.3.12", "@angular/platform-browser-dynamic": "17.3.12", "@angular/router": "17.3.12", - "@coveo/atomic": "3.1.1", + "@coveo/atomic": "3.2.3", "rxjs": "7.8.1" }, "peerDependencies": { - "@coveo/headless": "3.0.0" + "@coveo/headless": "3.1.3" }, "devDependencies": { "@angular-devkit/build-angular": "17.3.9", "@angular/cli": "17.3.9", "@angular/compiler-cli": "17.3.12", - "@coveo/headless": "3.0.0", + "@coveo/headless": "3.1.3", "@types/node": "20.14.12", "jasmine-core": "5.2.0", "karma": "6.4.3", diff --git a/packages/atomic-angular/projects/atomic-angular/CHANGELOG.md b/packages/atomic-angular/projects/atomic-angular/CHANGELOG.md index 0fee5f31241..8f76c184370 100644 --- a/packages/atomic-angular/projects/atomic-angular/CHANGELOG.md +++ b/packages/atomic-angular/projects/atomic-angular/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.1.0 (2024-09-24) + +- feat(atomic): add tab support for atomic-generated-answer (#4285) ([744fb61](https://github.com/coveo/ui-kit/commits/744fb61)), closes [#4285](https://github.com/coveo/ui-kit/issues/4285) +- feat(atomic): atomic insight user actions toggle component created (#4298) ([bad4ff5](https://github.com/coveo/ui-kit/commits/bad4ff5)), closes [#4298](https://github.com/coveo/ui-kit/issues/4298) + ## 3.0.0 (2024-09-18) - chore!: update node engine definition in all exported packages (#4330) ([d6d8a1a](https://github.com/coveo/ui-kit/commits/d6d8a1a)), closes [#4330](https://github.com/coveo/ui-kit/issues/4330) diff --git a/packages/atomic-angular/projects/atomic-angular/package.json b/packages/atomic-angular/projects/atomic-angular/package.json index 298c7411e44..85739caa6dc 100644 --- a/packages/atomic-angular/projects/atomic-angular/package.json +++ b/packages/atomic-angular/projects/atomic-angular/package.json @@ -1,6 +1,6 @@ { "name": "@coveo/atomic-angular", - "version": "3.0.2", + "version": "3.1.3", "license": "Apache-2.0", "repository": { "url": "https://github.com/coveo/ui-kit" @@ -8,10 +8,10 @@ "peerDependencies": { "@angular/common": "14 - 17", "@angular/core": "14 - 17", - "@coveo/headless": "3.0.0" + "@coveo/headless": "3.1.3" }, "dependencies": { - "@coveo/atomic": "3.1.1", + "@coveo/atomic": "3.2.3", "tslib": "2.6.3" }, "engines": { diff --git a/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/atomic-angular.module.ts b/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/atomic-angular.module.ts index c90fe40ecff..f523722e45a 100644 --- a/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/atomic-angular.module.ts +++ b/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/atomic-angular.module.ts @@ -51,7 +51,6 @@ AtomicFormatUnit, AtomicGeneratedAnswer, AtomicHtml, AtomicIcon, -AtomicInsightUserActionsTimeline, AtomicLayoutSection, AtomicLoadMoreResults, AtomicNoResults, @@ -195,7 +194,6 @@ AtomicFormatUnit, AtomicGeneratedAnswer, AtomicHtml, AtomicIcon, -AtomicInsightUserActionsTimeline, AtomicLayoutSection, AtomicLoadMoreResults, AtomicNoResults, diff --git a/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/components.ts b/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/components.ts index 12a188fcfa8..d57c6c8a5c9 100644 --- a/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/components.ts +++ b/packages/atomic-angular/projects/atomic-angular/src/lib/stencil-generated/components.ts @@ -984,14 +984,14 @@ export declare interface AtomicFormatUnit extends Components.AtomicFormatUnit {} @ProxyCmp({ - inputs: ['collapsible', 'withToggle'] + inputs: ['collapsible', 'tabsExcluded', 'tabsIncluded', 'withToggle'] }) @Component({ selector: 'atomic-generated-answer', changeDetection: ChangeDetectionStrategy.OnPush, template: '', // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property - inputs: ['collapsible', 'withToggle'], + inputs: ['collapsible', 'tabsExcluded', 'tabsIncluded', 'withToggle'], }) export class AtomicGeneratedAnswer { protected el: HTMLElement; @@ -1049,28 +1049,6 @@ export class AtomicIcon { export declare interface AtomicIcon extends Components.AtomicIcon {} -@ProxyCmp({ - inputs: ['ticketCreationDateTime', 'userId'] -}) -@Component({ - selector: 'atomic-insight-user-actions-timeline', - changeDetection: ChangeDetectionStrategy.OnPush, - template: '', - // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property - inputs: ['ticketCreationDateTime', 'userId'], -}) -export class AtomicInsightUserActionsTimeline { - protected el: HTMLElement; - constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) { - c.detach(); - this.el = r.nativeElement; - } -} - - -export declare interface AtomicInsightUserActionsTimeline extends Components.AtomicInsightUserActionsTimeline {} - - @ProxyCmp({ inputs: ['maxWidth', 'minWidth', 'section'] }) diff --git a/packages/atomic-hosted-page/package.json b/packages/atomic-hosted-page/package.json index 4948c30cbc9..5eb4fb78187 100644 --- a/packages/atomic-hosted-page/package.json +++ b/packages/atomic-hosted-page/package.json @@ -1,7 +1,7 @@ { "name": "@coveo/atomic-hosted-page", "description": "Web Component used to inject a Coveo Hosted Search Page in the DOM.", - "version": "1.0.0", + "version": "1.0.4", "repository": { "type": "git", "url": "git+https://github.com/coveo/ui-kit.git", @@ -30,8 +30,8 @@ "promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest" }, "dependencies": { - "@coveo/bueno": "1.0.0", - "@coveo/headless": "3.0.0", + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3", "@stencil/core": "4.20.0" }, "devDependencies": { diff --git a/packages/atomic-react/CHANGELOG.md b/packages/atomic-react/CHANGELOG.md index c000123f70a..ec24eb5e323 100644 --- a/packages/atomic-react/CHANGELOG.md +++ b/packages/atomic-react/CHANGELOG.md @@ -1,3 +1,14 @@ +## 3.1.1 (2024-09-24) + +- docs: document headless, atomic, and atomic-react entry points (#4455) ([3853bdc](https://github.com/coveo/ui-kit/commits/3853bdc)), closes [#4455](https://github.com/coveo/ui-kit/issues/4455) + +## 3.1.0 (2024-09-24) + +- chore(atomic, headless): make bueno external (#4433) ([e1f7f2d](https://github.com/coveo/ui-kit/commits/e1f7f2d)), closes [#4433](https://github.com/coveo/ui-kit/issues/4433) +- chore(headless,atomic): add type "module" to atomic, atomic-react and headless (#4442) ([21896c3](https://github.com/coveo/ui-kit/commits/21896c3)), closes [#4442](https://github.com/coveo/ui-kit/issues/4442) [/github.com/coveo/ui-kit/pull/4449/files#diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87](https://github.com//github.com/coveo/ui-kit/pull/4449/files/issues/diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87) +- feat(atomic): atomic insight user actions toggle component created (#4298) ([bad4ff5](https://github.com/coveo/ui-kit/commits/bad4ff5)), closes [#4298](https://github.com/coveo/ui-kit/issues/4298) +- docs(atomic-react): update examples in readme (#4432) ([037b2ca](https://github.com/coveo/ui-kit/commits/037b2ca)), closes [#4432](https://github.com/coveo/ui-kit/issues/4432) + ## 3.0.1 (2024-09-18) - fix(atomic, atomic-react): use root-relative URL for CDN (#4431) ([39313ea](https://github.com/coveo/ui-kit/commits/39313ea)), closes [#4431](https://github.com/coveo/ui-kit/issues/4431) diff --git a/packages/atomic-react/README.md b/packages/atomic-react/README.md index 2fcc1819c79..889123eba3e 100644 --- a/packages/atomic-react/README.md +++ b/packages/atomic-react/README.md @@ -24,6 +24,14 @@ Since Atomic React is built on top of the core [Atomic](https://docs.coveo.com/e However, there are still some special considerations. +## Entry points + +The `@coveo/atomic-react` package exposes the following entry points: + +- `@coveo/atomic-react`: exports the components and utilities for building non-commerce search interfaces with Atomic React. +- `@coveo/atomic-react/recommendation`: exports the components and utilities for building non-commerce recommendation interfaces with Atomic React. +- `@coveo/atomic-react/commerce`: exports the components and utilities for building commerce applications with Atomic React. + ## Static Assets - Languages and SVGs For performance reasons, the generated JavaScript bundle does not automatically include static assets that are loaded on demand. This impacts language support, as well as the use of included SVG icons. diff --git a/packages/atomic-react/package.json b/packages/atomic-react/package.json index ba02f726718..e6aa2ac4d07 100644 --- a/packages/atomic-react/package.json +++ b/packages/atomic-react/package.json @@ -1,7 +1,8 @@ { "name": "@coveo/atomic-react", "sideEffects": false, - "version": "3.0.2", + "type": "module", + "version": "3.1.3", "description": "React specific wrapper for the Atomic component library", "repository": { "type": "git", @@ -11,6 +12,7 @@ "scripts": { "build": "nx build", "clean": "rimraf -rf dist", + "build:fixGeneratedImportPaths": "fix-esm-import-path src/components/stencil-generated", "build:bundles:esm": "tsc -p tsconfig.esm.json", "build:bundles:iife-cjs": "rollup --config rollup.config.mjs --bundleConfigAsCjs", "build:bundles": "concurrently \"npm run build:bundles:esm\" \"npm run build:bundles:iife-cjs\"", @@ -19,7 +21,7 @@ "promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest", "build:assets": "ncp ../atomic/dist/atomic/assets dist/assets && ncp ../atomic/dist/atomic/lang dist/lang " }, - "main": "./dist/cjs/atomic-react.js", + "main": "./dist/cjs/atomic-react.cjs", "module": "./dist/index.js", "types": "./dist/index.d.ts", "files": [ @@ -28,11 +30,11 @@ "commerce/" ], "dependencies": { - "@coveo/atomic": "3.1.1" + "@coveo/atomic": "3.2.3" }, "devDependencies": { - "@coveo/rollup-plugin-replace-with-ast": "1.0.0", "@coveo/release": "1.0.0", + "@coveo/rollup-plugin-replace-with-ast": "1.0.0", "@rollup/plugin-commonjs": "^25.0.0", "@rollup/plugin-json": "6.1.0", "@rollup/plugin-node-resolve": "^15.0.0", @@ -42,6 +44,7 @@ "@types/node": "20.14.12", "@types/react": "18.3.3", "@types/react-dom": "18.3.0", + "fix-esm-import-path": "1.10.0", "ncp": "2.0.0", "react": "18.3.1", "react-dom": "18.3.1", @@ -49,7 +52,7 @@ "rollup-plugin-polyfill-node": "^0.13.0" }, "peerDependencies": { - "@coveo/headless": "3.0.0", + "@coveo/headless": "3.1.3", "react": ">=18.0.0", "react-dom": ">=18.0.0" }, @@ -60,17 +63,17 @@ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", - "require": "./dist/cjs/atomic-react.js" + "require": "./dist/cjs/atomic-react.cjs" }, "./commerce": { "types": "./dist/commerce.index.d.ts", "import": "./dist/commerce.index.js", - "require": "./dist/cjs/commerce/atomic-react.js" + "require": "./dist/cjs/commerce/atomic-react.cjs" }, "./recommendation": { "types": "./dist/recommendation.index.d.ts", "import": "./dist/recommendation.index.js", - "require": "./dist/cjs/recommendation/atomic-react.js" + "require": "./dist/cjs/recommendation/atomic-react.cjs" } } } diff --git a/packages/atomic-react/project.json b/packages/atomic-react/project.json index 5d391a98c5b..5af3ade9955 100644 --- a/packages/atomic-react/project.json +++ b/packages/atomic-react/project.json @@ -7,7 +7,11 @@ "dependsOn": ["^build", "clean"], "executor": "nx:run-commands", "options": { - "commands": ["npm run build:bundles", "npm run build:assets"], + "commands": [ + "npm run build:fixGeneratedImportPaths", + "npm run build:bundles", + "npm run build:assets" + ], "parallel": false, "cwd": "packages/atomic-react" } diff --git a/packages/atomic-react/rollup.config.mjs b/packages/atomic-react/rollup.config.mjs index 20e58942cdd..cc4e9596f95 100644 --- a/packages/atomic-react/rollup.config.mjs +++ b/packages/atomic-react/rollup.config.mjs @@ -52,9 +52,6 @@ const packageMappings = { '@coveo/headless/insight': { cdn: `/headless/${headlessVersion}/insight/headless.esm.js`, }, - '@coveo/headless/product-recommendation': { - cdn: `/headless/${headlessVersion}/product-recommendation/headless.esm.js`, - }, '@coveo/headless/recommendation': { cdn: `/headless/${headlessVersion}/recommendation/headless.esm.js`, }, @@ -97,7 +94,7 @@ const commonExternal = [ /** @returns {import('rollup').OutputOptions} */ const outputCJS = ({useCase}) => ({ - file: `dist/cjs/${useCase}atomic-react.js`, + file: `dist/cjs/${useCase}atomic-react.cjs`, format: 'cjs', }); diff --git a/packages/atomic-react/src/commerce.index.ts b/packages/atomic-react/src/commerce.index.ts index a0c1e37992f..59f141892c8 100644 --- a/packages/atomic-react/src/commerce.index.ts +++ b/packages/atomic-react/src/commerce.index.ts @@ -1 +1 @@ -export * from './components/commerce/index'; +export * from './components/commerce/index.js'; diff --git a/packages/atomic-react/src/components/commerce/CommerceInterfaceWrapper.tsx b/packages/atomic-react/src/components/commerce/CommerceInterfaceWrapper.tsx index d90dba7129d..c11375b142a 100644 --- a/packages/atomic-react/src/components/commerce/CommerceInterfaceWrapper.tsx +++ b/packages/atomic-react/src/components/commerce/CommerceInterfaceWrapper.tsx @@ -1,6 +1,6 @@ import type {JSX, i18n} from '@coveo/atomic'; import React, {useEffect, useRef} from 'react'; -import {AtomicCommerceInterface} from '../stencil-generated/commerce'; +import {AtomicCommerceInterface} from '../stencil-generated/commerce/index.js'; type ExecuteRequest = HTMLAtomicCommerceInterfaceElement['executeFirstRequest']; diff --git a/packages/atomic-react/src/components/commerce/CommerceProductListWrapper.tsx b/packages/atomic-react/src/components/commerce/CommerceProductListWrapper.tsx index 4769ae01562..b8cd37bac9a 100644 --- a/packages/atomic-react/src/components/commerce/CommerceProductListWrapper.tsx +++ b/packages/atomic-react/src/components/commerce/CommerceProductListWrapper.tsx @@ -6,7 +6,7 @@ import {renderToString} from 'react-dom/server'; import { AtomicCommerceProductList, AtomicProductLink, -} from '../stencil-generated/commerce'; +} from '../stencil-generated/commerce/index.js'; interface Template { contentTemplate: JSX.Element; diff --git a/packages/atomic-react/src/components/commerce/CommerceRecommendationListWrapper.tsx b/packages/atomic-react/src/components/commerce/CommerceRecommendationListWrapper.tsx index dd9b5de1d80..ee54bd59c5a 100644 --- a/packages/atomic-react/src/components/commerce/CommerceRecommendationListWrapper.tsx +++ b/packages/atomic-react/src/components/commerce/CommerceRecommendationListWrapper.tsx @@ -6,7 +6,7 @@ import {renderToString} from 'react-dom/server'; import { AtomicCommerceRecommendationList, AtomicProductLink, -} from '../stencil-generated/commerce'; +} from '../stencil-generated/commerce/index.js'; interface Template { contentTemplate: JSX.Element; diff --git a/packages/atomic-react/src/components/commerce/index.ts b/packages/atomic-react/src/components/commerce/index.ts index b05a05fe33a..f19c168d961 100644 --- a/packages/atomic-react/src/components/commerce/index.ts +++ b/packages/atomic-react/src/components/commerce/index.ts @@ -1,8 +1,8 @@ -export * from '../stencil-generated/commerce/index'; +export * from '../stencil-generated/commerce/index.js'; export {CommerceBindings, i18n} from '@coveo/atomic'; // Important: Re-exporting under the same name (eg: "AtomicCommerceInterface") shadows the original component // and should wrap it nicely for users of the library -export {InterfaceWrapper as AtomicCommerceInterface} from './CommerceInterfaceWrapper'; -export {ListWrapper as AtomicCommerceProductList} from './CommerceProductListWrapper'; -export {ListWrapper as AtomicCommerceRecommendationList} from './CommerceRecommendationListWrapper'; +export {InterfaceWrapper as AtomicCommerceInterface} from './CommerceInterfaceWrapper.js'; +export {ListWrapper as AtomicCommerceProductList} from './CommerceProductListWrapper.js'; +export {ListWrapper as AtomicCommerceRecommendationList} from './CommerceRecommendationListWrapper.js'; diff --git a/packages/atomic-react/src/components/recommendation/RecsInterfaceWrapper.tsx b/packages/atomic-react/src/components/recommendation/RecsInterfaceWrapper.tsx index 90978b630ee..b7db822b74a 100644 --- a/packages/atomic-react/src/components/recommendation/RecsInterfaceWrapper.tsx +++ b/packages/atomic-react/src/components/recommendation/RecsInterfaceWrapper.tsx @@ -4,7 +4,7 @@ import { buildRecommendationEngine, } from '@coveo/headless/recommendation'; import React, {useEffect, useRef} from 'react'; -import {AtomicRecsInterface} from '../stencil-generated/search'; +import {AtomicRecsInterface} from '../stencil-generated/search/index.js'; type GetRecommendations = HTMLAtomicRecsInterfaceElement['getRecommendations']; /** diff --git a/packages/atomic-react/src/components/recommendation/RecsListWrapper.tsx b/packages/atomic-react/src/components/recommendation/RecsListWrapper.tsx index 21f610cae81..1cca9001acd 100644 --- a/packages/atomic-react/src/components/recommendation/RecsListWrapper.tsx +++ b/packages/atomic-react/src/components/recommendation/RecsListWrapper.tsx @@ -3,7 +3,10 @@ import type {Result} from '@coveo/headless/recommendation'; import React, {useEffect, useRef} from 'react'; import {createRoot} from 'react-dom/client'; import {renderToString} from 'react-dom/server'; -import {AtomicRecsList, AtomicResultLink} from '../stencil-generated/search'; +import { + AtomicRecsList, + AtomicResultLink, +} from '../stencil-generated/search/index.js'; interface Template { contentTemplate: JSX.Element; diff --git a/packages/atomic-react/src/components/recommendation/index.ts b/packages/atomic-react/src/components/recommendation/index.ts index 6bf52b067d2..f958aeaa3d2 100644 --- a/packages/atomic-react/src/components/recommendation/index.ts +++ b/packages/atomic-react/src/components/recommendation/index.ts @@ -1,7 +1,7 @@ -export * from '../stencil-generated/search'; +export * from '../stencil-generated/search/index.js'; export {RecsBindings, i18n} from '@coveo/atomic'; // Important: Re-exporting under the same name (eg: "AtomicRecsInterface") shadows the original component // and should wrap it nicely for users of the library -export {RecsInterfaceWrapper as AtomicRecsInterface} from './RecsInterfaceWrapper'; -export {RecsListWrapper as AtomicRecsList} from './RecsListWrapper'; +export {RecsInterfaceWrapper as AtomicRecsInterface} from './RecsInterfaceWrapper.js'; +export {RecsListWrapper as AtomicRecsList} from './RecsListWrapper.js'; diff --git a/packages/atomic-react/src/components/search/FoldedResultListWrapper.tsx b/packages/atomic-react/src/components/search/FoldedResultListWrapper.tsx index 1a1ba555200..a67ef7af48f 100644 --- a/packages/atomic-react/src/components/search/FoldedResultListWrapper.tsx +++ b/packages/atomic-react/src/components/search/FoldedResultListWrapper.tsx @@ -3,7 +3,7 @@ import type {FoldedResult} from '@coveo/headless'; import React, {useEffect, useRef} from 'react'; import {createRoot} from 'react-dom/client'; import {renderToString} from 'react-dom/server'; -import {AtomicFoldedResultList} from '../stencil-generated/search'; +import {AtomicFoldedResultList} from '../stencil-generated/search/index.js'; /** * The properties of the AtomicFoldedResultList component diff --git a/packages/atomic-react/src/components/search/ResultListWrapper.tsx b/packages/atomic-react/src/components/search/ResultListWrapper.tsx index 183c1489a04..a678a38ada4 100644 --- a/packages/atomic-react/src/components/search/ResultListWrapper.tsx +++ b/packages/atomic-react/src/components/search/ResultListWrapper.tsx @@ -3,7 +3,10 @@ import type {Result} from '@coveo/headless'; import React, {useEffect, useRef} from 'react'; import {createRoot} from 'react-dom/client'; import {renderToString} from 'react-dom/server'; -import {AtomicResultLink, AtomicResultList} from '../stencil-generated/search'; +import { + AtomicResultLink, + AtomicResultList, +} from '../stencil-generated/search/index.js'; interface Template { contentTemplate: JSX.Element; diff --git a/packages/atomic-react/src/components/search/SearchBoxInstantResultsWrapper.tsx b/packages/atomic-react/src/components/search/SearchBoxInstantResultsWrapper.tsx index b35912589d4..61ee79a7142 100644 --- a/packages/atomic-react/src/components/search/SearchBoxInstantResultsWrapper.tsx +++ b/packages/atomic-react/src/components/search/SearchBoxInstantResultsWrapper.tsx @@ -3,7 +3,7 @@ import type {FoldedResult, Result} from '@coveo/headless'; import React, {useEffect, useRef} from 'react'; import {createRoot} from 'react-dom/client'; import {renderToString} from 'react-dom/server'; -import {AtomicSearchBoxInstantResults} from '../stencil-generated/search'; +import {AtomicSearchBoxInstantResults} from '../stencil-generated/search/index.js'; /** * The properties of the AtomicSearchBoxInstantResults component diff --git a/packages/atomic-react/src/components/search/SearchInterfaceWrapper.tsx b/packages/atomic-react/src/components/search/SearchInterfaceWrapper.tsx index 24be32f5e7a..fe28754930a 100644 --- a/packages/atomic-react/src/components/search/SearchInterfaceWrapper.tsx +++ b/packages/atomic-react/src/components/search/SearchInterfaceWrapper.tsx @@ -4,7 +4,7 @@ import { getSampleSearchEngineConfiguration, } from '@coveo/headless'; import React, {useEffect, useRef} from 'react'; -import {AtomicSearchInterface} from '../stencil-generated/search'; +import {AtomicSearchInterface} from '../stencil-generated/search/index.js'; type ExecuteSearch = HTMLAtomicSearchInterfaceElement['executeFirstSearch']; /** diff --git a/packages/atomic-react/src/components/search/index.ts b/packages/atomic-react/src/components/search/index.ts index 4972d7bb5c2..6f8c73831f7 100644 --- a/packages/atomic-react/src/components/search/index.ts +++ b/packages/atomic-react/src/components/search/index.ts @@ -1,9 +1,9 @@ -export * from '../stencil-generated/search/index'; +export * from '../stencil-generated/search/index.js'; export {Bindings, i18n} from '@coveo/atomic'; // Important: Re-exporting under the same name (eg: "AtomicSearchInterface") shadows the original component // and should wrap it nicely for users of the library -export {SearchInterfaceWrapper as AtomicSearchInterface} from './SearchInterfaceWrapper'; -export {ResultListWrapper as AtomicResultList} from './ResultListWrapper'; -export {FoldedResultListWrapper as AtomicFoldedResultList} from './FoldedResultListWrapper'; -export {SearchBoxInstantResultsWrapper as AtomicSearchBoxInstantResults} from './SearchBoxInstantResultsWrapper'; +export {SearchInterfaceWrapper as AtomicSearchInterface} from './SearchInterfaceWrapper.js'; +export {ResultListWrapper as AtomicResultList} from './ResultListWrapper.js'; +export {FoldedResultListWrapper as AtomicFoldedResultList} from './FoldedResultListWrapper.js'; +export {SearchBoxInstantResultsWrapper as AtomicSearchBoxInstantResults} from './SearchBoxInstantResultsWrapper.js'; diff --git a/packages/atomic-react/src/components/stencil-generated/commerce/index.ts b/packages/atomic-react/src/components/stencil-generated/commerce/index.ts index 36191fb6a57..1d1213dc90c 100644 --- a/packages/atomic-react/src/components/stencil-generated/commerce/index.ts +++ b/packages/atomic-react/src/components/stencil-generated/commerce/index.ts @@ -1,7 +1,7 @@ /* eslint-disable */ /* tslint:disable */ /* auto-generated react proxies */ -import { createReactComponent } from './react-component-lib'; +import { createReactComponent } from './react-component-lib/index.js'; import type { JSX } from '@coveo/atomic'; @@ -36,7 +36,6 @@ export const AtomicCommerceSortDropdown = /*@__PURE__*/createReactComponent('atomic-commerce-text'); export const AtomicCommerceTimeframeFacet = /*@__PURE__*/createReactComponent('atomic-commerce-timeframe-facet'); export const AtomicIcon = /*@__PURE__*/createReactComponent('atomic-icon'); -export const AtomicInsightUserActionsTimeline = /*@__PURE__*/createReactComponent('atomic-insight-user-actions-timeline'); export const AtomicLayoutSection = /*@__PURE__*/createReactComponent('atomic-layout-section'); export const AtomicNumericRange = /*@__PURE__*/createReactComponent('atomic-numeric-range'); export const AtomicProduct = /*@__PURE__*/createReactComponent('atomic-product'); diff --git a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createComponent.tsx b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createComponent.tsx index 7c7415a29d8..7e1d1ef7dbb 100644 --- a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createComponent.tsx +++ b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createComponent.tsx @@ -1,6 +1,6 @@ import React, { createElement } from 'react'; -import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils'; +import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils/index.js'; export interface HTMLStencilElement extends HTMLElement { componentOnReady(): Promise; diff --git a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createOverlayComponent.tsx b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createOverlayComponent.tsx index 288c38dd54c..f491c5927c9 100644 --- a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createOverlayComponent.tsx +++ b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/createOverlayComponent.tsx @@ -1,8 +1,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { OverlayEventDetail } from './interfaces'; -import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils'; +import { OverlayEventDetail } from './interfaces.js'; +import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils/index.js'; interface OverlayElement extends HTMLElement { present: () => Promise; diff --git a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/index.ts b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/index.ts index 85e81ad196c..611f53c9483 100644 --- a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/index.ts +++ b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/index.ts @@ -1,2 +1,2 @@ -export { createReactComponent } from './createComponent'; -export { createOverlayComponent } from './createOverlayComponent'; +export { createReactComponent } from './createComponent.js'; +export { createOverlayComponent } from './createOverlayComponent.js'; diff --git a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/attachProps.ts b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/attachProps.ts index 9a1825f54f3..b67b5f36f08 100644 --- a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/attachProps.ts +++ b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/attachProps.ts @@ -1,4 +1,4 @@ -import { camelToDashCase } from './case'; +import { camelToDashCase } from './case.js'; export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => { // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first diff --git a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/index.tsx b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/index.tsx index a66bd02de76..9ed0c12fd49 100644 --- a/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/index.tsx +++ b/packages/atomic-react/src/components/stencil-generated/commerce/react-component-lib/utils/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import type { StyleReactProps } from '../interfaces'; +import type { StyleReactProps } from '../interfaces.js'; export type StencilReactExternalProps = PropType & Omit, 'style'> & @@ -46,5 +46,5 @@ export const defineCustomElement = (tagName: string, customElement: any) => { } }; -export * from './attachProps'; -export * from './case'; +export * from './attachProps.js'; +export * from './case.js'; diff --git a/packages/atomic-react/src/components/stencil-generated/search/index.ts b/packages/atomic-react/src/components/stencil-generated/search/index.ts index 7e8c8dcb455..a70b162825e 100644 --- a/packages/atomic-react/src/components/stencil-generated/search/index.ts +++ b/packages/atomic-react/src/components/stencil-generated/search/index.ts @@ -1,7 +1,7 @@ /* eslint-disable */ /* tslint:disable */ /* auto-generated react proxies */ -import { createReactComponent } from './react-component-lib'; +import { createReactComponent } from './react-component-lib/index.js'; import type { JSX } from '@coveo/atomic'; @@ -26,7 +26,6 @@ export const AtomicFormatUnit = /*@__PURE__*/createReactComponent('atomic-generated-answer'); export const AtomicHtml = /*@__PURE__*/createReactComponent('atomic-html'); export const AtomicIcon = /*@__PURE__*/createReactComponent('atomic-icon'); -export const AtomicInsightUserActionsTimeline = /*@__PURE__*/createReactComponent('atomic-insight-user-actions-timeline'); export const AtomicLayoutSection = /*@__PURE__*/createReactComponent('atomic-layout-section'); export const AtomicLoadMoreResults = /*@__PURE__*/createReactComponent('atomic-load-more-results'); export const AtomicNoResults = /*@__PURE__*/createReactComponent('atomic-no-results'); diff --git a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createComponent.tsx b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createComponent.tsx index 7c7415a29d8..7e1d1ef7dbb 100644 --- a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createComponent.tsx +++ b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createComponent.tsx @@ -1,6 +1,6 @@ import React, { createElement } from 'react'; -import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils'; +import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils/index.js'; export interface HTMLStencilElement extends HTMLElement { componentOnReady(): Promise; diff --git a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createOverlayComponent.tsx b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createOverlayComponent.tsx index 288c38dd54c..f491c5927c9 100644 --- a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createOverlayComponent.tsx +++ b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/createOverlayComponent.tsx @@ -1,8 +1,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { OverlayEventDetail } from './interfaces'; -import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils'; +import { OverlayEventDetail } from './interfaces.js'; +import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils/index.js'; interface OverlayElement extends HTMLElement { present: () => Promise; diff --git a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/index.ts b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/index.ts index 85e81ad196c..611f53c9483 100644 --- a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/index.ts +++ b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/index.ts @@ -1,2 +1,2 @@ -export { createReactComponent } from './createComponent'; -export { createOverlayComponent } from './createOverlayComponent'; +export { createReactComponent } from './createComponent.js'; +export { createOverlayComponent } from './createOverlayComponent.js'; diff --git a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/attachProps.ts b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/attachProps.ts index 9a1825f54f3..b67b5f36f08 100644 --- a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/attachProps.ts +++ b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/attachProps.ts @@ -1,4 +1,4 @@ -import { camelToDashCase } from './case'; +import { camelToDashCase } from './case.js'; export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => { // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first diff --git a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/index.tsx b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/index.tsx index a66bd02de76..9ed0c12fd49 100644 --- a/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/index.tsx +++ b/packages/atomic-react/src/components/stencil-generated/search/react-component-lib/utils/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import type { StyleReactProps } from '../interfaces'; +import type { StyleReactProps } from '../interfaces.js'; export type StencilReactExternalProps = PropType & Omit, 'style'> & @@ -46,5 +46,5 @@ export const defineCustomElement = (tagName: string, customElement: any) => { } }; -export * from './attachProps'; -export * from './case'; +export * from './attachProps.js'; +export * from './case.js'; diff --git a/packages/atomic-react/src/index.ts b/packages/atomic-react/src/index.ts index 6ff5bae67ba..e47c98de44d 100644 --- a/packages/atomic-react/src/index.ts +++ b/packages/atomic-react/src/index.ts @@ -1 +1 @@ -export * from './components/search'; +export * from './components/search/index.js'; diff --git a/packages/atomic-react/src/recommendation.index.ts b/packages/atomic-react/src/recommendation.index.ts index 2455d463adc..277cd823808 100644 --- a/packages/atomic-react/src/recommendation.index.ts +++ b/packages/atomic-react/src/recommendation.index.ts @@ -1 +1 @@ -export * from './components/recommendation'; +export * from './components/recommendation/index.js'; diff --git a/packages/atomic/.eslintrc.js b/packages/atomic/.eslintrc.cjs similarity index 100% rename from packages/atomic/.eslintrc.js rename to packages/atomic/.eslintrc.cjs diff --git a/packages/atomic/.storybook/main.mts b/packages/atomic/.storybook/main.mts index 5d0e5e60ef5..91c3af17e60 100644 --- a/packages/atomic/.storybook/main.mts +++ b/packages/atomic/.storybook/main.mts @@ -1,14 +1,45 @@ import {nxViteTsPaths} from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; import type {StorybookConfig} from '@storybook/web-components-vite'; -import path from 'node:path'; +import path from 'path'; +import {PluginImpl} from 'rollup'; import {mergeConfig} from 'vite'; -import headlessJson from '../../../packages/headless/package.json'; +import {generateExternalPackageMappings} from '../scripts/externalPackageMappings'; +const externalizeDependencies: PluginImpl = () => { + return { + name: 'externalize-dependencies', + enforce: 'pre', + resolveId(source, _importer, _options) { + if (/^\/(headless|bueno)/.test(source)) { + return false; + } + + const packageMappings = generateExternalPackageMappings(__dirname); + const packageMapping = packageMappings[source]; + + if (packageMapping) { + if (!isCDN) { + return false; + } + + return { + id: packageMapping.cdn, + external: 'absolute', + }; + } + + return null; + }, + }; +}; const isCDN = process.env.DEPLOYMENT_ENVIRONMENT === 'CDN'; const config: StorybookConfig = { stories: ['../src/**/*.new.stories.@(js|jsx|ts|tsx|mdx)'], - staticDirs: [{from: '../dist/atomic', to: './assets'}], + staticDirs: [ + {from: '../dist/atomic', to: './assets'}, + {from: '../dist/atomic/lang', to: './lang'}, + ], addons: [ '@storybook/addon-essentials', '@storybook/addon-interactions', @@ -24,87 +55,28 @@ const config: StorybookConfig = { mergeConfig(config, { plugins: [ nxViteTsPaths(), + resolveStorybookUtils(), configType === 'PRODUCTION' && isCDN && externalizeDependencies(), ], }), }; -function externalizeDependencies() { +const resolveStorybookUtils: PluginImpl = () => { return { - name: 'externalize-dependencies', - enforce: 'pre', - resolveId: (id: string) => { - if (id.startsWith('/headless')) { - return false; - } - if (packageMappings[id]) { - if (!isCDN) { - return false; - } - - return { - id: packageMappings[id].cdn, - external: 'absolute', - }; + name: 'resolve-storybook-utils', + async resolveId(source: string, importer, options) { + if (source.startsWith('@coveo/atomic-storybook-utils')) { + return this.resolve( + source.replace( + '@coveo/atomic-storybook-utils', + path.resolve(__dirname, '../storybookUtils') + ), + importer, + options + ); } }, }; -} - -let headlessVersion: string; -if (isCDN) { - console.log('Building for CDN'); - headlessVersion = 'v' + headlessJson.version; -} - -const packageMappings: {[key: string]: {devWatch: string; cdn: string}} = { - '@coveo/headless/commerce': { - devWatch: path.resolve( - __dirname, - '../src/external-builds/commerce/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/commerce/headless.esm.js`, - }, - '@coveo/headless/insight': { - devWatch: path.resolve( - __dirname, - '../src/external-builds/insight/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/insight/headless.esm.js`, - }, - '@coveo/headless/product-recommendation': { - devWatch: path.resolve( - __dirname, - '../src/external-builds/product-recommendation/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/product-recommendation/headless.esm.js`, - }, - '@coveo/headless/recommendation': { - devWatch: path.resolve( - __dirname, - '../src/external-builds/recommendation/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/recommendation/headless.esm.js`, - }, - '@coveo/headless/case-assist': { - devWatch: path.resolve( - __dirname, - '../src/external-builds/case-assist/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/case-assist/headless.esm.js`, - }, - '@coveo/headless': { - devWatch: path.resolve(__dirname, '../src/external-builds/headless.esm.js'), - cdn: `/headless/${headlessVersion}/headless.esm.js`, - }, - /* '@coveo/bueno': { - devWatch: path.resolve(__dirname, './src/external-builds/bueno.esm.js'), - cdn: `/bueno/${headlessVersion}/bueno.esm.js`, - }, */ }; export default config; - -// To customize your Vite configuration you can use the viteFinal field. -// Check https://storybook.js.org/docs/react/builders/vite#configuration -// and https://nx.dev/recipes/storybook/custom-builder-configs diff --git a/packages/atomic/.storybook/preview.ts b/packages/atomic/.storybook/preview.ts index 91e4a18d94f..c34f863eca3 100644 --- a/packages/atomic/.storybook/preview.ts +++ b/packages/atomic/.storybook/preview.ts @@ -1,7 +1,7 @@ -import '@coveo/atomic/dist/atomic/atomic.esm.js'; -import '@coveo/atomic/dist/atomic/themes/coveo.css'; +import '@coveo/atomic/themes/coveo.css'; import {setCustomElementsManifest} from '@storybook/web-components'; import customElements from '../custom-elements.json'; +import '../dist/atomic/atomic.esm.js'; setCustomElementsManifest(customElements); diff --git a/packages/atomic/CHANGELOG.md b/packages/atomic/CHANGELOG.md index 51d198be6ab..dc1b64a16ac 100644 --- a/packages/atomic/CHANGELOG.md +++ b/packages/atomic/CHANGELOG.md @@ -1,3 +1,25 @@ +## 3.2.3 (2024-09-25) + +- chore(atomic): fix tsconfig resolution for the e2e folders (#4462) ([2a037ff](https://github.com/coveo/ui-kit/commits/2a037ff)), closes [#4462](https://github.com/coveo/ui-kit/issues/4462) + +## 3.2.1 (2024-09-24) + +- docs: document headless, atomic, and atomic-react entry points (#4455) ([3853bdc](https://github.com/coveo/ui-kit/commits/3853bdc)), closes [#4455](https://github.com/coveo/ui-kit/issues/4455) +- fix: use correct pjson for bueno version replacement (#4454) ([bab0883](https://github.com/coveo/ui-kit/commits/bab0883)), closes [#4454](https://github.com/coveo/ui-kit/issues/4454) + +## 3.2.0 (2024-09-24) + +- chore(atomic, headless): make bueno external (#4433) ([e1f7f2d](https://github.com/coveo/ui-kit/commits/e1f7f2d)), closes [#4433](https://github.com/coveo/ui-kit/issues/4433) +- chore(headless,atomic): add type "module" to atomic, atomic-react and headless (#4442) ([21896c3](https://github.com/coveo/ui-kit/commits/21896c3)), closes [#4442](https://github.com/coveo/ui-kit/issues/4442) [/github.com/coveo/ui-kit/pull/4449/files#diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87](https://github.com//github.com/coveo/ui-kit/pull/4449/files/issues/diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87) +- feat: add answer configuration id to atomic-insight-generated-answer (#4451) ([6b7c2bd](https://github.com/coveo/ui-kit/commits/6b7c2bd)), closes [#4451](https://github.com/coveo/ui-kit/issues/4451) +- feat(atomic): add tab support for atomic-generated-answer (#4285) ([744fb61](https://github.com/coveo/ui-kit/commits/744fb61)), closes [#4285](https://github.com/coveo/ui-kit/issues/4285) +- feat(atomic): atomic insight user actions toggle component created (#4298) ([bad4ff5](https://github.com/coveo/ui-kit/commits/bad4ff5)), closes [#4298](https://github.com/coveo/ui-kit/issues/4298) +- test(atomic): add tests for atomic-product-rating (#4440) ([498beff](https://github.com/coveo/ui-kit/commits/498beff)), closes [#4440](https://github.com/coveo/ui-kit/issues/4440) +- test(atomic): add tests for product link (#4203) ([b62f3c7](https://github.com/coveo/ui-kit/commits/b62f3c7)), closes [#4203](https://github.com/coveo/ui-kit/issues/4203) +- fix(atomic): bad search box layout when removing textarea prop (#4435) ([70d9378](https://github.com/coveo/ui-kit/commits/70d9378)), closes [#4435](https://github.com/coveo/ui-kit/issues/4435) +- fix(atomic): enable/disable facet based on tab with updateActiveTab action (#4313) ([08fe92a](https://github.com/coveo/ui-kit/commits/08fe92a)), closes [#4313](https://github.com/coveo/ui-kit/issues/4313) [#4311](https://github.com/coveo/ui-kit/issues/4311) +- fix(atomic): remove unnecessary css (#4397) ([1ee2897](https://github.com/coveo/ui-kit/commits/1ee2897)), closes [#4397](https://github.com/coveo/ui-kit/issues/4397) + ## 3.1.1 (2024-09-18) - chore: ensure absolute paths are not resolved as local when building for the CDN (#4434) ([b9ee6e1](https://github.com/coveo/ui-kit/commits/b9ee6e1)), closes [#4434](https://github.com/coveo/ui-kit/issues/4434) diff --git a/packages/atomic/README.md b/packages/atomic/README.md index 61813c5622a..c2334b43922 100644 --- a/packages/atomic/README.md +++ b/packages/atomic/README.md @@ -7,6 +7,16 @@ A web-component library for building modern UIs interfacing with the Coveo platf Using the library: [Coveo Atomic Library Official Documentation](https://docs.coveo.com/en/atomic/latest/). +## Entry points + +The `@coveo/atomic` package exposes the following entry points: + +- `@coveo/atomic`: exports various types and utilities used by Coveo Atomic. +- `@coveo/atomic/loader`: exports the Coveo Atomic components types, as well as the `defineCustomElements` and `setNonce` utilities. +- `@coveo/atomic/themes`: exports the sample Coveo Atomic themes. +- `@coveo/atomic/assets`: exports the SVG icons used by Coveo Atomic. +- `@coveo/atomic/lang`: exports the localization files used by Coveo Atomic. + ## Getting Started Once you have cloned the repo, follow the instructions in the top-level [README.md](../../README.md) to install dependencies and link packages. diff --git a/packages/atomic/cypress-hsp.config.ts b/packages/atomic/cypress-hsp.config.mjs similarity index 88% rename from packages/atomic/cypress-hsp.config.ts rename to packages/atomic/cypress-hsp.config.mjs index 7700f6e7a69..3e11bf69477 100644 --- a/packages/atomic/cypress-hsp.config.ts +++ b/packages/atomic/cypress-hsp.config.mjs @@ -1,4 +1,5 @@ import {defineConfig} from 'cypress'; +import plugin from './cypress/plugins/index.js'; export default defineConfig({ projectId: '5ph2j4', @@ -21,7 +22,7 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { - return require('./cypress/plugins/index.js')(on, config); + return plugin(on, config); }, baseUrl: 'http://localhost:3333', specPattern: 'cypress/integration-hsp/**/*.cypress.ts', diff --git a/packages/atomic/cypress-insight-panel.config.ts b/packages/atomic/cypress-insight-panel.config.mjs similarity index 89% rename from packages/atomic/cypress-insight-panel.config.ts rename to packages/atomic/cypress-insight-panel.config.mjs index 7e50c0c0343..308861318ef 100644 --- a/packages/atomic/cypress-insight-panel.config.ts +++ b/packages/atomic/cypress-insight-panel.config.mjs @@ -1,4 +1,5 @@ import {defineConfig} from 'cypress'; +import plugin from './cypress/plugins/index.js'; export default defineConfig({ projectId: '5ph2j4', @@ -21,7 +22,7 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { - return require('./cypress/plugins/index.js')(on, config); + return plugin(on, config); }, baseUrl: 'http://localhost:3333', specPattern: 'cypress/integration-insight-panel/**/*.cypress.ts', diff --git a/packages/atomic/cypress-screenshots.config.ts b/packages/atomic/cypress-screenshots.config.mjs similarity index 89% rename from packages/atomic/cypress-screenshots.config.ts rename to packages/atomic/cypress-screenshots.config.mjs index 675813955a5..b026a1183fb 100644 --- a/packages/atomic/cypress-screenshots.config.ts +++ b/packages/atomic/cypress-screenshots.config.mjs @@ -1,4 +1,5 @@ import {defineConfig} from 'cypress'; +import plugin from './cypress/plugins/index.js'; export default defineConfig({ projectId: '5ph2j4', @@ -21,7 +22,7 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { - return require('./cypress/plugins/index.js')(on, config); + return plugin(on, config); }, baseUrl: 'http://localhost:3333', specPattern: 'cypress/integration-screenshots/**/*.cypress.ts', diff --git a/packages/atomic/cypress.config.ts b/packages/atomic/cypress.config.mjs similarity index 88% rename from packages/atomic/cypress.config.ts rename to packages/atomic/cypress.config.mjs index 31fc03d189f..4f8e8844f4f 100644 --- a/packages/atomic/cypress.config.ts +++ b/packages/atomic/cypress.config.mjs @@ -1,4 +1,5 @@ import {defineConfig} from 'cypress'; +import plugin from './cypress/plugins/index.js'; export default defineConfig({ projectId: '5ph2j4', @@ -21,7 +22,7 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { - return require('./cypress/plugins/index.js')(on, config); + return plugin(on, config); }, baseUrl: 'http://localhost:3333', specPattern: 'cypress/e2e/**/*.cypress.ts', diff --git a/packages/atomic/cypress/e2e/external.cypress.ts b/packages/atomic/cypress/e2e/external.cypress.ts deleted file mode 100644 index 96f5508e53a..00000000000 --- a/packages/atomic/cypress/e2e/external.cypress.ts +++ /dev/null @@ -1,40 +0,0 @@ -import {RouteAlias, setupIntercept} from '../fixtures/fixture-common'; - -// TODO: https://coveord.atlassian.net/browse/KIT-3540 - rewrite in playwright -describe.skip('External Test Suite', () => { - describe('when modifying state of a component (search box) that is a child of an atomic-external component', () => { - beforeEach(() => { - setupIntercept(); - cy.visit('examples/external.html'); - cy.wait(RouteAlias.UA); - cy.wait(RouteAlias.UA); - - cy.get('atomic-external > atomic-search-box') - .shadow() - .find('[part="textarea"]') - .type('hello{enter}'); - cy.wait(RouteAlias.UA); - }); - - it("other components' state under the same atomic-external should be affected", () => { - cy.get('atomic-external > atomic-query-summary') - .shadow() - .invoke('text') - .should('contain', 'hello'); - }); - - it("other components' state under the linked atomic-search-interface should be affected", () => { - cy.get('atomic-search-interface#interface-2 > atomic-query-summary') - .shadow() - .invoke('text') - .should('contain', 'hello'); - }); - - it("other components' state under a different atomic-search-interface should not be affected", () => { - cy.get('atomic-search-interface#interface-1 > atomic-query-summary') - .shadow() - .invoke('text') - .should('not.contain', 'hello'); - }); - }); -}); diff --git a/packages/atomic/cypress/e2e/recommendations/recs-interface-utils.ts b/packages/atomic/cypress/e2e/recommendations/recs-interface-utils.ts deleted file mode 100644 index 359c58fac7a..00000000000 --- a/packages/atomic/cypress/e2e/recommendations/recs-interface-utils.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {RecsInterface} from '../../fixtures/test-recs-fixture'; - -export function getRecsInterface(cb: (searchInterface: RecsInterface) => void) { - return cy.get('atomic-recs-interface').then(($el) => { - cb($el.get(0) as RecsInterface); - }); -} - -export function setLanguage(lang: string) { - return getRecsInterface((recsInterface) => { - recsInterface.language = lang; - }); -} - -export function getRecommendations() { - return getRecsInterface((recsInterface) => { - recsInterface.getRecommendations(); - }); -} diff --git a/packages/atomic/cypress/e2e/recommendations/recs-interface.cypress.ts b/packages/atomic/cypress/e2e/recommendations/recs-interface.cypress.ts deleted file mode 100644 index 287b88c548c..00000000000 --- a/packages/atomic/cypress/e2e/recommendations/recs-interface.cypress.ts +++ /dev/null @@ -1,91 +0,0 @@ -import {TestRecsFixture} from '../../fixtures/test-recs-fixture'; -import { - assertConsoleError, - assertConsoleErrorMessage, -} from '../common-assertions'; -import {setLanguage, getRecommendations} from './recs-interface-utils'; - -// TODO: https://coveord.atlassian.net/browse/KIT-3540 - rewrite in playwright -describe.skip('Recs Interface Component', () => { - const engineError = - 'You have to call "initialize" on the atomic-recs-interface component before modifying the props or calling other public methods.'; - - describe('before being initialized', () => { - beforeEach(() => { - new TestRecsFixture().withoutInterfaceInitialization().init(); - }); - - describe('when calling "getRecommendations"', () => { - beforeEach(() => { - getRecommendations(); - }); - assertConsoleErrorMessage(engineError); - }); - - describe('when changing a prop', () => { - beforeEach(() => { - cy.wait(300); - setLanguage('fr'); - }); - assertConsoleErrorMessage(engineError); - }); - }); - - describe('when being initialized', () => { - beforeEach(() => { - new TestRecsFixture().withoutGetRecommendations().init(); - }); - - assertConsoleError(false); - }); - - function verifyLanguageIntercepts(language: string) { - it('should set locale for search request', (done) => { - cy.wait(TestRecsFixture.interceptAliases.Search).then((intercept) => { - expect(intercept.request.body.locale).to.be.eq(language); - done(); - }); - }); - - it('should set language for analytics request', (done) => { - cy.wait(TestRecsFixture.interceptAliases.UA).then((intercept) => { - const analyticsBody = intercept.request.body; - expect(analyticsBody).to.have.property('language', language); - done(); - }); - }); - } - - describe('initially setting language', () => { - const language = 'fr'; - beforeEach(() => { - new TestRecsFixture() - .withLanguage(language) - .withoutFirstIntercept() - .init(); - }); - - verifyLanguageIntercepts(language); - }); - - describe('updating the language after initialization', () => { - const language = 'fr'; - beforeEach(() => { - new TestRecsFixture().init(); - setLanguage('fr'); - getRecommendations(); - }); - - verifyLanguageIntercepts(language); - }); - - describe('without analytics', () => { - beforeEach(() => { - new TestRecsFixture().withoutAnalytics().init(); - }); - - it('should not call the analytics server', () => { - cy.shouldBeCalled(TestRecsFixture.interceptAliases.UA, 0); - }); - }); -}); diff --git a/packages/atomic/cypress/e2e/recommendations/recs-list-assertions.ts b/packages/atomic/cypress/e2e/recommendations/recs-list-assertions.ts deleted file mode 100644 index 2029c67e7ad..00000000000 --- a/packages/atomic/cypress/e2e/recommendations/recs-list-assertions.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {RecsSelectors} from './recs-list-selectors'; - -export function assertRendersRecommendations(numberOfRecs: number) { - RecsSelectors.result().should('have.length', numberOfRecs).and('be.visible'); -} - -export function assertRendersPlaceholders(numberOfRecs: number) { - RecsSelectors.placeholder() - .should('have.length', numberOfRecs) - .and('be.visible'); -} - -export function assertRendersIndicators(numberOfPages: number) { - RecsSelectors.indicator() - .should('have.length', numberOfPages) - .and('be.visible'); -} - -export function assertIndicatorsActiveAtIndex(index: number) { - RecsSelectors.indicator() - .eq(index) - .should('have.attr', 'part') - .then((part) => { - expect(part).to.contain('active-indicator'); - }); -} - -export function assertFirstRecommendationsContainsText(text: string) { - RecsSelectors.firstResult().should('contain.text', text); -} diff --git a/packages/atomic/cypress/e2e/recommendations/recs-list-selectors.ts b/packages/atomic/cypress/e2e/recommendations/recs-list-selectors.ts deleted file mode 100644 index e63c844592e..00000000000 --- a/packages/atomic/cypress/e2e/recommendations/recs-list-selectors.ts +++ /dev/null @@ -1,14 +0,0 @@ -export const recsListComponent = 'atomic-recs-list'; -export const resultPlaceholderComponent = 'atomic-result-placeholder'; -export const resultTemplateComponent = 'atomic-recs-result-template'; -export const resultComponent = 'atomic-recs-result'; - -export const RecsSelectors = { - shadow: () => cy.get(recsListComponent).shadow(), - placeholder: () => RecsSelectors.shadow().find(resultPlaceholderComponent), - result: () => RecsSelectors.shadow().find(resultComponent), - indicator: () => RecsSelectors.shadow().find('[part~="indicator"]'), - firstResult: () => RecsSelectors.result().first().shadow(), - nextButton: () => RecsSelectors.shadow().find('[part="next-button"]'), - previousButton: () => RecsSelectors.shadow().find('[part="previous-button"]'), -}; diff --git a/packages/atomic/cypress/e2e/recommendations/recs-list.cypress.ts b/packages/atomic/cypress/e2e/recommendations/recs-list.cypress.ts deleted file mode 100644 index 64d7da7be40..00000000000 --- a/packages/atomic/cypress/e2e/recommendations/recs-list.cypress.ts +++ /dev/null @@ -1,158 +0,0 @@ -import {generateComponentHTML} from '../../fixtures/fixture-common'; -import {TestRecsFixture} from '../../fixtures/test-recs-fixture'; -import * as CommonAssertions from '../common-assertions'; -import {buildTemplateWithSections} from '../result-list/result-list-actions'; -import {withAnySectionnableResultList} from '../result-list/result-list-utils'; -import * as RecsAssertions from './recs-list-assertions'; -import { - recsListComponent, - resultTemplateComponent, - RecsSelectors, -} from './recs-list-selectors'; - -export const addRecsList = - (props = {}, template?: HTMLElement) => - (env: TestRecsFixture) => { - const recsList = generateComponentHTML(recsListComponent, props); - if (template) { - recsList.appendChild(template); - } - env.withElement(recsList); - }; - -const numberOfRecs = 3; -const numberOfRecsPerPage = 1; - -// TODO: https://coveord.atlassian.net/browse/KIT-3540 - rewrite in playwright -describe.skip('Recs Interface Component', () => { - describe('before recommendation have loaded', () => { - beforeEach(() => { - new TestRecsFixture() - .withoutGetRecommendations() - .with(addRecsList({'number-of-recommendations': numberOfRecs})) - .init(); - }); - - it('verify accessibility and placeholders', () => { - CommonAssertions.assertAccessibility(); - RecsAssertions.assertRendersPlaceholders(numberOfRecs); - }); - }); - - describe('after recommendation have loaded', () => { - beforeEach(() => { - new TestRecsFixture() - .with(addRecsList({'number-of-recommendations': numberOfRecs})) - .init(); - }); - - it('verify accessibility and recommendations', () => { - CommonAssertions.assertConsoleError(false); - CommonAssertions.assertAccessibility(); - RecsAssertions.assertRendersRecommendations(numberOfRecs); - }); - }); - - describe('with a full result template', () => { - function generateSimpleTextElement() { - const element = generateComponentHTML('span'); - element.innerText = - 'I will not use meaningless placeholder text for testing'; - return element; - } - beforeEach(() => { - new TestRecsFixture() - .with( - addRecsList( - {'number-of-recommendations': numberOfRecs}, - buildTemplateWithSections( - { - visual: generateSimpleTextElement(), - badges: generateSimpleTextElement(), - actions: generateSimpleTextElement(), - title: generateSimpleTextElement(), - titleMetadata: generateSimpleTextElement(), - emphasized: generateSimpleTextElement(), - excerpt: generateSimpleTextElement(), - bottomMetadata: generateSimpleTextElement(), - }, - {}, - resultTemplateComponent - ) - ) - ) - .init(); - }); - withAnySectionnableResultList( - () => { - CommonAssertions.assertAccessibility(recsListComponent); - }, - { - componentTag: recsListComponent, - densities: ['normal'], - imageSizes: ['icon', 'small'], - useBeforeEach: true, - } - ); - }); - - describe('with a unloaded carousel', () => { - beforeEach(() => { - // Setup Carousel - new TestRecsFixture() - .withoutGetRecommendations() - .with( - addRecsList({ - 'number-of-recommendations': numberOfRecs, - 'number-of-recommendations-per-page': numberOfRecsPerPage, - }) - ) - .init(); - }); - it('verify placeholders', () => { - RecsAssertions.assertRendersPlaceholders(numberOfRecsPerPage); - }); - }); - - describe('with a loaded carousel', () => { - beforeEach(() => { - new TestRecsFixture() - .with( - addRecsList({ - 'number-of-recommendations': numberOfRecs, - 'number-of-recommendations-per-page': numberOfRecsPerPage, - }) - ) - .withCustomResponse((response) => { - response.results.forEach((result, index) => { - result.title = `${index}`; - }); - return response; - }) - .init(); - }); - - it('verify rendering and going forward/backward', () => { - CommonAssertions.assertConsoleError(false); - CommonAssertions.assertAccessibility(); - RecsAssertions.assertRendersIndicators( - numberOfRecs / numberOfRecsPerPage - ); - RecsAssertions.assertIndicatorsActiveAtIndex(0); - RecsAssertions.assertFirstRecommendationsContainsText('0'); - // Going forward - RecsSelectors.nextButton().click(); - RecsAssertions.assertIndicatorsActiveAtIndex(1); - RecsAssertions.assertFirstRecommendationsContainsText('1'); - // Going backward full loop - RecsSelectors.previousButton().click(); - RecsSelectors.previousButton().click(); - RecsAssertions.assertIndicatorsActiveAtIndex(2); - RecsAssertions.assertFirstRecommendationsContainsText('2'); - // Going forward full loop - RecsSelectors.nextButton().click(); - RecsAssertions.assertIndicatorsActiveAtIndex(0); - RecsAssertions.assertFirstRecommendationsContainsText('0'); - }); - }); -}); diff --git a/packages/atomic/cypress/plugins/index.js b/packages/atomic/cypress/plugins/index.js index f02a8039cb4..1c103079a47 100644 --- a/packages/atomic/cypress/plugins/index.js +++ b/packages/atomic/cypress/plugins/index.js @@ -1,4 +1,4 @@ -const cypressSplit = require('cypress-split'); +import cypressSplit from 'cypress-split'; /// // *********************************************************** @@ -17,7 +17,7 @@ const cypressSplit = require('cypress-split'); /** * @type {Cypress.PluginConfig} */ -module.exports = (on, config) => { +export default (on, config) => { cypressSplit(on, config); // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config diff --git a/packages/atomic/jest/setup.js b/packages/atomic/jest/setup.cjs similarity index 100% rename from packages/atomic/jest/setup.js rename to packages/atomic/jest/setup.cjs diff --git a/packages/atomic/package.json b/packages/atomic/package.json index 31a6db524c7..41f2232b7de 100644 --- a/packages/atomic/package.json +++ b/packages/atomic/package.json @@ -1,6 +1,7 @@ { "name": "@coveo/atomic", - "version": "3.1.1", + "type": "module", + "version": "3.2.3", "description": "A web-component library for building modern UIs interfacing with the Coveo platform", "homepage": "https://docs.coveo.com/en/atomic/latest/", "repository": { @@ -10,21 +11,39 @@ }, "main": "dist/index.cjs.js", "module": "dist/index.js", - "es2015": "dist/esm/index.mjs", - "es2017": "dist/esm/index.mjs", "types": "dist/types/index.d.ts", - "collection": "collection-manifest.json", - "collection:main": "dist/index.js", - "unpkg": "dist/atomic/atomic.esm.js", + "exports": { + "./loader": { + "types": "./loader/index.d.ts", + "import": "./loader/index.js", + "require": "./loader/index.cjs.js" + }, + ".": { + "types": "./dist/types/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.cjs.js" + }, + "./themes/*": { + "import": "./dist/atomic/themes/*", + "require": "./dist/atomic/themes/*" + }, + "./assets/*": { + "import": "./dist/atomic/assets/*", + "require": "./dist/atomic/assets/*" + }, + "./lang/*": { + "import": "./dist/atomic/lang/*", + "require": "./dist/atomic/lang/*" + } + }, "files": [ "dist/", - "loader/", "docs/", "licenses/", - "collection-manifest.json" + "loader/" ], "scripts": { - "clean": "rimraf -rf dist/*", + "clean": "rimraf -rf dist/* dist-storybook/* www/* docs/* loader/* playwright-report/*", "build": "nx build", "build:locales": "npx nx build:locales atomic", "start": "nx dev atomic", @@ -34,21 +53,21 @@ "e2e": "cypress run --browser chrome", "e2e:firefox": "cypress run --browser firefox", "e2e:watch": "cypress open --browser chrome --e2e", - "e2e:hsp": "cypress run --config-file cypress-hsp.config.ts --browser chrome", - "e2e:hsp:firefox": "cypress run --config-file cypress-hsp.config.ts --browser firefox", - "e2e:hsp:watch": "cypress open --config-file cypress-hsp.config.ts", - "e2e:snapshots": "cypress run --config-file cypress-screenshots.config.ts --browser chrome", - "e2e:snapshots:watch": "cypress open --config-file cypress-screenshots.config.ts --browser chrome", - "e2e:insight": "cypress run --config-file cypress-insight-panel.config.ts --browser chrome", - "e2e:insight:watch": "cypress open --config-file cypress-insight-panel.config.ts --browser chrome", + "e2e:hsp": "cypress run --config-file cypress-hsp.config.mjs --browser chrome", + "e2e:hsp:firefox": "cypress run --config-file cypress-hsp.config.mjs --browser firefox", + "e2e:hsp:watch": "cypress open --config-file cypress-hsp.config.mjs", + "e2e:snapshots": "cypress run --config-file cypress-screenshots.config.mjs --browser chrome", + "e2e:snapshots:watch": "cypress open --config-file cypress-screenshots.config.mjs --browser chrome", + "e2e:insight": "cypress run --config-file cypress-insight-panel.config.mjs --browser chrome", + "e2e:insight:watch": "cypress open --config-file cypress-insight-panel.config.mjs --browser chrome", "publish:npm": "npm run-script -w=@coveo/release npm-publish", "publish:bump": "npm run-script -w=@coveo/release bump", "promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest", "validate:definitions": "tsc --noEmit --esModuleInterop --skipLibCheck ./dist/types/components.d.ts" }, "dependencies": { - "@coveo/bueno": "1.0.0", - "@coveo/headless": "3.0.0", + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3", "@popperjs/core": "^2.11.6", "@salesforce-ux/design-system": "^2.16.1", "@stencil/store": "2.0.16", @@ -66,7 +85,7 @@ "devDependencies": { "@axe-core/playwright": "4.9.1", "@babel/core": "7.24.9", - "@coveo/atomic": "file:.", + "@coveo/atomic-storybook-utils": "file:./storybookUtils", "@coveo/release": "1.0.0", "@coveo/rollup-plugin-replace-with-ast": "1.0.0", "@custom-elements-manifest/analyzer": "0.10.3", @@ -129,6 +148,7 @@ "postcss-nested": "6.2.0", "puppeteer": "22.14.0", "react": "18.3.1", + "rollup": "4.22.4", "rollup-plugin-html": "0.2.1", "shadow-dom-testing-library": "1.11.2", "storybook": "8.1.2", @@ -141,7 +161,8 @@ "wait-on": "7.2.0" }, "peerDependencies": { - "@coveo/headless": "3.0.0" + "@coveo/bueno": "1.0.1", + "@coveo/headless": "3.1.3" }, "license": "Apache-2.0", "engines": { diff --git a/packages/atomic/project.json b/packages/atomic/project.json index af2134ea9ba..1b1eb78f69a 100644 --- a/packages/atomic/project.json +++ b/packages/atomic/project.json @@ -12,8 +12,8 @@ "buildInputs": [ "{projectRoot}/stencil.config.ts", "{projectRoot}/collection-manifest.json", - "{projectRoot}/tailwind.config.js", - "{projectRoot}/svg.transform.js", + "{projectRoot}/tailwind.config.cjs", + "{projectRoot}/svg.transform.cjs", "{projectRoot}/stencil-plugin/**", "!{projectRoot}/src/external-builds/**", "!{projectRoot}/src/generated/**", @@ -117,9 +117,16 @@ "command": "wait-on dist/atomic" } }, + "wait-on:stencil-ping": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "command": "wait-on http://localhost:3333/ping" + } + }, "storybook": { "executor": "nx:run-commands", - "dependsOn": ["wait-on:dist"], + "dependsOn": ["wait-on:stencil-ping"], "options": { "cwd": "{projectRoot}", "command": "npx storybook dev -p 4400" diff --git a/packages/atomic/scripts/externalPackageMappings.ts b/packages/atomic/scripts/externalPackageMappings.ts new file mode 100644 index 00000000000..6d1892678e9 --- /dev/null +++ b/packages/atomic/scripts/externalPackageMappings.ts @@ -0,0 +1,49 @@ +import path from 'node:path'; +import buenoJson from '../../bueno/package.json'; +import headlessJson from '../../headless/package.json'; + +const headlessVersion = 'v' + headlessJson.version; +const buenoVersion = 'v' + buenoJson.version; + +export function generateExternalPackageMappings(basePath: string): { + [key: string]: {devWatch: string; cdn: string}; +} { + return { + '@coveo/headless/commerce': { + devWatch: path.resolve( + basePath, + 'src/external-builds/commerce/headless.esm.js' + ), + cdn: `/headless/${headlessVersion}/commerce/headless.esm.js`, + }, + '@coveo/headless/insight': { + devWatch: path.resolve( + basePath, + 'src/external-builds/insight/headless.esm.js' + ), + cdn: `/headless/${headlessVersion}/insight/headless.esm.js`, + }, + '@coveo/headless/recommendation': { + devWatch: path.resolve( + basePath, + 'src/external-builds/recommendation/headless.esm.js' + ), + cdn: `/headless/${headlessVersion}/recommendation/headless.esm.js`, + }, + '@coveo/headless/case-assist': { + devWatch: path.resolve( + basePath, + 'src/external-builds/case-assist/headless.esm.js' + ), + cdn: `/headless/${headlessVersion}/case-assist/headless.esm.js`, + }, + '@coveo/headless': { + devWatch: path.resolve(basePath, 'src/external-builds/headless.esm.js'), + cdn: `/headless/${headlessVersion}/headless.esm.js`, + }, + '@coveo/bueno': { + devWatch: path.resolve(basePath, 'src/external-builds/bueno.esm.js'), + cdn: `/bueno/${buenoVersion}/bueno.esm.js`, + }, + }; +} diff --git a/packages/atomic/src/components.d.ts b/packages/atomic/src/components.d.ts index 64b5dab630d..1ed53e7e6ed 100644 --- a/packages/atomic/src/components.d.ts +++ b/packages/atomic/src/components.d.ts @@ -1073,6 +1073,14 @@ export namespace Components { * @default false */ "collapsible"?: boolean; + /** + * The tabs on which this generated answer must not be displayed. This property should not be used at the same time as `tabs-included`. Set this property as a stringified JSON array, e.g., ```html ``` If you don't set this property, the generated answer can be displayed on any tab. Otherwise, the generated answer won't be displayed on any of the specified tabs. + */ + "tabsExcluded": string[] | string; + /** + * The tabs on which the generated answer can be displayed. This property should not be used at the same time as `tabs-excluded`. Set this property as a stringified JSON array, e.g., ```html ``` If you don't set this property, the generated answer can be displayed on any tab. Otherwise, the generated answer can only be displayed on the specified tabs. + */ + "tabsIncluded": string[] | string; /** * Whether to render a toggle button that lets the user hide or show the answer. * @default false @@ -1205,6 +1213,7 @@ export namespace Components { "tooltip": string; } interface AtomicInsightGeneratedAnswer { + "answerConfigurationId"?: string; /** * Whether to allow the answer to be collapsed when the text is taller than 250px. * @default false @@ -1573,6 +1582,18 @@ export namespace Components { */ "withDatePicker": boolean; } + interface AtomicInsightUserActionsModal { + "isOpen": boolean; + "openButton"?: HTMLElement; + /** + * The date and time when the case was created. For example "2024-01-01T00:00:00Z" + */ + "ticketCreationDateTime": string; + /** + * The ID of the user whose actions are being displayed. + */ + "userId": string; + } /** * @category Insight Panel * @example @@ -1588,9 +1609,6 @@ export namespace Components { "userActions": Array; } /** - * This component displays all the actions performed by a user around the time they created a case. - * The actions are grouped into multiple sessions, including the session during which the case was created, - * the sessions preceding the case creation and the sessions following the case creation. * @component * @example */ @@ -1604,6 +1622,16 @@ export namespace Components { */ "userId": string; } + interface AtomicInsightUserActionsToggle { + /** + * The date and time when the case was created. For example "2024-01-01T00:00:00Z" + */ + "ticketCreationDateTime": string; + /** + * The ID of the user whose actions are being displayed. + */ + "userId": string; + } interface AtomicIpxBody { "displayFooterSlot": boolean; "isOpen"?: boolean; @@ -2082,6 +2110,7 @@ export namespace Components { "maxValueInIndex": number; /** * The field whose value you want to display next to the rating. This field can be used to display the number of reviews or the numerical value of the rating, for example. + * @type {string} */ "ratingDetailsField"?: string; } @@ -4482,6 +4511,12 @@ declare global { prototype: HTMLAtomicInsightTimeframeFacetElement; new (): HTMLAtomicInsightTimeframeFacetElement; }; + interface HTMLAtomicInsightUserActionsModalElement extends Components.AtomicInsightUserActionsModal, HTMLStencilElement { + } + var HTMLAtomicInsightUserActionsModalElement: { + prototype: HTMLAtomicInsightUserActionsModalElement; + new (): HTMLAtomicInsightUserActionsModalElement; + }; /** * @category Insight Panel * @example @@ -4493,9 +4528,6 @@ declare global { new (): HTMLAtomicInsightUserActionsSessionElement; }; /** - * This component displays all the actions performed by a user around the time they created a case. - * The actions are grouped into multiple sessions, including the session during which the case was created, - * the sessions preceding the case creation and the sessions following the case creation. * @component * @example */ @@ -4505,6 +4537,12 @@ declare global { prototype: HTMLAtomicInsightUserActionsTimelineElement; new (): HTMLAtomicInsightUserActionsTimelineElement; }; + interface HTMLAtomicInsightUserActionsToggleElement extends Components.AtomicInsightUserActionsToggle, HTMLStencilElement { + } + var HTMLAtomicInsightUserActionsToggleElement: { + prototype: HTMLAtomicInsightUserActionsToggleElement; + new (): HTMLAtomicInsightUserActionsToggleElement; + }; interface HTMLAtomicIpxBodyElementEventMap { "animationEnded": never; } @@ -5873,8 +5911,10 @@ declare global { "atomic-insight-tab": HTMLAtomicInsightTabElement; "atomic-insight-tabs": HTMLAtomicInsightTabsElement; "atomic-insight-timeframe-facet": HTMLAtomicInsightTimeframeFacetElement; + "atomic-insight-user-actions-modal": HTMLAtomicInsightUserActionsModalElement; "atomic-insight-user-actions-session": HTMLAtomicInsightUserActionsSessionElement; "atomic-insight-user-actions-timeline": HTMLAtomicInsightUserActionsTimelineElement; + "atomic-insight-user-actions-toggle": HTMLAtomicInsightUserActionsToggleElement; "atomic-ipx-body": HTMLAtomicIpxBodyElement; "atomic-ipx-button": HTMLAtomicIpxButtonElement; "atomic-ipx-embedded": HTMLAtomicIpxEmbeddedElement; @@ -6957,6 +6997,14 @@ declare namespace LocalJSX { * @default false */ "collapsible"?: boolean; + /** + * The tabs on which this generated answer must not be displayed. This property should not be used at the same time as `tabs-included`. Set this property as a stringified JSON array, e.g., ```html ``` If you don't set this property, the generated answer can be displayed on any tab. Otherwise, the generated answer won't be displayed on any of the specified tabs. + */ + "tabsExcluded"?: string[] | string; + /** + * The tabs on which the generated answer can be displayed. This property should not be used at the same time as `tabs-excluded`. Set this property as a stringified JSON array, e.g., ```html ``` If you don't set this property, the generated answer can be displayed on any tab. Otherwise, the generated answer can only be displayed on the specified tabs. + */ + "tabsIncluded"?: string[] | string; /** * Whether to render a toggle button that lets the user hide or show the answer. * @default false @@ -7086,6 +7134,7 @@ declare namespace LocalJSX { "tooltip"?: string; } interface AtomicInsightGeneratedAnswer { + "answerConfigurationId"?: string; /** * Whether to allow the answer to be collapsed when the text is taller than 250px. * @default false @@ -7428,6 +7477,18 @@ declare namespace LocalJSX { */ "withDatePicker"?: boolean; } + interface AtomicInsightUserActionsModal { + "isOpen"?: boolean; + "openButton"?: HTMLElement; + /** + * The date and time when the case was created. For example "2024-01-01T00:00:00Z" + */ + "ticketCreationDateTime": string; + /** + * The ID of the user whose actions are being displayed. + */ + "userId": string; + } /** * @category Insight Panel * @example @@ -7443,9 +7504,6 @@ declare namespace LocalJSX { "userActions": Array; } /** - * This component displays all the actions performed by a user around the time they created a case. - * The actions are grouped into multiple sessions, including the session during which the case was created, - * the sessions preceding the case creation and the sessions following the case creation. * @component * @example */ @@ -7459,6 +7517,16 @@ declare namespace LocalJSX { */ "userId": string; } + interface AtomicInsightUserActionsToggle { + /** + * The date and time when the case was created. For example "2024-01-01T00:00:00Z" + */ + "ticketCreationDateTime": string; + /** + * The ID of the user whose actions are being displayed. + */ + "userId": string; + } interface AtomicIpxBody { "displayFooterSlot"?: boolean; "isOpen"?: boolean; @@ -7913,6 +7981,7 @@ declare namespace LocalJSX { "maxValueInIndex"?: number; /** * The field whose value you want to display next to the rating. This field can be used to display the number of reviews or the numerical value of the rating, for example. + * @type {string} */ "ratingDetailsField"?: string; } @@ -9464,8 +9533,10 @@ declare namespace LocalJSX { "atomic-insight-tab": AtomicInsightTab; "atomic-insight-tabs": AtomicInsightTabs; "atomic-insight-timeframe-facet": AtomicInsightTimeframeFacet; + "atomic-insight-user-actions-modal": AtomicInsightUserActionsModal; "atomic-insight-user-actions-session": AtomicInsightUserActionsSession; "atomic-insight-user-actions-timeline": AtomicInsightUserActionsTimeline; + "atomic-insight-user-actions-toggle": AtomicInsightUserActionsToggle; "atomic-ipx-body": AtomicIpxBody; "atomic-ipx-button": AtomicIpxButton; "atomic-ipx-embedded": AtomicIpxEmbedded; @@ -9858,19 +9929,18 @@ declare module "@stencil/core" { "atomic-insight-tab": LocalJSX.AtomicInsightTab & JSXBase.HTMLAttributes; "atomic-insight-tabs": LocalJSX.AtomicInsightTabs & JSXBase.HTMLAttributes; "atomic-insight-timeframe-facet": LocalJSX.AtomicInsightTimeframeFacet & JSXBase.HTMLAttributes; + "atomic-insight-user-actions-modal": LocalJSX.AtomicInsightUserActionsModal & JSXBase.HTMLAttributes; /** * @category Insight Panel * @example */ "atomic-insight-user-actions-session": LocalJSX.AtomicInsightUserActionsSession & JSXBase.HTMLAttributes; /** - * This component displays all the actions performed by a user around the time they created a case. - * The actions are grouped into multiple sessions, including the session during which the case was created, - * the sessions preceding the case creation and the sessions following the case creation. * @component * @example */ "atomic-insight-user-actions-timeline": LocalJSX.AtomicInsightUserActionsTimeline & JSXBase.HTMLAttributes; + "atomic-insight-user-actions-toggle": LocalJSX.AtomicInsightUserActionsToggle & JSXBase.HTMLAttributes; "atomic-ipx-body": LocalJSX.AtomicIpxBody & JSXBase.HTMLAttributes; "atomic-ipx-button": LocalJSX.AtomicIpxButton & JSXBase.HTMLAttributes; "atomic-ipx-embedded": LocalJSX.AtomicIpxEmbedded & JSXBase.HTMLAttributes; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.new.stories.tsx index 14298677670..c788bfd1b76 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import { CommerceEngineConfiguration, getSampleCommerceEngineConfiguration, diff --git a/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.new.stories.tsx index 95bf1869029..97df1d7ea9f 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.new.stories.tsx @@ -1,5 +1,5 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import {getSampleCommerceEngineConfiguration} from '@coveo/headless/commerce'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-load-more-products/atomic-commerce-load-more-products.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-load-more-products/atomic-commerce-load-more-products.new.stories.tsx index c3424d36e6a..40ac967d443 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-load-more-products/atomic-commerce-load-more-products.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-load-more-products/atomic-commerce-load-more-products.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-no-products/atomic-commerce-no-products.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-no-products/atomic-commerce-no-products.new.stories.tsx index 68204dad741..cd23512b430 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-no-products/atomic-commerce-no-products.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-no-products/atomic-commerce-no-products.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-pager/atomic-commerce-pager.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-pager/atomic-commerce-pager.new.stories.tsx index 1dcd6a0f354..f720670d938 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-pager/atomic-commerce-pager.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-pager/atomic-commerce-pager.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInCommerceInterface({skipFirstSearch: true}); diff --git a/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.new.stories.tsx index 8a40b086557..44488284583 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import {CommerceEngineConfiguration} from '@coveo/headless/dist/definitions/commerce.index'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html/static.js'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.new.stories.tsx index 1db5cc66a2b..ec0f191225a 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.new.stories.tsx @@ -1,6 +1,6 @@ -import {wrapInCommerceInterface} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-query-error/atomic-commerce-query-error.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-query-error/atomic-commerce-query-error.new.stories.tsx index e52f6fd6d6f..8234e09d70d 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-query-error/atomic-commerce-query-error.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-query-error/atomic-commerce-query-error.new.stories.tsx @@ -1,6 +1,6 @@ -import {wrapInCommerceInterface} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInCommerceInterface({ diff --git a/packages/atomic/src/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.new.stories.tsx index 1fd72ed2065..ba599a0eff5 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.new.stories.tsx @@ -1,6 +1,6 @@ -import {wrapInCommerceInterface} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import {CommerceEngineConfiguration} from '@coveo/headless/commerce'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.new.stories.tsx index 723fcc10aa6..05b1919de42 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.pcss b/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.pcss index 69dc883c395..1225171962f 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.pcss +++ b/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.pcss @@ -1,5 +1 @@ @import '../../search/atomic-search-box/atomic-search-box.pcss'; - -:host { - @apply relative z-10; -} diff --git a/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts b/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts index e28c87f6c32..5e0eaa18596 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts +++ b/packages/atomic/src/components/commerce/atomic-commerce-search-box/e2e/atomic-commerce-search-box.e2e.ts @@ -514,3 +514,10 @@ test.describe('standalone searchbox', () => { expect(accessibilityResults.violations).toEqual([]); }); }); + +test('should have position:relative and z-index:10', async ({searchBox}) => { + await searchBox.load(); + + await expect(searchBox.hydrated).toHaveCSS('position', 'relative'); + await expect(searchBox.hydrated).toHaveCSS('z-index', '10'); +}); diff --git a/packages/atomic/src/components/commerce/atomic-commerce-text/atomic-commerce-text.new.stories.tsx b/packages/atomic/src/components/commerce/atomic-commerce-text/atomic-commerce-text.new.stories.tsx index 3573d1d4c0a..4b4930210b9 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-text/atomic-commerce-text.new.stories.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-text/atomic-commerce-text.new.stories.tsx @@ -1,6 +1,6 @@ -import {wrapInCommerceInterface} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import {within} from '@storybook/test'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; diff --git a/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.new.stories.tsx b/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.new.stories.tsx index cc6062f0694..49008602a83 100644 --- a/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.new.stories.tsx +++ b/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.new.stories.tsx @@ -2,9 +2,9 @@ import { wrapInCommerceInterface, playExecuteFirstSearch, playKeepOnlyFirstFacetOfType, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html'; diff --git a/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/atomic-commerce-facet.new.stories.tsx b/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/atomic-commerce-facet.new.stories.tsx index 2a2a0710abf..7380175930e 100644 --- a/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/atomic-commerce-facet.new.stories.tsx +++ b/packages/atomic/src/components/commerce/facets/atomic-commerce-facet/atomic-commerce-facet.new.stories.tsx @@ -2,9 +2,9 @@ import { wrapInCommerceInterface, playExecuteFirstSearch, playKeepOnlyFirstFacetOfType, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html'; diff --git a/packages/atomic/src/components/commerce/facets/atomic-commerce-facets/atomic-commerce-facets.new.stories.tsx b/packages/atomic/src/components/commerce/facets/atomic-commerce-facets/atomic-commerce-facets.new.stories.tsx index fbda2063598..30a644d854f 100644 --- a/packages/atomic/src/components/commerce/facets/atomic-commerce-facets/atomic-commerce-facets.new.stories.tsx +++ b/packages/atomic/src/components/commerce/facets/atomic-commerce-facets/atomic-commerce-facets.new.stories.tsx @@ -1,9 +1,9 @@ import { playExecuteFirstSearch, wrapInCommerceInterface, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/commerce/facets/atomic-commerce-numeric-facet/atomic-commerce-numeric-facet.new.stories.tsx b/packages/atomic/src/components/commerce/facets/atomic-commerce-numeric-facet/atomic-commerce-numeric-facet.new.stories.tsx index 710cd4c2d84..d87b38f5c1d 100644 --- a/packages/atomic/src/components/commerce/facets/atomic-commerce-numeric-facet/atomic-commerce-numeric-facet.new.stories.tsx +++ b/packages/atomic/src/components/commerce/facets/atomic-commerce-numeric-facet/atomic-commerce-numeric-facet.new.stories.tsx @@ -2,9 +2,9 @@ import { wrapInCommerceInterface, playExecuteFirstSearch, playKeepOnlyFirstFacetOfType, -} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html'; diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-link/atomic-product-link.new.stories.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-link/atomic-product-link.new.stories.tsx index db78f992ef9..473e51f78ec 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-link/atomic-product-link.new.stories.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-link/atomic-product-link.new.stories.tsx @@ -1,8 +1,8 @@ -import {wrapInCommerceInterface} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {wrapInCommerceProductList} from '@coveo/atomic/storybookUtils/commerce/commerce-product-list-wrapper'; -import {wrapInProductTemplate} from '@coveo/atomic/storybookUtils/commerce/commerce-product-template-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {wrapInCommerceProductList} from '@coveo/atomic-storybook-utils/commerce/commerce-product-list-wrapper'; +import {wrapInProductTemplate} from '@coveo/atomic-storybook-utils/commerce/commerce-product-template-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html'; diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-numeric-field-value/atomic-product-numeric-field-value.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-numeric-field-value/atomic-product-numeric-field-value.tsx index 632657e51bc..15295522b03 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-numeric-field-value/atomic-product-numeric-field-value.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-numeric-field-value/atomic-product-numeric-field-value.tsx @@ -1,4 +1,4 @@ -import {Product, ProductTemplatesHelpers} from '@coveo/headless/commerce'; +import {Product} from '@coveo/headless/commerce'; import {Component, Prop, Element, State, Listen} from '@stencil/core'; import {Bindings} from '../../../../components'; import {InitializeBindings} from '../../../../utils/initialization-utils'; @@ -7,6 +7,7 @@ import { NumberFormatter, } from '../../../common/formats/format-common'; import {ProductContext} from '../product-template-decorators'; +import {parseValue} from '../product-utils'; /** * @alpha @@ -43,24 +44,6 @@ export class AtomicProductNumber { this.formatter = event.detail; } - private parseValue() { - const value = ProductTemplatesHelpers.getProductProperty( - this.product, - this.field - ); - if (value === null) { - return null; - } - const valueAsNumber = parseFloat(`${value}`); - if (Number.isNaN(valueAsNumber)) { - this.error = new Error( - `Could not parse "${value}" from field "${this.field}" as a number.` - ); - return null; - } - return valueAsNumber; - } - private formatValue(value: number) { try { return this.formatter(value, this.bindings.i18n.languages as string[]); @@ -71,7 +54,7 @@ export class AtomicProductNumber { } private updateValueToDisplay() { - const value = this.parseValue(); + const value = parseValue(this.product, this.field); if (value !== null) { this.valueToDisplay = this.formatValue(value); } diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx index 6220cf32401..43fd9d1655b 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx @@ -10,8 +10,10 @@ import { InitializableComponent, InitializeBindings, } from '../../../../utils/initialization-utils'; +import {defaultCurrencyFormatter} from '../../../common/formats/format-common'; import {CommerceBindings} from '../../atomic-commerce-interface/atomic-commerce-interface'; import {ProductContext} from '../product-template-decorators'; +import {parseValue} from '../product-utils'; /** * @alpha @@ -35,31 +37,61 @@ export class AtomicProductPrice this.context = buildContext(this.bindings.engine); } - public render() { - const hasPromotionalPrice = + private formatValue(value: number) { + try { + const {currency} = this.contextState; + const formatter = defaultCurrencyFormatter(currency); + return formatter(value, this.bindings.i18n.languages as string[]); + } catch (error) { + this.error = error as Error; + return value.toString(); + } + } + + private parse(field: string) { + try { + return parseValue(this.product, field); + } catch (error) { + this.error = error as Error; + return null; + } + } + + private getFormattedValue(field: string) { + const value = this.parse(field); + if (value !== null) { + return this.formatValue(value); + } + } + + private get hasPromotionalPrice() { + return ( this.product.ec_promo_price !== null && this.product.ec_price !== null && - this.product.ec_promo_price < this.product.ec_price; + this.product.ec_promo_price < this.product.ec_price + ); + } + + public render() { + const mainPrice = this.getFormattedValue( + this.hasPromotionalPrice ? 'ec_promo_price' : 'ec_price' + ); - const {currency} = this.contextState; + const originalPrice = this.hasPromotionalPrice + ? this.getFormattedValue('ec_price') + : null; return ( - - - - {hasPromotionalPrice && ( - - - + {mainPrice} + + {originalPrice && ( + + {originalPrice} + )} ); diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.new.stories.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.new.stories.tsx new file mode 100644 index 00000000000..389ae29b469 --- /dev/null +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.new.stories.tsx @@ -0,0 +1,65 @@ +import type {Meta, StoryObj as Story} from '@storybook/web-components'; +import {wrapInCommerceInterface} from '../../../../../storybookUtils/commerce/commerce-interface-wrapper'; +import {wrapInCommerceProductList} from '../../../../../storybookUtils/commerce/commerce-product-list-wrapper'; +import {wrapInProductTemplate} from '../../../../../storybookUtils/commerce/commerce-product-template-wrapper'; +import {parameters} from '../../../../../storybookUtils/common/common-meta-parameters'; +import {renderComponent} from '../../../../../storybookUtils/common/render-component'; + +const { + decorator: commerceInterfaceDecorator, + play: initializeCommerceInterface, +} = wrapInCommerceInterface({ + skipFirstSearch: false, + type: 'product-listing', + engineConfig: { + context: { + view: { + url: 'https://sports.barca.group/browse/promotions/ui-kit-testing', + }, + language: 'en', + country: 'US', + currency: 'USD', + }, + }, +}); +const {decorator: commerceProductListDecorator} = wrapInCommerceProductList(); +const {decorator: productTemplateDecorator} = wrapInProductTemplate(); + +const meta: Meta = { + component: 'atomic-product-rating', + title: 'Atomic-Commerce/Product Template Components/ProductRating', + id: 'atomic-product-rating', + render: renderComponent, + decorators: [ + productTemplateDecorator, + commerceProductListDecorator, + commerceInterfaceDecorator, + ], + parameters, + play: initializeCommerceInterface, +}; + +export default meta; + +export const Default: Story = { + name: 'atomic-product-rating', +}; + +export const WithARatingDetailsField: Story = { + args: { + 'attributes-rating-details-field': 'ec_rating', + }, +}; + +export const WithAMaxValueInIndex: Story = { + args: { + 'attributes-max-value-in-index': 10, + }, +}; + +export const WithADifferentIcon: Story = { + args: { + 'attributes-icon': + 'https://raw.githubusercontent.com/Rush/Font-Awesome-SVG-PNG/master/black/svg/circle.svg', + }, +}; diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.tsx index b8dde9ffd48..9a34fa7ca0a 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/atomic-product-rating.tsx @@ -40,6 +40,7 @@ export class AtomicProductRating /** * The field whose value you want to display next to the rating. This field can be used to display the number of reviews or the numerical value of the rating, for example. + * @type {string} */ @Prop({reflect: true}) public ratingDetailsField?: string; diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/atomic-product-rating.e2e.ts b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/atomic-product-rating.e2e.ts new file mode 100644 index 00000000000..41a991a724d --- /dev/null +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/atomic-product-rating.e2e.ts @@ -0,0 +1,82 @@ +import {test, expect} from './fixture'; + +test.describe('default', () => { + test.beforeEach(async ({productRating}) => { + await productRating.load(); + }); + + test('should be accessible', async ({productRating, makeAxeBuilder}) => { + await expect(productRating.hydrated.first()).toBeVisible(); + + expect((await makeAxeBuilder().analyze()).violations.length).toBe(0); + }); + + test('should have the right number of yellow icons', async ({ + productRating, + }) => { + await expect(productRating.blueLagoonYellowIcons).toHaveAttribute( + 'style', + 'width: 80%;' + ); + }); +}); + +test.describe('with a rating details field', () => { + test.beforeEach(async ({productRating}) => { + await productRating.load({story: 'with-a-rating-details-field'}); + }); + + test('should be accessible', async ({productRating, makeAxeBuilder}) => { + await expect(productRating.hydrated.first()).toBeVisible(); + + expect((await makeAxeBuilder().analyze()).violations.length).toBe(0); + }); + + test('should show the rating details next to the rating', async ({ + productRating, + }) => { + await expect(productRating.hydrated.first().getByText('4')).toBeVisible(); + }); +}); + +test.describe('with a max value in index of 10', () => { + test.beforeEach(async ({productRating}) => { + await productRating.load({story: 'with-a-max-value-in-index'}); + }); + + test('should be accessible', async ({productRating, makeAxeBuilder}) => { + await expect(productRating.hydrated.first()).toBeVisible(); + + expect((await makeAxeBuilder().analyze()).violations.length).toBe(0); + }); + + test('should have the right number of yellow icons', async ({ + productRating, + }) => { + await expect(productRating.blueLagoonYellowIcons).toHaveAttribute( + 'style', + 'width: 40%;' + ); + }); +}); + +test.describe('with a different icon', () => { + test.beforeEach(async ({productRating}) => { + await productRating.load({story: 'with-a-different-icon'}); + }); + + test('should be accessible', async ({productRating, makeAxeBuilder}) => { + await expect(productRating.hydrated.first()).toBeVisible(); + + expect((await makeAxeBuilder().analyze()).violations.length).toBe(0); + }); + + test('should have the right number of yellow icons', async ({ + productRating, + }) => { + await expect(productRating.blueLagoonYellowIcons).toHaveAttribute( + 'style', + 'width: 80%;' + ); + }); +}); diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/fixture.ts b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/fixture.ts new file mode 100644 index 00000000000..0d4b561145d --- /dev/null +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/fixture.ts @@ -0,0 +1,19 @@ +import {test as base} from '@playwright/test'; +import { + makeAxeBuilder, + AxeFixture, +} from '../../../../../../playwright-utils/base-fixture'; +import {ProductRatingPageObject} from './page-object'; + +type MyFixtures = { + productRating: ProductRatingPageObject; +}; + +export const test = base.extend({ + makeAxeBuilder, + productRating: async ({page}, use) => { + await use(new ProductRatingPageObject(page)); + }, +}); + +export {expect} from '@playwright/test'; diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/page-object.ts b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/page-object.ts new file mode 100644 index 00000000000..a8c88fdcb98 --- /dev/null +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-rating/e2e/page-object.ts @@ -0,0 +1,15 @@ +import {Page} from '@playwright/test'; +import {BasePageObject} from '../../../../../../playwright-utils/base-page-object'; + +export class ProductRatingPageObject extends BasePageObject<'atomic-product-rating'> { + constructor(page: Page) { + super(page, 'atomic-product-rating'); + } + + get blueLagoonYellowIcons() { + return this.page + .getByLabel('4 stars out of', {exact: false}) + .locator('div') + .nth(1); + } +} diff --git a/packages/atomic/src/components/commerce/product-template-components/error.ts b/packages/atomic/src/components/commerce/product-template-components/error.ts new file mode 100644 index 00000000000..133a3855d34 --- /dev/null +++ b/packages/atomic/src/components/commerce/product-template-components/error.ts @@ -0,0 +1,6 @@ +export class FieldValueIsNaNError extends Error { + constructor(field: string, value?: {}) { + super(`Could not parse "${value}" from field "${field}" as a number.`); + this.name = 'FieldValueIsNaNError'; + } +} diff --git a/packages/atomic/src/components/commerce/product-template-components/product-utils.ts b/packages/atomic/src/components/commerce/product-template-components/product-utils.ts index bce0b69cb26..2f7f54f5573 100644 --- a/packages/atomic/src/components/commerce/product-template-components/product-utils.ts +++ b/packages/atomic/src/components/commerce/product-template-components/product-utils.ts @@ -1,6 +1,19 @@ import {Product, ProductTemplatesHelpers} from '@coveo/headless/commerce'; import {readFromObject} from '../../../utils/object-utils'; import {CommerceBindings} from '../atomic-commerce-interface/atomic-commerce-interface'; +import {FieldValueIsNaNError} from './error'; + +export function parseValue(product: Product, field: string) { + const value = ProductTemplatesHelpers.getProductProperty(product, field); + if (value === null) { + return null; + } + const valueAsNumber = parseFloat(`${value}`); + if (Number.isNaN(valueAsNumber)) { + throw new FieldValueIsNaNError(field, value); + } + return valueAsNumber; +} export function getStringValueFromProductOrNull( product: Product, diff --git a/packages/atomic/src/components/commerce/product-template/atomic-product-template.new.stories.tsx b/packages/atomic/src/components/commerce/product-template/atomic-product-template.new.stories.tsx index 6b0ade161d2..c17be0b9499 100644 --- a/packages/atomic/src/components/commerce/product-template/atomic-product-template.new.stories.tsx +++ b/packages/atomic/src/components/commerce/product-template/atomic-product-template.new.stories.tsx @@ -1,12 +1,12 @@ -import {wrapInCommerceInterface} from '@coveo/atomic/storybookUtils/commerce/commerce-interface-wrapper'; -import {wrapInCommerceProductList} from '@coveo/atomic/storybookUtils/commerce/commerce-product-list-wrapper'; -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponentWithoutCodeRoot} from '@coveo/atomic/storybookUtils/common/render-component'; +import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper'; +import {wrapInCommerceProductList} from '@coveo/atomic-storybook-utils/commerce/commerce-product-list-wrapper'; +import {wrapInCommerceRecommendationInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-recommendation-interface-wrapper'; +import {wrapInCommerceRecommendationList} from '@coveo/atomic-storybook-utils/commerce/commerce-recommendation-list-wrapper'; +import {wrapInCommerceSearchBoxInstantProducts} from '@coveo/atomic-storybook-utils/commerce/commerce-searchbox-instant-products-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponentWithoutCodeRoot} from '@coveo/atomic-storybook-utils/common/render-component'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {within} from 'shadow-dom-testing-library'; -import {wrapInCommerceRecommendationInterface} from '../../../../storybookUtils/commerce/commerce-recommendation-interface-wrapper'; -import {wrapInCommerceRecommendationList} from '../../../../storybookUtils/commerce/commerce-recommendation-list-wrapper'; -import {wrapInCommerceSearchBoxInstantProducts} from '../../../../storybookUtils/commerce/commerce-searchbox-instant-products-wrapper'; const TEMPLATE_EXAMPLE = ` diff --git a/packages/atomic/src/components/common/atomic-icon/atomic-icon.new.stories.tsx b/packages/atomic/src/components/common/atomic-icon/atomic-icon.new.stories.tsx index 3ffee991aa4..50b44084c28 100644 --- a/packages/atomic/src/components/common/atomic-icon/atomic-icon.new.stories.tsx +++ b/packages/atomic/src/components/common/atomic-icon/atomic-icon.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import bgIcons from '@salesforce-ux/design-system/design-tokens/dist/bg-standard.common'; import {userEvent, waitFor, expect} from '@storybook/test'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; diff --git a/packages/atomic/src/components/common/atomic-numeric-range/atomic-numeric-range.new.stories.tsx b/packages/atomic/src/components/common/atomic-numeric-range/atomic-numeric-range.new.stories.tsx index a816d9cae95..5ae159b43a9 100644 --- a/packages/atomic/src/components/common/atomic-numeric-range/atomic-numeric-range.new.stories.tsx +++ b/packages/atomic/src/components/common/atomic-numeric-range/atomic-numeric-range.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/common/atomic-rating/atomic-rating.tsx b/packages/atomic/src/components/common/atomic-rating/atomic-rating.tsx index 42584ed4462..0c7c8ee75f8 100644 --- a/packages/atomic/src/components/common/atomic-rating/atomic-rating.tsx +++ b/packages/atomic/src/components/common/atomic-rating/atomic-rating.tsx @@ -1,5 +1,6 @@ import {FunctionalComponent, h, VNode} from '@stencil/core'; import {i18n} from 'i18next'; +import {FieldValueIsNaNError} from '../../commerce/product-template-components/error'; interface RatingProps { i18n: i18n; @@ -72,9 +73,7 @@ export const computeNumberOfStars = ( } const valueAsNumber = parseFloat(`${value}`); if (Number.isNaN(valueAsNumber)) { - throw new Error( - `Could not parse "${value}" from field "${field}" as a number.` - ); + throw new FieldValueIsNaNError(field, value); } return valueAsNumber; }; diff --git a/packages/atomic/src/components/common/atomic-timeframe/atomic-timeframe.new.stories.tsx b/packages/atomic/src/components/common/atomic-timeframe/atomic-timeframe.new.stories.tsx index 04d2c39d6d7..545365d7939 100644 --- a/packages/atomic/src/components/common/atomic-timeframe/atomic-timeframe.new.stories.tsx +++ b/packages/atomic/src/components/common/atomic-timeframe/atomic-timeframe.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/common/facets/facet-tabs/facet-tabs-utils.ts b/packages/atomic/src/components/common/facets/facet-tabs/facet-tabs-utils.ts deleted file mode 100644 index c5ff24eb242..00000000000 --- a/packages/atomic/src/components/common/facets/facet-tabs/facet-tabs-utils.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {CategoryFacet, DateFacet, Facet, NumericFacet} from '@coveo/headless'; -import {shouldDisplayOnCurrentTab} from '../../../../utils/tab-utils'; - -type AnyFacetType = Facet | NumericFacet | CategoryFacet | DateFacet; - -/** - * Updates the visibility of a facet based on the active tab. - * @param tabsIncluded - An array of tab names that should include the facet. - * @param tabsExcluded - An array of tab names that should exclude the facet. - * @param activeTab - The currently active tab. - * @param facet - The facet to update. - */ -export function updateFacetVisibilityForActiveTab( - tabsIncluded: string[], - tabsExcluded: string[], - activeTab: string, - facet?: AnyFacetType -): void { - if ( - !facet || - (tabsIncluded.length === 0 && tabsExcluded.length === 0) || - !activeTab - ) { - return; - } - const shouldDisplay = shouldDisplayOnCurrentTab( - tabsIncluded, - tabsExcluded, - activeTab - ); - - if (shouldDisplay && !facet.state.enabled) { - facet.enable(); - return; - } - - if (!shouldDisplay && facet.state.enabled) { - facet.disable(); - return; - } -} diff --git a/packages/atomic/src/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.tsx b/packages/atomic/src/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.tsx index 5c4f77b5de1..82dc15be2f6 100644 --- a/packages/atomic/src/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.tsx +++ b/packages/atomic/src/components/insight/atomic-insight-generated-answer/atomic-insight-generated-answer.tsx @@ -101,6 +101,12 @@ export class AtomicInsightGeneratedAnswer */ @Prop() collapsible?: boolean; + /** + * @internal + * The unique identifier of the answer configuration to use to generate the answer. + */ + @Prop() answerConfigurationId?: string; + @AriaLiveRegion('generated-answer') protected ariaMessage!: string; @@ -132,6 +138,9 @@ export class AtomicInsightGeneratedAnswer contentFormat: ['text/markdown', 'text/plain'], }, }, + ...(this.answerConfigurationId && { + answerConfigurationId: this.answerConfigurationId, + }), }); this.searchStatus = buildInsightSearchStatus(this.bindings.engine); this.generatedAnswerCommon.insertFeedbackModal(); diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-modal/atomic-insight-user-actions-modal.pcss b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-modal/atomic-insight-user-actions-modal.pcss new file mode 100644 index 00000000000..562059b603f --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-modal/atomic-insight-user-actions-modal.pcss @@ -0,0 +1,9 @@ +@import '../../../common/refine-modal/refine-modal-common.pcss'; +:host { + position: absolute; +} + +atomic-modal::part(body-wrapper), +atomic-modal::part(footer-wrapper) { + padding: 2px; +} diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-modal/atomic-insight-user-actions-modal.tsx b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-modal/atomic-insight-user-actions-modal.tsx new file mode 100644 index 00000000000..4a9f7ec90fd --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-modal/atomic-insight-user-actions-modal.tsx @@ -0,0 +1,150 @@ +import {Component, h, State, Prop, Element, Watch, Host} from '@stencil/core'; +import CloseIcon from '../../../../images/close.svg'; +import {rectEquals} from '../../../../utils/dom-utils'; +import { + InitializableComponent, + InitializeBindings, +} from '../../../../utils/initialization-utils'; +import {Button} from '../../../common/button'; +import {InsightBindings} from '../../atomic-insight-interface/atomic-insight-interface'; + +const exportparts = + 'container,header,header-wrapper,header-ruler,body,body-wrapper,footer,footer-wrapper,footer-wrapper'; + +/** + * @internal + * The `atomic-insight-user-actions-modal` is automatically created as a child of the `atomic-insight-interface` when the `atomic-insight-user-actions-toggle` is initialized. + * + * When the modal is opened, the CSS class `atomic-modal-opened` is added to the interface element and the body, allowing further customization. + */ +@Component({ + tag: 'atomic-insight-user-actions-modal', + styleUrl: 'atomic-insight-user-actions-modal.pcss', + shadow: true, +}) +export class AtomicInsightUserActionsModal + implements InitializableComponent +{ + @Element() public host!: HTMLElement; + @InitializeBindings() public bindings!: InsightBindings; + @State() + public error!: Error; + @State() + public interfaceDimensions?: DOMRect; + + @Prop({mutable: true}) openButton?: HTMLElement; + @Prop({reflect: true, mutable: true}) isOpen = false; + + /** + * The ID of the user whose actions are being displayed. + */ + @Prop() public userId!: string; + /** + * The date and time when the case was created. For example "2024-01-01T00:00:00Z" + */ + @Prop() public ticketCreationDateTime!: string; + + public componentDidLoad() { + this.host.style.display = ''; + } + + @Watch('isOpen') + watchEnabled(isOpen: boolean) { + if (isOpen) { + this.onAnimationFrame(); + } + } + + private onAnimationFrame() { + if (!this.isOpen) { + return; + } + if (this.dimensionChanged()) { + this.updateDimensions(); + } + window.requestAnimationFrame(() => this.onAnimationFrame()); + } + + private dimensionChanged() { + if (!this.interfaceDimensions) { + return true; + } + + return !rectEquals( + this.interfaceDimensions, + this.bindings.interfaceElement.getBoundingClientRect() + ); + } + + public updateDimensions() { + this.interfaceDimensions = + this.bindings.interfaceElement.getBoundingClientRect(); + } + + public render() { + const renderHeader = () => { + return ( + + + {this.bindings.i18n.t('user-actions')} + + (this.isOpen = false)} + ariaLabel={this.bindings.i18n.t('close')} + > + + + + ); + }; + + const renderBody = () => { + return ( + + ); + }; + return ( + + {this.interfaceDimensions && ( + + )} + (this.isOpen = false)} + exportparts={exportparts} + scope={this.bindings.interfaceElement} + > + {renderHeader()} + {renderBody()} + + + ); + } +} diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.new.stories.tsx b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.new.stories.tsx index ba3115d8205..f9765aaa41c 100644 --- a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.new.stories.tsx +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.new.stories.tsx @@ -1,18 +1,46 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInInsightInterface} from '@coveo/atomic-storybook-utils/insight/insight-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; -import {wrapInInsightInterface} from '../../../../../storybookUtils/insight/insight-interface-wrapper'; const {decorator, play} = wrapInInsightInterface(); const meta: Meta = { component: 'atomic-insight-user-actions-timeline', - title: 'Atomic/Insight/UserActionsTimelines', + title: 'Atomic/Insight/UserActionsTimeline', id: 'atomic-insight-user-actions-timeline', render: renderComponent, decorators: [decorator], parameters, + argTypes: { + 'attributes-user-id': { + control: { + type: 'text', + }, + description: 'The ID of the user whose actions are being displayed.', + table: { + category: 'attributes', + type: { + summary: 'string', + }, + defaultValue: {}, + }, + }, + 'attributes-ticket-creation-date-time': { + control: { + type: 'text', + }, + description: 'The date and time when the case was created.', + table: { + category: 'attributes', + type: { + summary: 'string', + }, + defaultValue: {}, + }, + }, + }, play, }; diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.tsx b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.tsx index dfdb30fdbbc..72b3790e2fe 100644 --- a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.tsx +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-timeline/atomic-insight-user-actions-timeline.tsx @@ -18,6 +18,7 @@ import {MagnifyingGlass} from '../../../common/no-items/magnifying-glass'; import {InsightBindings} from '../../atomic-insight-interface/atomic-insight-interface'; /** + * @internal * This component displays all the actions performed by a user around the time they created a case. * The actions are grouped into multiple sessions, including the session during which the case was created, * the sessions preceding the case creation and the sessions following the case creation. diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.new.stories.tsx b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.new.stories.tsx new file mode 100644 index 00000000000..3c6001db88f --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.new.stories.tsx @@ -0,0 +1,54 @@ +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInInsightInterface} from '@coveo/atomic-storybook-utils/insight/insight-interface-wrapper'; +import type {Meta, StoryObj as Story} from '@storybook/web-components'; + +const {decorator, play} = wrapInInsightInterface(); + +const meta: Meta = { + component: 'atomic-insight-user-actions-toggle', + title: 'Atomic/Insight/UserActionsToggle', + id: 'atomic-insight-user-actions-toggle', + + render: renderComponent, + decorators: [decorator], + parameters, + argTypes: { + 'attributes-user-id': { + control: { + type: 'text', + }, + description: 'The ID of the user whose actions are being displayed.', + table: { + category: 'attributes', + type: { + summary: 'string', + }, + defaultValue: {}, + }, + }, + 'attributes-ticket-creation-date-time': { + control: { + type: 'text', + }, + description: 'The date and time when the case was created.', + table: { + category: 'attributes', + type: { + summary: 'string', + }, + defaultValue: {}, + }, + }, + }, + play, +}; + +export default meta; + +export const Default: Story = { + name: 'atomic-insight-user-actions-toggle', + play: async (context) => { + await play(context); + }, +}; diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.pcss b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.pcss new file mode 100644 index 00000000000..7a0133e5e82 --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.pcss @@ -0,0 +1 @@ +@import '../../../../global/global.pcss'; diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.tsx b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.tsx new file mode 100644 index 00000000000..7e1cf99af31 --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/atomic-insight-user-actions-toggle.tsx @@ -0,0 +1,71 @@ +import {Component, h, Prop, Element, State} from '@stencil/core'; +import Clockicon from '../../../../images/clock.svg'; +import {InitializeBindings} from '../../../../utils/initialization-utils'; +import {IconButton} from '../../../common/iconButton'; +import {InsightBindings} from '../../atomic-insight-interface/atomic-insight-interface'; + +/** + * @internal + * The `atomic-insight-user-actions-toggle` component displays a button that opens a modal containing the user actions timeline component. + */ +@Component({ + tag: 'atomic-insight-user-actions-toggle', + styleUrl: 'atomic-insight-user-actions-toggle.pcss', + shadow: true, +}) +export class AtomicInsightUserActionsToggle { + @Element() public host!: HTMLElement; + @InitializeBindings() public bindings!: InsightBindings; + @State() public error!: Error; + + /** + * The ID of the user whose actions are being displayed. + */ + @Prop() public userId!: string; + /** + * The date and time when the case was created. For example "2024-01-01T00:00:00Z" + */ + @Prop() public ticketCreationDateTime!: string; + + private buttonRef?: HTMLButtonElement; + private modalRef?: HTMLAtomicInsightUserActionsModalElement; + + private enableModal() { + this.modalRef && (this.modalRef.isOpen = true); + } + + private loadModal() { + if (this.modalRef) { + return; + } + + this.modalRef = document.createElement('atomic-insight-user-actions-modal'); + + this.host.insertAdjacentElement('beforebegin', this.modalRef); + this.modalRef.openButton = this.buttonRef; + this.modalRef.userId = this.userId; + this.modalRef.ticketCreationDateTime = this.ticketCreationDateTime; + } + + public render() { + return ( + { + this.enableModal(); + }} + title={this.bindings.i18n.t('user-actions')} + buttonRef={(button?: HTMLButtonElement) => { + if (!button) { + return; + } + this.buttonRef = button; + this.loadModal(); + }} + /> + ); + } +} diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/atomic-insight-user-actions-toggle.e2e.ts b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/atomic-insight-user-actions-toggle.e2e.ts new file mode 100644 index 00000000000..abc4ac153a4 --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/atomic-insight-user-actions-toggle.e2e.ts @@ -0,0 +1,32 @@ +import {test, expect} from './fixture'; + +const exampleUserId = 'exampleUserId'; +const exampleTicketCreationDate = encodeURIComponent('2024-08-30'); + +test.describe('user actions toggle', () => { + test.beforeEach(async ({userActionsToggle}) => { + await userActionsToggle.load({ + args: { + userId: exampleUserId, + ticketCreationDateTime: exampleTicketCreationDate, + }, + }); + }); + + test('should display the user actions toggle button', async ({ + userActionsToggle, + }) => { + await expect(userActionsToggle.atomicInsightHistoryToggle).toBeVisible(); + }); + + test.describe('when clicking the user actions toggle', () => { + test('should display the user actions timeline', async ({ + userActionsToggle, + }) => { + await userActionsToggle.atomicInsightHistoryToggle.click(); + await expect( + userActionsToggle.atomicInsightUserActionsTimeline + ).toBeVisible(); + }); + }); +}); diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/fixture.ts b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/fixture.ts new file mode 100644 index 00000000000..e061c6a4773 --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/fixture.ts @@ -0,0 +1,21 @@ +import {test as base} from '@playwright/test'; +import { + AxeFixture, + makeAxeBuilder, +} from '../../../../../../playwright-utils/base-fixture'; +import {UserActionsTogglePageObject} from './page-object'; + +type AtomicInsightUserActionsToggleE2EFixtures = { + userActionsToggle: UserActionsTogglePageObject; +}; + +export const test = base.extend< + AtomicInsightUserActionsToggleE2EFixtures & AxeFixture +>({ + makeAxeBuilder, + userActionsToggle: async ({page}, use) => { + await use(new UserActionsTogglePageObject(page)); + }, +}); + +export {expect} from '@playwright/test'; diff --git a/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/page-object.ts b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/page-object.ts new file mode 100644 index 00000000000..5b1bd0e668b --- /dev/null +++ b/packages/atomic/src/components/insight/user-actions/atomic-insight-user-actions-toggle/e2e/page-object.ts @@ -0,0 +1,16 @@ +import {Page} from '@playwright/test'; +import {BasePageObject} from '../../../../../../playwright-utils/base-page-object'; + +export class UserActionsTogglePageObject extends BasePageObject { + constructor(page: Page) { + super(page, 'atomic-insight-user-actions-toggle'); + } + + get atomicInsightHistoryToggle() { + return this.page.locator('button[title="User actions"]'); + } + + get atomicInsightUserActionsTimeline() { + return this.page.locator('atomic-insight-user-actions-timeline'); + } +} diff --git a/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.new.stories.tsx b/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.new.stories.tsx new file mode 100644 index 00000000000..9f031711f11 --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.new.stories.tsx @@ -0,0 +1,89 @@ +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import type {Meta, StoryObj as Story} from '@storybook/web-components'; + +async function initializeRecsInterface(canvasElement: HTMLElement) { + await customElements.whenDefined('atomic-recs-interface'); + const recsInterface = canvasElement.querySelector('atomic-recs-interface'); + await recsInterface!.initialize({ + accessToken: 'xx149e3ec9-786f-4c6c-b64f-49a403b930de', + organizationId: 'fashioncoveodemocomgzh7iep8', + }); +} + +const meta: Meta = { + component: 'atomic-recs-interface', + title: 'Atomic/Recommendations/atomic-recs-interface', + id: 'atomic-recs-interface', + render: renderComponent, + parameters, + play: async (context) => { + await initializeRecsInterface(context.canvasElement); + const recsInterface = context.canvasElement.querySelector( + 'atomic-recs-interface' + ); + await recsInterface!.getRecommendations(); + }, +}; + +export default meta; + +export const Default: Story = { + name: 'atomic-recs-interface', +}; + +export const WithRecsList: Story = { + args: { + 'slots-default': ` + + + + + + + + + + + + + + reviews + + + + + + + + + + + + `, + }, +}; + +export const RecsBeforeInit: Story = { + tags: ['test'], + play: async (context) => { + const recsInterface = context.canvasElement.querySelector( + 'atomic-recs-interface' + ); + await recsInterface!.getRecommendations(); + }, +}; diff --git a/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.tsx b/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.tsx index 580742d388a..9d12726eb6b 100644 --- a/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.tsx +++ b/packages/atomic/src/components/recommendations/atomic-recs-interface/atomic-recs-interface.tsx @@ -41,6 +41,8 @@ export type RecsBindings = CommonBindings< /** * The `atomic-recs-interface` component is the parent to all other atomic components in a recommendation interface. It handles the headless recommendation engine and localization configurations. + * @slot default - The default slot where you can add child components to the recommendation interface. + * */ @Component({ tag: 'atomic-recs-interface', diff --git a/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/atomic-recs-interface.e2e.ts b/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/atomic-recs-interface.e2e.ts new file mode 100644 index 00000000000..0e74e3ccd2e --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/atomic-recs-interface.e2e.ts @@ -0,0 +1,18 @@ +import {test, expect} from './fixture'; + +test.describe('before being initialized', () => { + test('should return error if request is executed', async ({ + page, + recsInterface, + }) => { + await recsInterface.load({story: 'recs-before-init'}); + + const errorMessage = await page.waitForEvent('console', (msg) => { + return msg.type() === 'error'; + }); + + expect(errorMessage.text()).toContain( + 'You have to call "initialize" on the atomic-recs-interface component before modifying the props or calling other public methods.' + ); + }); +}); diff --git a/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/fixture.ts b/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/fixture.ts new file mode 100644 index 00000000000..1bbb69aee72 --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/fixture.ts @@ -0,0 +1,19 @@ +import {test as base} from '@playwright/test'; +import { + AxeFixture, + makeAxeBuilder, +} from '../../../../../playwright-utils/base-fixture'; +import {RecsInterfacePageObject as RecsInterface} from './page-object'; + +type MyFixtures = { + recsInterface: RecsInterface; +}; + +export const test = base.extend({ + makeAxeBuilder, + recsInterface: async ({page}, use) => { + await use(new RecsInterface(page)); + }, +}); + +export {expect} from '@playwright/test'; diff --git a/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/page-object.ts b/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/page-object.ts new file mode 100644 index 00000000000..55404e2f8e3 --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-interface/e2e/page-object.ts @@ -0,0 +1,8 @@ +import type {Page} from '@playwright/test'; +import {BasePageObject} from '../../../../../playwright-utils/base-page-object'; + +export class RecsInterfacePageObject extends BasePageObject<'atomic-recs-interface'> { + constructor(page: Page) { + super(page, 'atomic-recs-interface'); + } +} diff --git a/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.new.stories.tsx b/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.new.stories.tsx index 90ff2175be8..1bafd56311c 100644 --- a/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.new.stories.tsx +++ b/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInRecommendationInterface} from '@coveo/atomic/storybookUtils/search/recs-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInRecommendationInterface} from '@coveo/atomic-storybook-utils/search/recs-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html/static.js'; @@ -10,7 +10,6 @@ const meta: Meta = { component: 'atomic-recs-list', title: 'Atomic/RecsList', id: 'atomic-recs-list', - render: renderComponent, decorators: [decorator], parameters, @@ -31,3 +30,52 @@ export const Default: Story = { ${story()}`, ], }; + +const {play: playNoFirstQuery} = wrapInRecommendationInterface({ + skipFirstQuery: true, +}); + +export const RecsBeforeQuery: Story = { + tags: ['test'], + play: playNoFirstQuery, +}; + +export const RecsWithFullTemplate: Story = { + tags: ['test'], + args: { + 'slots-default': ` + + + Visual Section + + + Badge Section + + + Actions Section + + + Title Section + + + Title Metadata Section + + + Emphasized Section + + + Excerpt Section + + + Bottom Metadata Section + + + `, + }, +}; + +export const RecsAsCarousel: Story = { + args: { + 'attributes-number-of-recommendations-per-page': 4, + }, +}; diff --git a/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.tsx b/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.tsx index c51a8b70776..eea0f7a3790 100644 --- a/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.tsx +++ b/packages/atomic/src/components/recommendations/atomic-recs-list/atomic-recs-list.tsx @@ -54,6 +54,7 @@ import {RecsBindings} from '../atomic-recs-interface/atomic-recs-interface'; * @part indicators - The list of indicators. * @part indicator - A single indicator. * @part active-indicator - The active indicator. + * @slot default - The default slot where to insert the template element. */ @Component({ tag: 'atomic-recs-list', diff --git a/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/atomic-recs-list.e2e.ts b/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/atomic-recs-list.e2e.ts new file mode 100644 index 00000000000..9511e10b607 --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/atomic-recs-list.e2e.ts @@ -0,0 +1,98 @@ +import {test, expect} from './fixture'; + +test.describe('before query is loaded', () => { + test.beforeEach(async ({recsList}) => { + await recsList.load({story: 'recs-before-query'}); + await recsList.hydrated.waitFor(); + }); + + test('should be ally compliant', async ({makeAxeBuilder}) => { + const accessibilityResults = await makeAxeBuilder().analyze(); + expect(accessibilityResults.violations.length).toEqual(0); + }); + + test('should have placeholders', async ({recsList}) => { + await expect(recsList.placeholder.first()).toBeVisible(); + }); +}); + +test.describe('after query is loaded', () => { + test.beforeEach(async ({recsList}) => { + await recsList.load({story: 'default'}); + await recsList.hydrated.waitFor(); + }); + + test('should be ally compliant', async ({makeAxeBuilder}) => { + const accessibilityResults = await makeAxeBuilder().analyze(); + expect(accessibilityResults.violations.length).toEqual(0); + }); + + test('should have recommendations', async ({recsList}) => { + await expect(recsList.recommendation.first()).toBeVisible(); + }); +}); + +test.describe('with a full result template', () => { + test.beforeEach(async ({recsList}) => { + await recsList.load({story: 'recs-with-full-template'}); + await recsList.hydrated.waitFor(); + }); + + test('should be ally compliant', async ({makeAxeBuilder}) => { + const accessibilityResults = await makeAxeBuilder().analyze(); + expect(accessibilityResults.violations.length).toEqual(0); + }); + + test('should have recommendations', async ({recsList}) => { + await expect(recsList.recommendation.first()).toBeVisible(); + }); +}); + +test.describe('with a carousel', () => { + test.beforeEach(async ({recsList}) => { + await recsList.load({story: 'recs-as-carousel'}); + await recsList.hydrated.waitFor(); + }); + + test('should be ally compliant', async ({makeAxeBuilder}) => { + const accessibilityResults = await makeAxeBuilder().analyze(); + expect(accessibilityResults.violations.length).toEqual(0); + }); + + test('should have recommendations', async ({recsList}) => { + await expect(recsList.recommendation.first()).toBeVisible(); + }); + + test('should support going forward and backward', async ({recsList}) => { + await recsList.nextButton.click(); + await expect(recsList.indicators.nth(1)).toHaveAttribute( + 'part', + 'indicator active-indicator' + ); + + await recsList.prevButton.click(); + await recsList.prevButton.click(); + await expect(recsList.indicators.nth(2)).toHaveAttribute( + 'part', + 'indicator active-indicator' + ); + + await recsList.nextButton.click(); + await expect(recsList.indicators.nth(0)).toHaveAttribute( + 'part', + 'indicator active-indicator' + ); + }); +}); + +test('with no recommendations returned by the API, should render placeholders', async ({ + recsList, + page, +}) => { + await recsList.noRecommendations(); + await recsList.load({story: 'default'}); + await recsList.hydrated.waitFor(); + + await page.waitForLoadState('networkidle'); + await expect(recsList.placeholder.first()).toBeVisible(); +}); diff --git a/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/fixture.ts b/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/fixture.ts new file mode 100644 index 00000000000..09aafd71918 --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/fixture.ts @@ -0,0 +1,19 @@ +import {test as base} from '@playwright/test'; +import { + AxeFixture, + makeAxeBuilder, +} from '../../../../../playwright-utils/base-fixture'; +import {AtomicCommerceRecsListPageObject as RecsList} from './page-object'; + +type MyFixtures = { + recsList: RecsList; +}; + +export const test = base.extend({ + makeAxeBuilder, + recsList: async ({page}, use) => { + await use(new RecsList(page)); + }, +}); + +export {expect} from '@playwright/test'; diff --git a/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/page-object.ts b/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/page-object.ts new file mode 100644 index 00000000000..dd3406a8674 --- /dev/null +++ b/packages/atomic/src/components/recommendations/atomic-recs-list/e2e/page-object.ts @@ -0,0 +1,47 @@ +import type {Page} from '@playwright/test'; +import {BasePageObject} from '../../../../../playwright-utils/base-page-object'; + +export class AtomicCommerceRecsListPageObject extends BasePageObject<'atomic-recs-list'> { + constructor(page: Page) { + super(page, 'atomic-recs-list'); + } + + get placeholder() { + return this.page.locator('.placeholder'); + } + + get recommendation() { + return this.page.locator( + '[part="result-list-grid-clickable-container outline"]' + ); + } + + get indicators() { + return this.page.getByRole('listitem'); + } + + get nextButton() { + return this.page.getByLabel('Next'); + } + + get prevButton() { + return this.page.getByLabel('Previous'); + } + + async noRecommendations() { + await this.page.route( + '**/search/v2?organizationId=searchuisamples', + async (route) => { + const response = await route.fetch(); + const body = await response.json(); + body.results = []; + await route.fulfill({ + response, + json: body, + }); + } + ); + + return this; + } +} diff --git a/packages/atomic/src/components/search/atomic-breadbox/atomic-breadbox.new.stories.tsx b/packages/atomic/src/components/search/atomic-breadbox/atomic-breadbox.new.stories.tsx index fadf3fe42e7..8c68dc86ae8 100644 --- a/packages/atomic/src/components/search/atomic-breadbox/atomic-breadbox.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-breadbox/atomic-breadbox.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import {userEvent, waitFor, expect} from '@storybook/test'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/search/atomic-did-you-mean/atomic-did-you-mean.new.stories.tsx b/packages/atomic/src/components/search/atomic-did-you-mean/atomic-did-you-mean.new.stories.tsx index b52b0af4ec8..1f7e15b98be 100644 --- a/packages/atomic/src/components/search/atomic-did-you-mean/atomic-did-you-mean.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-did-you-mean/atomic-did-you-mean.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/atomic-external/atomic-external.new.stories.tsx b/packages/atomic/src/components/search/atomic-external/atomic-external.new.stories.tsx new file mode 100644 index 00000000000..a3dee05375a --- /dev/null +++ b/packages/atomic/src/components/search/atomic-external/atomic-external.new.stories.tsx @@ -0,0 +1,100 @@ +import {Meta, StoryObj} from '@storybook/web-components'; +import {html} from 'lit-html'; + +const meta: Meta = { + component: 'atomic-external', + title: 'Atomic/Atomic External', + id: 'atomic-external', + render: () => html` + + + + External components of interface #2 + + + + + + + + Interface #1, not linked to URL + + + + + + + + + + + Interface #2, linked to URL + + + + + + + `, + play: async () => { + await customElements.whenDefined('atomic-search-interface'); + + const searchInterface1 = document.querySelector( + '#interface-1' + ) as HTMLAtomicSearchInterfaceElement; + const searchInterface2 = document.querySelector( + '#interface-2' + ) as HTMLAtomicSearchInterfaceElement; + + await Promise.all([ + searchInterface1.initialize({ + accessToken: 'xxc23ce82a-3733-496e-b37e-9736168c4fd9', + organizationId: 'electronicscoveodemocomo0n2fu8v', + analytics: { + analyticsMode: 'legacy', + }, + }), + searchInterface2.initialize({ + accessToken: 'xx564559b1-0045-48e1-953c-3addd1ee4457', + organizationId: 'searchuisamples', + analytics: { + analyticsMode: 'legacy', + }, + }), + ]); + + searchInterface1.executeFirstSearch(); + searchInterface2.executeFirstSearch(); + }, +}; + +export default meta; + +export const Default: StoryObj = { + name: 'atomic-external', +}; diff --git a/packages/atomic/src/components/search/atomic-external/e2e/atomic-external.e2e.ts b/packages/atomic/src/components/search/atomic-external/e2e/atomic-external.e2e.ts new file mode 100644 index 00000000000..526428e14ec --- /dev/null +++ b/packages/atomic/src/components/search/atomic-external/e2e/atomic-external.e2e.ts @@ -0,0 +1,39 @@ +import {test, expect} from './fixture'; + +test.describe('External Test Suite', () => { + test.describe('when modifying state of a component (search box) that is a child of an atomic-external component', () => { + test.beforeEach(async ({external}) => { + await external.load(); + + await external.searchBox + .locator('[part="textarea"]') + .fill('hello', {timeout: 1000}); + + await external.searchBox.press('Enter'); + }); + + test("other components' state under the same atomic-external should be affected", async ({ + external, + }) => { + await expect(external.querySummary).toHaveText(/hello/); + }); + + test("other components' state under the linked atomic-search-interface should be affected", async ({ + page, + }) => { + const querySummary = page.locator( + 'atomic-search-interface#interface-2 > atomic-query-summary' + ); + await expect(querySummary).toHaveText(/hello/); + }); + + test("other components' state under a different atomic-search-interface should not be affected", async ({ + page, + }) => { + const querySummary = page.locator( + 'atomic-search-interface#interface-1 > atomic-query-summary' + ); + await expect(querySummary).not.toHaveText(/hello/); + }); + }); +}); diff --git a/packages/atomic/src/components/search/atomic-external/e2e/fixture.ts b/packages/atomic/src/components/search/atomic-external/e2e/fixture.ts new file mode 100644 index 00000000000..39e0491ee79 --- /dev/null +++ b/packages/atomic/src/components/search/atomic-external/e2e/fixture.ts @@ -0,0 +1,19 @@ +import {test as base} from '@playwright/test'; +import { + AxeFixture, + makeAxeBuilder, +} from '../../../../../playwright-utils/base-fixture'; +import {AtomicExternalPageObject as External} from './page-object'; + +type MyFixtures = { + external: External; +}; + +export const test = base.extend({ + makeAxeBuilder, + external: async ({page}, use) => { + await use(new External(page)); + }, +}); + +export {expect} from '@playwright/test'; diff --git a/packages/atomic/src/components/search/atomic-external/e2e/page-object.ts b/packages/atomic/src/components/search/atomic-external/e2e/page-object.ts new file mode 100644 index 00000000000..72816aacac2 --- /dev/null +++ b/packages/atomic/src/components/search/atomic-external/e2e/page-object.ts @@ -0,0 +1,16 @@ +import {Page} from '@playwright/test'; +import {BasePageObject} from '../../../../../playwright-utils/base-page-object'; + +export class AtomicExternalPageObject extends BasePageObject<'atomic-external'> { + constructor(page: Page) { + super(page, 'atomic-external'); + } + + get searchBox() { + return this.page.locator('atomic-external > atomic-search-box'); + } + + get querySummary() { + return this.page.locator('atomic-external > atomic-query-summary'); + } +} diff --git a/packages/atomic/src/components/search/atomic-facet-manager/atomic-facet-manager.new.stories.tsx b/packages/atomic/src/components/search/atomic-facet-manager/atomic-facet-manager.new.stories.tsx index 51fe573fe8e..0fb341490b4 100644 --- a/packages/atomic/src/components/search/atomic-facet-manager/atomic-facet-manager.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-facet-manager/atomic-facet-manager.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx b/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx index de664a250f4..6882feee8ef 100644 --- a/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx +++ b/packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.tsx @@ -6,8 +6,11 @@ import { GeneratedAnswer, GeneratedAnswerState, buildInteractiveCitation, + buildTabManager, + TabManagerState, + TabManager, } from '@coveo/headless'; -import {Component, Element, State, Prop, Watch} from '@stencil/core'; +import {Component, Element, State, Prop, Watch, h} from '@stencil/core'; import {AriaLiveRegion} from '../../../utils/accessibility-utils'; import {debounce} from '../../../utils/debounce-utils'; import { @@ -15,7 +18,10 @@ import { InitializableComponent, InitializeBindings, } from '../../../utils/initialization-utils'; +import {ArrayProp} from '../../../utils/props-utils'; +import {shouldDisplayOnCurrentTab} from '../../../utils/tab-utils'; import {GeneratedAnswerCommon} from '../../common/generated-answer/generated-answer-common'; +import {Hidden} from '../../common/hidden'; import {Bindings} from '../atomic-search-interface/atomic-search-interface'; /** @@ -75,6 +81,12 @@ export class AtomicGeneratedAnswer implements InitializableComponent { @State() private searchStatusState!: SearchStatusState; + public tabManager!: TabManager; + + @BindStateToController('tabManager') + @State() + public tabManagerState!: TabManagerState; + @State() public error!: Error; @@ -104,6 +116,32 @@ export class AtomicGeneratedAnswer implements InitializableComponent { */ @Prop() answerConfigurationId?: string; + /** + * The tabs on which the generated answer can be displayed. This property should not be used at the same time as `tabs-excluded`. + * + * Set this property as a stringified JSON array, e.g., + * ```html + * + * ``` + * If you don't set this property, the generated answer can be displayed on any tab. Otherwise, the generated answer can only be displayed on the specified tabs. + */ + @ArrayProp() + @Prop({reflect: true, mutable: true}) + public tabsIncluded: string[] | string = '[]'; + + /** + * The tabs on which this generated answer must not be displayed. This property should not be used at the same time as `tabs-included`. + * + * Set this property as a stringified JSON array, e.g., + * ```html + * + * ``` + * If you don't set this property, the generated answer can be displayed on any tab. Otherwise, the generated answer won't be displayed on any of the specified tabs. + */ + @ArrayProp() + @Prop({reflect: true, mutable: true}) + public tabsExcluded: string[] | string = '[]'; + @AriaLiveRegion('generated-answer') protected ariaMessage!: string; @@ -112,6 +150,14 @@ export class AtomicGeneratedAnswer implements InitializableComponent { private maxCollapsedHeight = 250; public initialize() { + if ( + [...this.tabsIncluded].length > 0 && + [...this.tabsExcluded].length > 0 + ) { + console.warn( + 'Values for both "tabs-included" and "tabs-excluded" have been provided. This could lead to unexpected behaviors.' + ); + } this.generatedAnswerCommon = new GeneratedAnswerCommon({ host: this.host, withToggle: this.withToggle, @@ -150,6 +196,7 @@ export class AtomicGeneratedAnswer implements InitializableComponent { this.resizeObserver = new ResizeObserver(debouncedAdaptAnswerHeight); this.resizeObserver.observe(this.host); } + this.tabManager = buildTabManager(this.bindings.engine); } @Watch('generatedAnswerState') @@ -253,7 +300,36 @@ export class AtomicGeneratedAnswer implements InitializableComponent { } } + @Watch('tabManagerState') + watchTabManagerState( + newValue: {activeTab: string}, + oldValue: {activeTab: string} + ) { + if (newValue?.activeTab !== oldValue?.activeTab) { + if ( + !shouldDisplayOnCurrentTab( + [...this.tabsIncluded], + [...this.tabsExcluded], + this.tabManagerState?.activeTab + ) + ) { + this.generatedAnswer.disable(); + } else { + this.generatedAnswer.enable(); + } + } + } + public render() { + if ( + !shouldDisplayOnCurrentTab( + [...this.tabsIncluded], + [...this.tabsExcluded], + this.tabManagerState?.activeTab + ) + ) { + return ; + } return this.generatedAnswerCommon.render(); } } diff --git a/packages/atomic/src/components/search/atomic-load-more-results/atomic-load-more-results.new.stories.tsx b/packages/atomic/src/components/search/atomic-load-more-results/atomic-load-more-results.new.stories.tsx index d55fe899311..8bb4189df76 100644 --- a/packages/atomic/src/components/search/atomic-load-more-results/atomic-load-more-results.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-load-more-results/atomic-load-more-results.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/atomic-no-results/atomic-no-results.new.stories.tsx b/packages/atomic/src/components/search/atomic-no-results/atomic-no-results.new.stories.tsx index 959bec11492..758dfdba258 100644 --- a/packages/atomic/src/components/search/atomic-no-results/atomic-no-results.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-no-results/atomic-no-results.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/atomic-notification/atomic-notifications.new.stories.tsx b/packages/atomic/src/components/search/atomic-notification/atomic-notifications.new.stories.tsx index 618bf261377..e97df52e1f0 100644 --- a/packages/atomic/src/components/search/atomic-notification/atomic-notifications.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-notification/atomic-notifications.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/atomic-pager/atomic-pager.new.stories.tsx b/packages/atomic/src/components/search/atomic-pager/atomic-pager.new.stories.tsx index e614be02dfc..f471e92d941 100644 --- a/packages/atomic/src/components/search/atomic-pager/atomic-pager.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-pager/atomic-pager.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/atomic-query-error/atomic-query-error.new.stories.tsx b/packages/atomic/src/components/search/atomic-query-error/atomic-query-error.new.stories.tsx index 017fb5821f5..dd5a44867cb 100644 --- a/packages/atomic/src/components/search/atomic-query-error/atomic-query-error.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-query-error/atomic-query-error.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/atomic-query-summary/atomic-query-summary.new.stories.tsx b/packages/atomic/src/components/search/atomic-query-summary/atomic-query-summary.new.stories.tsx index 2da89b4195a..9dcc461d4bd 100644 --- a/packages/atomic/src/components/search/atomic-query-summary/atomic-query-summary.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-query-summary/atomic-query-summary.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/atomic-refine-toggle/atomic-refine-toggle.new.stories.tsx b/packages/atomic/src/components/search/atomic-refine-toggle/atomic-refine-toggle.new.stories.tsx index 049c3a14552..04e78c44661 100644 --- a/packages/atomic/src/components/search/atomic-refine-toggle/atomic-refine-toggle.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-refine-toggle/atomic-refine-toggle.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/search/atomic-results-per-page/atomic-results-per-page.new.stories.tsx b/packages/atomic/src/components/search/atomic-results-per-page/atomic-results-per-page.new.stories.tsx index 3035afb696f..5d971c0c2dc 100644 --- a/packages/atomic/src/components/search/atomic-results-per-page/atomic-results-per-page.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-results-per-page/atomic-results-per-page.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.new.stories.tsx b/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.new.stories.tsx index 9268d8c69e0..bcc3d914a33 100644 --- a/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.new.stories.tsx @@ -1,9 +1,9 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; import { playExecuteFirstSearch, wrapInSearchInterface, -} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; @@ -26,9 +26,6 @@ const meta: Meta = { decorators: [decorator], parameters, play, - args: { - 'attributes-textarea': true, - }, }; export default meta; diff --git a/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.pcss b/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.pcss index 66f67164b88..5ca524d20ad 100644 --- a/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.pcss +++ b/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.pcss @@ -26,6 +26,6 @@ } } -:host([textarea]) { +:host { @apply relative z-10; } diff --git a/packages/atomic/src/components/search/atomic-search-box/e2e/atomic-search-box.e2e.ts b/packages/atomic/src/components/search/atomic-search-box/e2e/atomic-search-box.e2e.ts index 71d19516183..dc8d09792d9 100644 --- a/packages/atomic/src/components/search/atomic-search-box/e2e/atomic-search-box.e2e.ts +++ b/packages/atomic/src/components/search/atomic-search-box/e2e/atomic-search-box.e2e.ts @@ -257,3 +257,10 @@ test.describe('with minimum-query-length=4', () => { }); }); }); + +test('should have position:relative and z-index:10', async ({searchBox}) => { + await searchBox.load(); + + await expect(searchBox.hydrated).toHaveCSS('position', 'relative'); + await expect(searchBox.hydrated).toHaveCSS('z-index', '10'); +}); diff --git a/packages/atomic/src/components/search/atomic-sort-dropdown/atomic-sort-dropdown.new.stories.tsx b/packages/atomic/src/components/search/atomic-sort-dropdown/atomic-sort-dropdown.new.stories.tsx index 5d9646349ad..634f08beb97 100644 --- a/packages/atomic/src/components/search/atomic-sort-dropdown/atomic-sort-dropdown.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-sort-dropdown/atomic-sort-dropdown.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/atomic-sort-expression/atomic-sort-expression.new.stories.tsx b/packages/atomic/src/components/search/atomic-sort-expression/atomic-sort-expression.new.stories.tsx index af4942a3bc7..fcf9e8a6987 100644 --- a/packages/atomic/src/components/search/atomic-sort-expression/atomic-sort-expression.new.stories.tsx +++ b/packages/atomic/src/components/search/atomic-sort-expression/atomic-sort-expression.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.new.stories.tsx index 7424f55c8e2..c56efe4a026 100644 --- a/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.new.stories.tsx index 0049f5b2ee8..e3febfc941c 100644 --- a/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.tsx b/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.tsx index 4956dc0fcda..9c4073c99a2 100644 --- a/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-category-facet/atomic-category-facet.tsx @@ -16,15 +16,7 @@ import { TabManager, buildTabManager, } from '@coveo/headless'; -import { - Component, - h, - State, - Prop, - Element, - Fragment, - Watch, -} from '@stencil/core'; +import {Component, h, State, Prop, Element, Fragment} from '@stencil/core'; import { AriaLiveRegion, FocusTargetController, @@ -62,7 +54,6 @@ import { shouldDisplaySearchResults, } from '../../../common/facets/facet-search/facet-search-utils'; import {FacetShowMoreLess} from '../../../common/facets/facet-show-more-less/facet-show-more-less'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {FacetValuesGroup} from '../../../common/facets/facet-values-group/facet-values-group'; import {initializePopover} from '../../../common/facets/popover/popover-type'; import {Bindings} from '../../atomic-search-interface/atomic-search-interface'; @@ -287,6 +278,10 @@ export class AtomicCategoryFacet implements InitializableComponent { filterByBasePath: this.filterByBasePath, injectionDepth: this.injectionDepth, filterFacetCount: this.filterFacetCount, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }; this.facet = buildCategoryFacet(this.bindings.engine, {options}); announceFacetSearchResultsWithAriaLive( @@ -349,21 +344,6 @@ export class AtomicCategoryFacet implements InitializableComponent { ); } - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facet - ); - } - } - public componentShouldUpdate( next: unknown, prev: unknown, diff --git a/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.new.stories.tsx index 53f6f178d58..10e6b8deda0 100644 --- a/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {facetDecorator} from '@coveo/atomic/storybookUtils/common/facets-decorator'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {facetDecorator} from '@coveo/atomic-storybook-utils/common/facets-decorator'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import { ArgTypes, Args, diff --git a/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.tsx b/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.tsx index 928b6a4848f..d83e131ee38 100644 --- a/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-color-facet/atomic-color-facet.tsx @@ -17,7 +17,7 @@ import { TabManager, TabManagerState, } from '@coveo/headless'; -import {Component, h, State, Prop, VNode, Element, Watch} from '@stencil/core'; +import {Component, h, State, Prop, VNode, Element} from '@stencil/core'; import { AriaLiveRegion, FocusTargetController, @@ -45,7 +45,6 @@ import { shouldDisplaySearchResults, } from '../../../common/facets/facet-search/facet-search-utils'; import {FacetShowMoreLess} from '../../../common/facets/facet-show-more-less/facet-show-more-less'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {FacetValueBox} from '../../../common/facets/facet-value-box/facet-value-box'; import {FacetValueLabelHighlight} from '../../../common/facets/facet-value-label-highlight/facet-value-label-highlight'; import {FacetValuesGroup} from '../../../common/facets/facet-values-group/facet-values-group'; @@ -348,21 +347,6 @@ export class AtomicColorFacet implements InitializableComponent { ); } - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facet - ); - } - } - public componentShouldUpdate( next: unknown, prev: unknown, @@ -606,6 +590,10 @@ export class AtomicColorFacet implements InitializableComponent { ? [...this.allowedValues] : undefined, customSort: this.customSort.length ? [...this.customSort] : undefined, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }; } diff --git a/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.new.stories.tsx index 1fe9ad71a6d..9791adfdd08 100644 --- a/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {facetDecorator} from '@coveo/atomic/storybookUtils/common/facets-decorator'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {facetDecorator} from '@coveo/atomic-storybook-utils/common/facets-decorator'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.tsx b/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.tsx index ec05e74d226..eea2caa2292 100644 --- a/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-facet/atomic-facet.tsx @@ -24,7 +24,6 @@ import { Element, VNode, Fragment, - Watch, } from '@stencil/core'; import { AriaLiveRegion, @@ -53,7 +52,6 @@ import { } from '../../../common/facets/facet-search/facet-search-utils'; import {FacetSearchValue} from '../../../common/facets/facet-search/facet-search-value'; import {FacetShowMoreLess} from '../../../common/facets/facet-show-more-less/facet-show-more-less'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import { FacetValueProps, FacetValue, @@ -318,21 +316,6 @@ export class AtomicFacet implements InitializableComponent { this.facetConditionsManager?.stopWatching(); } - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facet - ); - } - } - public componentShouldUpdate( next: FacetState, prev: FacetState, @@ -541,6 +524,10 @@ export class AtomicFacet implements InitializableComponent { ? [...this.allowedValues] : undefined, customSort: this.customSort.length ? [...this.customSort] : undefined, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }; } diff --git a/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.new.stories.tsx index c8b42a9b951..2b4149e7801 100644 --- a/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {facetDecorator} from '@coveo/atomic/storybookUtils/common/facets-decorator'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {facetDecorator} from '@coveo/atomic-storybook-utils/common/facets-decorator'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.tsx b/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.tsx index 6f0d9857da0..1f4ee6bfcd6 100644 --- a/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-numeric-facet/atomic-numeric-facet.tsx @@ -22,7 +22,7 @@ import { TabManager, TabManagerState, } from '@coveo/headless'; -import {Component, Element, h, Listen, Prop, State, Watch} from '@stencil/core'; +import {Component, Element, h, Listen, Prop, State} from '@stencil/core'; import {FocusTargetController} from '../../../../utils/accessibility-utils'; import { BindStateToController, @@ -39,7 +39,6 @@ import {FacetGuard} from '../../../common/facets/facet-guard'; import {FacetHeader} from '../../../common/facets/facet-header/facet-header'; import {NumberInputType} from '../../../common/facets/facet-number-input/number-input-type'; import {FacetPlaceholder} from '../../../common/facets/facet-placeholder/facet-placeholder'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {formatHumanReadable} from '../../../common/facets/numeric-facet/formatter'; import {NumericFacetValueLink} from '../../../common/facets/numeric-facet/value-link'; import {NumericFacetValuesContainer} from '../../../common/facets/numeric-facet/values-container'; @@ -264,22 +263,6 @@ export class AtomicNumericFacet implements InitializableComponent { private initializeTabManager() { this.tabManager = buildTabManager(this.bindings.engine); } - - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facetForRange - ); - } - } - private initializeFacetForInput() { if (!this.withInput) { return; @@ -294,6 +277,10 @@ export class AtomicNumericFacet implements InitializableComponent { rangeAlgorithm: this.rangeAlgorithm, filterFacetCount: this.filterFacetCount, injectionDepth: this.injectionDepth, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }, }); diff --git a/packages/atomic/src/components/search/facets/atomic-popover/atomic-popover.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-popover/atomic-popover.new.stories.tsx index fc4b719a0cc..76a1db8d5bb 100644 --- a/packages/atomic/src/components/search/facets/atomic-popover/atomic-popover.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-popover/atomic-popover.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.new.stories.tsx index 611ebbeb9db..6652f3c940a 100644 --- a/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {facetDecorator} from '@coveo/atomic/storybookUtils/common/facets-decorator'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {facetDecorator} from '@coveo/atomic-storybook-utils/common/facets-decorator'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.tsx b/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.tsx index 93bbe311216..d3a1b0e261e 100644 --- a/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-rating-facet/atomic-rating-facet.tsx @@ -18,7 +18,7 @@ import { TabManager, TabManagerState, } from '@coveo/headless'; -import {Component, h, State, Prop, VNode, Element, Watch} from '@stencil/core'; +import {Component, h, State, Prop, VNode, Element} from '@stencil/core'; import Star from '../../../../images/star.svg'; import {FocusTargetController} from '../../../../utils/accessibility-utils'; import { @@ -33,7 +33,6 @@ import {FacetInfo} from '../../../common/facets/facet-common-store'; import {FacetContainer} from '../../../common/facets/facet-container/facet-container'; import {FacetHeader} from '../../../common/facets/facet-header/facet-header'; import {FacetPlaceholder} from '../../../common/facets/facet-placeholder/facet-placeholder'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {FacetValueCheckbox} from '../../../common/facets/facet-value-checkbox/facet-value-checkbox'; import {FacetValueLink} from '../../../common/facets/facet-value-link/facet-value-link'; import {FacetValuesGroup} from '../../../common/facets/facet-values-group/facet-values-group'; @@ -244,6 +243,10 @@ export class AtomicRatingFacet implements InitializableComponent { generateAutomaticRanges: false, filterFacetCount: this.filterFacetCount, injectionDepth: this.injectionDepth, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }; this.facet = buildNumericFacet(this.bindings.engine, {options}); this.facetId = this.facet.state.facetId; @@ -271,22 +274,6 @@ export class AtomicRatingFacet implements InitializableComponent { } this.dependenciesManager?.stopWatching(); } - - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facet - ); - } - } - private get isHidden() { return ( this.searchStatusState.hasError || diff --git a/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.new.stories.tsx index 0277bd16b00..0af4b57fe28 100644 --- a/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {facetDecorator} from '@coveo/atomic/storybookUtils/common/facets-decorator'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {facetDecorator} from '@coveo/atomic-storybook-utils/common/facets-decorator'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.tsx b/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.tsx index 4a9052c8837..6f3384b0b2f 100644 --- a/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-rating-range-facet/atomic-rating-range-facet.tsx @@ -17,7 +17,7 @@ import { TabManager, TabManagerState, } from '@coveo/headless'; -import {Component, h, State, Prop, VNode, Element, Watch} from '@stencil/core'; +import {Component, h, State, Prop, VNode, Element} from '@stencil/core'; import Star from '../../../../images/star.svg'; import {FocusTargetController} from '../../../../utils/accessibility-utils'; import { @@ -32,7 +32,6 @@ import {FacetInfo} from '../../../common/facets/facet-common-store'; import {FacetContainer} from '../../../common/facets/facet-container/facet-container'; import {FacetHeader} from '../../../common/facets/facet-header/facet-header'; import {FacetPlaceholder} from '../../../common/facets/facet-placeholder/facet-placeholder'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {FacetValueLink} from '../../../common/facets/facet-value-link/facet-value-link'; import {FacetValuesGroup} from '../../../common/facets/facet-values-group/facet-values-group'; import {initializePopover} from '../../../common/facets/popover/popover-type'; @@ -216,20 +215,6 @@ export class AtomicRatingRangeFacet implements InitializableComponent { this.initializeFacet(); this.initializeDependenciesManager(); } - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facet - ); - } - } public disconnectedCallback() { if (this.host.isConnected) { return; @@ -255,6 +240,10 @@ export class AtomicRatingRangeFacet implements InitializableComponent { generateAutomaticRanges: false, filterFacetCount: this.filterFacetCount, injectionDepth: this.injectionDepth, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }; this.facet = buildNumericFacet(this.bindings.engine, {options}); this.facetId = this.facet.state.facetId; diff --git a/packages/atomic/src/components/search/facets/atomic-segmented-facet-scrollable/atomic-segmented-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-segmented-facet-scrollable/atomic-segmented-facet.new.stories.tsx index 3b2fb215c40..4e6b394de94 100644 --- a/packages/atomic/src/components/search/facets/atomic-segmented-facet-scrollable/atomic-segmented-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-segmented-facet-scrollable/atomic-segmented-facet.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.new.stories.tsx index fae20c695a8..eb322701b8e 100644 --- a/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.tsx b/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.tsx index bc9e55d25e7..a2707a656da 100644 --- a/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-segmented-facet/atomic-segmented-facet.tsx @@ -16,7 +16,7 @@ import { TabManager, TabManagerState, } from '@coveo/headless'; -import {Component, h, Prop, State, VNode, Watch} from '@stencil/core'; +import {Component, h, Prop, State, VNode} from '@stencil/core'; import {getFieldValueCaption} from '../../../../utils/field-utils'; import { BindStateToController, @@ -25,7 +25,6 @@ import { } from '../../../../utils/initialization-utils'; import {ArrayProp, MapProp} from '../../../../utils/props-utils'; import {parseDependsOn} from '../../../common/facets/depends-on'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {FacetValuesGroup} from '../../../common/facets/facet-values-group/facet-values-group'; import {Hidden} from '../../../common/hidden'; import {Bindings} from '../../atomic-search-interface/atomic-search-interface'; @@ -215,21 +214,6 @@ export class AtomicSegmentedFacet implements InitializableComponent { ); } - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facet - ); - } - } - disconnectedCallback() { this.dependenciesManager.stopWatching(); } @@ -298,6 +282,10 @@ export class AtomicSegmentedFacet implements InitializableComponent { ? [...this.allowedValues] : undefined, customSort: this.customSort.length ? [...this.customSort] : undefined, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }; } diff --git a/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.new.stories.tsx b/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.new.stories.tsx index e089835c42f..fa9a0244d8f 100644 --- a/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.new.stories.tsx +++ b/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {facetDecorator} from '@coveo/atomic/storybookUtils/common/facets-decorator'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {facetDecorator} from '@coveo/atomic-storybook-utils/common/facets-decorator'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface(); diff --git a/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.tsx b/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.tsx index f624c80eeb7..a9d6ea78817 100644 --- a/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.tsx +++ b/packages/atomic/src/components/search/facets/atomic-timeframe-facet/atomic-timeframe-facet.tsx @@ -20,7 +20,7 @@ import { TabManager, TabManagerState, } from '@coveo/headless'; -import {Component, Element, h, Listen, Prop, State, Watch} from '@stencil/core'; +import {Component, Element, h, Listen, Prop, State} from '@stencil/core'; import {FocusTargetController} from '../../../../utils/accessibility-utils'; import { BindStateToController, @@ -30,7 +30,6 @@ import { import {ArrayProp, MapProp} from '../../../../utils/props-utils'; import {parseDependsOn} from '../../../common/facets/depends-on'; import {FacetPlaceholder} from '../../../common/facets/facet-placeholder/facet-placeholder'; -import {updateFacetVisibilityForActiveTab} from '../../../common/facets/facet-tabs/facet-tabs-utils'; import {TimeframeFacetCommon} from '../../../common/facets/timeframe-facet-common'; import {Bindings} from '../../atomic-search-interface/atomic-search-interface'; @@ -256,21 +255,6 @@ export class AtomicTimeframeFacet implements InitializableComponent { this.tabManager = buildTabManager(this.bindings.engine); } - @Watch('tabManagerState') - watchTabManagerState( - newValue: {activeTab: string}, - oldValue: {activeTab: string} - ) { - if (newValue?.activeTab !== oldValue?.activeTab) { - updateFacetVisibilityForActiveTab( - [...this.tabsIncluded], - [...this.tabsExcluded], - this.tabManagerState?.activeTab, - this.facetForDateRange - ); - } - } - public disconnectedCallback() { this.timeframeFacetCommon?.disconnectedCallback(); } @@ -284,6 +268,10 @@ export class AtomicTimeframeFacet implements InitializableComponent { field: this.field, filterFacetCount: this.filterFacetCount, injectionDepth: this.injectionDepth, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }, }); return this.facetForDatePicker; @@ -299,6 +287,10 @@ export class AtomicTimeframeFacet implements InitializableComponent { sortCriteria: this.sortCriteria, filterFacetCount: this.filterFacetCount, injectionDepth: this.injectionDepth, + tabs: { + included: [...this.tabsIncluded], + excluded: [...this.tabsExcluded], + }, }, }); return this.facetForDateRange; diff --git a/packages/atomic/src/components/search/formats/atomic-format-currency.new.stories.tsx b/packages/atomic/src/components/search/formats/atomic-format-currency.new.stories.tsx index b73ef61bfe1..7fc497c36f9 100644 --- a/packages/atomic/src/components/search/formats/atomic-format-currency.new.stories.tsx +++ b/packages/atomic/src/components/search/formats/atomic-format-currency.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html/static.js'; diff --git a/packages/atomic/src/components/search/formats/atomic-format-number.new.stories.tsx b/packages/atomic/src/components/search/formats/atomic-format-number.new.stories.tsx index d5a0f1c270b..07f99f47b48 100644 --- a/packages/atomic/src/components/search/formats/atomic-format-number.new.stories.tsx +++ b/packages/atomic/src/components/search/formats/atomic-format-number.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html/static.js'; diff --git a/packages/atomic/src/components/search/formats/atomic-format-unit.new.stories.tsx b/packages/atomic/src/components/search/formats/atomic-format-unit.new.stories.tsx index 642403ef7c7..ffcc5358160 100644 --- a/packages/atomic/src/components/search/formats/atomic-format-unit.new.stories.tsx +++ b/packages/atomic/src/components/search/formats/atomic-format-unit.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit-html/static.js'; diff --git a/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/atomic-folded-result-list.new.stories.tsx b/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/atomic-folded-result-list.new.stories.tsx index 9441309da9e..a8acd775546 100644 --- a/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/atomic-folded-result-list.new.stories.tsx +++ b/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/atomic-folded-result-list.new.stories.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const SLOTS_DEFAULT = ` diff --git a/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/e2e/page-object.ts b/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/e2e/page-object.ts index 7568e8dc1fc..870788e58de 100644 --- a/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/e2e/page-object.ts +++ b/packages/atomic/src/components/search/result-lists/atomic-folded-result-list/e2e/page-object.ts @@ -1,5 +1,5 @@ -import {BasePageObject} from '@coveo/atomic/playwright-utils/base-page-object'; import type {Page} from '@playwright/test'; +import {BasePageObject} from '../../../../../../playwright-utils/base-page-object'; export class AtomicFoldedResultListPageObject extends BasePageObject<'atomic-folded-result-list'> { constructor(page: Page) { diff --git a/packages/atomic/src/components/search/result-lists/atomic-result-list/atomic-result-list.new.stories.tsx b/packages/atomic/src/components/search/result-lists/atomic-result-list/atomic-result-list.new.stories.tsx index 691c1111b30..fec67110b01 100644 --- a/packages/atomic/src/components/search/result-lists/atomic-result-list/atomic-result-list.new.stories.tsx +++ b/packages/atomic/src/components/search/result-lists/atomic-result-list/atomic-result-list.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-field-condition/atomic-field-condition.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-field-condition/atomic-field-condition.new.stories.tsx index 3ff1e84c762..165c42d4a87 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-field-condition/atomic-field-condition.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-field-condition/atomic-field-condition.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/search/result-template-components/atomic-quickview/atomic-quickview.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-quickview/atomic-quickview.new.stories.tsx index 5c154452039..00152fad54b 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-quickview/atomic-quickview.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-quickview/atomic-quickview.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-badge/atomic-result-badge.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-badge/atomic-result-badge.new.stories.tsx index 41f34ef452a..de6cea758d4 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-badge/atomic-result-badge.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-badge/atomic-result-badge.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult(); diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-date/atomic-result-date.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-date/atomic-result-date.new.stories.tsx index 138559cb1ce..830dc8bddad 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-date/atomic-result-date.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-date/atomic-result-date.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult(); diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-fields-list/atomic-result-field-list.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-fields-list/atomic-result-field-list.new.stories.tsx index 636846d6c44..c38c0506aeb 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-fields-list/atomic-result-field-list.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-fields-list/atomic-result-field-list.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult(); diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-html/atomic-result-html.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-html/atomic-result-html.new.stories.tsx index 6d4b2263ecd..bacf3717032 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-html/atomic-result-html.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-html/atomic-result-html.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-icon/atomic-result-icon.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-icon/atomic-result-icon.new.stories.tsx index c50cc20957f..5423e36440a 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-icon/atomic-result-icon.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-icon/atomic-result-icon.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult(); diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-image/atomic-result-image.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-image/atomic-result-image.new.stories.tsx index 0a340ebf929..461aef70ee0 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-image/atomic-result-image.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-image/atomic-result-image.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-link/atomic-result-link.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-link/atomic-result-link.new.stories.tsx index 30c13f68c53..7dd09687290 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-link/atomic-result-link.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-link/atomic-result-link.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult(); diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-multi-value-text/atomic-result-multi-value-text.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-multi-value-text/atomic-result-multi-value-text.new.stories.tsx index 7789ac6cafe..a88fe8cc10c 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-multi-value-text/atomic-result-multi-value-text.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-multi-value-text/atomic-result-multi-value-text.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-number/atomic-result-number.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-number/atomic-result-number.new.stories.tsx index 5b387eb1c3d..424fde5f173 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-number/atomic-result-number.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-number/atomic-result-number.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-printable-uri/atomic-result-printable-uri.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-printable-uri/atomic-result-printable-uri.new.stories.tsx index 70c85d220b6..3f4370960d3 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-printable-uri/atomic-result-printable-uri.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-printable-uri/atomic-result-printable-uri.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult(); diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-rating/atomic-result-rating.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-rating/atomic-result-rating.new.stories.tsx index 8f4de1243ab..6be40b24eeb 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-rating/atomic-result-rating.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-rating/atomic-result-rating.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-text/atomic-result-text.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-text/atomic-result-text.new.stories.tsx index 8763edd167b..cbc18f625d0 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-text/atomic-result-text.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-text/atomic-result-text.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/result-template-components/atomic-result-timespan/atomic-result-timespan.new.stories.tsx b/packages/atomic/src/components/search/result-template-components/atomic-result-timespan/atomic-result-timespan.new.stories.tsx index 7ea00185fff..0d5da12fcbb 100644 --- a/packages/atomic/src/components/search/result-template-components/atomic-result-timespan/atomic-result-timespan.new.stories.tsx +++ b/packages/atomic/src/components/search/result-template-components/atomic-result-timespan/atomic-result-timespan.new.stories.tsx @@ -1,7 +1,7 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInResult} from '@coveo/atomic/storybookUtils/search/result-wrapper'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInResult} from '@coveo/atomic-storybook-utils/search/result-wrapper'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator: resultDecorator, engineConfig} = wrapInResult({ diff --git a/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.new.stories.tsx b/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.new.stories.tsx index 7a7b42e62c8..7d8aefc2052 100644 --- a/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.new.stories.tsx +++ b/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; import {within} from 'shadow-dom-testing-library'; diff --git a/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-instant-results.new.stories.tsx b/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-instant-results.new.stories.tsx index b526e48139c..8c059d25db8 100644 --- a/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-instant-results.new.stories.tsx +++ b/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-query-suggestions/atomic-search-box-instant-results.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; import {within} from 'shadow-dom-testing-library'; diff --git a/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.new.stories.tsx b/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.new.stories.tsx index 0dd248459f2..fe4a50b3331 100644 --- a/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.new.stories.tsx +++ b/packages/atomic/src/components/search/search-box-suggestions/atomic-search-box-recent-queries/atomic-search-box-recent-queries.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import {userEvent} from '@storybook/test'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; diff --git a/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet-suggestions/atomic-smart-snippet-suggestions.new.stories.tsx b/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet-suggestions/atomic-smart-snippet-suggestions.new.stories.tsx index 90cda84290e..7f133b6ae5e 100644 --- a/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet-suggestions/atomic-smart-snippet-suggestions.new.stories.tsx +++ b/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet-suggestions/atomic-smart-snippet-suggestions.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet/atomic-smart-snippet.new.stories.tsx b/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet/atomic-smart-snippet.new.stories.tsx index 02f12e49583..c00ac92914d 100644 --- a/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet/atomic-smart-snippet.new.stories.tsx +++ b/packages/atomic/src/components/search/smart-snippets/atomic-smart-snippet/atomic-smart-snippet.new.stories.tsx @@ -1,6 +1,6 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; -import {wrapInSearchInterface} from '@coveo/atomic/storybookUtils/search/search-interface-wrapper'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; const {decorator, play} = wrapInSearchInterface({ diff --git a/packages/atomic/src/components/search/tabs/atomic-tab-manager/atomic-tab-manager.new.stories.tsx b/packages/atomic/src/components/search/tabs/atomic-tab-manager/atomic-tab-manager.new.stories.tsx index c0b4c1a382f..6480f787d76 100644 --- a/packages/atomic/src/components/search/tabs/atomic-tab-manager/atomic-tab-manager.new.stories.tsx +++ b/packages/atomic/src/components/search/tabs/atomic-tab-manager/atomic-tab-manager.new.stories.tsx @@ -1,8 +1,8 @@ -import {parameters} from '@coveo/atomic/storybookUtils/common/common-meta-parameters'; -import {renderComponent} from '@coveo/atomic/storybookUtils/common/render-component'; +import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters'; +import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component'; +import {wrapInSearchInterface} from '@coveo/atomic-storybook-utils/search/search-interface-wrapper'; import type {Meta, StoryObj as Story} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; -import {wrapInSearchInterface} from '../../../../../storybookUtils/search/search-interface-wrapper'; const {decorator, play} = wrapInSearchInterface({ search: { diff --git a/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html b/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html index 0a3d4917b41..b4a3e82f08d 100644 --- a/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html +++ b/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html @@ -55,7 +55,7 @@ Surf accessories - + diff --git a/packages/atomic/src/pages/examples/csp.html b/packages/atomic/src/pages/examples/csp.html index acc8d4e57d6..0e8690d8944 100644 --- a/packages/atomic/src/pages/examples/csp.html +++ b/packages/atomic/src/pages/examples/csp.html @@ -135,7 +135,7 @@ - + diff --git a/packages/atomic/src/pages/examples/external.html b/packages/atomic/src/pages/examples/external.html index c526287bf79..cee138c1035 100644 --- a/packages/atomic/src/pages/examples/external.html +++ b/packages/atomic/src/pages/examples/external.html @@ -56,7 +56,7 @@ External components of interface #2 - + @@ -73,7 +73,7 @@ Interface #1, not linked to url - + diff --git a/packages/atomic/src/pages/examples/fashion.html b/packages/atomic/src/pages/examples/fashion.html index 01d42c6757a..84553ce64a4 100644 --- a/packages/atomic/src/pages/examples/fashion.html +++ b/packages/atomic/src/pages/examples/fashion.html @@ -87,7 +87,7 @@ - + diff --git a/packages/atomic/src/pages/examples/folding.html b/packages/atomic/src/pages/examples/folding.html index 5b3c8c892b4..ae0723680bf 100644 --- a/packages/atomic/src/pages/examples/folding.html +++ b/packages/atomic/src/pages/examples/folding.html @@ -56,7 +56,7 @@ - + diff --git a/packages/atomic/src/pages/examples/genqa.html b/packages/atomic/src/pages/examples/genqa.html index a9f9d01c32b..3b7fb2fc020 100644 --- a/packages/atomic/src/pages/examples/genqa.html +++ b/packages/atomic/src/pages/examples/genqa.html @@ -45,7 +45,7 @@ - + diff --git a/packages/atomic/src/pages/examples/headless.html b/packages/atomic/src/pages/examples/headless.html index 588557f8b8a..2be160e254c 100644 --- a/packages/atomic/src/pages/examples/headless.html +++ b/packages/atomic/src/pages/examples/headless.html @@ -47,7 +47,7 @@ - + diff --git a/packages/atomic/src/pages/examples/horizontal-facets.html b/packages/atomic/src/pages/examples/horizontal-facets.html index a8fe2ee61fc..557f0866fe4 100644 --- a/packages/atomic/src/pages/examples/horizontal-facets.html +++ b/packages/atomic/src/pages/examples/horizontal-facets.html @@ -41,7 +41,7 @@ - + diff --git a/packages/atomic/src/pages/examples/slack.html b/packages/atomic/src/pages/examples/slack.html index 3330860f8f8..ed3431fb76d 100644 --- a/packages/atomic/src/pages/examples/slack.html +++ b/packages/atomic/src/pages/examples/slack.html @@ -64,7 +64,7 @@ - + diff --git a/packages/atomic/src/pages/examples/standalone-results.html b/packages/atomic/src/pages/examples/standalone-results.html index faf10b4802a..323a736f141 100644 --- a/packages/atomic/src/pages/examples/standalone-results.html +++ b/packages/atomic/src/pages/examples/standalone-results.html @@ -47,7 +47,7 @@ - + diff --git a/packages/atomic/src/pages/examples/standalone.html b/packages/atomic/src/pages/examples/standalone.html index 552d5aecf90..6faae74efe2 100644 --- a/packages/atomic/src/pages/examples/standalone.html +++ b/packages/atomic/src/pages/examples/standalone.html @@ -20,7 +20,7 @@ - + diff --git a/packages/atomic/src/pages/examples/suggestions.html b/packages/atomic/src/pages/examples/suggestions.html index b80ba179906..5052dc72a18 100644 --- a/packages/atomic/src/pages/examples/suggestions.html +++ b/packages/atomic/src/pages/examples/suggestions.html @@ -97,7 +97,7 @@ - + diff --git a/packages/atomic/src/pages/examples/tabs.html b/packages/atomic/src/pages/examples/tabs.html index bbf3f696556..34cdb003a87 100644 --- a/packages/atomic/src/pages/examples/tabs.html +++ b/packages/atomic/src/pages/examples/tabs.html @@ -17,6 +17,10 @@ await searchInterface.initialize({ accessToken: 'xx564559b1-0045-48e1-953c-3addd1ee4457', organizationId: 'searchuisamples', + search: { + pipeline: 'genqatest', + }, + organizationEndpoints: await searchInterface.getOrganizationEndpoints('searchuisamples'), }); // Trigger a first search @@ -136,7 +140,7 @@ - + @@ -199,7 +203,7 @@ - + @@ -232,6 +236,7 @@ + - + diff --git a/packages/atomic/src/pages/index.html b/packages/atomic/src/pages/index.html index 8d79bad3e7d..5d54fd9a883 100644 --- a/packages/atomic/src/pages/index.html +++ b/packages/atomic/src/pages/index.html @@ -135,7 +135,7 @@ - + diff --git a/packages/atomic/src/pages/visualTests.html b/packages/atomic/src/pages/visualTests.html index ec1893971db..f2c0a5ff28e 100644 --- a/packages/atomic/src/pages/visualTests.html +++ b/packages/atomic/src/pages/visualTests.html @@ -134,7 +134,7 @@ - + diff --git a/packages/atomic/stencil.config.ts b/packages/atomic/stencil.config.ts index 15d55a49733..fd92aada780 100644 --- a/packages/atomic/stencil.config.ts +++ b/packages/atomic/stencil.config.ts @@ -6,73 +6,23 @@ import {Config} from '@stencil/core'; import {reactOutputTarget as react} from '@stencil/react-output-target'; import autoprefixer from 'autoprefixer'; import {readFileSync, readdirSync} from 'fs'; -import path from 'path'; import focusVisible from 'postcss-focus-visible'; import atImport from 'postcss-import'; import postcssMap from 'postcss-map'; import mixins from 'postcss-mixins'; import postcssNesting from 'postcss-nested'; +import {PluginImpl} from 'rollup'; import html from 'rollup-plugin-html'; import {inlineSvg} from 'stencil-inline-svg'; import tailwind from 'tailwindcss'; import tailwindNesting from 'tailwindcss/nesting'; -import headlessJson from '../../packages/headless/package.json'; +import {generateExternalPackageMappings} from './scripts/externalPackageMappings'; import {generateAngularModuleDefinition as angularModule} from './stencil-plugin/atomic-angular-module'; const isProduction = process.env.BUILD === 'production'; const isCDN = process.env.DEPLOYMENT_ENVIRONMENT === 'CDN'; -let headlessVersion: string = ''; -if (isCDN) { - console.log('Building for CDN'); - headlessVersion = 'v' + headlessJson.version; -} - -const packageMappings: {[key: string]: {devWatch: string; cdn: string}} = { - '@coveo/headless/commerce': { - devWatch: path.resolve( - __dirname, - './src/external-builds/commerce/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/commerce/headless.esm.js`, - }, - '@coveo/headless/insight': { - devWatch: path.resolve( - __dirname, - './src/external-builds/insight/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/insight/headless.esm.js`, - }, - '@coveo/headless/product-recommendation': { - devWatch: path.resolve( - __dirname, - './src/external-builds/product-recommendation/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/product-recommendation/headless.esm.js`, - }, - '@coveo/headless/recommendation': { - devWatch: path.resolve( - __dirname, - './src/external-builds/recommendation/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/recommendation/headless.esm.js`, - }, - '@coveo/headless/case-assist': { - devWatch: path.resolve( - __dirname, - './src/external-builds/case-assist/headless.esm.js' - ), - cdn: `/headless/${headlessVersion}/case-assist/headless.esm.js`, - }, - '@coveo/headless': { - devWatch: path.resolve(__dirname, './src/external-builds/headless.esm.js'), - cdn: `/headless/${headlessVersion}/headless.esm.js`, - }, - /* '@coveo/bueno': { - devWatch: path.resolve(__dirname, './src/external-builds/bueno.esm.js'), - cdn: `/bueno/${buenoVersion}/bueno.esm.js`, - }, */ -}; +const packageMappings = generateExternalPackageMappings(__dirname); function generateAliasEntries() { return Object.entries(packageMappings).map(([find, paths]) => ({ @@ -125,45 +75,70 @@ function replace() { }); } +const externalizeDependenciesPlugin: PluginImpl = () => { + return { + name: 'externalize-dependencies', + resolveId: (source, _importer, _options) => { + const packageMapping = packageMappings[source]; + + if (packageMapping) { + if (!isCDN) { + return false; + } + + return { + id: packageMapping.cdn, + external: 'absolute', + }; + } + + return null; + }, + }; +}; + const isDevWatch: boolean = process.argv && process.argv.indexOf('--dev') > -1 && process.argv.indexOf('--watch') > -1; export const config: Config = { + tsconfig: 'tsconfig.stencil.json', namespace: 'atomic', taskQueue: 'async', sourceMap: true, outputTargets: [ - react({ - componentCorePackage: '@coveo/atomic', - proxiesFile: - '../atomic-react/src/components/stencil-generated/search/index.ts', - includeDefineCustomElements: true, - excludeComponents: [ - 'atomic-result-template', - 'atomic-recs-result-template', - 'atomic-field-condition', - ].concat( - filterComponentsByUseCaseForReactOutput('src/components/commerce') - ), - }), - react({ - componentCorePackage: '@coveo/atomic', - proxiesFile: - '../atomic-react/src/components/stencil-generated/commerce/index.ts', - includeDefineCustomElements: true, - excludeComponents: [ - 'atomic-product-template', - 'atomic-recs-result-template', - 'atomic-field-condition', - ].concat( - filterComponentsByUseCaseForReactOutput('src/components/search'), - filterComponentsByUseCaseForReactOutput( - 'src/components/recommendations' - ) - ), - }), + !isDevWatch && + react({ + componentCorePackage: '@coveo/atomic', + proxiesFile: + '../atomic-react/src/components/stencil-generated/search/index.ts', + includeDefineCustomElements: true, + excludeComponents: [ + 'atomic-result-template', + 'atomic-recs-result-template', + 'atomic-field-condition', + ].concat( + filterComponentsByUseCaseForReactOutput('src/components/commerce') + ), + }), + !isDevWatch && + react({ + componentCorePackage: '@coveo/atomic', + proxiesFile: + '../atomic-react/src/components/stencil-generated/commerce/index.ts', + includeDefineCustomElements: true, + excludeComponents: [ + 'atomic-product-template', + 'atomic-recs-result-template', + 'atomic-field-condition', + ].concat( + filterComponentsByUseCaseForReactOutput('src/components/search'), + filterComponentsByUseCaseForReactOutput( + 'src/components/recommendations' + ) + ), + }), angular({ componentCorePackage: '@coveo/atomic', directivesProxyFile: @@ -208,16 +183,16 @@ export const config: Config = { }, ].filter((n) => n.src), }, - ], + ].filter(Boolean), testing: { browserArgs: ['--no-sandbox'], transform: { '^.+\\.html?$': 'html-loader-jest', - '^.+\\.svg$': './svg.transform.js', + '^.+\\.svg$': './svg.transform.cjs', }, transformIgnorePatterns: [], testPathIgnorePatterns: ['.snap'], - setupFiles: ['./jest/setup.js', 'jest-localstorage-mock'], + setupFiles: ['./jest/setup.cjs', 'jest-localstorage-mock'], resetMocks: false, }, devServer: { @@ -261,22 +236,3 @@ export const config: Config = { enableImportInjection: true, }, }; -function externalizeDependenciesPlugin() { - return { - name: 'externalize-dependencies', - resolveId(source: string) { - if (packageMappings[source]) { - if (!isCDN) { - return false; - } - - return { - id: packageMappings[source].cdn, - external: 'absolute', - }; - } - - return null; - }, - }; -} diff --git a/packages/atomic/storybookUtils/insight/insight-interface-wrapper.tsx b/packages/atomic/storybookUtils/insight/insight-interface-wrapper.tsx index b24078c6b24..e35933cd978 100644 --- a/packages/atomic/storybookUtils/insight/insight-interface-wrapper.tsx +++ b/packages/atomic/storybookUtils/insight/insight-interface-wrapper.tsx @@ -13,6 +13,16 @@ export const wrapInInsightInterface = ( play: (context: StoryContext) => Promise; } => ({ decorator: (story) => html` + ${story()} diff --git a/packages/atomic/storybookUtils/search/recs-interface-wrapper.tsx b/packages/atomic/storybookUtils/search/recs-interface-wrapper.tsx index 83d8775bceb..b8f861aad2d 100644 --- a/packages/atomic/storybookUtils/search/recs-interface-wrapper.tsx +++ b/packages/atomic/storybookUtils/search/recs-interface-wrapper.tsx @@ -7,9 +7,13 @@ import {Decorator, StoryContext} from '@storybook/web-components'; import {html} from 'lit/static-html.js'; import type * as _ from '../../src/components'; -export const wrapInRecommendationInterface = ( - config?: Partial -): { +export const wrapInRecommendationInterface = ({ + config, + skipFirstQuery = false, +}: { + config?: Partial; + skipFirstQuery?: boolean; +} = {}): { decorator: Decorator; play: (context: StoryContext) => Promise; } => ({ @@ -21,18 +25,21 @@ export const wrapInRecommendationInterface = ( play: async ({canvasElement, step}) => { await customElements.whenDefined('atomic-recs-interface'); const canvas = within(canvasElement); - const searchInterface = + const recsInterface = await canvas.findByTestId( 'root-interface' ); await step('Render the Recs Interface', async () => { - await searchInterface!.initialize({ + await recsInterface!.initialize({ ...getSampleRecommendationEngineConfiguration(), ...config, }); }); + if (skipFirstQuery) { + return; + } await step('Execute the first search', async () => { - await searchInterface!.getRecommendations(); + await recsInterface.getRecommendations(); }); }, }); diff --git a/packages/atomic/svg.transform.js b/packages/atomic/svg.transform.cjs similarity index 100% rename from packages/atomic/svg.transform.js rename to packages/atomic/svg.transform.cjs diff --git a/packages/atomic/tailwind.config.js b/packages/atomic/tailwind.config.cjs similarity index 100% rename from packages/atomic/tailwind.config.js rename to packages/atomic/tailwind.config.cjs diff --git a/packages/atomic/tsconfig.json b/packages/atomic/tsconfig.json index a0896969c23..3d5942e2885 100644 --- a/packages/atomic/tsconfig.json +++ b/packages/atomic/tsconfig.json @@ -1,32 +1,10 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "declaration": false, - "experimentalDecorators": true, - "lib": ["dom", "ES2023", "ESNext.Collection"], - "moduleResolution": "Bundler", - "module": "ES2022", - "target": "ES2021", - "resolveJsonModule": true, - "useDefineForClassFields": false, - "noUnusedLocals": true, - "noUnusedParameters": true, - "jsx": "react", - "jsxFactory": "h" - }, - "references": [ - { - "path": "./tsconfig.storybook.json" - } - ], - "include": ["src", "types/jsx.d.ts"], + "extends": "./tsconfig.stencil.json", "exclude": [ "node_modules", "src/external-builds", "**/*.stories.tsx", "**/*.stories.ts", - "**/*.stories.js", - "**/e2e/**/*" + "**/*.stories.js" ] } diff --git a/packages/atomic/tsconfig.stencil.json b/packages/atomic/tsconfig.stencil.json new file mode 100644 index 00000000000..a0896969c23 --- /dev/null +++ b/packages/atomic/tsconfig.stencil.json @@ -0,0 +1,32 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "declaration": false, + "experimentalDecorators": true, + "lib": ["dom", "ES2023", "ESNext.Collection"], + "moduleResolution": "Bundler", + "module": "ES2022", + "target": "ES2021", + "resolveJsonModule": true, + "useDefineForClassFields": false, + "noUnusedLocals": true, + "noUnusedParameters": true, + "jsx": "react", + "jsxFactory": "h" + }, + "references": [ + { + "path": "./tsconfig.storybook.json" + } + ], + "include": ["src", "types/jsx.d.ts"], + "exclude": [ + "node_modules", + "src/external-builds", + "**/*.stories.tsx", + "**/*.stories.ts", + "**/*.stories.js", + "**/e2e/**/*" + ] +} diff --git a/packages/atomic/tsconfig.storybook.json b/packages/atomic/tsconfig.storybook.json index 30d5ba207d2..204c4760d5b 100644 --- a/packages/atomic/tsconfig.storybook.json +++ b/packages/atomic/tsconfig.storybook.json @@ -21,6 +21,7 @@ ".storybook/*.tsx", ".storybook/*.jsx", ".storybook/register.tsx", - ".storybook/main.mts" + ".storybook/main.mts", + "scripts/externalPackageMappings.ts" ] } diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index 6c0c83c72ae..06e462e280a 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 (2024-09-24) + +- chore(headless,atomic): add type "module" to atomic, atomic-react and headless (#4442) ([21896c3](https://github.com/coveo/ui-kit/commits/21896c3)), closes [#4442](https://github.com/coveo/ui-kit/issues/4442) [/github.com/coveo/ui-kit/pull/4449/files#diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87](https://github.com//github.com/coveo/ui-kit/pull/4449/files/issues/diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87) + ## 2.0.0 (2024-09-18) - chore: update tsconfigs to match node version (#4402) ([e5bf6b8](https://github.com/coveo/ui-kit/commits/e5bf6b8)), closes [#4402](https://github.com/coveo/ui-kit/issues/4402) diff --git a/packages/auth/jest.config.js b/packages/auth/jest.config.cjs similarity index 100% rename from packages/auth/jest.config.js rename to packages/auth/jest.config.cjs diff --git a/packages/auth/package.json b/packages/auth/package.json index 5bc37abc098..f57bce0b1b6 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@coveo/auth", - "version": "2.0.0", + "version": "2.0.1", "description": "Functions to help authenticate with the Coveo platform.", "main": "./dist/auth.js", "module": "./dist/auth.esm.js", diff --git a/packages/bueno/CHANGELOG.md b/packages/bueno/CHANGELOG.md index 62ab50cea5f..91806dad8bf 100644 --- a/packages/bueno/CHANGELOG.md +++ b/packages/bueno/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.1 (2024-09-24) + +- chore(atomic, headless): make bueno external (#4433) ([e1f7f2d](https://github.com/coveo/ui-kit/commits/e1f7f2d)), closes [#4433](https://github.com/coveo/ui-kit/issues/4433) +- chore(headless,atomic): add type "module" to atomic, atomic-react and headless (#4442) ([21896c3](https://github.com/coveo/ui-kit/commits/21896c3)), closes [#4442](https://github.com/coveo/ui-kit/issues/4442) [/github.com/coveo/ui-kit/pull/4449/files#diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87](https://github.com//github.com/coveo/ui-kit/pull/4449/files/issues/diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87) + ## 1.0.0 (2024-09-18) - chore: update tsconfigs to match node version (#4402) ([e5bf6b8](https://github.com/coveo/ui-kit/commits/e5bf6b8)), closes [#4402](https://github.com/coveo/ui-kit/issues/4402) diff --git a/packages/bueno/esbuild.mjs b/packages/bueno/esbuild.mjs index 92a53cbe190..7ec5d636e38 100644 --- a/packages/bueno/esbuild.mjs +++ b/packages/bueno/esbuild.mjs @@ -44,6 +44,28 @@ function browserEsm() { }); } +function browserEsmForAtomicDevelopment() { + const buildAtomic = build({ + ...base, + platform: 'browser', + outfile: '../atomic/src/external-builds/bueno.esm.js', + format: 'esm', + watch: devMode, + minify: false, + }); + + const buildHeadless = build({ + ...base, + platform: 'browser', + outfile: '../headless/src/external-builds/bueno.esm.js', + format: 'esm', + watch: devMode, + minify: false, + }); + + return Promise.all([buildAtomic, buildHeadless]); +} + function browserUmd() { return build({ ...base, @@ -58,7 +80,13 @@ function browserUmd() { } async function main() { - await Promise.all([nodeCjs(), nodeEsm(), browserEsm(), browserUmd()]); + await Promise.all([ + nodeCjs(), + nodeEsm(), + browserEsm(), + browserUmd(), + browserEsmForAtomicDevelopment(), + ]); } main(); diff --git a/packages/bueno/jest.config.js b/packages/bueno/jest.config.cjs similarity index 100% rename from packages/bueno/jest.config.js rename to packages/bueno/jest.config.cjs diff --git a/packages/bueno/package.json b/packages/bueno/package.json index f3f6c6aa92f..1cec4261d1b 100644 --- a/packages/bueno/package.json +++ b/packages/bueno/package.json @@ -13,7 +13,7 @@ }, "types": "./dist/definitions/index.d.ts", "license": "Apache-2.0", - "version": "1.0.0", + "version": "1.0.1", "files": [ "dist/" ], diff --git a/packages/bueno/project.json b/packages/bueno/project.json index d3cec81afb3..17a91046d3a 100644 --- a/packages/bueno/project.json +++ b/packages/bueno/project.json @@ -1,10 +1,22 @@ { "name": "bueno", "$schema": "../../node_modules/nx/schemas/project-schema.json", + "namedInputs": { + "negativeBuildOutputs": [ + "!{projectRoot}/dist", + "!{workspaceRoot}/packages/atomic/src/external-builds", + "!{workspaceRoot}/packages/headless/src/external-builds" + ] + }, "targets": { "release:phase1": {}, "cached:build": { "executor": "nx:run-commands", + "outputs": [ + "{projectRoot}/dist", + "{workspaceRoot}/packages/atomic/src/external-builds", + "{workspaceRoot}/packages/headless/src/external-builds" + ], "options": { "commands": ["npm run build:bundles", "npm run build:definitions"], "parallel": true, diff --git a/packages/headless-react/CHANGELOG.md b/packages/headless-react/CHANGELOG.md index 4b5ef7632e5..76cf1470984 100644 --- a/packages/headless-react/CHANGELOG.md +++ b/packages/headless-react/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.4 (2024-09-25) + +- chore: eliminate network calls in npm test (#4453) ([c6393a9](https://github.com/coveo/ui-kit/commits/c6393a9)), closes [#4453](https://github.com/coveo/ui-kit/issues/4453) + +## 2.0.1 (2024-09-24) + +- chore(headless,atomic): add type "module" to atomic, atomic-react and headless (#4442) ([21896c3](https://github.com/coveo/ui-kit/commits/21896c3)), closes [#4442](https://github.com/coveo/ui-kit/issues/4442) [/github.com/coveo/ui-kit/pull/4449/files#diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87](https://github.com//github.com/coveo/ui-kit/pull/4449/files/issues/diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87) + ## 2.0.0 (2024-09-18) - chore!: update node engine definition in all exported packages (#4330) ([d6d8a1a](https://github.com/coveo/ui-kit/commits/d6d8a1a)), closes [#4330](https://github.com/coveo/ui-kit/issues/4330) diff --git a/packages/headless-react/jest.config.mjs b/packages/headless-react/jest.config.mjs deleted file mode 100644 index 7c9c75e22c1..00000000000 --- a/packages/headless-react/jest.config.mjs +++ /dev/null @@ -1,22 +0,0 @@ -/** @type {import('ts-jest').JestConfigWithTsJest} */ -export default { - testEnvironment: 'jsdom', - moduleNameMapper: { - '^(\\.{1,2}/.*)\\.js$': '$1', - }, - transform: { - '^.+\\.tsx?$': [ - 'ts-jest', - { - tsconfig: 'tsconfig.test.json', - }, - ], - }, - collectCoverage: true, - collectCoverageFrom: ['./src/**/**.ts', './src/**/**.tsx'], - coverageThreshold: { - global: { - lines: 90, - }, - }, -}; diff --git a/packages/headless-react/package.json b/packages/headless-react/package.json index 9b8ee6632d8..235418faf69 100644 --- a/packages/headless-react/package.json +++ b/packages/headless-react/package.json @@ -1,6 +1,6 @@ { "name": "@coveo/headless-react", - "version": "2.0.0", + "version": "2.0.4", "description": "React utilities for SSR (Server Side Rendering) with headless", "homepage": "https://docs.coveo.com/en/headless/latest/", "repository": { @@ -25,15 +25,15 @@ "scripts": { "build": "nx build", "clean": "rimraf dist", - "test": "jest", - "test:watch": "jest --watch --colors --no-cache", + "test": "vitest run", + "test:watch": "vitest", "lint": "eslint .; publint", "publish:npm": "npm run-script -w=@coveo/release npm-publish", "publish:bump": "npm run-script -w=@coveo/release bump", "promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest" }, "dependencies": { - "@coveo/headless": "3.0.0" + "@coveo/headless": "3.1.3" }, "devDependencies": { "@coveo/release": "1.0.0", @@ -46,12 +46,11 @@ "eslint-plugin-react": "7.35.0", "eslint-plugin-testing-library": "6.2.2", "gts": "5.3.1", - "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "publint": "0.2.9", "rimraf": "5.0.9", - "ts-jest": "29.2.3", - "typescript": "5.4.5" + "typescript": "5.4.5", + "vitest": "2.1.1" }, "peerDependencies": { "react": "^18", diff --git a/packages/headless-react/src/ssr/client-utils.test.tsx b/packages/headless-react/src/ssr/client-utils.test.tsx index fce0e3b1054..95dd0cd52c4 100644 --- a/packages/headless-react/src/ssr/client-utils.test.tsx +++ b/packages/headless-react/src/ssr/client-utils.test.tsx @@ -1,12 +1,13 @@ import {renderHook} from '@testing-library/react'; +import {vi, expect, describe, test, it} from 'vitest'; import {useSyncMemoizedStore} from './client-utils'; describe('useSyncMemoizedStore', () => { test('should return the initial snapshot', () => { const snapshot = {count: 0}; - const unsubscribe = jest.fn(); - const subscribe = jest.fn(() => unsubscribe); - const getSnapshot = jest.fn(() => snapshot); + const unsubscribe = vi.fn(); + const subscribe = vi.fn(() => unsubscribe); + const getSnapshot = vi.fn(() => snapshot); const {result} = renderHook(() => useSyncMemoizedStore(subscribe, getSnapshot) @@ -17,9 +18,9 @@ describe('useSyncMemoizedStore', () => { test('should not call getSnapshot when there is a re-render with the same getSnapshot', () => { const snapshot = {count: 0}; - const unsubscribe = jest.fn(); - const subscribe = jest.fn(() => unsubscribe); - const getSnapshot = jest.fn(() => snapshot); + const unsubscribe = vi.fn(); + const subscribe = vi.fn(() => unsubscribe); + const getSnapshot = vi.fn(() => snapshot); const {rerender} = renderHook(() => useSyncMemoizedStore(subscribe, getSnapshot) @@ -33,26 +34,26 @@ describe('useSyncMemoizedStore', () => { test('should update the state when getSnapshot changes', () => { const snapshot1 = {count: 0}; const snapshot2 = {count: 1}; - const subscribe = jest.fn(() => jest.fn()); - let getSnapshot = jest.fn(() => snapshot1); + const subscribe = vi.fn(() => vi.fn()); + let getSnapshot = vi.fn(() => snapshot1); const {result, rerender} = renderHook(() => useSyncMemoizedStore(subscribe, getSnapshot) ); expect(result.current).toEqual(snapshot1); - getSnapshot = jest.fn(() => snapshot2); + getSnapshot = vi.fn(() => snapshot2); rerender(); expect(result.current).toEqual(snapshot2); }); test('should unsubscribe and re-subscribe to new function when subscribe function is changed', () => { const snapshot = {count: 0}; - const unsubscribe1 = jest.fn(); - const unsubscribe2 = jest.fn(); - const subscribe1 = jest.fn(() => unsubscribe1); - const subscribe2 = jest.fn(() => unsubscribe2); - const getSnapshot = jest.fn(() => snapshot); + const unsubscribe1 = vi.fn(); + const unsubscribe2 = vi.fn(); + const subscribe1 = vi.fn(() => unsubscribe1); + const subscribe2 = vi.fn(() => unsubscribe2); + const getSnapshot = vi.fn(() => snapshot); const {rerender} = renderHook( ({subscribe}) => useSyncMemoizedStore(subscribe, getSnapshot), @@ -71,10 +72,10 @@ describe('useSyncMemoizedStore', () => { test('should replace current snapshot when getSnapshot function is changed', () => { const snapshot1 = {count: 0}; const snapshot2 = {count: 1}; - const unsubscribe = jest.fn(); - const subscribe = jest.fn(() => unsubscribe); - const getSnapshot1 = jest.fn(() => snapshot1); - const getSnapshot2 = jest.fn(() => snapshot2); + const unsubscribe = vi.fn(); + const subscribe = vi.fn(() => unsubscribe); + const getSnapshot1 = vi.fn(() => snapshot1); + const getSnapshot2 = vi.fn(() => snapshot2); const {result, rerender} = renderHook( ({getSnapshot}) => useSyncMemoizedStore(subscribe, getSnapshot), @@ -88,13 +89,13 @@ describe('useSyncMemoizedStore', () => { it('should call the subscribe listener on mount and unsubscribe on unmount', () => { const snapshot = {count: 0}; - const unsubscribe = jest.fn(); - const listener = jest.fn(); - const subscribe = jest.fn(() => { + const unsubscribe = vi.fn(); + const listener = vi.fn(); + const subscribe = vi.fn(() => { listener(); return unsubscribe; }); - const getSnapshot = jest.fn(() => snapshot); + const getSnapshot = vi.fn(() => snapshot); const {result, unmount} = renderHook(() => { return useSyncMemoizedStore(subscribe, getSnapshot); diff --git a/packages/headless-react/src/ssr/search-engine.test.tsx b/packages/headless-react/src/ssr/search-engine.test.tsx index f9486393541..df3b30de4ca 100644 --- a/packages/headless-react/src/ssr/search-engine.test.tsx +++ b/packages/headless-react/src/ssr/search-engine.test.tsx @@ -1,18 +1,30 @@ -import {NavigatorContextProvider} from '@coveo/headless/dist/definitions/app/navigatorContextProvider.js'; import { getSampleSearchEngineConfiguration, InferStaticState, InferHydratedState, defineResultList, defineSearchBox, + Result, + NavigatorContextProvider, } from '@coveo/headless/ssr'; import {act, render, renderHook, screen} from '@testing-library/react'; +import {randomUUID} from 'crypto'; import {PropsWithChildren} from 'react'; +import React from 'react'; +import { + vi, + expect, + describe, + test, + beforeEach, + MockInstance, + afterEach, +} from 'vitest'; import {MissingEngineProviderError} from './common.js'; import {defineSearchEngine} from './search-engine.js'; describe('Headless react SSR utils', () => { - let errorSpy: jest.SpyInstance; + let errorSpy: MockInstance; const mockedNavigatorContextProvider: NavigatorContextProvider = () => { return { clientId: '123', @@ -27,7 +39,7 @@ describe('Headless react SSR utils', () => { }; beforeEach(() => { - errorSpy = jest.spyOn(console, 'error'); + errorSpy = vi.spyOn(console, 'error'); }); afterEach(() => { @@ -97,7 +109,38 @@ describe('Headless react SSR utils', () => { } = engineDefinition; function TestResultList() { + const generateMockResult: () => Result = () => { + return { + absentTerms: [], + clickUri: '', + excerpt: '', + excerptHighlights: [], + firstSentences: '', + firstSentencesHighlights: [], + flags: '', + hasHtmlVersion: false, + isRecommendation: false, + isTopResult: false, + isUserActionView: false, + percentScore: 0, + printableUri: '', + printableUriHighlights: [], + rankingInfo: null, + raw: {urihash: ''}, + score: 0, + searchUid: '', + summary: null, + summaryHighlights: [], + title: '', + titleHighlights: [], + uniqueId: randomUUID(), + uri: '', + }; + }; + const {state} = controllers.useResultList(); + + state.results = Array.from({length: numResults}, generateMockResult); return ( {state.results.map((result) => ( @@ -113,6 +156,8 @@ describe('Headless react SSR utils', () => { const results = await screen.findAllByTestId(resultItemTestId); expect(errorSpy).not.toHaveBeenCalled(); expect(results).toHaveLength(numResults); + + results.forEach((result) => result.remove()); } function checkRenderError( @@ -121,7 +166,7 @@ describe('Headless react SSR utils', () => { ) { let err: Error | undefined = undefined; // Prevent expected error from being thrown in console when running tests - const consoleErrorStub = jest + const consoleErrorStub = vi .spyOn(console, 'error') .mockImplementation(() => {}); try { @@ -248,7 +293,7 @@ describe('Headless react SSR utils', () => { wrapper: hydratedStateProviderWrapper, }); const initialState = result.current.state; - const controllerSpy = jest.spyOn( + const controllerSpy = vi.spyOn( hydratedState.controllers.searchBox, 'updateText' ); diff --git a/packages/headless-react/tsconfig.json b/packages/headless-react/tsconfig.json index f88ddf17864..f1ed5cdcd4f 100644 --- a/packages/headless-react/tsconfig.json +++ b/packages/headless-react/tsconfig.json @@ -20,7 +20,8 @@ "moduleResolution": "NodeNext", "module": "NodeNext", "target": "ES2022", - "lib": ["dom", "ES2023"] + "lib": ["dom", "ES2023"], + "types": ["vitest/globals"] }, "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"], "include": ["src/**/*.ts", "src/**/*.tsx"] diff --git a/packages/headless-react/tsconfig.test.json b/packages/headless-react/tsconfig.test.json deleted file mode 100644 index aa436fef8cd..00000000000 --- a/packages/headless-react/tsconfig.test.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - // TODO: Remove override after bug is fixed https://github.com/kulshekhar/ts-jest/issues/4198 - "moduleResolution": "Node", - "module": "CommonJS", - "types": ["jest", "react", "react-dom"] - } -} diff --git a/packages/headless-react/vitest.config.js b/packages/headless-react/vitest.config.js new file mode 100644 index 00000000000..cb3b6172800 --- /dev/null +++ b/packages/headless-react/vitest.config.js @@ -0,0 +1,8 @@ +import {defineConfig} from 'vitest/config'; + +/// +export default defineConfig({ + test: { + environment: 'jsdom', + }, +}); diff --git a/packages/headless/.eslintrc.js b/packages/headless/.eslintrc.cjs similarity index 85% rename from packages/headless/.eslintrc.js rename to packages/headless/.eslintrc.cjs index 15709cc26ff..549e9ce930a 100644 --- a/packages/headless/.eslintrc.js +++ b/packages/headless/.eslintrc.cjs @@ -1,7 +1,7 @@ const {resolve} = require('path'); module.exports = { - ignorePatterns: ['dist', 'temp', 'ponyfills'], + ignorePatterns: ['dist', 'temp', 'ponyfills', 'src/external-builds/**/*'], plugins: ['canonical'], settings: { 'import/parsers': { @@ -13,6 +13,7 @@ module.exports = { }, }, }, + rules: { '@typescript-eslint/no-namespace': 'off', curly: ['error'], diff --git a/packages/headless/.gitignore b/packages/headless/.gitignore index a38284ed80e..a1fe693e0be 100644 --- a/packages/headless/.gitignore +++ b/packages/headless/.gitignore @@ -1,3 +1,5 @@ docs/js temp/ -doc-parser/build \ No newline at end of file +doc-parser/build + +src/external-builds diff --git a/packages/headless/CHANGELOG.md b/packages/headless/CHANGELOG.md index 9bba664ebad..18883180e8c 100644 --- a/packages/headless/CHANGELOG.md +++ b/packages/headless/CHANGELOG.md @@ -1,3 +1,27 @@ +## 3.1.3 (2024-09-25) + +- chore: eliminate network calls in npm test (#4453) ([c6393a9](https://github.com/coveo/ui-kit/commits/c6393a9)), closes [#4453](https://github.com/coveo/ui-kit/issues/4453) +- docs(headless): update adding-a-sub-package (#4456) ([92c5404](https://github.com/coveo/ui-kit/commits/92c5404)), closes [#4456](https://github.com/coveo/ui-kit/issues/4456) + +## 3.1.2 (2024-09-25) + +- chore(headless): ensure Bueno is loaded from the CDN, not from NPM specifier (#4459) ([ba823e2](https://github.com/coveo/ui-kit/commits/ba823e2)), closes [#4459](https://github.com/coveo/ui-kit/issues/4459) + +## 3.1.1 (2024-09-24) + +- docs: document headless, atomic, and atomic-react entry points (#4455) ([3853bdc](https://github.com/coveo/ui-kit/commits/3853bdc)), closes [#4455](https://github.com/coveo/ui-kit/issues/4455) + +## 3.1.0 (2024-09-24) + +- chore(atomic, headless): make bueno external (#4433) ([e1f7f2d](https://github.com/coveo/ui-kit/commits/e1f7f2d)), closes [#4433](https://github.com/coveo/ui-kit/issues/4433) +- chore(headless,atomic): add type "module" to atomic, atomic-react and headless (#4442) ([21896c3](https://github.com/coveo/ui-kit/commits/21896c3)), closes [#4442](https://github.com/coveo/ui-kit/issues/4442) [/github.com/coveo/ui-kit/pull/4449/files#diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87](https://github.com//github.com/coveo/ui-kit/pull/4449/files/issues/diff-75f80b97846615f5b074710648b8191f74aa4f00fd1536c45bc344b284ca8e87) +- fix(headless, commerce): schema validation error when switching between search page and plp (#4448) ([5808edb](https://github.com/coveo/ui-kit/commits/5808edb)), closes [#4448](https://github.com/coveo/ui-kit/issues/4448) +- fix(quantic, searchbox): Issue with searchbox suggestions list flashing after selecting recent query ([6f75ad6](https://github.com/coveo/ui-kit/commits/6f75ad6)), closes [#4401](https://github.com/coveo/ui-kit/issues/4401) +- feat: add answer configuration id to atomic-insight-generated-answer (#4451) ([6b7c2bd](https://github.com/coveo/ui-kit/commits/6b7c2bd)), closes [#4451](https://github.com/coveo/ui-kit/issues/4451) +- feat(headless): add a way to disable/enable the generated answer controller (#4288) ([a2f167b](https://github.com/coveo/ui-kit/commits/a2f167b)), closes [#4288](https://github.com/coveo/ui-kit/issues/4288) +- fix(atomic): enable/disable facet based on tab with updateActiveTab action (#4313) ([08fe92a](https://github.com/coveo/ui-kit/commits/08fe92a)), closes [#4313](https://github.com/coveo/ui-kit/issues/4313) [#4311](https://github.com/coveo/ui-kit/issues/4311) +- fix(headless): ensure each result keep a reference of its 'source' searchId (#4391) ([d0aa1fc](https://github.com/coveo/ui-kit/commits/d0aa1fc)), closes [#4391](https://github.com/coveo/ui-kit/issues/4391) + ## 3.0.0 (2024-09-18) - chore!: remove abab (#3908) ([e7b5682](https://github.com/coveo/ui-kit/commits/e7b5682)), closes [#3908](https://github.com/coveo/ui-kit/issues/3908) [#3897](https://github.com/coveo/ui-kit/issues/3897) diff --git a/packages/headless/README.md b/packages/headless/README.md index f01d842fcc8..e069d67d1e7 100644 --- a/packages/headless/README.md +++ b/packages/headless/README.md @@ -4,6 +4,22 @@ Using the library: [Coveo Headless Library Official Documentation](https://docs.coveo.com/en/headless/latest/). +## Entry points + +The `@coveo/headless` package exposes several entry points. + +The entry point from which you will import Coveo Headless resources depends on the engine type you are using: + +| Engine type | Entry point | +| --------------------- | -------------------------------- | +| Search engine | `@coveo/headless` | +| Search SSR engine | `@coveo/headless/ssr` | +| CaseAssist engine | `@coveo/headless/case-assist` | +| Commerce engine | `@coveo/headless/commerce` | +| Commerce SSR engine | `@coveo/headless/ssr-commerce`Â | +| Insight engine | `@coveo/headless/insight` | +| Recommendation engine | `@coveo/headless/recommendation` | + ## Contributing ### Getting started diff --git a/packages/headless/contributors/adding-a-sub-package.md b/packages/headless/contributors/adding-a-sub-package.md index ea159b77872..3ac0305094b 100644 --- a/packages/headless/contributors/adding-a-sub-package.md +++ b/packages/headless/contributors/adding-a-sub-package.md @@ -1,11 +1,13 @@ # Adding a sub-package -Headless provides exports through multiple sub packages. A sub-package groups together exports (i.e. controllers, actions, reducers, engines) that work together as a cohesive unit. By separating exports into sub-packages, it becomes clear to users of headless what exports are available to build a use-case. +Headless provides exports through multiple sub-packages. + +A sub-package groups together exports (i.e. engine, controllers, action loaders, selectors, types, utilities) that work together as a cohesive unit. By separating exports into sub-packages, it becomes clear to users of Headless what exports are available to build a specific use-case. ## To add a new sub-package: -1. Create an entry file for your sub-package inside the `src` directory (e.g. `case-assist.index.ts`). -2. Configure nodejs and browser bundles inside `esbuild.mjs` for the entry file created in step #1. Add entries in `useCaseEntries` and `getUmdGlobalName` map for the global name (used to store exports for iife) +1. In the `headless/src` directory, create an entry file for your new sub-package (e.g. `headless/src/case-assist.index.ts`). Everything you export from this file will be part of the public API of your sub-package. +2. In `headless/esbuild.mjs`, Configure NodeJS add entries for your new sub-package in the `useCaseEntries` object and `getUmdGlobalName` function map. ```javascript // headless/esbuild.mjs @@ -19,12 +21,12 @@ Headless provides exports through multiple sub packages. A sub-package groups to // ... }; + // ... + function getUmdGlobalName(useCase) { const map = { search: 'CoveoHeadless', recommendation: 'CoveoHeadlessRecommendation', - 'product-recommendation': 'CoveoHeadlessProductRecommendation', - 'product-listing': 'CoveoHeadlessProductListing', 'case-assist': 'CoveoHeadlessCaseAssist', // ... }; @@ -33,23 +35,33 @@ Headless provides exports through multiple sub packages. A sub-package groups to } ``` -3. Create a new directory with the name of your sub-package at the `headless/` root. -4. Inside the new directory, add a `package.json` file. Add the paths to your bundled files and type definitions. Make sure to mark the package as `private` so it doesn't get published individually. - - ```json - { - "private": true, - "name": "case-assist", - "description": "Headless Case Assist Module", - "main": "../dist/case-assist/headless.js", - "module": "../dist/case-assist/headless.esm.js", - "browser": "../dist/browser/case-assist/headless.esm.js", - "types": "../dist/definitions/case-assist.index.d.ts", - "license": "Apache-2.0" - } - ``` +3. In `headless/package.json`, add an entry point for your sub-package in the `exports` object. -5. Add the directory name to the `files` array in the project root `package.json` file. + ````json + // headless/package.json + + // ... + "exports": { + // ... + "./case-assist": { + "types": "./dist/definitions/case-assist.index.d.ts", + "node": { + "types": "./dist/definitions/case-assist.index.d.ts", + "import": "./dist/case-assist/headless.esm.js", + "require": "./dist/case-assist/headless.cjs" + }, + "browser": { + "types": "./dist/definitions/case-assist.index.d.ts", + "import": "./dist/browser/case-assist/headless.esm.js", + "require": "./dist/browser/case-assist/headless.js" + }, + "import": "./dist/browser/case-assist/headless.esm.js", + "require": "./dist/browser/case-assist/headless.js" + }, + // ... + } + ```Â + ```` ## Testing your sub-package: diff --git a/packages/headless/doc-parser/package.json b/packages/headless/doc-parser/package.json new file mode 100644 index 00000000000..2cd2b80d94b --- /dev/null +++ b/packages/headless/doc-parser/package.json @@ -0,0 +1,7 @@ +{ + "type": "commonjs", + "dependencies": { + "@microsoft/api-extractor-model": "7.29.3", + "@microsoft/tsdoc": "0.15.0" + } +} diff --git a/packages/headless/doc-parser/src/interface-resolver.test.ts b/packages/headless/doc-parser/src/interface-resolver.test.ts index 072650a7356..09f9a82b043 100644 --- a/packages/headless/doc-parser/src/interface-resolver.test.ts +++ b/packages/headless/doc-parser/src/interface-resolver.test.ts @@ -1,22 +1,23 @@ -import {facetValueStates} from '../../src/features/facets/facet-api/value'; -import {buildMockApiCallSignature} from '../mocks/mock-api-call-signature'; -import {buildMockApiDocComment} from '../mocks/mock-api-doc-comment'; -import {buildMockApiIndexSignature} from '../mocks/mock-api-index-signature'; -import {buildMockApiInterface} from '../mocks/mock-api-interface'; -import {buildMockApiMethodSignature} from '../mocks/mock-api-method-signature'; -import {buildMockApiPropertySignature} from '../mocks/mock-api-property-signature'; -import {buildMockApiTypeAlias} from '../mocks/mock-api-type-alias'; -import {buildMockEntity} from '../mocks/mock-entity'; -import {buildMockEntityWithTypeAlias} from '../mocks/mock-entity-with-type-alias'; -import {buildMockEntryPoint} from '../mocks/mock-entry-point'; +// eslint-disable-next-line n/no-unpublished-import +import {facetValueStates} from '../../src/features/facets/facet-api/value.js'; +import {buildMockApiCallSignature} from '../mocks/mock-api-call-signature.js'; +import {buildMockApiDocComment} from '../mocks/mock-api-doc-comment.js'; +import {buildMockApiIndexSignature} from '../mocks/mock-api-index-signature.js'; +import {buildMockApiInterface} from '../mocks/mock-api-interface.js'; +import {buildMockApiMethodSignature} from '../mocks/mock-api-method-signature.js'; +import {buildMockApiPropertySignature} from '../mocks/mock-api-property-signature.js'; +import {buildMockApiTypeAlias} from '../mocks/mock-api-type-alias.js'; +import {buildMockEntityWithTypeAlias} from '../mocks/mock-entity-with-type-alias.js'; +import {buildMockEntity} from '../mocks/mock-entity.js'; +import {buildMockEntryPoint} from '../mocks/mock-entry-point.js'; import { buildContentExcerptToken, buildReferenceExcerptToken, -} from '../mocks/mock-excerpt-token'; -import {buildMockFuncEntity} from '../mocks/mock-func-entity'; -import {buildMockObjEntity} from '../mocks/mock-obj-entity'; -import {AnyEntity} from './entity'; -import {resolveInterfaceMembers} from './interface-resolver'; +} from '../mocks/mock-excerpt-token.js'; +import {buildMockFuncEntity} from '../mocks/mock-func-entity.js'; +import {buildMockObjEntity} from '../mocks/mock-obj-entity.js'; +import {AnyEntity} from './entity.js'; +import {resolveInterfaceMembers} from './interface-resolver.js'; describe('#resolveInterfaceMembers', () => { it('resolves a property with a primitive type', () => { diff --git a/packages/headless/esbuild.mjs b/packages/headless/esbuild.mjs index f338a8a8436..5f4472e50b1 100644 --- a/packages/headless/esbuild.mjs +++ b/packages/headless/esbuild.mjs @@ -1,14 +1,28 @@ import alias from 'esbuild-plugin-alias'; +import {aliasPath} from 'esbuild-plugin-alias-path'; import {umdWrapper} from 'esbuild-plugin-umd-wrapper'; -import {readFileSync, promises, writeFileSync} from 'node:fs'; +import {readFileSync, writeFileSync} from 'node:fs'; import {createRequire} from 'node:module'; -import {dirname, resolve} from 'node:path'; +import path, {dirname, resolve} from 'node:path'; +import {join} from 'path'; import {build} from '../../scripts/esbuild/build.mjs'; import {apacheLicense} from '../../scripts/license/apache.mjs'; +const __dirname = dirname(new URL(import.meta.url).pathname); + +const buenoJsonPath = join(__dirname, '../bueno/package.json'); +const buenoJson = JSON.parse(readFileSync(buenoJsonPath, 'utf-8')); + const require = createRequire(import.meta.url); const devMode = process.argv[2] === 'dev'; +const isCDN = process.env.DEPLOYMENT_ENVIRONMENT === 'CDN'; + +const buenoVersion = 'v' + buenoJson.version; +const buenoPath = isCDN + ? `/bueno/${buenoVersion}/bueno.esm.js` + : '@coveo/bueno'; + const useCaseEntries = { search: 'src/index.ts', recommendation: 'src/recommendation.index.ts', @@ -30,8 +44,6 @@ function getUmdGlobalName(useCase) { const map = { search: 'CoveoHeadless', recommendation: 'CoveoHeadlessRecommendation', - 'product-recommendation': 'CoveoHeadlessProductRecommendation', - 'product-listing': 'CoveoHeadlessProductListing', 'case-assist': 'CoveoHeadlessCaseAssist', insight: 'CoveoHeadlessInsight', ssr: 'CoveoHeadlessSSR', @@ -85,6 +97,16 @@ const browserEsmForAtomicDevelopment = Object.entries(useCaseEntries).map( format: 'esm', watch: devMode, minify: false, + plugins: [ + aliasPath({ + alias: { + '@coveo/bueno': path.resolve( + __dirname, + './src/external-builds/bueno.esm.js' + ), + }, + }), + ], }, outDir ); @@ -150,6 +172,7 @@ const quanticUmd = Object.entries(quanticUseCaseEntries).map((entry) => { banner: { js: `${base.banner.js}`, }, + external: ['crypto'], inject: [ 'ponyfills/abortable-fetch-shim.js', '../../node_modules/navigator.sendbeacon/dist/navigator.sendbeacon.cjs.js', @@ -186,20 +209,32 @@ function resolveBrowser(moduleName) { * @returns {Promise} */ async function buildBrowserConfig(options, outDir) { + const replaceBuenoImport = [ + { + name: 'replace-bueno-import', + setup(build) { + build.onResolve({filter: /^@coveo\/bueno$/}, (args) => { + return {path: buenoPath, external: true}; + }); + }, + }, + ]; const out = await build({ ...base, platform: 'browser', minify: true, sourcemap: true, metafile: true, - external: ['crypto'], + external: ['crypto', buenoPath], ...options, + plugins: [ alias({ 'coveo.analytics': resolveEsm('coveo.analytics'), pino: resolveBrowser('pino'), '@coveo/pendragon': resolve('./ponyfills', 'magic-cookie-browser.js'), }), + ...(isCDN ? replaceBuenoImport : []), ...(options.plugins || []), ], }); @@ -210,7 +245,7 @@ async function buildBrowserConfig(options, outDir) { const nodeCjs = Object.entries(useCaseEntries).map((entry) => { const [useCase, entryPoint] = entry; const dir = getUseCaseDir('dist/', useCase); - const outfile = `${dir}/headless.js`; + const outfile = `${dir}/headless.cjs`; return buildNodeConfig( { entryPoints: [entryPoint], diff --git a/packages/headless/insight/package.json b/packages/headless/insight/package.json deleted file mode 100644 index 19b0b166909..00000000000 --- a/packages/headless/insight/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "name": "insight", - "description": "Headless Insight Module", - "main": "../dist/insight/headless.js", - "module": "../dist/insight/headless.esm.js", - "browser": "../dist/browser/insight/headless.esm.js", - "types": "../dist/definitions/insight.index.d.ts", - "license": "Apache-2.0" -} diff --git a/packages/headless/jest.config.js b/packages/headless/jest.config.js deleted file mode 100644 index 3199372c884..00000000000 --- a/packages/headless/jest.config.js +++ /dev/null @@ -1,9 +0,0 @@ -process.env.TZ = 'Australia/Eucla'; - -module.exports = { - preset: 'ts-jest', - silent: true, - moduleNameMapper: { - '@coveo/pendragon': '/ponyfills/magic-cookie-node.js', - }, -}; diff --git a/packages/headless/package.json b/packages/headless/package.json index 83b7c00fdf9..19fb833b3d0 100644 --- a/packages/headless/package.json +++ b/packages/headless/package.json @@ -6,15 +6,16 @@ "url": "git+https://github.com/coveo/ui-kit.git", "directory": "packages/headless" }, - "main": "./dist/headless.js", + "main": "./dist/headless.cjs", "module": "./dist/headless.esm.js", + "type": "module", "exports": { ".": { "types": "./dist/definitions/index.d.ts", "node": { "types": "./dist/definitions/index.d.ts", "import": "./dist/headless.esm.js", - "require": "./dist/headless.js" + "require": "./dist/headless.cjs" }, "browser": { "types": "./dist/definitions/index.d.ts", @@ -29,7 +30,7 @@ "node": { "types": "./dist/definitions/case-assist.index.d.ts", "import": "./dist/case-assist/headless.esm.js", - "require": "./dist/case-assist/headless.js" + "require": "./dist/case-assist/headless.cjs" }, "browser": { "types": "./dist/definitions/case-assist.index.d.ts", @@ -44,7 +45,7 @@ "node": { "types": "./dist/definitions/commerce.index.d.ts", "import": "./dist/commerce/headless.esm.js", - "require": "./dist/commerce/headless.js" + "require": "./dist/commerce/headless.cjs" }, "browser": { "types": "./dist/definitions/commerce.index.d.ts", @@ -59,7 +60,7 @@ "node": { "types": "./dist/definitions/insight.index.d.ts", "import": "./dist/insight/headless.esm.js", - "require": "./dist/insight/headless.js" + "require": "./dist/insight/headless.cjs" }, "browser": { "types": "./dist/definitions/insight.index.d.ts", @@ -74,7 +75,7 @@ "node": { "types": "./dist/definitions/recommendation.index.d.ts", "import": "./dist/recommendation/headless.esm.js", - "require": "./dist/recommendation/headless.js" + "require": "./dist/recommendation/headless.cjs" }, "browser": { "types": "./dist/definitions/recommendation.index.d.ts", @@ -89,7 +90,7 @@ "node": { "types": "./dist/definitions/ssr.index.d.ts", "import": "./dist/ssr/headless.esm.js", - "require": "./dist/ssr/headless.js" + "require": "./dist/ssr/headless.cjs" }, "browser": { "types": "./dist/definitions/ssr.index.d.ts", @@ -104,7 +105,7 @@ "node": { "types": "./dist/definitions/ssr-commerce.index.d.ts", "import": "./dist/ssr-commerce/headless.esm.js", - "require": "./dist/ssr-commerce/headless.js" + "require": "./dist/ssr-commerce/headless.cjs" }, "browser": { "types": "./dist/definitions/ssr-commerce.index.d.ts", @@ -117,7 +118,7 @@ }, "types": "./dist/definitions/index.d.ts", "license": "Apache-2.0", - "version": "3.0.0", + "version": "3.1.3", "files": [ "dist/" ], @@ -128,10 +129,10 @@ "build:bundles": "node esbuild.mjs", "build:definitions": "tsc -p src/tsconfig.build.json -d --emitDeclarationOnly --declarationDir dist/definitions", "clean": "rimraf -rf dist/*", - "test": "jest", - "test:watch": "jest --watch --colors --no-cache --silent=false", - "test:unit": "jest --testPathIgnorePatterns=src/integration-tests", - "test:integration": "jest --testPathPattern=src/integration-tests", + "test": "vitest run --exclude \"src/integration-tests/**\"", + "test:watch": "vitest --exclude \"src/integration-tests/**\"", + "integration-test": "vitest run --poolOptions.threads.singleThread src/integration-tests/**", + "integration-test:watch": "vitest --poolOptions.threads.singleThread src/integration-tests/**", "publish:npm": "npm run-script -w=@coveo/release npm-publish", "publish:bump": "npm run-script -w=@coveo/release bump", "promote:npm:latest": "node ../../scripts/deploy/update-npm-tag.mjs latest", @@ -144,7 +145,7 @@ "pino-pretty": "^6.0.0 || ^10.0.0 || ^11.0.0" }, "dependencies": { - "@coveo/bueno": "1.0.0", + "@coveo/bueno": "1.0.1", "@coveo/relay": "0.7.10", "@coveo/relay-event-types": "9.4.0", "@microsoft/fetch-event-source": "2.0.1", @@ -165,12 +166,12 @@ "@microsoft/api-extractor": "7.47.3", "@microsoft/api-extractor-model": "7.29.3", "@microsoft/tsdoc": "0.15.0", + "esbuild-plugin-alias-path": "2.0.2", "eslint-plugin-canonical": "4.18.0", "execa": "8.0.1", "install": "0.13.0", - "jest": "29.7.0", - "ts-jest": "29.2.3", - "ts-node": "10.9.2" + "ts-node": "10.9.2", + "vitest": "2.1.1" }, "engines": { "node": "^20.9.0" diff --git a/packages/headless/src/api/analytics/analytics-relay-client.test.ts b/packages/headless/src/api/analytics/analytics-relay-client.test.ts index 59599caf86c..192e1d0f7e8 100644 --- a/packages/headless/src/api/analytics/analytics-relay-client.test.ts +++ b/packages/headless/src/api/analytics/analytics-relay-client.test.ts @@ -1,28 +1,28 @@ import {createRelay} from '@coveo/relay'; -import {createMockState} from '../../test/mock-state'; -import {getAnalyticsNextApiBaseUrl} from '../platform-client'; -import {getRelayInstanceFromState} from './analytics-relay-client'; -import {getAnalyticsSource} from './analytics-selectors'; +import {createMockState} from '../../test/mock-state.js'; +import {getAnalyticsNextApiBaseUrl} from '../platform-client.js'; +import {getRelayInstanceFromState} from './analytics-relay-client.js'; +import {getAnalyticsSource} from './analytics-selectors.js'; -jest.mock('@coveo/relay'); -jest.mock('./analytics-selectors'); +vi.mock('@coveo/relay'); +vi.mock('./analytics-selectors'); describe('#getRelayInstanceFromState', () => { - const mockedCreateRelay = jest.mocked(createRelay).mockImplementation(() => ({ - emit: jest.fn(), - on: jest.fn(), - off: jest.fn(), - getMeta: jest.fn(), - updateConfig: jest.fn(), + const mockedCreateRelay = vi.mocked(createRelay).mockImplementation(() => ({ + emit: vi.fn(), + on: vi.fn(), + off: vi.fn(), + getMeta: vi.fn(), + updateConfig: vi.fn(), version: 'test', })); beforeEach(() => { - jest.mocked(getAnalyticsSource).mockReturnValue(['baguette']); + vi.mocked(getAnalyticsSource).mockReturnValue(['baguette']); }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('creates a Relay client properly and returns it', () => { diff --git a/packages/headless/src/api/analytics/analytics-relay-client.ts b/packages/headless/src/api/analytics/analytics-relay-client.ts index 23531d11da7..ca7ce34e382 100644 --- a/packages/headless/src/api/analytics/analytics-relay-client.ts +++ b/packages/headless/src/api/analytics/analytics-relay-client.ts @@ -3,9 +3,9 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceConfigurationSection, ConfigurationSection, -} from '../../state/state-sections'; -import {getAnalyticsNextApiBaseUrl} from '../platform-client'; -import {getAnalyticsSource} from './analytics-selectors'; +} from '../../state/state-sections.js'; +import {getAnalyticsNextApiBaseUrl} from '../platform-client.js'; +import {getAnalyticsSource} from './analytics-selectors.js'; type StateNeededByRelay = ConfigurationSection | CommerceConfigurationSection; diff --git a/packages/headless/src/api/analytics/analytics-selectors.test.ts b/packages/headless/src/api/analytics/analytics-selectors.test.ts index 10117e71c26..bbfd99fac61 100644 --- a/packages/headless/src/api/analytics/analytics-selectors.test.ts +++ b/packages/headless/src/api/analytics/analytics-selectors.test.ts @@ -1,6 +1,6 @@ -import {createMockState} from '../../test/mock-state'; -import {VERSION} from '../../utils/version'; -import {getAnalyticsSource} from './analytics-selectors'; +import {createMockState} from '../../test/mock-state.js'; +import {VERSION} from '../../utils/version.js'; +import {getAnalyticsSource} from './analytics-selectors.js'; describe('#getAnalyticsSources', () => { it('without a source, returns an array only with `@coveo/headless`', () => { diff --git a/packages/headless/src/api/analytics/analytics-selectors.ts b/packages/headless/src/api/analytics/analytics-selectors.ts index 931bd30aa2d..e45dceade5d 100644 --- a/packages/headless/src/api/analytics/analytics-selectors.ts +++ b/packages/headless/src/api/analytics/analytics-selectors.ts @@ -1,6 +1,6 @@ import {createSelector} from '@reduxjs/toolkit'; -import {CoreAnalyticsState} from '../../features/configuration/configuration-state'; -import {VERSION} from '../../utils/version'; +import {CoreAnalyticsState} from '../../features/configuration/configuration-state.js'; +import {VERSION} from '../../utils/version.js'; export const getAnalyticsSource = createSelector( (state: CoreAnalyticsState) => state.source, diff --git a/packages/headless/src/api/analytics/base-analytics.test.ts b/packages/headless/src/api/analytics/base-analytics.test.ts index 2cea0418506..d6d2739f256 100644 --- a/packages/headless/src/api/analytics/base-analytics.test.ts +++ b/packages/headless/src/api/analytics/base-analytics.test.ts @@ -1,11 +1,11 @@ -import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events'; -import {getConfigurationInitialState} from '../../features/configuration/configuration-state'; -import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state'; -import {buildMockAnalyticsState} from '../../test/mock-analytics-state'; +import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js'; +import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js'; +import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js'; +import {buildMockAnalyticsState} from '../../test/mock-analytics-state.js'; import { BaseAnalyticsProvider, StateNeededByBaseAnalyticsProvider, -} from './base-analytics'; +} from './base-analytics.js'; class TestProvider extends BaseAnalyticsProvider { public getPipeline(): string { diff --git a/packages/headless/src/api/analytics/base-analytics.ts b/packages/headless/src/api/analytics/base-analytics.ts index 8c3038f8920..0404ee7d79e 100644 --- a/packages/headless/src/api/analytics/base-analytics.ts +++ b/packages/headless/src/api/analytics/base-analytics.ts @@ -1,14 +1,14 @@ import {SearchPageClientProvider} from 'coveo.analytics'; -import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events'; -import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state'; +import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js'; +import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js'; import { ConfigurationSection, ContextSection, PipelineSection, QuerySection, SearchHubSection, -} from '../../state/state-sections'; -import {VERSION} from '../../utils/version'; +} from '../../state/state-sections.js'; +import {VERSION} from '../../utils/version.js'; export const getLanguage = (state: ConfigurationSection) => { const langKey = state.configuration.search.locale.split('-')[0]; diff --git a/packages/headless/src/api/analytics/case-assist-analytics.ts b/packages/headless/src/api/analytics/case-assist-analytics.ts index 48106be517e..ba358d6200a 100644 --- a/packages/headless/src/api/analytics/case-assist-analytics.ts +++ b/packages/headless/src/api/analytics/case-assist-analytics.ts @@ -4,7 +4,7 @@ import { CaseAssistClientProvider, } from 'coveo.analytics'; import {Logger} from 'pino'; -import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state'; +import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js'; import { CaseAssistConfigurationSection, CaseFieldSection, @@ -12,13 +12,13 @@ import { ConfigurationSection, DocumentSuggestionSection, SearchHubSection, -} from '../../state/state-sections'; -import {getOrganizationEndpoint} from '../platform-client'; -import {PreprocessRequest} from '../preprocess-request'; +} from '../../state/state-sections.js'; +import {getOrganizationEndpoint} from '../platform-client.js'; +import {PreprocessRequest} from '../preprocess-request.js'; import { wrapAnalyticsClientSendEventHook, wrapPreprocessRequest, -} from './coveo-analytics-utils'; +} from './coveo-analytics-utils.js'; export type StateNeededByCaseAssistAnalytics = ConfigurationSection & Partial & diff --git a/packages/headless/src/api/analytics/coveo-analytics-utils.test.ts b/packages/headless/src/api/analytics/coveo-analytics-utils.test.ts index 498888a7a8e..f114c56a113 100644 --- a/packages/headless/src/api/analytics/coveo-analytics-utils.test.ts +++ b/packages/headless/src/api/analytics/coveo-analytics-utils.test.ts @@ -1,10 +1,13 @@ import {AnalyticsClientSendEventHook} from 'coveo.analytics'; import {pino} from 'pino'; -import {PlatformRequestOptions, PreprocessRequest} from '../preprocess-request'; +import { + PlatformRequestOptions, + PreprocessRequest, +} from '../preprocess-request.js'; import { wrapAnalyticsClientSendEventHook, wrapPreprocessRequest, -} from './coveo-analytics-utils'; +} from './coveo-analytics-utils.js'; describe('coveo-analytics-utils', () => { it('should properly wrap preprocessRequest', () => { diff --git a/packages/headless/src/api/analytics/coveo-analytics-utils.ts b/packages/headless/src/api/analytics/coveo-analytics-utils.ts index 011fdcf6855..5a4645a8095 100644 --- a/packages/headless/src/api/analytics/coveo-analytics-utils.ts +++ b/packages/headless/src/api/analytics/coveo-analytics-utils.ts @@ -5,8 +5,8 @@ import { history, } from 'coveo.analytics'; import {Logger} from 'pino'; -import {clone} from '../../utils/utils'; -import {PreprocessRequest} from '../preprocess-request'; +import {clone} from '../../utils/utils.js'; +import {PreprocessRequest} from '../preprocess-request.js'; export const getVisitorID = (options: { runtimeEnvironment?: IRuntimeEnvironment; diff --git a/packages/headless/src/api/analytics/insight-analytics.test.ts b/packages/headless/src/api/analytics/insight-analytics.test.ts index 4057667759d..176692cd728 100644 --- a/packages/headless/src/api/analytics/insight-analytics.test.ts +++ b/packages/headless/src/api/analytics/insight-analytics.test.ts @@ -1,21 +1,21 @@ import {CoveoAnalyticsClient} from 'coveo.analytics'; -import pino from 'pino'; -import {getConfigurationInitialState} from '../../features/configuration/configuration-state'; -import {getGeneratedAnswerInitialState} from '../../features/generated-answer/generated-answer-state'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../test/mock-facet-value'; -import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockQueryState} from '../../test/mock-query-state'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchState} from '../../test/mock-search-state'; +import {pino} from 'pino'; +import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js'; +import {getGeneratedAnswerInitialState} from '../../features/generated-answer/generated-answer-state.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request.js'; +import {buildMockFacetValue} from '../../test/mock-facet-value.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockQueryState} from '../../test/mock-query-state.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; import { configureInsightAnalytics, InsightAnalyticsProvider, StateNeededByInsightAnalyticsProvider, -} from './insight-analytics'; +} from './insight-analytics.js'; describe('insight analytics', () => { const logger = pino({level: 'silent'}); diff --git a/packages/headless/src/api/analytics/insight-analytics.ts b/packages/headless/src/api/analytics/insight-analytics.ts index 7149ac8405c..70b4923735a 100644 --- a/packages/headless/src/api/analytics/insight-analytics.ts +++ b/packages/headless/src/api/analytics/insight-analytics.ts @@ -3,16 +3,16 @@ import { InsightClientProvider, CoveoInsightClient, } from 'coveo.analytics'; -import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events'; +import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js'; import {Logger} from 'pino'; import { buildFacetStateMetadata, getStateNeededForFacetMetadata, SectionNeededForFacetMetadata, -} from '../../features/facets/facet-set/facet-set-analytics-actions-utils'; -import {getQueryInitialState} from '../../features/query/query-state'; -import {getSearchInitialState} from '../../features/search/search-state'; -import {InsightAppState} from '../../state/insight-app-state'; +} from '../../features/facets/facet-set/facet-set-analytics-actions-utils.js'; +import {getQueryInitialState} from '../../features/query/query-state.js'; +import {getSearchInitialState} from '../../features/search/search-state.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; import { ConfigurationSection, GeneratedAnswerSection, @@ -20,14 +20,14 @@ import { QuerySection, SearchHubSection, SearchSection, -} from '../../state/state-sections'; -import {getOrganizationEndpoint} from '../platform-client'; -import {PreprocessRequest} from '../preprocess-request'; -import {BaseAnalyticsProvider} from './base-analytics'; +} from '../../state/state-sections.js'; +import {getOrganizationEndpoint} from '../platform-client.js'; +import {PreprocessRequest} from '../preprocess-request.js'; +import {BaseAnalyticsProvider} from './base-analytics.js'; import { wrapAnalyticsClientSendEventHook, wrapPreprocessRequest, -} from './coveo-analytics-utils'; +} from './coveo-analytics-utils.js'; export type StateNeededByInsightAnalyticsProvider = ConfigurationSection & Partial & diff --git a/packages/headless/src/api/analytics/instant-result-analytics.ts b/packages/headless/src/api/analytics/instant-result-analytics.ts index 94fa3853b66..dfc3d383d39 100644 --- a/packages/headless/src/api/analytics/instant-result-analytics.ts +++ b/packages/headless/src/api/analytics/instant-result-analytics.ts @@ -1,10 +1,10 @@ -import {getQueryInitialState} from '../../features/query/query-state'; -import {getSearchInitialState} from '../../features/search/search-state'; -import {InstantResultSection} from '../../state/state-sections'; +import {getQueryInitialState} from '../../features/query/query-state.js'; +import {getSearchInitialState} from '../../features/search/search-state.js'; +import {InstantResultSection} from '../../state/state-sections.js'; import { SearchAnalyticsProvider, StateNeededBySearchAnalyticsProvider, -} from './search-analytics'; +} from './search-analytics.js'; export type StateNeededByInstantResultsAnalyticsProvider = StateNeededBySearchAnalyticsProvider & InstantResultSection; diff --git a/packages/headless/src/api/analytics/instant-results-analytics.test.ts b/packages/headless/src/api/analytics/instant-results-analytics.test.ts index 63ed48bf7c5..55298eaa2a1 100644 --- a/packages/headless/src/api/analytics/instant-results-analytics.test.ts +++ b/packages/headless/src/api/analytics/instant-results-analytics.test.ts @@ -1,14 +1,14 @@ -import {getConfigurationInitialState} from '../../features/configuration/configuration-state'; +import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js'; import { getInstantResultsInitialState, InstantResultCache, -} from '../../features/instant-results/instant-results-state'; -import {buildMockResult} from '../../test/mock-result'; -import {getObjectHash} from '../../utils/utils'; +} from '../../features/instant-results/instant-results-state.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {getObjectHash} from '../../utils/utils.js'; import { InstantResultsAnalyticsProvider, StateNeededByInstantResultsAnalyticsProvider, -} from './instant-result-analytics'; +} from './instant-result-analytics.js'; describe('instant results analytics provider', () => { const getBaseState = (): StateNeededByInstantResultsAnalyticsProvider => ({ diff --git a/packages/headless/src/api/analytics/recommendations-analytics.test.ts b/packages/headless/src/api/analytics/recommendations-analytics.test.ts index 1c68eb9a880..381725603a6 100644 --- a/packages/headless/src/api/analytics/recommendations-analytics.test.ts +++ b/packages/headless/src/api/analytics/recommendations-analytics.test.ts @@ -1,9 +1,9 @@ -import {createMockRecommendationState} from '../../test/mock-recommendation-state'; -import {buildMockResult} from '../../test/mock-result'; +import {createMockRecommendationState} from '../../test/mock-recommendation-state.js'; +import {buildMockResult} from '../../test/mock-result.js'; import { RecommendationAnalyticsProvider, StateNeededByRecommendationAnalyticsProvider, -} from './recommendations-analytics'; +} from './recommendations-analytics.js'; describe('recommendations analytics', () => { const getBaseState = (): StateNeededByRecommendationAnalyticsProvider => diff --git a/packages/headless/src/api/analytics/recommendations-analytics.ts b/packages/headless/src/api/analytics/recommendations-analytics.ts index 22a3446a075..7a05a1365b0 100644 --- a/packages/headless/src/api/analytics/recommendations-analytics.ts +++ b/packages/headless/src/api/analytics/recommendations-analytics.ts @@ -1,15 +1,15 @@ import {SearchPageClientProvider} from 'coveo.analytics'; -import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events'; -import {getQueryInitialState} from '../../features/query/query-state'; -import {getRecommendationInitialState} from '../../features/recommendation/recommendation-state'; +import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js'; +import {getQueryInitialState} from '../../features/query/query-state.js'; +import {getRecommendationInitialState} from '../../features/recommendation/recommendation-state.js'; import { ConfigurationSection, ContextSection, PipelineSection, RecommendationSection, SearchHubSection, -} from '../../state/state-sections'; -import {BaseAnalyticsProvider} from './base-analytics'; +} from '../../state/state-sections.js'; +import {BaseAnalyticsProvider} from './base-analytics.js'; export type StateNeededByRecommendationAnalyticsProvider = ConfigurationSection & diff --git a/packages/headless/src/api/analytics/search-analytics.test.ts b/packages/headless/src/api/analytics/search-analytics.test.ts index 50d989df647..b238254b84f 100644 --- a/packages/headless/src/api/analytics/search-analytics.test.ts +++ b/packages/headless/src/api/analytics/search-analytics.test.ts @@ -1,43 +1,43 @@ import {CoveoAnalyticsClient} from 'coveo.analytics'; -import pino from 'pino'; -import {getConfigurationInitialState} from '../../features/configuration/configuration-state'; -import {getCategoryFacetSetInitialState} from '../../features/facets/category-facet-set/category-facet-set-state'; -import {getFacetSetInitialState} from '../../features/facets/facet-set/facet-set-state'; -import {FacetSortCriterion} from '../../features/facets/facet-set/interfaces/request'; -import {DateFacetValue} from '../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {getGeneratedAnswerInitialState} from '../../features/generated-answer/generated-answer-state'; -import {OmniboxSuggestionMetadata} from '../../features/query-suggest/query-suggest-analytics-actions'; -import {getQuerySuggestSetInitialState} from '../../features/query-suggest/query-suggest-state'; -import {StaticFilterValueMetadata} from '../../features/static-filter-set/static-filter-set-actions'; -import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../test/mock-facet-value'; -import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request'; -import {buildMockQueryState} from '../../test/mock-query-state'; -import {buildMockQuerySuggestSet} from '../../test/mock-query-suggest-slice'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {createMockState} from '../../test/mock-state'; -import {QuerySuggestCompletion} from '../search/query-suggest/query-suggest-response'; +import {pino} from 'pino'; +import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js'; +import {getCategoryFacetSetInitialState} from '../../features/facets/category-facet-set/category-facet-set-state.js'; +import {getFacetSetInitialState} from '../../features/facets/facet-set/facet-set-state.js'; +import {FacetSortCriterion} from '../../features/facets/facet-set/interfaces/request.js'; +import {DateFacetValue} from '../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {getGeneratedAnswerInitialState} from '../../features/generated-answer/generated-answer-state.js'; +import {OmniboxSuggestionMetadata} from '../../features/query-suggest/query-suggest-analytics-actions.js'; +import {getQuerySuggestSetInitialState} from '../../features/query-suggest/query-suggest-state.js'; +import {StaticFilterValueMetadata} from '../../features/static-filter-set/static-filter-set-actions.js'; +import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request.js'; +import {buildMockFacetValue} from '../../test/mock-facet-value.js'; +import {buildMockQueryState} from '../../test/mock-query-state.js'; +import {buildMockQuerySuggestSet} from '../../test/mock-query-suggest-slice.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {createMockState} from '../../test/mock-state.js'; +import {QuerySuggestCompletion} from '../search/query-suggest/query-suggest-response.js'; import { configureLegacyAnalytics, getPageID, SearchAnalyticsProvider, StateNeededBySearchAnalyticsProvider, -} from './search-analytics'; +} from './search-analytics.js'; -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -const mockGetHistory = jest.fn(); +const mockGetHistory = vi.fn(); -jest.mock('coveo.analytics', () => { - const originalModule = jest.requireActual('coveo.analytics'); +vi.mock('coveo.analytics', async () => { + const originalModule = await vi.importActual('coveo.analytics'); return { ...originalModule, history: { - HistoryStore: jest.fn().mockImplementation(() => { + HistoryStore: vi.fn().mockImplementation(() => { return { getHistory: () => mockGetHistory(), }; diff --git a/packages/headless/src/api/analytics/search-analytics.ts b/packages/headless/src/api/analytics/search-analytics.ts index 763df9494b0..59f9c20f930 100644 --- a/packages/headless/src/api/analytics/search-analytics.ts +++ b/packages/headless/src/api/analytics/search-analytics.ts @@ -3,31 +3,31 @@ import { SearchPageClientProvider, AnalyticsClientSendEventHook, } from 'coveo.analytics'; -import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events'; +import {SearchEventRequest} from 'coveo.analytics/dist/definitions/events.js'; import {Logger} from 'pino'; import { buildFacetStateMetadata, getStateNeededForFacetMetadata, -} from '../../features/facets/facet-set/facet-set-analytics-actions-utils'; -import {FacetSortCriterion} from '../../features/facets/facet-set/interfaces/request'; -import {DateFacetValue} from '../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {RangeFacetSortCriterion} from '../../features/facets/range-facets/generic/interfaces/request'; -import {NumericFacetValue} from '../../features/facets/range-facets/numeric-facet-set/interfaces/response'; -import {OmniboxSuggestionMetadata} from '../../features/query-suggest/query-suggest-analytics-actions'; -import {getQueryInitialState} from '../../features/query/query-state'; -import {getSearchInitialState} from '../../features/search/search-state'; -import {getSortCriteriaInitialState} from '../../features/sort-criteria/sort-criteria-state'; -import {StaticFilterValueMetadata} from '../../features/static-filter-set/static-filter-set-actions'; -import {SearchAppState} from '../../state/search-app-state'; -import {ConfigurationSection} from '../../state/state-sections'; -import {getOrganizationEndpoint} from '../platform-client'; -import {PreprocessRequest} from '../preprocess-request'; -import {BaseAnalyticsProvider} from './base-analytics'; +} from '../../features/facets/facet-set/facet-set-analytics-actions-utils.js'; +import {FacetSortCriterion} from '../../features/facets/facet-set/interfaces/request.js'; +import {DateFacetValue} from '../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {RangeFacetSortCriterion} from '../../features/facets/range-facets/generic/interfaces/request.js'; +import {NumericFacetValue} from '../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; +import {OmniboxSuggestionMetadata} from '../../features/query-suggest/query-suggest-analytics-actions.js'; +import {getQueryInitialState} from '../../features/query/query-state.js'; +import {getSearchInitialState} from '../../features/search/search-state.js'; +import {getSortCriteriaInitialState} from '../../features/sort-criteria/sort-criteria-state.js'; +import {StaticFilterValueMetadata} from '../../features/static-filter-set/static-filter-set-actions.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {ConfigurationSection} from '../../state/state-sections.js'; +import {getOrganizationEndpoint} from '../platform-client.js'; +import {PreprocessRequest} from '../preprocess-request.js'; +import {BaseAnalyticsProvider} from './base-analytics.js'; import { historyStore, wrapAnalyticsClientSendEventHook, wrapPreprocessRequest, -} from './coveo-analytics-utils'; +} from './coveo-analytics-utils.js'; export type StateNeededBySearchAnalyticsProvider = ConfigurationSection & Partial>; diff --git a/packages/headless/src/api/api-client-utils.ts b/packages/headless/src/api/api-client-utils.ts index cb883b789d5..47977706157 100644 --- a/packages/headless/src/api/api-client-utils.ts +++ b/packages/headless/src/api/api-client-utils.ts @@ -1,11 +1,11 @@ -import {PlatformResponse} from './platform-client'; -import {BaseParam} from './platform-service-params'; -import {AllSearchAPIResponse} from './search/search-api-client'; +import {PlatformResponse} from './platform-client.js'; +import {BaseParam} from './platform-service-params.js'; +import {AllSearchAPIResponse} from './search/search-api-client.js'; import { SearchAPIErrorWithStatusCode, SearchAPIErrorWithExceptionInBody, -} from './search/search-api-error-response'; -import {AuthenticationParam} from './search/search-api-params'; +} from './search/search-api-error-response.js'; +import {AuthenticationParam} from './search/search-api-params.js'; export function pickNonBaseParams< Params extends BaseParam & AuthenticationParam, diff --git a/packages/headless/src/api/commerce/commerce-api-client.test.ts b/packages/headless/src/api/commerce/commerce-api-client.test.ts index 3e3b18734b1..90a41d73845 100644 --- a/packages/headless/src/api/commerce/commerce-api-client.test.ts +++ b/packages/headless/src/api/commerce/commerce-api-client.test.ts @@ -1,11 +1,15 @@ -import {SortBy} from '../../features/sort/sort'; -import {buildMockCommerceAPIClient} from '../../test/mock-commerce-api-client'; -import {VERSION} from '../../utils/version'; -import {PlatformClient} from '../platform-client'; -import {CommerceAPIClient, getCommerceApiBaseUrl} from './commerce-api-client'; -import {CommerceAPIRequest} from './common/request'; -import {CommerceResponse} from './common/response'; -import {CommerceRecommendationsRequest} from './recommendations/recommendations-request'; +import {Mock} from 'vitest'; +import {SortBy} from '../../features/sort/sort.js'; +import {buildMockCommerceAPIClient} from '../../test/mock-commerce-api-client.js'; +import {VERSION} from '../../utils/version.js'; +import {PlatformClient} from '../platform-client.js'; +import { + CommerceAPIClient, + getCommerceApiBaseUrl, +} from './commerce-api-client.js'; +import {CommerceAPIRequest} from './common/request.js'; +import {CommerceResponse} from './common/response.js'; +import {CommerceRecommendationsRequest} from './recommendations/recommendations-request.js'; describe('commerce api client', () => { const organizationId = 'organization'; @@ -14,18 +18,18 @@ describe('commerce api client', () => { const trackingId = 'some-tracking-id'; let client: CommerceAPIClient; - let platformCallMock: jest.Mock; + let platformCallMock: Mock; beforeEach(() => { client = buildMockCommerceAPIClient(); }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); const mockPlatformCall = (fakeResponse: unknown) => { - platformCallMock = jest.fn(); + platformCallMock = vi.fn(); platformCallMock.mockReturnValue(fakeResponse); PlatformClient.call = platformCallMock; diff --git a/packages/headless/src/api/commerce/commerce-api-client.ts b/packages/headless/src/api/commerce/commerce-api-client.ts index b5093291bc0..106e1ed9091 100644 --- a/packages/headless/src/api/commerce/commerce-api-client.ts +++ b/packages/headless/src/api/commerce/commerce-api-client.ts @@ -1,37 +1,37 @@ import {Logger} from 'pino'; -import {CommerceThunkExtraArguments} from '../../app/commerce-thunk-extra-arguments'; -import {CommerceAppState} from '../../state/commerce-app-state'; -import {PlatformEnvironment} from '../../utils/url-utils'; +import {CommerceThunkExtraArguments} from '../../app/commerce-thunk-extra-arguments.js'; +import {CommerceAppState} from '../../state/commerce-app-state.js'; +import {PlatformEnvironment} from '../../utils/url-utils.js'; import { getOrganizationEndpoint, PlatformClient, PlatformClientCallOptions, -} from '../platform-client'; -import {PreprocessRequest} from '../preprocess-request'; -import {SpecificFacetSearchResponse} from '../search/facet-search/specific-facet-search/specific-facet-search-response'; -import {buildAPIResponseFromErrorOrThrow} from '../search/search-api-error-response'; +} from '../platform-client.js'; +import {PreprocessRequest} from '../preprocess-request.js'; +import {SpecificFacetSearchResponse} from '../search/facet-search/specific-facet-search/specific-facet-search-response.js'; +import {buildAPIResponseFromErrorOrThrow} from '../search/search-api-error-response.js'; import { CommerceAPIErrorResponse, CommerceAPIErrorStatusResponse, -} from './commerce-api-error-response'; -import {buildRequest, CommerceAPIRequest} from './common/request'; -import {CommerceSuccessResponse} from './common/response'; +} from './commerce-api-error-response.js'; +import {buildRequest, CommerceAPIRequest} from './common/request.js'; +import {CommerceSuccessResponse} from './common/response.js'; import { CommerceFacetSearchRequest, FacetSearchType, -} from './facet-search/facet-search-request'; +} from './facet-search/facet-search-request.js'; import { CommerceRecommendationsRequest, buildRecommendationsRequest, -} from './recommendations/recommendations-request'; -import {RecommendationsCommerceSuccessResponse} from './recommendations/recommendations-response'; +} from './recommendations/recommendations-request.js'; +import {RecommendationsCommerceSuccessResponse} from './recommendations/recommendations-response.js'; import { buildQuerySuggestRequest, QuerySuggestRequest, -} from './search/query-suggest/query-suggest-request'; -import {QuerySuggestSuccessResponse} from './search/query-suggest/query-suggest-response'; -import {CommerceSearchRequest} from './search/request'; -import {SearchCommerceSuccessResponse} from './search/response'; +} from './search/query-suggest/query-suggest-request.js'; +import {QuerySuggestSuccessResponse} from './search/query-suggest/query-suggest-response.js'; +import {CommerceSearchRequest} from './search/request.js'; +import {SearchCommerceSuccessResponse} from './search/response.js'; export interface CommerceFacetSearchAPIClient { facetSearch( diff --git a/packages/headless/src/api/commerce/commerce-api-params.ts b/packages/headless/src/api/commerce/commerce-api-params.ts index ecb58980b0d..d2edabe1d36 100644 --- a/packages/headless/src/api/commerce/commerce-api-params.ts +++ b/packages/headless/src/api/commerce/commerce-api-params.ts @@ -1,5 +1,5 @@ -import {AnyFacetRequest} from '../../features/commerce/facets/facet-set/interfaces/request'; -import {SortOption} from './common/sort'; +import {AnyFacetRequest} from '../../features/commerce/facets/facet-set/interfaces/request.js'; +import {SortOption} from './common/sort.js'; export interface TrackingIdParam { trackingId: string; diff --git a/packages/headless/src/api/commerce/common/product.ts b/packages/headless/src/api/commerce/common/product.ts index 950a25a386e..73f240b3863 100644 --- a/packages/headless/src/api/commerce/common/product.ts +++ b/packages/headless/src/api/commerce/common/product.ts @@ -1,4 +1,4 @@ -import {HighlightKeyword} from '../../../utils/highlight'; +import {HighlightKeyword} from '../../../utils/highlight.js'; export type ChildProduct = Omit< BaseProduct, diff --git a/packages/headless/src/api/commerce/common/request.ts b/packages/headless/src/api/commerce/common/request.ts index af34f3416ad..4a3ed8d425a 100644 --- a/packages/headless/src/api/commerce/common/request.ts +++ b/packages/headless/src/api/commerce/common/request.ts @@ -1,5 +1,5 @@ -import {PlatformClientCallOptions} from '../../platform-client'; -import {BaseParam} from '../../platform-service-params'; +import {PlatformClientCallOptions} from '../../platform-client.js'; +import {BaseParam} from '../../platform-service-params.js'; import { TrackingIdParam, LanguageParam, @@ -11,8 +11,8 @@ import { PageParam, SortParam, PerPageParam, -} from '../commerce-api-params'; -import {CommerceApiMethod} from '../commerce-metadata'; +} from '../commerce-api-params.js'; +import {CommerceApiMethod} from '../commerce-metadata.js'; export type BaseCommerceAPIRequest = BaseParam & TrackingIdParam & diff --git a/packages/headless/src/api/commerce/common/response.ts b/packages/headless/src/api/commerce/common/response.ts index 4d478d0c4af..da1d5476f17 100644 --- a/packages/headless/src/api/commerce/common/response.ts +++ b/packages/headless/src/api/commerce/common/response.ts @@ -1,12 +1,12 @@ -import {AnyFacetResponse} from '../../../features/commerce/facets/facet-set/interfaces/response'; -import {Trigger} from '../../common/trigger'; +import {AnyFacetResponse} from '../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {Trigger} from '../../common/trigger.js'; import { SearchAPIErrorWithExceptionInBody, SearchAPIErrorWithStatusCode, -} from '../../search/search-api-error-response'; -import {Pagination} from './pagination'; -import {BaseProduct} from './product'; -import {Sort} from './sort'; +} from '../../search/search-api-error-response.js'; +import {Pagination} from './pagination.js'; +import {BaseProduct} from './product.js'; +import {Sort} from './sort.js'; export interface BaseCommerceSuccessResponse { responseId: string; diff --git a/packages/headless/src/api/commerce/common/sort.ts b/packages/headless/src/api/commerce/common/sort.ts index 6895f7634a6..0983085dff9 100644 --- a/packages/headless/src/api/commerce/common/sort.ts +++ b/packages/headless/src/api/commerce/common/sort.ts @@ -1,4 +1,4 @@ -import {SortBy, SortDirection} from '../../../features/sort/sort'; +import {SortBy, SortDirection} from '../../../features/sort/sort.js'; export type SortOption = {sortCriteria: SortBy} & { fields?: { diff --git a/packages/headless/src/api/commerce/facet-search/facet-search-request.ts b/packages/headless/src/api/commerce/facet-search/facet-search-request.ts index fdeddfb5cf8..068fb948cfa 100644 --- a/packages/headless/src/api/commerce/facet-search/facet-search-request.ts +++ b/packages/headless/src/api/commerce/facet-search/facet-search-request.ts @@ -2,8 +2,8 @@ import { FacetIdParam, FacetQueryParam, IgnorePathsParam, -} from '../commerce-api-params'; -import {CommerceSearchRequest} from '../search/request'; +} from '../commerce-api-params.js'; +import {CommerceSearchRequest} from '../search/request.js'; export type CommerceFacetSearchRequest = CommerceSearchRequest & FacetIdParam & diff --git a/packages/headless/src/api/commerce/recommendations/recommendations-request.ts b/packages/headless/src/api/commerce/recommendations/recommendations-request.ts index 8053f278a1d..a104754efcd 100644 --- a/packages/headless/src/api/commerce/recommendations/recommendations-request.ts +++ b/packages/headless/src/api/commerce/recommendations/recommendations-request.ts @@ -1,6 +1,6 @@ -import {SlotIdParam} from '../commerce-api-params'; -import {CommerceApiMethod} from '../commerce-metadata'; -import {BaseCommerceAPIRequest, baseRequest} from '../common/request'; +import {SlotIdParam} from '../commerce-api-params.js'; +import {CommerceApiMethod} from '../commerce-metadata.js'; +import {BaseCommerceAPIRequest, baseRequest} from '../common/request.js'; export type CommerceRecommendationsRequest = BaseCommerceAPIRequest & SlotIdParam; diff --git a/packages/headless/src/api/commerce/recommendations/recommendations-response.ts b/packages/headless/src/api/commerce/recommendations/recommendations-response.ts index 5e7c113b1b0..9e135cca44c 100644 --- a/packages/headless/src/api/commerce/recommendations/recommendations-response.ts +++ b/packages/headless/src/api/commerce/recommendations/recommendations-response.ts @@ -1,4 +1,4 @@ -import {BaseCommerceSuccessResponse} from '../common/response'; +import {BaseCommerceSuccessResponse} from '../common/response.js'; export interface RecommendationsCommerceSuccessResponse extends Omit { diff --git a/packages/headless/src/api/commerce/search/query-suggest/query-suggest-request.ts b/packages/headless/src/api/commerce/search/query-suggest/query-suggest-request.ts index bca43003ccb..2cc75b6445c 100644 --- a/packages/headless/src/api/commerce/search/query-suggest/query-suggest-request.ts +++ b/packages/headless/src/api/commerce/search/query-suggest/query-suggest-request.ts @@ -1,4 +1,4 @@ -import {BaseParam} from '../../../platform-service-params'; +import {BaseParam} from '../../../platform-service-params.js'; import { ClientIdParam, CurrencyParam, @@ -7,8 +7,8 @@ import { TrackingIdParam, ContextParam, CountryParam, -} from '../../commerce-api-params'; -import {baseRequest} from '../../common/request'; +} from '../../commerce-api-params.js'; +import {baseRequest} from '../../common/request.js'; export type QuerySuggestRequest = BaseParam & TrackingIdParam & diff --git a/packages/headless/src/api/commerce/search/query-suggest/query-suggest-response.ts b/packages/headless/src/api/commerce/search/query-suggest/query-suggest-response.ts index 3dc63990136..095df84f0ec 100644 --- a/packages/headless/src/api/commerce/search/query-suggest/query-suggest-response.ts +++ b/packages/headless/src/api/commerce/search/query-suggest/query-suggest-response.ts @@ -1,7 +1,7 @@ import { SearchAPIErrorWithExceptionInBody, SearchAPIErrorWithStatusCode, -} from '../../../search/search-api-error-response'; +} from '../../../search/search-api-error-response.js'; /** * A Coveo ML query suggestion. diff --git a/packages/headless/src/api/commerce/search/request.ts b/packages/headless/src/api/commerce/search/request.ts index 83fc01797fa..7bd51cc29f9 100644 --- a/packages/headless/src/api/commerce/search/request.ts +++ b/packages/headless/src/api/commerce/search/request.ts @@ -1,4 +1,4 @@ -import {QueryParam} from '../commerce-api-params'; -import {CommerceAPIRequest} from '../common/request'; +import {QueryParam} from '../commerce-api-params.js'; +import {CommerceAPIRequest} from '../common/request.js'; export type CommerceSearchRequest = CommerceAPIRequest & QueryParam; diff --git a/packages/headless/src/api/commerce/search/response.ts b/packages/headless/src/api/commerce/search/response.ts index 0213e29ea39..336dfb779c3 100644 --- a/packages/headless/src/api/commerce/search/response.ts +++ b/packages/headless/src/api/commerce/search/response.ts @@ -1,5 +1,5 @@ -import {Correction} from '../../search/search/query-corrections'; -import {CommerceSuccessResponse} from '../common/response'; +import {Correction} from '../../search/search/query-corrections.js'; +import {CommerceSuccessResponse} from '../common/response.js'; export interface SearchCommerceSuccessResponse extends CommerceSuccessResponse { queryCorrection?: Correction; diff --git a/packages/headless/src/api/form-url-encoder.test.ts b/packages/headless/src/api/form-url-encoder.test.ts index bf161dcb494..6b4e6f441af 100644 --- a/packages/headless/src/api/form-url-encoder.test.ts +++ b/packages/headless/src/api/form-url-encoder.test.ts @@ -1,4 +1,4 @@ -import {encodeAsFormUrl, canBeFormUrlEncoded} from './form-url-encoder'; +import {encodeAsFormUrl, canBeFormUrlEncoded} from './form-url-encoder.js'; describe('#encodeAsFormUrl', () => { it('a record with string key and value, it encodes it correctly', () => { diff --git a/packages/headless/src/api/generated-answer/generated-answer-client.ts b/packages/headless/src/api/generated-answer/generated-answer-client.ts index 4a3ca6241ac..542bb4a93d8 100644 --- a/packages/headless/src/api/generated-answer/generated-answer-client.ts +++ b/packages/headless/src/api/generated-answer/generated-answer-client.ts @@ -1,13 +1,13 @@ import {fetchEventSource} from '@microsoft/fetch-event-source'; import {Logger} from 'pino'; -import {AsyncThunkOptions} from '../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {GeneratedAnswerErrorPayload} from '../../features/generated-answer/generated-answer-actions'; -import {SearchAppState} from '../../state/search-app-state'; -import {URLPath} from '../../utils/url-utils'; -import {resetTimeout} from '../../utils/utils'; -import {GeneratedAnswerStreamEventData} from './generated-answer-event-payload'; -import {GeneratedAnswerStreamRequest} from './generated-answer-request'; +import {AsyncThunkOptions} from '../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {GeneratedAnswerErrorPayload} from '../../features/generated-answer/generated-answer-actions.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {URLPath} from '../../utils/url-utils.js'; +import {resetTimeout} from '../../utils/utils.js'; +import {GeneratedAnswerStreamEventData} from './generated-answer-event-payload.js'; +import {GeneratedAnswerStreamRequest} from './generated-answer-request.js'; export interface GeneratedAnswerAPIClientOptions { logger: Logger; diff --git a/packages/headless/src/api/generated-answer/generated-answer-event-payload.ts b/packages/headless/src/api/generated-answer/generated-answer-event-payload.ts index de9fe6096fd..65edf4c0d85 100644 --- a/packages/headless/src/api/generated-answer/generated-answer-event-payload.ts +++ b/packages/headless/src/api/generated-answer/generated-answer-event-payload.ts @@ -1,5 +1,5 @@ -import {GeneratedContentFormat} from '../../features/generated-answer/generated-response-format'; -import {Raw} from '../search/search/raw'; +import {GeneratedContentFormat} from '../../features/generated-answer/generated-response-format.js'; +import {Raw} from '../search/search/raw.js'; export type GeneratedAnswerStreamFinishReason = 'COMPLETED' | 'ERROR'; diff --git a/packages/headless/src/api/generated-answer/generated-answer-request.ts b/packages/headless/src/api/generated-answer/generated-answer-request.ts index c7746463de1..aa4f3cca036 100644 --- a/packages/headless/src/api/generated-answer/generated-answer-request.ts +++ b/packages/headless/src/api/generated-answer/generated-answer-request.ts @@ -1,4 +1,4 @@ -import {BaseParam} from '../platform-service-params'; +import {BaseParam} from '../platform-service-params.js'; interface GeneratedAnswerParam { streamId?: string; diff --git a/packages/headless/src/api/knowledge/answer-slice.ts b/packages/headless/src/api/knowledge/answer-slice.ts index f34ee4f8f7a..4f93b6a66dc 100644 --- a/packages/headless/src/api/knowledge/answer-slice.ts +++ b/packages/headless/src/api/knowledge/answer-slice.ts @@ -9,8 +9,8 @@ import { import { ConfigurationSection, GeneratedAnswerSection, -} from '../../state/state-sections'; -import {getOrganizationEndpoint} from '../platform-client'; +} from '../../state/state-sections.js'; +import {getOrganizationEndpoint} from '../platform-client.js'; type StateNeededByAnswerSlice = ConfigurationSection & GeneratedAnswerSection; diff --git a/packages/headless/src/api/knowledge/post-answer-evaluation.ts b/packages/headless/src/api/knowledge/post-answer-evaluation.ts index 1b32e13e446..12472c2fa3e 100644 --- a/packages/headless/src/api/knowledge/post-answer-evaluation.ts +++ b/packages/headless/src/api/knowledge/post-answer-evaluation.ts @@ -1,4 +1,4 @@ -import {answerSlice} from './answer-slice'; +import {answerSlice} from './answer-slice.js'; export interface AnswerEvaluationPOSTParams { question: string; diff --git a/packages/headless/src/api/knowledge/stream-answer-api.ts b/packages/headless/src/api/knowledge/stream-answer-api.ts index 8f82c13469b..a13184555db 100644 --- a/packages/headless/src/api/knowledge/stream-answer-api.ts +++ b/packages/headless/src/api/knowledge/stream-answer-api.ts @@ -3,26 +3,26 @@ import { fetchEventSource, } from '@microsoft/fetch-event-source'; import {createSelector} from '@reduxjs/toolkit'; -import {selectFieldsToIncludeInCitation} from '../../features/generated-answer/generated-answer-selectors'; -import {GeneratedContentFormat} from '../../features/generated-answer/generated-response-format'; -import {maximumNumberOfResultsFromIndex} from '../../features/pagination/pagination-constants'; -import {selectPipeline} from '../../features/pipeline/select-pipeline'; -import {selectQuery} from '../../features/query/query-selectors'; -import {selectSearchHub} from '../../features/search-hub/search-hub-selectors'; +import {selectFieldsToIncludeInCitation} from '../../features/generated-answer/generated-answer-selectors.js'; +import {GeneratedContentFormat} from '../../features/generated-answer/generated-response-format.js'; +import {maximumNumberOfResultsFromIndex} from '../../features/pagination/pagination-constants.js'; +import {selectPipeline} from '../../features/pipeline/select-pipeline.js'; +import {selectQuery} from '../../features/query/query-selectors.js'; +import {selectSearchHub} from '../../features/search-hub/search-hub-selectors.js'; import { initialSearchMappings, mapFacetRequest, -} from '../../features/search/search-mappings'; -import {SearchAppState} from '../../state/search-app-state'; +} from '../../features/search/search-mappings.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { ConfigurationSection, GeneratedAnswerSection, -} from '../../state/state-sections'; -import {getFacets} from '../../utils/facet-utils'; -import {GeneratedAnswerCitation} from '../generated-answer/generated-answer-event-payload'; -import {getOrganizationEndpoint} from '../platform-client'; -import {SearchRequest} from '../search/search/search-request'; -import {answerSlice} from './answer-slice'; +} from '../../state/state-sections.js'; +import {getFacets} from '../../utils/facet-utils.js'; +import {GeneratedAnswerCitation} from '../generated-answer/generated-answer-event-payload.js'; +import {getOrganizationEndpoint} from '../platform-client.js'; +import {SearchRequest} from '../search/search/search-request.js'; +import {answerSlice} from './answer-slice.js'; export type StateNeededByAnswerAPI = { searchHub: string; diff --git a/packages/headless/src/api/knowledge/tests/stream-answer-api-state-mock.ts b/packages/headless/src/api/knowledge/tests/stream-answer-api-state-mock.ts index 53106ff7296..a32adee8a2f 100644 --- a/packages/headless/src/api/knowledge/tests/stream-answer-api-state-mock.ts +++ b/packages/headless/src/api/knowledge/tests/stream-answer-api-state-mock.ts @@ -1,5 +1,5 @@ /* eslint-disable @cspell/spellchecker */ -import {StateNeededByAnswerAPI} from '../stream-answer-api'; +import {StateNeededByAnswerAPI} from '../stream-answer-api.js'; export const streamAnswerAPIStateMock: StateNeededByAnswerAPI = { configuration: { @@ -1031,6 +1031,7 @@ export const streamAnswerAPIStateMock: StateNeededByAnswerAPI = { generatedAnswer: { id: '', isVisible: true, + isEnabled: true, isLoading: false, isStreaming: false, citations: [], diff --git a/packages/headless/src/api/knowledge/tests/stream-answer-api.test.ts b/packages/headless/src/api/knowledge/tests/stream-answer-api.test.ts index 051df860fac..4cb62168d45 100644 --- a/packages/headless/src/api/knowledge/tests/stream-answer-api.test.ts +++ b/packages/headless/src/api/knowledge/tests/stream-answer-api.test.ts @@ -1,17 +1,17 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import {constructAnswerQueryParams} from '../stream-answer-api'; +import {constructAnswerQueryParams} from '../stream-answer-api.js'; import { expectedStreamAnswerAPIParam, streamAnswerAPIStateMock, -} from './stream-answer-api-state-mock'; +} from './stream-answer-api-state-mock.js'; describe('#streamAnswerApi', () => { describe('constructAnswerQueryParams', () => { beforeEach(() => { - jest.useFakeTimers().setSystemTime(new Date('2020-01-01')); + vi.useFakeTimers().setSystemTime(new Date('2020-01-01')); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('returns the correct query params with fetch usage', () => { const queryParams = constructAnswerQueryParams( @@ -25,7 +25,7 @@ describe('#streamAnswerApi', () => { it('will create the right selector with select usage', () => { constructAnswerQueryParams(streamAnswerAPIStateMock as any, 'select'); - jest.useFakeTimers().setSystemTime(new Date('2024-01-01')); + vi.useFakeTimers().setSystemTime(new Date('2024-01-01')); const queryParams = constructAnswerQueryParams( streamAnswerAPIStateMock as any, 'select' diff --git a/packages/headless/src/api/platform-client.test.ts b/packages/headless/src/api/platform-client.test.ts index ecda99813c0..64d9cfa5970 100644 --- a/packages/headless/src/api/platform-client.test.ts +++ b/packages/headless/src/api/platform-client.test.ts @@ -1,23 +1,24 @@ import * as BackOff from 'exponential-backoff'; -import pino from 'pino'; -import {ExpiredTokenError} from '../utils/errors'; -import {PlatformEnvironment} from '../utils/url-utils'; +import {pino} from 'pino'; +import {Mock} from 'vitest'; +import {ExpiredTokenError} from '../utils/errors.js'; +import {PlatformEnvironment} from '../utils/url-utils.js'; import { getAnalyticsNextApiBaseUrl, getOrganizationEndpoint, getSearchApiBaseUrl, PlatformClient, PlatformClientCallOptions, -} from './platform-client'; +} from './platform-client.js'; import { NoopPreprocessRequest, PlatformRequestOptions, PreprocessRequest, -} from './preprocess-request'; +} from './preprocess-request.js'; -const {Response} = jest.requireActual('node-fetch'); -global.fetch = jest.fn(); -const mockFetch = global.fetch as jest.Mock; +const {Response} = await vi.importActual('node-fetch'); +global.fetch = vi.fn(); +const mockFetch = global.fetch as Mock; it.each([ { @@ -325,7 +326,7 @@ describe('PlatformClient call', () => { }); it('should not throw when backOff rejects with a response', async () => { - const spy = jest.spyOn(BackOff, 'backOff'); + const spy = vi.spyOn(BackOff, 'backOff'); const expectedResponse = new Response( JSON.stringify({someProps: 'someValue'}), { diff --git a/packages/headless/src/api/platform-client.ts b/packages/headless/src/api/platform-client.ts index 99bab736231..8a475e4d93e 100644 --- a/packages/headless/src/api/platform-client.ts +++ b/packages/headless/src/api/platform-client.ts @@ -1,15 +1,15 @@ import {backOff} from 'exponential-backoff'; import {Logger} from 'pino'; -import {DisconnectedError, ExpiredTokenError} from '../utils/errors'; -import {PlatformEnvironment} from '../utils/url-utils'; -import {clone} from '../utils/utils'; -import {canBeFormUrlEncoded, encodeAsFormUrl} from './form-url-encoder'; +import {DisconnectedError, ExpiredTokenError} from '../utils/errors.js'; +import {PlatformEnvironment} from '../utils/url-utils.js'; +import {clone} from '../utils/utils.js'; +import {canBeFormUrlEncoded, encodeAsFormUrl} from './form-url-encoder.js'; import { PlatformClientOrigin, PlatformRequestOptions, PreprocessRequest, RequestMetadata, -} from './preprocess-request'; +} from './preprocess-request.js'; export type HttpMethods = 'POST' | 'GET' | 'DELETE' | 'PUT'; export type HTTPContentType = diff --git a/packages/headless/src/api/preprocess-request.ts b/packages/headless/src/api/preprocess-request.ts index 1088269576c..0ea46ea4c52 100644 --- a/packages/headless/src/api/preprocess-request.ts +++ b/packages/headless/src/api/preprocess-request.ts @@ -1,6 +1,6 @@ -import {AnalyticsClientOrigin} from 'coveo.analytics/dist/definitions/client/analyticsRequestClient'; -import {CommerceApiMethod} from './commerce/commerce-metadata'; -import {SearchApiMethod, SearchOrigin} from './search/search-metadata'; +import {AnalyticsClientOrigin} from 'coveo.analytics/dist/definitions/client/analyticsRequestClient.js'; +import {CommerceApiMethod} from './commerce/commerce-metadata.js'; +import {SearchApiMethod, SearchOrigin} from './search/search-metadata.js'; export interface PlatformRequestOptions extends RequestInit { url: string; diff --git a/packages/headless/src/api/search/date/date-format.test.ts b/packages/headless/src/api/search/date/date-format.test.ts index eef3ab42245..fcdba71f362 100644 --- a/packages/headless/src/api/search/date/date-format.test.ts +++ b/packages/headless/src/api/search/date/date-format.test.ts @@ -3,7 +3,7 @@ import { formatDateForSearchApi, validateAbsoluteDate, parseDate, -} from './date-format'; +} from './date-format.js'; describe('#parseDate', () => { it('can parse the search API format', () => { @@ -16,7 +16,7 @@ describe('#parseDate', () => { expect(parseDate('2022-08-23T17:42:55').toDate().toUTCString()).toEqual( new Date('2022-08-23T17:42:55+08:45').toUTCString() ); - jest.resetAllMocks(); + vi.resetAllMocks(); }); }); diff --git a/packages/headless/src/api/search/date/date-format.ts b/packages/headless/src/api/search/date/date-format.ts index 93a17ebb846..ed64db57931 100644 --- a/packages/headless/src/api/search/date/date-format.ts +++ b/packages/headless/src/api/search/date/date-format.ts @@ -1,5 +1,5 @@ import dayjs, {ConfigType} from 'dayjs'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; +import customParseFormat from 'dayjs/plugin/customParseFormat.js'; dayjs.extend(customParseFormat); diff --git a/packages/headless/src/api/search/date/relative-date.test.ts b/packages/headless/src/api/search/date/relative-date.test.ts index bf4f11b1741..9dc03003a1c 100644 --- a/packages/headless/src/api/search/date/relative-date.test.ts +++ b/packages/headless/src/api/search/date/relative-date.test.ts @@ -1,4 +1,4 @@ -import {isSearchApiDate} from './date-format'; +import {isSearchApiDate} from './date-format.js'; import { deserializeRelativeDate, RelativeDate, @@ -7,7 +7,7 @@ import { isRelativeDateFormat, formatRelativeDateForSearchApi, validateRelativeDate, -} from './relative-date'; +} from './relative-date.js'; describe('#deserializeRelativeDate', () => { it('parses "now"', () => { diff --git a/packages/headless/src/api/search/date/relative-date.ts b/packages/headless/src/api/search/date/relative-date.ts index bdec296cf51..1b00a6a7c9a 100644 --- a/packages/headless/src/api/search/date/relative-date.ts +++ b/packages/headless/src/api/search/date/relative-date.ts @@ -1,7 +1,10 @@ import {NumberValue, Schema, StringValue} from '@coveo/bueno'; import dayjs, {QUnitType} from 'dayjs'; -import quarterOfYear from 'dayjs/plugin/quarterOfYear'; -import {assertDateAboveAPIMinimum, formatDateForSearchApi} from './date-format'; +import quarterOfYear from 'dayjs/plugin/quarterOfYear.js'; +import { + assertDateAboveAPIMinimum, + formatDateForSearchApi, +} from './date-format.js'; dayjs.extend(quarterOfYear); diff --git a/packages/headless/src/api/search/encoding-finder.test.ts b/packages/headless/src/api/search/encoding-finder.test.ts index fedffc4aa1d..251b8236d6d 100644 --- a/packages/headless/src/api/search/encoding-finder.test.ts +++ b/packages/headless/src/api/search/encoding-finder.test.ts @@ -1,4 +1,4 @@ -import {findEncoding} from './encoding-finder'; +import {findEncoding} from './encoding-finder.js'; describe('#findEncoding', () => { it('when the response has no content-type header, it returns UTF-8', () => { diff --git a/packages/headless/src/api/search/facet-search/base/base-facet-search-request.ts b/packages/headless/src/api/search/facet-search/base/base-facet-search-request.ts index 97d95d56448..6d5d9674b94 100644 --- a/packages/headless/src/api/search/facet-search/base/base-facet-search-request.ts +++ b/packages/headless/src/api/search/facet-search/base/base-facet-search-request.ts @@ -1,6 +1,6 @@ -import {BaseParam, VisitorIDParam} from '../../../platform-service-params'; -import {AuthenticationParam} from '../../search-api-params'; -import {SearchRequest} from '../../search/search-request'; +import {BaseParam, VisitorIDParam} from '../../../platform-service-params.js'; +import {AuthenticationParam} from '../../search-api-params.js'; +import {SearchRequest} from '../../search/search-request.js'; export interface FacetSearchRequestOptions { /** A dictionary that maps index field values to facet value display names. */ diff --git a/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-request.ts b/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-request.ts index 97fe6e555b2..8bef54c7532 100644 --- a/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-request.ts +++ b/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-request.ts @@ -1,7 +1,7 @@ import { BaseFacetSearchRequest, FacetSearchType, -} from '../base/base-facet-search-request'; +} from '../base/base-facet-search-request.js'; export interface CategoryFacetSearchRequest extends BaseFacetSearchRequest, diff --git a/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-response.ts b/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-response.ts index 720192f9e61..377df4d16be 100644 --- a/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-response.ts +++ b/packages/headless/src/api/search/facet-search/category-facet-search/category-facet-search-response.ts @@ -1,7 +1,7 @@ import { BaseFacetSearchResult, BaseFacetSearchResponse, -} from '../base/base-facet-search-response'; +} from '../base/base-facet-search-response.js'; export interface CategoryFacetSearchResult extends BaseFacetSearchResult { /** diff --git a/packages/headless/src/api/search/facet-search/facet-search-request.ts b/packages/headless/src/api/search/facet-search/facet-search-request.ts index 6cb7ab5e06e..8fea9e078de 100644 --- a/packages/headless/src/api/search/facet-search/facet-search-request.ts +++ b/packages/headless/src/api/search/facet-search/facet-search-request.ts @@ -1,7 +1,7 @@ -import {BaseParam} from '../../platform-service-params'; -import {AuthenticationParam} from '../search-api-params'; -import {CategoryFacetSearchRequest} from './category-facet-search/category-facet-search-request'; -import {SpecificFacetSearchRequest} from './specific-facet-search/specific-facet-search-request'; +import {BaseParam} from '../../platform-service-params.js'; +import {AuthenticationParam} from '../search-api-params.js'; +import {CategoryFacetSearchRequest} from './category-facet-search/category-facet-search-request.js'; +import {SpecificFacetSearchRequest} from './specific-facet-search/specific-facet-search-request.js'; export type FacetSearchRequest = BaseParam & AuthenticationParam & diff --git a/packages/headless/src/api/search/facet-search/facet-search-response.ts b/packages/headless/src/api/search/facet-search/facet-search-response.ts index d935497a6b8..5c254d360e9 100644 --- a/packages/headless/src/api/search/facet-search/facet-search-response.ts +++ b/packages/headless/src/api/search/facet-search/facet-search-response.ts @@ -1,5 +1,5 @@ -import {CategoryFacetSearchResponse} from './category-facet-search/category-facet-search-response'; -import {SpecificFacetSearchResponse} from './specific-facet-search/specific-facet-search-response'; +import {CategoryFacetSearchResponse} from './category-facet-search/category-facet-search-response.js'; +import {SpecificFacetSearchResponse} from './specific-facet-search/specific-facet-search-response.js'; export type FacetSearchResponse = | SpecificFacetSearchResponse diff --git a/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-request.ts b/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-request.ts index eb80bcc46fa..d457d5a6bc5 100644 --- a/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-request.ts +++ b/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-request.ts @@ -1,7 +1,7 @@ import { BaseFacetSearchRequest, FacetSearchType, -} from '../base/base-facet-search-request'; +} from '../base/base-facet-search-request.js'; export interface SpecificFacetSearchRequest extends BaseFacetSearchRequest, diff --git a/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-response.ts b/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-response.ts index 50ad4527b4e..fd18e000317 100644 --- a/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-response.ts +++ b/packages/headless/src/api/search/facet-search/specific-facet-search/specific-facet-search-response.ts @@ -1,7 +1,7 @@ import { BaseFacetSearchResult, BaseFacetSearchResponse, -} from '../base/base-facet-search-response'; +} from '../base/base-facet-search-response.js'; export type SpecificFacetSearchResult = BaseFacetSearchResult; export type SpecificFacetSearchResponse = diff --git a/packages/headless/src/api/search/fields/fields-response.ts b/packages/headless/src/api/search/fields/fields-response.ts index 96430317b6c..779aab6d330 100644 --- a/packages/headless/src/api/search/fields/fields-response.ts +++ b/packages/headless/src/api/search/fields/fields-response.ts @@ -1,7 +1,7 @@ import { SearchAPIErrorWithExceptionInBody, SearchAPIErrorWithStatusCode, -} from '../search-api-error-response'; +} from '../search-api-error-response.js'; /** * Field description diff --git a/packages/headless/src/api/search/html/html-api-client.ts b/packages/headless/src/api/search/html/html-api-client.ts index 8645eeec101..bbc7b405e13 100644 --- a/packages/headless/src/api/search/html/html-api-client.ts +++ b/packages/headless/src/api/search/html/html-api-client.ts @@ -1,12 +1,12 @@ import {Logger} from 'pino'; -import {URLPath} from '../../../utils/url-utils'; -import {pickNonBaseParams, unwrapError} from '../../api-client-utils'; -import {PlatformClient} from '../../platform-client'; -import {PreprocessRequest, RequestMetadata} from '../../preprocess-request'; -import {findEncoding} from '../encoding-finder'; -import {SearchAPIErrorWithStatusCode} from '../search-api-error-response'; -import {baseSearchRequest} from '../search-api-params'; -import {HtmlRequest} from './html-request'; +import {URLPath} from '../../../utils/url-utils.js'; +import {pickNonBaseParams, unwrapError} from '../../api-client-utils.js'; +import {PlatformClient} from '../../platform-client.js'; +import {PreprocessRequest, RequestMetadata} from '../../preprocess-request.js'; +import {findEncoding} from '../encoding-finder.js'; +import {SearchAPIErrorWithStatusCode} from '../search-api-error-response.js'; +import {baseSearchRequest} from '../search-api-params.js'; +import {HtmlRequest} from './html-request.js'; export interface HtmlApiClient { html: (req: HtmlRequest) => Promise< diff --git a/packages/headless/src/api/search/html/html-request.ts b/packages/headless/src/api/search/html/html-request.ts index 88a75429807..19b91020907 100644 --- a/packages/headless/src/api/search/html/html-request.ts +++ b/packages/headless/src/api/search/html/html-request.ts @@ -1,5 +1,5 @@ -import {BaseParam, VisitorIDParam} from '../../platform-service-params'; -import {AuthenticationParam} from '../search-api-params'; +import {BaseParam, VisitorIDParam} from '../../platform-service-params.js'; +import {AuthenticationParam} from '../search-api-params.js'; export interface HtmlRequestOptions { uniqueId: string; diff --git a/packages/headless/src/api/search/plan/plan-endpoint.test.ts b/packages/headless/src/api/search/plan/plan-endpoint.test.ts index 78e0df69abb..40f7fbedaa5 100644 --- a/packages/headless/src/api/search/plan/plan-endpoint.test.ts +++ b/packages/headless/src/api/search/plan/plan-endpoint.test.ts @@ -1,6 +1,6 @@ -import {TriggerRedirect} from '../../common/trigger'; -import {ExecutionPlan} from './plan-endpoint'; -import {PlanResponseSuccess} from './plan-response'; +import {TriggerRedirect} from '../../common/trigger.js'; +import {ExecutionPlan} from './plan-endpoint.js'; +import {PlanResponseSuccess} from './plan-response.js'; describe('execution plan', () => { const planResponse: PlanResponseSuccess = { diff --git a/packages/headless/src/api/search/plan/plan-endpoint.ts b/packages/headless/src/api/search/plan/plan-endpoint.ts index a1f48910ac1..5ff0d407193 100644 --- a/packages/headless/src/api/search/plan/plan-endpoint.ts +++ b/packages/headless/src/api/search/plan/plan-endpoint.ts @@ -1,5 +1,5 @@ -import {isRedirectTrigger} from '../../common/trigger'; -import {PlanResponseSuccess} from './plan-response'; +import {isRedirectTrigger} from '../../common/trigger.js'; +import {PlanResponseSuccess} from './plan-response.js'; /** * The plan of execution of a search request. diff --git a/packages/headless/src/api/search/plan/plan-request.ts b/packages/headless/src/api/search/plan/plan-request.ts index 7e6a8321dc4..c3f94208456 100644 --- a/packages/headless/src/api/search/plan/plan-request.ts +++ b/packages/headless/src/api/search/plan/plan-request.ts @@ -3,7 +3,7 @@ import { ContextParam, LocaleParam, VisitorIDParam, -} from '../../platform-service-params'; +} from '../../platform-service-params.js'; import { AnalyticsParam, AuthenticationParam, @@ -11,7 +11,7 @@ import { QueryParam, SearchHubParam, TimezoneParam, -} from '../search-api-params'; +} from '../search-api-params.js'; export type PlanRequest = BaseParam & SearchHubParam & diff --git a/packages/headless/src/api/search/plan/plan-response.ts b/packages/headless/src/api/search/plan/plan-response.ts index 492878f2143..1f6857875aa 100644 --- a/packages/headless/src/api/search/plan/plan-response.ts +++ b/packages/headless/src/api/search/plan/plan-response.ts @@ -1,8 +1,8 @@ -import {Trigger} from '../../common/trigger'; +import {Trigger} from '../../common/trigger.js'; import { SearchAPIErrorWithExceptionInBody, SearchAPIErrorWithStatusCode, -} from '../search-api-error-response'; +} from '../search-api-error-response.js'; /** * Describes the plan of execution of a search request. diff --git a/packages/headless/src/api/search/query-suggest/query-suggest-request.ts b/packages/headless/src/api/search/query-suggest/query-suggest-request.ts index f74e7ac59fa..7a53eb3fbf0 100644 --- a/packages/headless/src/api/search/query-suggest/query-suggest-request.ts +++ b/packages/headless/src/api/search/query-suggest/query-suggest-request.ts @@ -3,7 +3,7 @@ import { ContextParam, LocaleParam, VisitorIDParam, -} from '../../platform-service-params'; +} from '../../platform-service-params.js'; import { ActionsHistoryParam, AnalyticsParam, @@ -13,7 +13,7 @@ import { SearchHubParam, TabParam, TimezoneParam, -} from '../search-api-params'; +} from '../search-api-params.js'; export type QuerySuggestRequest = BaseParam & QueryParam & diff --git a/packages/headless/src/api/search/query-suggest/query-suggest-response.ts b/packages/headless/src/api/search/query-suggest/query-suggest-response.ts index cfcf2411c32..cd0ddb178ef 100644 --- a/packages/headless/src/api/search/query-suggest/query-suggest-response.ts +++ b/packages/headless/src/api/search/query-suggest/query-suggest-response.ts @@ -1,7 +1,7 @@ import { SearchAPIErrorWithExceptionInBody, SearchAPIErrorWithStatusCode, -} from '../search-api-error-response'; +} from '../search-api-error-response.js'; /** * A Coveo ML query suggestion. diff --git a/packages/headless/src/api/search/recommendation/recommendation-request.ts b/packages/headless/src/api/search/recommendation/recommendation-request.ts index 67e4a55f8a9..74be238a1c1 100644 --- a/packages/headless/src/api/search/recommendation/recommendation-request.ts +++ b/packages/headless/src/api/search/recommendation/recommendation-request.ts @@ -5,7 +5,7 @@ import { LocaleParam, NumberOfResultsParam, VisitorIDParam, -} from '../../platform-service-params'; +} from '../../platform-service-params.js'; import { ActionsHistoryParam, AdvancedQueryParam, @@ -19,7 +19,7 @@ import { SearchHubParam, TabParam, TimezoneParam, -} from '../search-api-params'; +} from '../search-api-params.js'; export type RecommendationRequest = BaseParam & RecommendationParam & diff --git a/packages/headless/src/api/search/search-api-client-middleware.ts b/packages/headless/src/api/search/search-api-client-middleware.ts index 94d9059f06b..c8b1ea47712 100644 --- a/packages/headless/src/api/search/search-api-client-middleware.ts +++ b/packages/headless/src/api/search/search-api-client-middleware.ts @@ -1,7 +1,7 @@ -import {PlatformResponse} from '../platform-client'; -import {FacetSearchResponse} from './facet-search/facet-search-response'; -import {QuerySuggestSuccessResponse} from './query-suggest/query-suggest-response'; -import {SearchResponseSuccess} from './search/search-response'; +import {PlatformResponse} from '../platform-client.js'; +import {FacetSearchResponse} from './facet-search/facet-search-response.js'; +import {QuerySuggestSuccessResponse} from './query-suggest/query-suggest-response.js'; +import {SearchResponseSuccess} from './search/search-response.js'; export type PostprocessSearchResponseMiddleware = ( response: PlatformResponse diff --git a/packages/headless/src/api/search/search-api-client.test.ts b/packages/headless/src/api/search/search-api-client.test.ts index 2c1f4d5a97f..6aaf39bcc35 100644 --- a/packages/headless/src/api/search/search-api-client.test.ts +++ b/packages/headless/src/api/search/search-api-client.test.ts @@ -1,51 +1,52 @@ -import pino from 'pino'; -import {buildCategoryFacetSearchRequest} from '../../features/facets/facet-search-set/category/category-facet-search-request-builder'; -import {buildSpecificFacetSearchRequest} from '../../features/facets/facet-search-set/specific/specific-facet-search-request-builder'; -import {buildQuerySuggestRequest} from '../../features/query-suggest/query-suggest-actions'; -import {buildRecommendationRequest} from '../../features/recommendation/recommendation-actions'; -import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder'; -import {buildSearchRequest} from '../../features/search/search-request'; -import {emptyQuestionAnswer} from '../../features/search/search-state'; -import {buildPlanRequest} from '../../features/standalone-search-box-set/standalone-search-box-set-actions'; -import {SearchAppState} from '../../state/search-app-state'; -import {buildMockAnalyticsState} from '../../test/mock-analytics-state'; -import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSearch} from '../../test/mock-category-facet-search'; -import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice'; -import {buildMockFacetSearch} from '../../test/mock-facet-search'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider'; -import {buildMockQuerySuggest} from '../../test/mock-query-suggest'; -import {buildMockQuerySuggestCompletion} from '../../test/mock-query-suggest-completion'; -import {createMockRecommendationState} from '../../test/mock-recommendation-state'; -import {buildMockSearchAPIClient} from '../../test/mock-search-api-client'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {createMockState} from '../../test/mock-state'; +import {pino} from 'pino'; +import {Mock} from 'vitest'; +import {buildCategoryFacetSearchRequest} from '../../features/facets/facet-search-set/category/category-facet-search-request-builder.js'; +import {buildSpecificFacetSearchRequest} from '../../features/facets/facet-search-set/specific/specific-facet-search-request-builder.js'; +import {buildQuerySuggestRequest} from '../../features/query-suggest/query-suggest-actions.js'; +import {buildRecommendationRequest} from '../../features/recommendation/recommendation-actions.js'; +import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder.js'; +import {buildSearchRequest} from '../../features/search/search-request.js'; +import {emptyQuestionAnswer} from '../../features/search/search-state.js'; +import {buildPlanRequest} from '../../features/standalone-search-box-set/standalone-search-box-set-actions.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {buildMockAnalyticsState} from '../../test/mock-analytics-state.js'; +import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSearch} from '../../test/mock-category-facet-search.js'; +import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice.js'; +import {buildMockFacetSearch} from '../../test/mock-facet-search.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider.js'; +import {buildMockQuerySuggestCompletion} from '../../test/mock-query-suggest-completion.js'; +import {buildMockQuerySuggest} from '../../test/mock-query-suggest.js'; +import {createMockRecommendationState} from '../../test/mock-recommendation-state.js'; +import {buildMockSearchAPIClient} from '../../test/mock-search-api-client.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {createMockState} from '../../test/mock-state.js'; import { getSearchApiBaseUrl, PlatformClient, PlatformClientCallOptions, -} from '../platform-client'; -import {NoopPreprocessRequest} from '../preprocess-request'; -import {FacetSearchRequest} from './facet-search/facet-search-request'; -import {HtmlRequest} from './html/html-request'; -import {PlanRequest} from './plan/plan-request'; -import {QuerySuggestRequest} from './query-suggest/query-suggest-request'; -import {RecommendationRequest} from './recommendation/recommendation-request'; +} from '../platform-client.js'; +import {NoopPreprocessRequest} from '../preprocess-request.js'; +import {FacetSearchRequest} from './facet-search/facet-search-request.js'; +import {HtmlRequest} from './html/html-request.js'; +import {PlanRequest} from './plan/plan-request.js'; +import {QuerySuggestRequest} from './query-suggest/query-suggest-request.js'; +import {RecommendationRequest} from './recommendation/recommendation-request.js'; import { isErrorResponse, SearchAPIClient, SearchAPIClientOptions, -} from './search-api-client'; +} from './search-api-client.js'; import { getAuthenticationQueryParam, getOrganizationIdQueryParam, -} from './search-api-params'; -import {QuestionsAnswers} from './search/question-answering'; -import {SearchRequest} from './search/search-request'; -import {SearchResponseSuccess} from './search/search-response'; +} from './search-api-params.js'; +import {QuestionsAnswers} from './search/question-answering.js'; +import {SearchRequest} from './search/search-request.js'; +import {SearchResponseSuccess} from './search/search-response.js'; -jest.mock('../platform-client'); +vi.mock('../platform-client'); describe('search api client', () => { const logger = pino({level: 'silent'}); @@ -62,7 +63,7 @@ describe('search api client', () => { } function mockPlatformResponse(buildResponse: () => Response, times = 1) { - const mock = jest.fn(); + const mock = vi.fn(); let count = times; while (count > 0) { @@ -79,7 +80,7 @@ describe('search api client', () => { } function getPlatformClientCalls() { - return (PlatformClient.call as jest.Mock).mock.calls.map( + return (PlatformClient.call as Mock).mock.calls.map( (call) => call[0] as PlatformClientCallOptions ); } @@ -89,7 +90,7 @@ describe('search api client', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('middleware', () => { @@ -216,7 +217,7 @@ describe('search api client', () => { const req = (await buildSearchRequest(state, navigatorContextProvier())) .request; searchAPIClient.search(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedRequest: PlatformClientCallOptions< Omit @@ -269,7 +270,7 @@ describe('search api client', () => { await buildSearchRequest(state, buildMockNavigatorContextProvider()()) ).request; searchAPIClient.search(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedUrl = `${ state.configuration.search.apiBaseUrl ?? getSearchApiBaseUrl( @@ -321,7 +322,7 @@ describe('search api client', () => { buildMockNavigatorContextProvider()() ); searchAPIClient.plan(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedRequest: PlatformClientCallOptions< Omit @@ -362,7 +363,7 @@ describe('search api client', () => { buildMockNavigatorContextProvider()() ); searchAPIClient.plan(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedUrl = `${ state.configuration.search.apiBaseUrl ?? getSearchApiBaseUrl( @@ -388,7 +389,7 @@ describe('search api client', () => { buildMockNavigatorContextProvider()() ); searchAPIClient.querySuggest(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedRequest: PlatformClientCallOptions< Omit @@ -438,7 +439,7 @@ describe('search api client', () => { buildMockNavigatorContextProvider()() ); searchAPIClient.querySuggest(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedUrl = `${ state.configuration.search.apiBaseUrl ?? @@ -469,7 +470,7 @@ describe('search api client', () => { ); searchAPIClient.facetSearch(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedRequest: PlatformClientCallOptions< Omit > = { @@ -519,7 +520,7 @@ describe('search api client', () => { ); searchAPIClient.facetSearch(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedUrl = `${ state.configuration.search.apiBaseUrl ?? getSearchApiBaseUrl( @@ -550,7 +551,7 @@ describe('search api client', () => { searchAPIClient.facetSearch(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const {query} = facetSearchState.options; const newQuery = `*${query}*`; @@ -600,7 +601,7 @@ it calls PlatformClient.call with the category facet search params`, async () => searchAPIClient.facetSearch(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const {query} = categoryFacetSearch.options; const newQuery = `*${query}*`; @@ -690,7 +691,7 @@ it calls PlatformClient.call with the category facet search params`, async () => preprocessRequest: NoopPreprocessRequest, requestMetadata: {method: 'recommendations'}, }; - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; expect(request).toMatchObject(expectedRequest); }); @@ -715,7 +716,7 @@ it calls PlatformClient.call with the category facet search params`, async () => }?${getOrganizationIdQueryParam(req)}&${getAuthenticationQueryParam( req )}`; - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; expect(request.url).toBe(expectedUrl); }); @@ -727,7 +728,7 @@ should call PlatformClient.call with the right options`, async () => { ).request; searchAPIClient.fieldDescriptions(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedRequest: PlatformClientCallOptions<{}> = { accessToken: state.configuration.accessToken, @@ -777,7 +778,7 @@ should call PlatformClient.call with the right options`, async () => { it('when calling SearchAPIClient.html should call PlatformClient.call with the right options', async () => { const req = await buildResultPreviewRequest(state, {uniqueId: '1'}); searchAPIClient.html(req); - const request = (PlatformClient.call as jest.Mock).mock.calls[0][0]; + const request = (PlatformClient.call as Mock).mock.calls[0][0]; const expectedRequest: PlatformClientCallOptions< Omit > = { diff --git a/packages/headless/src/api/search/search-api-client.ts b/packages/headless/src/api/search/search-api-client.ts index 098aba59e28..bdfd535b6a1 100644 --- a/packages/headless/src/api/search/search-api-client.ts +++ b/packages/headless/src/api/search/search-api-client.ts @@ -1,41 +1,41 @@ import {isNullOrUndefined} from '@coveo/bueno'; -import {AsyncThunkOptions} from '../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {emptyQuestionAnswer} from '../../features/search/search-state'; -import {SearchAppState} from '../../state/search-app-state'; -import {pickNonBaseParams, unwrapError} from '../api-client-utils'; -import {PlatformClient} from '../platform-client'; -import {BaseParam} from '../platform-service-params'; -import {APICallsQueue} from './api-calls-queue'; -import {FacetSearchRequest} from './facet-search/facet-search-request'; -import {FacetSearchResponse} from './facet-search/facet-search-response'; +import {AsyncThunkOptions} from '../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {emptyQuestionAnswer} from '../../features/search/search-state.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {pickNonBaseParams, unwrapError} from '../api-client-utils.js'; +import {PlatformClient} from '../platform-client.js'; +import {BaseParam} from '../platform-service-params.js'; +import {APICallsQueue} from './api-calls-queue.js'; +import {FacetSearchRequest} from './facet-search/facet-search-request.js'; +import {FacetSearchResponse} from './facet-search/facet-search-response.js'; import { FieldDescription, FieldDescriptionsResponseSuccess, -} from './fields/fields-response'; -import {getHtml, HtmlAPIClientOptions} from './html/html-api-client'; -import {HtmlRequest} from './html/html-request'; -import {PlanRequest} from './plan/plan-request'; -import {PlanResponseSuccess, Plan} from './plan/plan-response'; -import {QuerySuggestRequest} from './query-suggest/query-suggest-request'; +} from './fields/fields-response.js'; +import {getHtml, HtmlAPIClientOptions} from './html/html-api-client.js'; +import {HtmlRequest} from './html/html-request.js'; +import {PlanRequest} from './plan/plan-request.js'; +import {PlanResponseSuccess, Plan} from './plan/plan-response.js'; +import {QuerySuggestRequest} from './query-suggest/query-suggest-request.js'; import { QuerySuggestSuccessResponse, QuerySuggest, -} from './query-suggest/query-suggest-response'; -import {RecommendationRequest} from './recommendation/recommendation-request'; +} from './query-suggest/query-suggest-response.js'; +import {RecommendationRequest} from './recommendation/recommendation-request.js'; import { PostprocessFacetSearchResponseMiddleware, PostprocessQuerySuggestResponseMiddleware, PostprocessSearchResponseMiddleware, -} from './search-api-client-middleware'; +} from './search-api-client-middleware.js'; import { SearchAPIErrorWithStatusCode, buildAPIResponseFromErrorOrThrow, -} from './search-api-error-response'; -import {baseSearchRequest} from './search-api-params'; -import {SearchOrigin} from './search-metadata'; -import {SearchRequest} from './search/search-request'; -import {Search, SearchResponseSuccess} from './search/search-response'; +} from './search-api-error-response.js'; +import {baseSearchRequest} from './search-api-params.js'; +import {SearchOrigin} from './search-metadata.js'; +import {SearchRequest} from './search/search-request.js'; +import {Search, SearchResponseSuccess} from './search/search-response.js'; export interface FacetSearchAPIClient { facetSearch(req: FacetSearchRequest): Promise; diff --git a/packages/headless/src/api/search/search-api-error-response.ts b/packages/headless/src/api/search/search-api-error-response.ts index 2adcb4b5653..3556248c8f2 100644 --- a/packages/headless/src/api/search/search-api-error-response.ts +++ b/packages/headless/src/api/search/search-api-error-response.ts @@ -1,5 +1,5 @@ -import {DisconnectedError} from '../../utils/errors'; -import {QueryException} from './search/query-exception'; +import {DisconnectedError} from '../../utils/errors.js'; +import {QueryException} from './search/query-exception.js'; export interface SearchAPIErrorWithStatusCode { statusCode: number; diff --git a/packages/headless/src/api/search/search-api-params.ts b/packages/headless/src/api/search/search-api-params.ts index 1bde5200397..6867c76c468 100644 --- a/packages/headless/src/api/search/search-api-params.ts +++ b/packages/headless/src/api/search/search-api-params.ts @@ -1,15 +1,15 @@ import {history} from 'coveo.analytics'; -import {FacetOptions} from '../../features/facet-options/facet-options'; -import {AutomaticFacetRequest} from '../../features/facets/automatic-facet-set/interfaces/request'; -import {AnyFacetRequest} from '../../features/facets/generic/interfaces/generic-facet-request'; -import {GeneratedContentFormat} from '../../features/generated-answer/generated-response-format'; -import {URLPath} from '../../utils/url-utils'; +import {FacetOptions} from '../../features/facet-options/facet-options.js'; +import {AutomaticFacetRequest} from '../../features/facets/automatic-facet-set/interfaces/request.js'; +import {AnyFacetRequest} from '../../features/facets/generic/interfaces/generic-facet-request.js'; +import {GeneratedContentFormat} from '../../features/generated-answer/generated-response-format.js'; +import {URLPath} from '../../utils/url-utils.js'; import { HTTPContentType, HttpMethods, PlatformClientCallOptions, -} from '../platform-client'; -import {BaseParam} from '../platform-service-params'; +} from '../platform-client.js'; +import {BaseParam} from '../platform-service-params.js'; export interface QueryParam { q?: string; diff --git a/packages/headless/src/api/search/search/automatic-facets.ts b/packages/headless/src/api/search/search/automatic-facets.ts index 24452fc20ce..cdfe3f8a156 100644 --- a/packages/headless/src/api/search/search/automatic-facets.ts +++ b/packages/headless/src/api/search/search/automatic-facets.ts @@ -1,4 +1,4 @@ -import {AutomaticFacetResponse} from '../../../features/facets/automatic-facet-set/interfaces/response'; +import {AutomaticFacetResponse} from '../../../features/facets/automatic-facet-set/interfaces/response.js'; export interface AutomaticFacets { /** diff --git a/packages/headless/src/api/search/search/result.ts b/packages/headless/src/api/search/search/result.ts index 2158ed85746..7b8425aec8e 100644 --- a/packages/headless/src/api/search/search/result.ts +++ b/packages/headless/src/api/search/search/result.ts @@ -1,5 +1,5 @@ -import {HighlightKeyword} from '../../../utils/highlight'; -import {Raw} from './raw'; +import {HighlightKeyword} from '../../../utils/highlight.js'; +import {Raw} from './raw.js'; export interface Result { /** @@ -177,4 +177,9 @@ export interface Result { * Whether the result item has been previously viewed by one of the users specified in the `canSeeUserProfileOf` section of the [search token](https://docs.coveo.com/en/13/api-reference/search-api#tag/Search-V2/operation/token) generated to perform the search request. */ isUserActionView: boolean; + + /** + * The unique identifier of the search that returned this result. + */ + searchUid: string; } diff --git a/packages/headless/src/api/search/search/search-request.ts b/packages/headless/src/api/search/search/search-request.ts index 5d61ffbeb52..2a7c1f0ccac 100644 --- a/packages/headless/src/api/search/search/search-request.ts +++ b/packages/headless/src/api/search/search/search-request.ts @@ -7,7 +7,7 @@ import { LocaleParam, NumberOfResultsParam, VisitorIDParam, -} from '../../platform-service-params'; +} from '../../platform-service-params.js'; import { ActionsHistoryParam, AdvancedQueryParam, @@ -33,7 +33,7 @@ import { TimezoneParam, QueryCorrectionParam, PipelineRuleParams, -} from '../search-api-params'; +} from '../search-api-params.js'; export type SearchRequest = BaseParam & QueryParam & diff --git a/packages/headless/src/api/search/search/search-response.ts b/packages/headless/src/api/search/search/search-response.ts index 4653809cbf9..46e81499f1e 100644 --- a/packages/headless/src/api/search/search/search-response.ts +++ b/packages/headless/src/api/search/search/search-response.ts @@ -1,18 +1,18 @@ -import {AnyFacetResponse} from '../../../features/facets/generic/interfaces/generic-facet-response'; -import {Trigger} from '../../common/trigger'; +import {AnyFacetResponse} from '../../../features/facets/generic/interfaces/generic-facet-response.js'; +import {Trigger} from '../../common/trigger.js'; import { SearchAPIErrorWithExceptionInBody, SearchAPIErrorWithStatusCode, -} from '../search-api-error-response'; -import {AutomaticFacets} from './automatic-facets'; -import {ExecutionReport} from './execution-report'; -import {ExtendedResults} from './extended-results'; -import {Correction, QueryCorrection} from './query-corrections'; -import {QueryRankingExpression} from './query-ranking-expression'; -import {QuestionsAnswers} from './question-answering'; -import {Result} from './result'; -import {SecurityIdentity} from './security-identity'; -import {PhrasesToHighlight, TermsToHighlight} from './stemming'; +} from '../search-api-error-response.js'; +import {AutomaticFacets} from './automatic-facets.js'; +import {ExecutionReport} from './execution-report.js'; +import {ExtendedResults} from './extended-results.js'; +import {Correction, QueryCorrection} from './query-corrections.js'; +import {QueryRankingExpression} from './query-ranking-expression.js'; +import {QuestionsAnswers} from './question-answering.js'; +import {Result} from './result.js'; +import {SecurityIdentity} from './security-identity.js'; +import {PhrasesToHighlight, TermsToHighlight} from './stemming.js'; export interface SearchResponseSuccess { generateAutomaticFacets?: AutomaticFacets; diff --git a/packages/headless/src/api/service/case-assist/case-assist-api-client.test.ts b/packages/headless/src/api/service/case-assist/case-assist-api-client.test.ts index 3fac254ddcd..94cfd079684 100644 --- a/packages/headless/src/api/service/case-assist/case-assist-api-client.test.ts +++ b/packages/headless/src/api/service/case-assist/case-assist-api-client.test.ts @@ -1,10 +1,14 @@ -import {buildResultPreviewRequest} from '../../../features/result-preview/result-preview-request-builder'; -import {buildMockCaseAssistAPIClient} from '../../../test/mock-case-assist-api-client'; -import {createMockState} from '../../../test/mock-state'; -import {getOrganizationEndpoint, PlatformClient} from '../../platform-client'; -import {CaseAssistAPIClient} from './case-assist-api-client'; -import {GetCaseClassificationsRequest} from './get-case-classifications/get-case-classifications-request'; -import {GetDocumentSuggestionsRequest} from './get-document-suggestions/get-document-suggestions-request'; +import {Mock} from 'vitest'; +import {buildResultPreviewRequest} from '../../../features/result-preview/result-preview-request-builder.js'; +import {buildMockCaseAssistAPIClient} from '../../../test/mock-case-assist-api-client.js'; +import {createMockState} from '../../../test/mock-state.js'; +import { + getOrganizationEndpoint, + PlatformClient, +} from '../../platform-client.js'; +import {CaseAssistAPIClient} from './case-assist-api-client.js'; +import {GetCaseClassificationsRequest} from './get-case-classifications/get-case-classifications-request.js'; +import {GetDocumentSuggestionsRequest} from './get-document-suggestions/get-document-suggestions-request.js'; describe('case assist api client', () => { const orgId = 'some org id'; @@ -15,18 +19,18 @@ describe('case assist api client', () => { const clientId = 'some client id'; let client: CaseAssistAPIClient; - let platformCallMock: jest.Mock; + let platformCallMock: Mock; beforeEach(() => { client = buildMockCaseAssistAPIClient(); }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); const mockPlatformCall = (fakeResponse: unknown) => { - platformCallMock = jest.fn(); + platformCallMock = vi.fn(); platformCallMock.mockReturnValue(fakeResponse); PlatformClient.call = platformCallMock; diff --git a/packages/headless/src/api/service/case-assist/case-assist-api-client.ts b/packages/headless/src/api/service/case-assist/case-assist-api-client.ts index 32f48d69358..ca7e9c014fd 100644 --- a/packages/headless/src/api/service/case-assist/case-assist-api-client.ts +++ b/packages/headless/src/api/service/case-assist/case-assist-api-client.ts @@ -1,20 +1,23 @@ -import {AsyncThunkOptions} from '../../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {CaseAssistAppState} from '../../../state/case-assist-app-state'; -import {PlatformClient} from '../../platform-client'; -import {getHtml, HtmlAPIClientOptions} from '../../search/html/html-api-client'; -import {HtmlRequest} from '../../search/html/html-request'; -import {buildAPIResponseFromErrorOrThrow} from '../../search/search-api-error-response'; +import {AsyncThunkOptions} from '../../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {CaseAssistAppState} from '../../../state/case-assist-app-state.js'; +import {PlatformClient} from '../../platform-client.js'; +import { + getHtml, + HtmlAPIClientOptions, +} from '../../search/html/html-api-client.js'; +import {HtmlRequest} from '../../search/html/html-request.js'; +import {buildAPIResponseFromErrorOrThrow} from '../../search/search-api-error-response.js'; import { buildGetCaseClassificationsRequest, GetCaseClassificationsRequest, -} from './get-case-classifications/get-case-classifications-request'; -import {GetCaseClassificationsResponse} from './get-case-classifications/get-case-classifications-response'; +} from './get-case-classifications/get-case-classifications-request.js'; +import {GetCaseClassificationsResponse} from './get-case-classifications/get-case-classifications-response.js'; import { buildGetDocumentSuggestionsRequest, GetDocumentSuggestionsRequest, -} from './get-document-suggestions/get-document-suggestions-request'; -import {GetDocumentSuggestionsResponse} from './get-document-suggestions/get-document-suggestions-response'; +} from './get-document-suggestions/get-document-suggestions-request.js'; +import {GetDocumentSuggestionsResponse} from './get-document-suggestions/get-document-suggestions-response.js'; /** * Initialization options for the `CaseAssistAPIClient`. diff --git a/packages/headless/src/api/service/case-assist/case-assist-params.test.ts b/packages/headless/src/api/service/case-assist/case-assist-params.test.ts index 3790acf9395..f79a91bfca0 100644 --- a/packages/headless/src/api/service/case-assist/case-assist-params.test.ts +++ b/packages/headless/src/api/service/case-assist/case-assist-params.test.ts @@ -3,7 +3,7 @@ import { CaseAssistParam, prepareSuggestionRequestFields, prepareContextFromFields, -} from './case-assist-params'; +} from './case-assist-params.js'; describe('case assist params', () => { describe('baseCaseAssistRequest', () => { diff --git a/packages/headless/src/api/service/case-assist/case-assist-params.ts b/packages/headless/src/api/service/case-assist/case-assist-params.ts index e8ea1a1e103..dce3ddfa4b1 100644 --- a/packages/headless/src/api/service/case-assist/case-assist-params.ts +++ b/packages/headless/src/api/service/case-assist/case-assist-params.ts @@ -2,8 +2,8 @@ import { HTTPContentType, HttpMethods, PlatformClientCallOptions, -} from '../../platform-client'; -import {BaseParam} from '../../platform-service-params'; +} from '../../platform-client.js'; +import {BaseParam} from '../../platform-service-params.js'; export interface CaseAssistIdParam { caseAssistId: string; diff --git a/packages/headless/src/api/service/case-assist/get-case-classifications/get-case-classifications-request.ts b/packages/headless/src/api/service/case-assist/get-case-classifications/get-case-classifications-request.ts index 30443c64c55..00ac5b8adf3 100644 --- a/packages/headless/src/api/service/case-assist/get-case-classifications/get-case-classifications-request.ts +++ b/packages/headless/src/api/service/case-assist/get-case-classifications/get-case-classifications-request.ts @@ -4,13 +4,13 @@ import { ContextParam, DebugParam, LocaleParam, -} from '../../../platform-service-params'; +} from '../../../platform-service-params.js'; import { baseCaseAssistRequest, CaseAssistIdParam, FieldsParam, prepareSuggestionRequestFields, -} from '../case-assist-params'; +} from '../case-assist-params.js'; export type GetCaseClassificationsRequest = BaseParam & CaseAssistIdParam & diff --git a/packages/headless/src/api/service/case-assist/get-document-suggestions/get-document-suggestions-request.ts b/packages/headless/src/api/service/case-assist/get-document-suggestions/get-document-suggestions-request.ts index 8d546b99785..08927334d3d 100644 --- a/packages/headless/src/api/service/case-assist/get-document-suggestions/get-document-suggestions-request.ts +++ b/packages/headless/src/api/service/case-assist/get-document-suggestions/get-document-suggestions-request.ts @@ -5,13 +5,13 @@ import { DebugParam, LocaleParam, NumberOfResultsParam, -} from '../../../platform-service-params'; +} from '../../../platform-service-params.js'; import { baseCaseAssistRequest, CaseAssistIdParam, FieldsParam, prepareSuggestionRequestFields, -} from '../case-assist-params'; +} from '../case-assist-params.js'; export type GetDocumentSuggestionsRequest = BaseParam & CaseAssistIdParam & diff --git a/packages/headless/src/api/service/insight/get-interface/get-interface-config-request.ts b/packages/headless/src/api/service/insight/get-interface/get-interface-config-request.ts index f726d622b01..3dfa05c9dfd 100644 --- a/packages/headless/src/api/service/insight/get-interface/get-interface-config-request.ts +++ b/packages/headless/src/api/service/insight/get-interface/get-interface-config-request.ts @@ -1,5 +1,5 @@ -import {BaseParam} from '../../../platform-service-params'; -import {baseInsightRequest, InsightIdParam} from '../insight-params'; +import {BaseParam} from '../../../platform-service-params.js'; +import {baseInsightRequest, InsightIdParam} from '../insight-params.js'; export type GetInsightInterfaceConfigRequest = BaseParam & InsightIdParam; diff --git a/packages/headless/src/api/service/insight/insight-api-client.test.ts b/packages/headless/src/api/service/insight/insight-api-client.test.ts index 776f543c4b7..d25f7d4ea4b 100644 --- a/packages/headless/src/api/service/insight/insight-api-client.test.ts +++ b/packages/headless/src/api/service/insight/insight-api-client.test.ts @@ -1,7 +1,7 @@ -import pino from 'pino'; -import {PlatformClient} from '../../platform-client'; -import {NoopPreprocessRequest} from '../../preprocess-request'; -import {InsightAPIClient} from './insight-api-client'; +import {pino} from 'pino'; +import {PlatformClient} from '../../platform-client.js'; +import {NoopPreprocessRequest} from '../../preprocess-request.js'; +import {InsightAPIClient} from './insight-api-client.js'; describe('insight api client', () => { const configuration = { @@ -18,7 +18,7 @@ describe('insight api client', () => { let client: InsightAPIClient; const setupCallMock = (success: boolean, response: unknown) => { - return jest.spyOn(PlatformClient, 'call').mockResolvedValue({ + return vi.spyOn(PlatformClient, 'call').mockResolvedValue({ ok: success, json: () => Promise.resolve(response), } as unknown as Response); @@ -32,7 +32,7 @@ describe('insight api client', () => { }); afterEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); describe('getInterface', () => { diff --git a/packages/headless/src/api/service/insight/insight-api-client.ts b/packages/headless/src/api/service/insight/insight-api-client.ts index 7f8f9ac58c7..2ce09a26b8e 100644 --- a/packages/headless/src/api/service/insight/insight-api-client.ts +++ b/packages/headless/src/api/service/insight/insight-api-client.ts @@ -1,33 +1,33 @@ import {Logger} from 'pino'; -import {AsyncThunkOptions} from '../../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {InsightAppState} from '../../../state/insight-app-state'; -import {PlatformClient} from '../../platform-client'; -import {PreprocessRequest} from '../../preprocess-request'; -import {QuerySuggestSuccessResponse} from '../../search/query-suggest/query-suggest-response'; +import {AsyncThunkOptions} from '../../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; +import {PlatformClient} from '../../platform-client.js'; +import {PreprocessRequest} from '../../preprocess-request.js'; +import {QuerySuggestSuccessResponse} from '../../search/query-suggest/query-suggest-response.js'; import { isSuccessSearchResponse, SearchOptions, shimResponse, -} from '../../search/search-api-client'; -import {buildAPIResponseFromErrorOrThrow} from '../../search/search-api-error-response'; -import {SearchResponseSuccess} from '../../search/search/search-response'; +} from '../../search/search-api-client.js'; +import {buildAPIResponseFromErrorOrThrow} from '../../search/search-api-error-response.js'; +import {SearchResponseSuccess} from '../../search/search/search-response.js'; import { buildGetInsightInterfaceConfigRequest, GetInsightInterfaceConfigRequest, -} from './get-interface/get-interface-config-request'; -import {GetInsightInterfaceConfigResponse} from './get-interface/get-interface-config-response'; -import {InsightQuerySuggestRequest} from './query-suggest/query-suggest-request'; +} from './get-interface/get-interface-config-request.js'; +import {GetInsightInterfaceConfigResponse} from './get-interface/get-interface-config-response.js'; +import {InsightQuerySuggestRequest} from './query-suggest/query-suggest-request.js'; import { buildInsightQueryRequest, buildInsightQuerySuggestRequest, InsightQueryRequest, -} from './query/query-request'; +} from './query/query-request.js'; import { buildInsightUserActionsRequest, InsightUserActionsRequest, -} from './user-actions/user-actions-request'; -import {InsightUserActionsResponse} from './user-actions/user-actions-response'; +} from './user-actions/user-actions-request.js'; +import {InsightUserActionsResponse} from './user-actions/user-actions-response.js'; /** * Initialization options for the `InsightAPIClient`. diff --git a/packages/headless/src/api/service/insight/insight-params.test.ts b/packages/headless/src/api/service/insight/insight-params.test.ts index efab6c88f82..d03d5b7daa2 100644 --- a/packages/headless/src/api/service/insight/insight-params.test.ts +++ b/packages/headless/src/api/service/insight/insight-params.test.ts @@ -2,7 +2,7 @@ import { baseInsightRequest, InsightParam, pickNonInsightParams, -} from './insight-params'; +} from './insight-params.js'; describe('insight params', () => { const method = 'POST'; diff --git a/packages/headless/src/api/service/insight/insight-params.ts b/packages/headless/src/api/service/insight/insight-params.ts index 4d1351f167d..adeaa55e907 100644 --- a/packages/headless/src/api/service/insight/insight-params.ts +++ b/packages/headless/src/api/service/insight/insight-params.ts @@ -1,11 +1,11 @@ -import {pickNonBaseParams} from '../../api-client-utils'; +import {pickNonBaseParams} from '../../api-client-utils.js'; import { HTTPContentType, HttpMethods, PlatformClientCallOptions, -} from '../../platform-client'; -import {BaseParam} from '../../platform-service-params'; -import {InsightUserActionsRequest} from './user-actions/user-actions-request'; +} from '../../platform-client.js'; +import {BaseParam} from '../../platform-service-params.js'; +import {InsightUserActionsRequest} from './user-actions/user-actions-request.js'; export interface InsightIdParam { insightId: string; diff --git a/packages/headless/src/api/service/insight/query-suggest/query-suggest-request.ts b/packages/headless/src/api/service/insight/query-suggest/query-suggest-request.ts index 09518bffe3a..fc747775f5b 100644 --- a/packages/headless/src/api/service/insight/query-suggest/query-suggest-request.ts +++ b/packages/headless/src/api/service/insight/query-suggest/query-suggest-request.ts @@ -2,15 +2,15 @@ import { ContextParam, LocaleParam, VisitorIDParam, -} from '../../../platform-service-params'; +} from '../../../platform-service-params.js'; import { ActionsHistoryParam, AnalyticsParam, AuthenticationParam, QueryParam, TimezoneParam, -} from '../../../search/search-api-params'; -import {InsightParam} from '../insight-params'; +} from '../../../search/search-api-params.js'; +import {InsightParam} from '../insight-params.js'; export type InsightQuerySuggestRequest = InsightParam & QueryParam & diff --git a/packages/headless/src/api/service/insight/query/query-request.ts b/packages/headless/src/api/service/insight/query/query-request.ts index 4cc00a566b6..0d682777724 100644 --- a/packages/headless/src/api/service/insight/query/query-request.ts +++ b/packages/headless/src/api/service/insight/query/query-request.ts @@ -3,7 +3,7 @@ import { FoldingParam, LocaleParam, NumberOfResultsParam, -} from '../../../platform-service-params'; +} from '../../../platform-service-params.js'; import { AnalyticsParam, ConstantQueryParam, @@ -15,13 +15,13 @@ import { QueryParam, SortCriteriaParam, TabParam, -} from '../../../search/search-api-params'; +} from '../../../search/search-api-params.js'; import { baseInsightRequest, InsightParam, pickNonInsightParams, -} from '../insight-params'; -import {InsightQuerySuggestRequest} from '../query-suggest/query-suggest-request'; +} from '../insight-params.js'; +import {InsightQuerySuggestRequest} from '../query-suggest/query-suggest-request.js'; export type InsightQueryRequest = InsightParam & AnalyticsParam & diff --git a/packages/headless/src/api/service/insight/user-actions/user-actions-request.ts b/packages/headless/src/api/service/insight/user-actions/user-actions-request.ts index f3f11532583..33628f70919 100644 --- a/packages/headless/src/api/service/insight/user-actions/user-actions-request.ts +++ b/packages/headless/src/api/service/insight/user-actions/user-actions-request.ts @@ -1,5 +1,5 @@ -import {BaseParam} from '../../../platform-service-params'; -import {baseInsightUserActionRequest} from '../insight-params'; +import {BaseParam} from '../../../platform-service-params.js'; +import {baseInsightUserActionRequest} from '../insight-params.js'; export type InsightUserActionsRequest = BaseParam & UserIdParam; diff --git a/packages/headless/src/api/service/insight/user-actions/user-actions-response.ts b/packages/headless/src/api/service/insight/user-actions/user-actions-response.ts index 45dd88f16cc..cb6c376c768 100644 --- a/packages/headless/src/api/service/insight/user-actions/user-actions-response.ts +++ b/packages/headless/src/api/service/insight/user-actions/user-actions-response.ts @@ -1,4 +1,4 @@ -import {UserActionType} from '../../../../features/insight-user-actions/insight-user-actions-state'; +import {UserActionType} from '../../../../features/insight-user-actions/insight-user-actions-state.js'; export interface InsightUserActionsResponse { value: Array; diff --git a/packages/headless/src/app/__snapshots__/engine.test.ts.snap b/packages/headless/src/app/__snapshots__/engine.test.ts.snap index 2f55034af8a..539f8844307 100644 --- a/packages/headless/src/app/__snapshots__/engine.test.ts.snap +++ b/packages/headless/src/app/__snapshots__/engine.test.ts.snap @@ -1,3 +1,3 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`engine should throw an error if trackingId is not set in the analytics configuration and analyticsMode is next 1`] = `"analytics.trackingId is required when analytics.analyticsMode="next""`; +exports[`engine > should throw an error if trackingId is not set in the analytics configuration and analyticsMode is next 1`] = `[InvalidEngineConfiguration: analytics.trackingId is required when analytics.analyticsMode="next"]`; diff --git a/packages/headless/src/app/async-thunk-options.ts b/packages/headless/src/app/async-thunk-options.ts index 25207013964..8f9610c2f29 100644 --- a/packages/headless/src/app/async-thunk-options.ts +++ b/packages/headless/src/app/async-thunk-options.ts @@ -1,4 +1,4 @@ -import {ThunkExtraArguments} from './thunk-extra-arguments'; +import {ThunkExtraArguments} from './thunk-extra-arguments.js'; export interface AsyncThunkOptions< T, diff --git a/packages/headless/src/app/case-assist-engine/case-assist-engine-configuration.ts b/packages/headless/src/app/case-assist-engine/case-assist-engine-configuration.ts index 6e7067e6aff..61600c2dced 100644 --- a/packages/headless/src/app/case-assist-engine/case-assist-engine-configuration.ts +++ b/packages/headless/src/app/case-assist-engine/case-assist-engine-configuration.ts @@ -2,11 +2,11 @@ import {Schema} from '@coveo/bueno'; import { nonEmptyString, requiredNonEmptyString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { EngineConfiguration, engineConfigurationDefinitions, -} from '../engine-configuration'; +} from '../engine-configuration.js'; /** * The case assist engine configuration. diff --git a/packages/headless/src/app/case-assist-engine/case-assist-engine.test.ts b/packages/headless/src/app/case-assist-engine/case-assist-engine.test.ts index 6ebe5a4af88..2e6e2d19ccf 100644 --- a/packages/headless/src/app/case-assist-engine/case-assist-engine.test.ts +++ b/packages/headless/src/app/case-assist-engine/case-assist-engine.test.ts @@ -1,10 +1,10 @@ -import {getSampleEngineConfiguration} from '../engine-configuration'; +import {getSampleEngineConfiguration} from '../engine-configuration.js'; +import {CaseAssistEngineConfiguration} from './case-assist-engine-configuration.js'; import { buildCaseAssistEngine, CaseAssistEngine, CaseAssistEngineOptions, -} from './case-assist-engine'; -import {CaseAssistEngineConfiguration} from './case-assist-engine-configuration'; +} from './case-assist-engine.js'; function getSampleCaseAssistEngineConfiguration(): CaseAssistEngineConfiguration { return { diff --git a/packages/headless/src/app/case-assist-engine/case-assist-engine.ts b/packages/headless/src/app/case-assist-engine/case-assist-engine.ts index 75c0a009475..03f359c1809 100644 --- a/packages/headless/src/app/case-assist-engine/case-assist-engine.ts +++ b/packages/headless/src/app/case-assist-engine/case-assist-engine.ts @@ -1,27 +1,27 @@ import {isNullOrUndefined} from '@coveo/bueno'; import {StateFromReducersMapObject} from '@reduxjs/toolkit'; import {Logger} from 'pino'; -import {NoopPreprocessRequest} from '../../api/preprocess-request'; -import {CaseAssistAPIClient} from '../../api/service/case-assist/case-assist-api-client'; -import {setCaseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-actions'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; -import {setSearchHub} from '../../features/search-hub/search-hub-actions'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; -import {CaseAssistAppState} from '../../state/case-assist-app-state'; -import {CaseAssistThunkExtraArguments} from '../case-assist-thunk-extra-arguments'; +import {NoopPreprocessRequest} from '../../api/preprocess-request.js'; +import {CaseAssistAPIClient} from '../../api/service/case-assist/case-assist-api-client.js'; +import {setCaseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-actions.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; +import {setSearchHub} from '../../features/search-hub/search-hub-actions.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; +import {CaseAssistAppState} from '../../state/case-assist-app-state.js'; +import {CaseAssistThunkExtraArguments} from '../case-assist-thunk-extra-arguments.js'; import { buildEngine, CoreEngine, EngineOptions, ExternalEngineOptions, -} from '../engine'; -import {buildLogger} from '../logger'; -import {buildThunkExtraArguments} from '../thunk-extra-arguments'; +} from '../engine.js'; +import {buildLogger} from '../logger.js'; +import {buildThunkExtraArguments} from '../thunk-extra-arguments.js'; import { CaseAssistEngineConfiguration, caseAssistEngineConfigurationSchema, -} from './case-assist-engine-configuration'; +} from './case-assist-engine-configuration.js'; export type {CaseAssistEngineConfiguration}; diff --git a/packages/headless/src/app/case-assist-thunk-extra-arguments.ts b/packages/headless/src/app/case-assist-thunk-extra-arguments.ts index 7fccc7edaa4..e112602ab0d 100644 --- a/packages/headless/src/app/case-assist-thunk-extra-arguments.ts +++ b/packages/headless/src/app/case-assist-thunk-extra-arguments.ts @@ -1,5 +1,5 @@ -import {CaseAssistAPIClient} from '../api/service/case-assist/case-assist-api-client'; -import {ClientThunkExtraArguments} from './thunk-extra-arguments'; +import {CaseAssistAPIClient} from '../api/service/case-assist/case-assist-api-client.js'; +import {ClientThunkExtraArguments} from './thunk-extra-arguments.js'; export interface CaseAssistThunkExtraArguments extends ClientThunkExtraArguments {} diff --git a/packages/headless/src/app/commerce-engine/commerce-engine-configuration.ts b/packages/headless/src/app/commerce-engine/commerce-engine-configuration.ts index 94bc9289ed4..204c4ca4fb0 100644 --- a/packages/headless/src/app/commerce-engine/commerce-engine-configuration.ts +++ b/packages/headless/src/app/commerce-engine/commerce-engine-configuration.ts @@ -1,17 +1,17 @@ import {BooleanValue, RecordValue, Schema, StringValue} from '@coveo/bueno'; -import {CartInitialState} from '../../controllers/commerce/context/cart/headless-cart'; -import {ContextOptions} from '../../controllers/commerce/context/headless-context'; -import {cartDefinition} from '../../features/commerce/context/cart/cart-validation'; -import {contextDefinition} from '../../features/commerce/context/context-validation'; +import {CartInitialState} from '../../controllers/commerce/context/cart/headless-cart.js'; +import {ContextOptions} from '../../controllers/commerce/context/headless-context.js'; +import {cartDefinition} from '../../features/commerce/context/cart/cart-validation.js'; +import {contextDefinition} from '../../features/commerce/context/context-validation.js'; import { nonEmptyString, requiredNonEmptyString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { AnalyticsConfiguration, EngineConfiguration, engineConfigurationDefinitions, -} from '../engine-configuration'; +} from '../engine-configuration.js'; /** * The commerce engine configuration. diff --git a/packages/headless/src/app/commerce-engine/commerce-engine.ssr.ts b/packages/headless/src/app/commerce-engine/commerce-engine.ssr.ts index 92a902feb69..dc32ca921ee 100644 --- a/packages/headless/src/app/commerce-engine/commerce-engine.ssr.ts +++ b/packages/headless/src/app/commerce-engine/commerce-engine.ssr.ts @@ -2,33 +2,33 @@ * Utility functions to be used for Commerce Server Side Rendering. */ import {Action, UnknownAction} from '@reduxjs/toolkit'; -import {stateKey} from '../../app/state-key'; -import {buildProductListing} from '../../controllers/commerce/product-listing/headless-product-listing'; -import {buildSearch} from '../../controllers/commerce/search/headless-search'; -import type {Controller} from '../../controllers/controller/headless-controller'; -import {createWaitForActionMiddleware} from '../../utils/utils'; -import {buildControllerDefinitions} from '../commerce-ssr-engine/common'; +import {stateKey} from '../../app/state-key.js'; +import {buildProductListing} from '../../controllers/commerce/product-listing/headless-product-listing.js'; +import {buildSearch} from '../../controllers/commerce/search/headless-search.js'; +import type {Controller} from '../../controllers/controller/headless-controller.js'; +import {createWaitForActionMiddleware} from '../../utils/utils.js'; +import {buildControllerDefinitions} from '../commerce-ssr-engine/common.js'; import { ControllerDefinitionsMap, InferControllerStaticStateMapFromDefinitionsWithSolutionType, SolutionType, -} from '../commerce-ssr-engine/types/common'; +} from '../commerce-ssr-engine/types/common.js'; import { EngineDefinition, EngineDefinitionOptions, -} from '../commerce-ssr-engine/types/core-engine'; -import {NavigatorContextProvider} from '../navigatorContextProvider'; -import {composeFunction} from '../ssr-engine/common'; -import {createStaticState} from '../ssr-engine/common'; +} from '../commerce-ssr-engine/types/core-engine.js'; +import {NavigatorContextProvider} from '../navigatorContextProvider.js'; +import {composeFunction} from '../ssr-engine/common.js'; +import {createStaticState} from '../ssr-engine/common.js'; import { EngineStaticState, InferControllerPropsMapFromDefinitions, -} from '../ssr-engine/types/common'; +} from '../ssr-engine/types/common.js'; import { CommerceEngine, CommerceEngineOptions, buildCommerceEngine, -} from './commerce-engine'; +} from './commerce-engine.js'; /** * The SSR commerce engine. diff --git a/packages/headless/src/app/commerce-engine/commerce-engine.test.ts b/packages/headless/src/app/commerce-engine/commerce-engine.test.ts index 1e049740450..204dcbda89f 100644 --- a/packages/headless/src/app/commerce-engine/commerce-engine.test.ts +++ b/packages/headless/src/app/commerce-engine/commerce-engine.test.ts @@ -1,11 +1,11 @@ -import {createCartKey} from '../../controllers/commerce/context/cart/headless-cart'; -import {stateKey} from '../state-key'; +import {createCartKey} from '../../controllers/commerce/context/cart/headless-cart.js'; +import {stateKey} from '../state-key.js'; +import {getSampleCommerceEngineConfiguration} from './commerce-engine-configuration.js'; import { buildCommerceEngine, CommerceEngine, CommerceEngineOptions, -} from './commerce-engine'; -import {getSampleCommerceEngineConfiguration} from './commerce-engine-configuration'; +} from './commerce-engine.js'; describe('buildCommerceEngine', () => { let options: CommerceEngineOptions; diff --git a/packages/headless/src/app/commerce-engine/commerce-engine.ts b/packages/headless/src/app/commerce-engine/commerce-engine.ts index 095166bf063..cdbc403e1a6 100644 --- a/packages/headless/src/app/commerce-engine/commerce-engine.ts +++ b/packages/headless/src/app/commerce-engine/commerce-engine.ts @@ -1,49 +1,49 @@ import {StateFromReducersMapObject} from '@reduxjs/toolkit'; import {Logger} from 'pino'; -import {CommerceAPIClient} from '../../api/commerce/commerce-api-client'; -import {NoopPreprocessRequest} from '../../api/preprocess-request'; +import {CommerceAPIClient} from '../../api/commerce/commerce-api-client.js'; +import {NoopPreprocessRequest} from '../../api/preprocess-request.js'; import { updateAnalyticsConfiguration, updateBasicConfiguration, updateProxyBaseUrl, -} from '../../features/commerce/configuration/configuration-actions'; -import {configurationReducer} from '../../features/commerce/configuration/configuration-slice'; -import {ConfigurationState} from '../../features/commerce/configuration/configuration-state'; -import {setItems} from '../../features/commerce/context/cart/cart-actions'; -import {cartReducer} from '../../features/commerce/context/cart/cart-slice'; -import {setContext} from '../../features/commerce/context/context-actions'; -import {contextReducer} from '../../features/commerce/context/context-slice'; -import {didYouMeanReducer} from '../../features/commerce/did-you-mean/did-you-mean-slice'; -import {commerceFacetSetReducer} from '../../features/commerce/facets/facet-set/facet-set-slice'; -import {fieldSuggestionsOrderReducer} from '../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {manualNumericFacetReducer} from '../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice'; -import {paginationReducer} from '../../features/commerce/pagination/pagination-slice'; -import {productListingReducer} from '../../features/commerce/product-listing/product-listing-slice'; -import {queryReducer} from '../../features/commerce/query/query-slice'; -import {recommendationsReducer} from '../../features/commerce/recommendations/recommendations-slice'; -import {commerceSearchReducer} from '../../features/commerce/search/search-slice'; -import {sortReducer} from '../../features/commerce/sort/sort-slice'; -import {commerceTriggersReducer} from '../../features/commerce/triggers/triggers-slice'; -import {versionReducer} from '../../features/debug/version-slice'; -import {facetOrderReducer} from '../../features/facets/facet-order/facet-order-slice'; -import {categoryFacetSearchSetReducer} from '../../features/facets/facet-search-set/category/category-facet-search-set-slice'; -import {specificFacetSearchSetReducer} from '../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; -import {CommerceAppState} from '../../state/commerce-app-state'; -import {CommerceThunkExtraArguments} from '../commerce-thunk-extra-arguments'; +} from '../../features/commerce/configuration/configuration-actions.js'; +import {configurationReducer} from '../../features/commerce/configuration/configuration-slice.js'; +import {ConfigurationState} from '../../features/commerce/configuration/configuration-state.js'; +import {setItems} from '../../features/commerce/context/cart/cart-actions.js'; +import {cartReducer} from '../../features/commerce/context/cart/cart-slice.js'; +import {setContext} from '../../features/commerce/context/context-actions.js'; +import {contextReducer} from '../../features/commerce/context/context-slice.js'; +import {didYouMeanReducer} from '../../features/commerce/did-you-mean/did-you-mean-slice.js'; +import {commerceFacetSetReducer} from '../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {fieldSuggestionsOrderReducer} from '../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {manualNumericFacetReducer} from '../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice.js'; +import {paginationReducer} from '../../features/commerce/pagination/pagination-slice.js'; +import {productListingReducer} from '../../features/commerce/product-listing/product-listing-slice.js'; +import {queryReducer} from '../../features/commerce/query/query-slice.js'; +import {recommendationsReducer} from '../../features/commerce/recommendations/recommendations-slice.js'; +import {commerceSearchReducer} from '../../features/commerce/search/search-slice.js'; +import {sortReducer} from '../../features/commerce/sort/sort-slice.js'; +import {commerceTriggersReducer} from '../../features/commerce/triggers/triggers-slice.js'; +import {versionReducer} from '../../features/debug/version-slice.js'; +import {facetOrderReducer} from '../../features/facets/facet-order/facet-order-slice.js'; +import {categoryFacetSearchSetReducer} from '../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; +import {specificFacetSearchSetReducer} from '../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; +import {CommerceAppState} from '../../state/commerce-app-state.js'; +import {CommerceThunkExtraArguments} from '../commerce-thunk-extra-arguments.js'; import { buildCoreEngine, CoreEngineNext, CoreState, EngineOptions, ExternalEngineOptions, -} from '../engine'; -import {buildLogger} from '../logger'; -import {redactEngine, stateKey} from '../state-key'; -import {buildThunkExtraArguments} from '../thunk-extra-arguments'; +} from '../engine.js'; +import {buildLogger} from '../logger.js'; +import {redactEngine, stateKey} from '../state-key.js'; +import {buildThunkExtraArguments} from '../thunk-extra-arguments.js'; import { CommerceEngineConfiguration, commerceEngineConfigurationSchema, -} from './commerce-engine-configuration'; +} from './commerce-engine-configuration.js'; export type {CommerceEngineConfiguration}; diff --git a/packages/headless/src/app/commerce-ssr-engine/common.ts b/packages/headless/src/app/commerce-ssr-engine/common.ts index 5289dcaafa6..2b8907bf678 100644 --- a/packages/headless/src/app/commerce-ssr-engine/common.ts +++ b/packages/headless/src/app/commerce-ssr-engine/common.ts @@ -1,8 +1,8 @@ -import {Controller} from '../../controllers/controller/headless-controller'; -import {InvalidControllerDefinition} from '../../utils/errors'; -import {filterObject, mapObject} from '../../utils/utils'; -import {CoreEngine, CoreEngineNext} from '../engine'; -import {InferControllerPropsMapFromDefinitions} from '../ssr-engine/types/common'; +import {Controller} from '../../controllers/controller/headless-controller.js'; +import {InvalidControllerDefinition} from '../../utils/errors.js'; +import {filterObject, mapObject} from '../../utils/utils.js'; +import {CoreEngine, CoreEngineNext} from '../engine.js'; +import {InferControllerPropsMapFromDefinitions} from '../ssr-engine/types/common.js'; import { ControllerDefinition, ControllerDefinitionOption, @@ -11,7 +11,7 @@ import { InferControllerPropsFromDefinition, InferControllersMapFromDefinition, SolutionType, -} from './types/common'; +} from './types/common.js'; function buildControllerFromDefinition< TControllerDefinition extends ControllerDefinition, diff --git a/packages/headless/src/app/commerce-ssr-engine/types/common.ts b/packages/headless/src/app/commerce-ssr-engine/types/common.ts index 51f85511f6a..e19b4c9bde8 100644 --- a/packages/headless/src/app/commerce-ssr-engine/types/common.ts +++ b/packages/headless/src/app/commerce-ssr-engine/types/common.ts @@ -1,12 +1,12 @@ -import type {Controller} from '../../../controllers/controller/headless-controller'; -import type {InvalidControllerDefinition} from '../../../utils/errors'; -import type {CommerceEngine} from '../../commerce-engine/commerce-engine'; -import type {CoreEngine, CoreEngineNext} from '../../engine'; +import type {Controller} from '../../../controllers/controller/headless-controller.js'; +import type {InvalidControllerDefinition} from '../../../utils/errors.js'; +import type {CommerceEngine} from '../../commerce-engine/commerce-engine.js'; +import type {CoreEngine, CoreEngineNext} from '../../engine.js'; import type { HasKey, InferControllerStaticStateMapFromControllers, InferControllerStaticStateFromController, -} from '../../ssr-engine/types/common'; +} from '../../ssr-engine/types/common.js'; export type { InferControllerStaticStateFromController, diff --git a/packages/headless/src/app/commerce-ssr-engine/types/core-engine.ts b/packages/headless/src/app/commerce-ssr-engine/types/core-engine.ts index 5636c9ca8cd..5c7dc8e06ec 100644 --- a/packages/headless/src/app/commerce-ssr-engine/types/core-engine.ts +++ b/packages/headless/src/app/commerce-ssr-engine/types/core-engine.ts @@ -1,18 +1,18 @@ import {UnknownAction} from '@reduxjs/toolkit'; -import type {Controller} from '../../../controllers/controller/headless-controller'; -import {CoreEngine, CoreEngineNext} from '../../engine'; -import {EngineConfiguration} from '../../engine-configuration'; -import {NavigatorContextProvider} from '../../navigatorContextProvider'; -import {Build} from '../../ssr-engine/types/build'; -import {InferControllerPropsMapFromDefinitions} from '../../ssr-engine/types/common'; -import {FetchStaticState} from '../../ssr-engine/types/fetch-static-state'; -import {HydrateStaticState} from '../../ssr-engine/types/hydrate-static-state'; +import type {Controller} from '../../../controllers/controller/headless-controller.js'; +import {EngineConfiguration} from '../../engine-configuration.js'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; +import {NavigatorContextProvider} from '../../navigatorContextProvider.js'; +import {Build} from '../../ssr-engine/types/build.js'; +import {InferControllerPropsMapFromDefinitions} from '../../ssr-engine/types/common.js'; +import {FetchStaticState} from '../../ssr-engine/types/fetch-static-state.js'; +import {HydrateStaticState} from '../../ssr-engine/types/hydrate-static-state.js'; import { ControllerDefinitionsMap, InferControllersMapFromDefinition, SolutionType, InferControllerStaticStateMapFromDefinitionsWithSolutionType, -} from './common'; +} from './common.js'; export type EngineDefinitionOptions< TOptions extends {configuration: EngineConfiguration}, diff --git a/packages/headless/src/app/commerce-thunk-extra-arguments.ts b/packages/headless/src/app/commerce-thunk-extra-arguments.ts index 3291464312f..dd9ac6eeb6b 100644 --- a/packages/headless/src/app/commerce-thunk-extra-arguments.ts +++ b/packages/headless/src/app/commerce-thunk-extra-arguments.ts @@ -1,5 +1,5 @@ -import {CommerceAPIClient} from '../api/commerce/commerce-api-client'; -import {ClientThunkExtraArguments} from './thunk-extra-arguments'; +import {CommerceAPIClient} from '../api/commerce/commerce-api-client.js'; +import {ClientThunkExtraArguments} from './thunk-extra-arguments.js'; export interface CommerceThunkExtraArguments extends ClientThunkExtraArguments {} diff --git a/packages/headless/src/app/common-reducers.ts b/packages/headless/src/app/common-reducers.ts index ae0bf19fb9d..71d44cb2103 100644 --- a/packages/headless/src/app/common-reducers.ts +++ b/packages/headless/src/app/common-reducers.ts @@ -1,3 +1,3 @@ -import {configurationReducer} from '../features/configuration/configuration-slice'; +import {configurationReducer} from '../features/configuration/configuration-slice.js'; export const configuration = configurationReducer; diff --git a/packages/headless/src/app/engine-configuration.ts b/packages/headless/src/app/engine-configuration.ts index 199d2bb2c95..2f61479c10c 100644 --- a/packages/headless/src/app/engine-configuration.ts +++ b/packages/headless/src/app/engine-configuration.ts @@ -8,10 +8,10 @@ import { AnalyticsClientSendEventHook, IRuntimeEnvironment, } from 'coveo.analytics'; -import {PreprocessRequest} from '../api/preprocess-request'; -import {PlatformEnvironment} from '../utils/url-utils'; -import {requiredNonEmptyString} from '../utils/validate-payload'; -import {CoveoFramework} from '../utils/version'; +import {PreprocessRequest} from '../api/preprocess-request.js'; +import {PlatformEnvironment} from '../utils/url-utils.js'; +import {requiredNonEmptyString} from '../utils/validate-payload.js'; +import {CoveoFramework} from '../utils/version.js'; /** * The global headless engine configuration options. diff --git a/packages/headless/src/app/engine.test.ts b/packages/headless/src/app/engine.test.ts index 3ee6aa32c8a..637b264f63f 100644 --- a/packages/headless/src/app/engine.test.ts +++ b/packages/headless/src/app/engine.test.ts @@ -3,25 +3,25 @@ import { createAction, createReducer, } from '@reduxjs/toolkit'; -import * as Store from '../app/store'; -import {updateAnalyticsConfiguration} from '../features/configuration/configuration-actions'; -import {ConfigurationState} from '../features/configuration/configuration-state'; -import {buildMockThunkExtraArguments} from '../test/mock-thunk-extra-arguments'; -import {configuration} from './common-reducers'; -import {buildEngine, CoreEngine, EngineOptions} from './engine'; -import {getSampleEngineConfiguration} from './engine-configuration'; -import {ThunkExtraArguments} from './thunk-extra-arguments'; - -jest.mock('pino', () => ({ - ...jest.requireActual('pino'), - __esModule: true, - default: () => ({ - info: jest.fn(), - error: jest.fn(), - warn: jest.fn(), - debug: jest.fn(), - }), -})); +import * as Store from '../app/store.js'; +import {updateAnalyticsConfiguration} from '../features/configuration/configuration-actions.js'; +import {ConfigurationState} from '../features/configuration/configuration-state.js'; +import {buildMockThunkExtraArguments} from '../test/mock-thunk-extra-arguments.js'; +import {configuration} from './common-reducers.js'; +import {getSampleEngineConfiguration} from './engine-configuration.js'; +import {buildEngine, CoreEngine, EngineOptions} from './engine.js'; +import {ThunkExtraArguments} from './thunk-extra-arguments.js'; + +vi.mock(import('pino'), async (importOriginal) => { + const mod = await importOriginal(); // type is inferred + return { + ...mod, + info: vi.fn(), + error: vi.fn(), + warn: vi.fn(), + debug: vi.fn(), + }; +}); describe('engine', () => { let options: EngineOptions<{}>; @@ -125,7 +125,7 @@ describe('engine', () => { it("when name is specified in the config, the engine's store name is initialized with the config's value", () => { options.configuration.name = 'myEngine'; - const spy = jest.spyOn(Store, 'configureStore'); + const spy = vi.spyOn(Store, 'configureStore'); initEngine(); expect(spy).toHaveBeenCalledWith( @@ -136,7 +136,7 @@ describe('engine', () => { }); it("when no name is specified, the engine's store name is initialized to the default value: 'coveo-headless'", () => { - const spy = jest.spyOn(Store, 'configureStore'); + const spy = vi.spyOn(Store, 'configureStore'); initEngine(); expect(spy).toHaveBeenCalledWith( @@ -150,7 +150,7 @@ describe('engine', () => { options.reducers = {configuration}; initEngine(); - const stateListener = jest.fn(); + const stateListener = vi.fn(); engine.subscribe(stateListener); engine.addReducers({configuration}); diff --git a/packages/headless/src/app/engine.ts b/packages/headless/src/app/engine.ts index 9ec050d06fd..274e80e0372 100644 --- a/packages/headless/src/app/engine.ts +++ b/packages/headless/src/app/engine.ts @@ -11,40 +11,40 @@ import { UnknownAction, } from '@reduxjs/toolkit'; import {Logger} from 'pino'; -import {getRelayInstanceFromState} from '../api/analytics/analytics-relay-client'; -import {answerApi} from '../api/knowledge/stream-answer-api'; +import {getRelayInstanceFromState} from '../api/analytics/analytics-relay-client.js'; +import {answerApi} from '../api/knowledge/stream-answer-api.js'; import { disableAnalytics, enableAnalytics, updateAnalyticsConfiguration, UpdateAnalyticsConfigurationActionCreatorPayload, updateBasicConfiguration, -} from '../features/configuration/configuration-actions'; +} from '../features/configuration/configuration-actions.js'; import { ConfigurationState, CoreConfigurationState, -} from '../features/configuration/configuration-state'; -import {versionReducer as version} from '../features/debug/version-slice'; -import {SearchParametersState} from '../state/search-app-state'; -import {isBrowser} from '../utils/runtime'; -import {doNotTrack} from '../utils/utils'; -import {analyticsMiddleware} from './analytics-middleware'; -import {configuration} from './common-reducers'; -import {EngineConfiguration} from './engine-configuration'; -import {instantlyCallableThunkActionMiddleware} from './instantly-callable-middleware'; -import {LoggerOptions} from './logger'; -import {logActionErrorMiddleware} from './logger-middlewares'; +} from '../features/configuration/configuration-state.js'; +import {versionReducer as version} from '../features/debug/version-slice.js'; +import {SearchParametersState} from '../state/search-app-state.js'; +import {isBrowser} from '../utils/runtime.js'; +import {doNotTrack} from '../utils/utils.js'; +import {analyticsMiddleware} from './analytics-middleware.js'; +import {configuration} from './common-reducers.js'; +import {EngineConfiguration} from './engine-configuration.js'; +import {instantlyCallableThunkActionMiddleware} from './instantly-callable-middleware.js'; +import {logActionErrorMiddleware} from './logger-middlewares.js'; +import {LoggerOptions} from './logger.js'; import { NavigatorContext, NavigatorContextProvider, defaultBrowserNavigatorContextProvider, defaultNodeJSNavigatorContextProvider, -} from './navigatorContextProvider'; -import {createReducerManager, ReducerManager} from './reducer-manager'; -import {createRenewAccessTokenMiddleware} from './renew-access-token-middleware'; -import {stateKey} from './state-key'; -import {CoreExtraArguments, Store, configureStore} from './store'; -import {ThunkExtraArguments} from './thunk-extra-arguments'; +} from './navigatorContextProvider.js'; +import {createReducerManager, ReducerManager} from './reducer-manager.js'; +import {createRenewAccessTokenMiddleware} from './renew-access-token-middleware.js'; +import {stateKey} from './state-key.js'; +import {CoreExtraArguments, Store, configureStore} from './store.js'; +import {ThunkExtraArguments} from './thunk-extra-arguments.js'; export type CoreState< Configuration extends CoreConfigurationState = CoreConfigurationState, diff --git a/packages/headless/src/app/insight-engine/insight-engine-configuration.ts b/packages/headless/src/app/insight-engine/insight-engine-configuration.ts index 6a9c524fbae..27feda12fc6 100644 --- a/packages/headless/src/app/insight-engine/insight-engine-configuration.ts +++ b/packages/headless/src/app/insight-engine/insight-engine-configuration.ts @@ -2,12 +2,12 @@ import {RecordValue, Schema} from '@coveo/bueno'; import { nonEmptyString, requiredNonEmptyString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { EngineConfiguration, engineConfigurationDefinitions, getSampleEngineConfiguration, -} from '../engine-configuration'; +} from '../engine-configuration.js'; /** * The insight engine configuration. diff --git a/packages/headless/src/app/insight-engine/insight-engine.test.ts b/packages/headless/src/app/insight-engine/insight-engine.test.ts index f703bad376b..7ccf43caf4c 100644 --- a/packages/headless/src/app/insight-engine/insight-engine.test.ts +++ b/packages/headless/src/app/insight-engine/insight-engine.test.ts @@ -1,10 +1,10 @@ -import {getSampleEngineConfiguration} from '../engine-configuration'; +import {getSampleEngineConfiguration} from '../engine-configuration.js'; import { buildInsightEngine, InsightEngine, InsightEngineConfiguration, InsightEngineOptions, -} from './insight-engine'; +} from './insight-engine.js'; function getSampleInsightEngineConfiguration(): InsightEngineConfiguration { return { diff --git a/packages/headless/src/app/insight-engine/insight-engine.ts b/packages/headless/src/app/insight-engine/insight-engine.ts index ac3dcbf8396..e8293b137d9 100644 --- a/packages/headless/src/app/insight-engine/insight-engine.ts +++ b/packages/headless/src/app/insight-engine/insight-engine.ts @@ -1,37 +1,37 @@ import {StateFromReducersMapObject} from '@reduxjs/toolkit'; import {Logger} from 'pino'; -import {GeneratedAnswerAPIClient} from '../../api/generated-answer/generated-answer-client'; -import {NoopPreprocessRequest} from '../../api/preprocess-request'; -import {InsightAPIClient} from '../../api/service/insight/insight-api-client'; -import {interfaceLoad} from '../../features/analytics/analytics-actions'; -import {LegacySearchAction} from '../../features/analytics/analytics-utils'; -import {updateSearchConfiguration} from '../../features/configuration/configuration-actions'; -import {setInsightConfiguration} from '../../features/insight-configuration/insight-configuration-actions'; -import {insightConfigurationReducer as insightConfiguration} from '../../features/insight-configuration/insight-configuration-slice'; -import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice'; -import {executeSearch} from '../../features/insight-search/insight-search-actions'; -import {logInsightInterfaceLoad} from '../../features/insight-search/insight-search-analytics-actions'; -import {resultPreviewReducer as resultPreview} from '../../features/result-preview/result-preview-slice'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; -import {firstSearchExecutedSelector} from '../../features/search/search-selectors'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {InsightAppState} from '../../state/insight-app-state'; +import {GeneratedAnswerAPIClient} from '../../api/generated-answer/generated-answer-client.js'; +import {NoopPreprocessRequest} from '../../api/preprocess-request.js'; +import {InsightAPIClient} from '../../api/service/insight/insight-api-client.js'; +import {interfaceLoad} from '../../features/analytics/analytics-actions.js'; +import {LegacySearchAction} from '../../features/analytics/analytics-utils.js'; +import {updateSearchConfiguration} from '../../features/configuration/configuration-actions.js'; +import {setInsightConfiguration} from '../../features/insight-configuration/insight-configuration-actions.js'; +import {insightConfigurationReducer as insightConfiguration} from '../../features/insight-configuration/insight-configuration-slice.js'; +import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice.js'; +import {executeSearch} from '../../features/insight-search/insight-search-actions.js'; +import {logInsightInterfaceLoad} from '../../features/insight-search/insight-search-analytics-actions.js'; +import {resultPreviewReducer as resultPreview} from '../../features/result-preview/result-preview-slice.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; +import {firstSearchExecutedSelector} from '../../features/search/search-selectors.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; import { buildEngine, CoreEngine, EngineOptions, ExternalEngineOptions, -} from '../engine'; -import {InsightThunkExtraArguments} from '../insight-thunk-extra-arguments'; -import {buildLogger} from '../logger'; -import {AdditionalCoreExtraArguments} from '../store'; -import {buildThunkExtraArguments} from '../thunk-extra-arguments'; +} from '../engine.js'; +import {InsightThunkExtraArguments} from '../insight-thunk-extra-arguments.js'; +import {buildLogger} from '../logger.js'; +import {AdditionalCoreExtraArguments} from '../store.js'; +import {buildThunkExtraArguments} from '../thunk-extra-arguments.js'; import { InsightEngineConfiguration, insightEngineConfigurationSchema, InsightEngineSearchConfigurationOptions, getSampleInsightEngineConfiguration, -} from './insight-engine-configuration'; +} from './insight-engine-configuration.js'; export type { InsightEngineConfiguration, diff --git a/packages/headless/src/app/insight-thunk-extra-arguments.ts b/packages/headless/src/app/insight-thunk-extra-arguments.ts index 87ac2ed5406..9812bf12fbe 100644 --- a/packages/headless/src/app/insight-thunk-extra-arguments.ts +++ b/packages/headless/src/app/insight-thunk-extra-arguments.ts @@ -1,5 +1,5 @@ -import {InsightAPIClient} from '../api/service/insight/insight-api-client'; -import {ClientThunkExtraArguments} from './thunk-extra-arguments'; +import {InsightAPIClient} from '../api/service/insight/insight-api-client.js'; +import {ClientThunkExtraArguments} from './thunk-extra-arguments.js'; export interface InsightThunkExtraArguments extends ClientThunkExtraArguments {} diff --git a/packages/headless/src/app/logger-middlewares.test.ts b/packages/headless/src/app/logger-middlewares.test.ts index 997b156400f..9f92893ea48 100644 --- a/packages/headless/src/app/logger-middlewares.test.ts +++ b/packages/headless/src/app/logger-middlewares.test.ts @@ -1,18 +1,18 @@ import {SchemaValidationError} from '@coveo/bueno'; import {Logger} from 'pino'; -import {serializeSchemaValidationError} from '../utils/validate-payload'; +import {serializeSchemaValidationError} from '../utils/validate-payload.js'; import { logActionErrorMiddleware, logActionMiddleware, -} from './logger-middlewares'; +} from './logger-middlewares.js'; const createMiddlewareBoilerplate = () => { - const logger = {error: jest.fn(), debug: jest.fn()} as unknown as Logger; + const logger = {error: vi.fn(), debug: vi.fn()} as unknown as Logger; const store = { - getState: jest.fn(() => {}), - dispatch: jest.fn(), + getState: vi.fn(() => {}), + dispatch: vi.fn(), }; - const next = jest.fn(); + const next = vi.fn(); return {store, next, logger}; }; @@ -37,7 +37,7 @@ const createLogActionMiddleware = () => { describe('logActionErrorMiddleware', () => { beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); it(`when a action has no error parameter it should not log an error`, () => { diff --git a/packages/headless/src/app/logger.ts b/packages/headless/src/app/logger.ts index 2d99fbd3a6d..24868463b1a 100644 --- a/packages/headless/src/app/logger.ts +++ b/packages/headless/src/app/logger.ts @@ -1,4 +1,4 @@ -import pino, {LevelWithSilent} from 'pino'; +import {pino, LevelWithSilent} from 'pino'; export type LogLevel = LevelWithSilent; diff --git a/packages/headless/src/app/recommendation-engine/recommendation-engine-configuration.ts b/packages/headless/src/app/recommendation-engine/recommendation-engine-configuration.ts index 3d25707af2c..c01dde9e850 100644 --- a/packages/headless/src/app/recommendation-engine/recommendation-engine-configuration.ts +++ b/packages/headless/src/app/recommendation-engine/recommendation-engine-configuration.ts @@ -1,11 +1,11 @@ import {Schema, StringValue} from '@coveo/bueno'; -import {PostprocessSearchResponseMiddleware} from '../../api/search/search-api-client-middleware'; -import {nonEmptyString} from '../../utils/validate-payload'; +import {PostprocessSearchResponseMiddleware} from '../../api/search/search-api-client-middleware.js'; +import {nonEmptyString} from '../../utils/validate-payload.js'; import { EngineConfiguration, engineConfigurationDefinitions, getSampleEngineConfiguration, -} from '../engine-configuration'; +} from '../engine-configuration.js'; /** * The recommendation engine configuration. diff --git a/packages/headless/src/app/recommendation-engine/recommendation-engine.test.ts b/packages/headless/src/app/recommendation-engine/recommendation-engine.test.ts index 754c05034eb..1336cb3ebf0 100644 --- a/packages/headless/src/app/recommendation-engine/recommendation-engine.test.ts +++ b/packages/headless/src/app/recommendation-engine/recommendation-engine.test.ts @@ -1,10 +1,10 @@ -import {setSearchHub} from '../../features/search-hub/search-hub-actions'; +import {setSearchHub} from '../../features/search-hub/search-hub-actions.js'; +import {getSampleRecommendationEngineConfiguration} from './recommendation-engine-configuration.js'; import { buildRecommendationEngine, RecommendationEngine, RecommendationEngineOptions, -} from './recommendation-engine'; -import {getSampleRecommendationEngineConfiguration} from './recommendation-engine-configuration'; +} from './recommendation-engine.js'; describe('buildRecommendationEngine', () => { let options: RecommendationEngineOptions; diff --git a/packages/headless/src/app/recommendation-engine/recommendation-engine.ts b/packages/headless/src/app/recommendation-engine/recommendation-engine.ts index 12bbae1d5b0..266d464940e 100644 --- a/packages/headless/src/app/recommendation-engine/recommendation-engine.ts +++ b/packages/headless/src/app/recommendation-engine/recommendation-engine.ts @@ -1,35 +1,35 @@ import {isNullOrUndefined} from '@coveo/bueno'; import {StateFromReducersMapObject} from '@reduxjs/toolkit'; import {Logger} from 'pino'; -import {NoopPreprocessRequest} from '../../api/preprocess-request'; -import {SearchAPIClient} from '../../api/search/search-api-client'; +import {NoopPreprocessRequest} from '../../api/preprocess-request.js'; import { NoopPostprocessFacetSearchResponseMiddleware, NoopPostprocessQuerySuggestResponseMiddleware, NoopPostprocessSearchResponseMiddleware, -} from '../../api/search/search-api-client-middleware'; -import {updateSearchConfiguration} from '../../features/configuration/configuration-actions'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; -import {setPipeline} from '../../features/pipeline/pipeline-actions'; -import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice'; -import {recommendationReducer as recommendation} from '../../features/recommendation/recommendation-slice'; -import {setSearchHub} from '../../features/search-hub/search-hub-actions'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; -import {RecommendationAppState} from '../../state/recommendation-app-state'; +} from '../../api/search/search-api-client-middleware.js'; +import {SearchAPIClient} from '../../api/search/search-api-client.js'; +import {updateSearchConfiguration} from '../../features/configuration/configuration-actions.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; +import {setPipeline} from '../../features/pipeline/pipeline-actions.js'; +import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice.js'; +import {recommendationReducer as recommendation} from '../../features/recommendation/recommendation-slice.js'; +import {setSearchHub} from '../../features/search-hub/search-hub-actions.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; +import {RecommendationAppState} from '../../state/recommendation-app-state.js'; import { buildEngine, CoreEngine, EngineOptions, ExternalEngineOptions, -} from '../engine'; -import {buildLogger} from '../logger'; -import {SearchThunkExtraArguments} from '../search-thunk-extra-arguments'; -import {buildThunkExtraArguments} from '../thunk-extra-arguments'; +} from '../engine.js'; +import {buildLogger} from '../logger.js'; +import {SearchThunkExtraArguments} from '../search-thunk-extra-arguments.js'; +import {buildThunkExtraArguments} from '../thunk-extra-arguments.js'; import { RecommendationEngineConfiguration, recommendationEngineConfigurationSchema, getSampleRecommendationEngineConfiguration, -} from './recommendation-engine-configuration'; +} from './recommendation-engine-configuration.js'; export type {RecommendationEngineConfiguration}; export {getSampleRecommendationEngineConfiguration}; diff --git a/packages/headless/src/app/reducer-manager.test.ts b/packages/headless/src/app/reducer-manager.test.ts index d6b732815fc..bf45fab2785 100644 --- a/packages/headless/src/app/reducer-manager.test.ts +++ b/packages/headless/src/app/reducer-manager.test.ts @@ -1,7 +1,7 @@ -import {paginationReducer as pagination} from '../features/pagination/pagination-slice'; -import {getPaginationInitialState} from '../features/pagination/pagination-state'; -import {searchReducer as search} from '../features/search/search-slice'; -import {createReducerManager} from './reducer-manager'; +import {paginationReducer as pagination} from '../features/pagination/pagination-slice.js'; +import {getPaginationInitialState} from '../features/pagination/pagination-state.js'; +import {searchReducer as search} from '../features/search/search-slice.js'; +import {createReducerManager} from './reducer-manager.js'; describe('ReducerManager', () => { it('when a key does not exist, #add stores the key-reducer pair', () => { @@ -32,7 +32,7 @@ describe('ReducerManager', () => { it('should call root reducer when configured', () => { const manager = createReducerManager({pagination}, {}); - const rootReducer = jest.fn(); + const rootReducer = vi.fn(); manager.addCrossReducer(rootReducer); manager.combinedReducer(undefined, {type: ''}); expect(rootReducer).toHaveBeenCalled(); diff --git a/packages/headless/src/app/reducer-manager.ts b/packages/headless/src/app/reducer-manager.ts index a1a9f2ae04b..070d8295fe8 100644 --- a/packages/headless/src/app/reducer-manager.ts +++ b/packages/headless/src/app/reducer-manager.ts @@ -5,7 +5,7 @@ import { AnyAction, StateFromReducersMapObject, } from '@reduxjs/toolkit'; -import {fromEntries} from '../utils/utils'; +import {fromEntries} from '../utils/utils.js'; export interface ReducerManager { combinedReducer: Reducer; diff --git a/packages/headless/src/app/renew-access-token-middleware.test.ts b/packages/headless/src/app/renew-access-token-middleware.test.ts index 7e8bb7fa08c..61834a40b83 100644 --- a/packages/headless/src/app/renew-access-token-middleware.test.ts +++ b/packages/headless/src/app/renew-access-token-middleware.test.ts @@ -1,8 +1,9 @@ import {Middleware, MiddlewareAPI} from '@reduxjs/toolkit'; -import pino, {Logger} from 'pino'; -import {updateBasicConfiguration} from '../features/configuration/configuration-actions'; -import {ExpiredTokenError} from '../utils/errors'; -import {createRenewAccessTokenMiddleware} from './renew-access-token-middleware'; +import {pino, Logger} from 'pino'; +import {Mock} from 'vitest'; +import {updateBasicConfiguration} from '../features/configuration/configuration-actions.js'; +import {ExpiredTokenError} from '../utils/errors.js'; +import {createRenewAccessTokenMiddleware} from './renew-access-token-middleware.js'; describe('createRenewAccessTokenMiddleware', () => { let logger: Logger; @@ -19,7 +20,7 @@ describe('createRenewAccessTokenMiddleware', () => { } function buildDispatch() { - return jest.fn((action: unknown) => + return vi.fn((action: unknown) => typeof action === 'function' ? action() : action ); } @@ -32,7 +33,7 @@ describe('createRenewAccessTokenMiddleware', () => { logger = pino({level: 'silent'}); store = { dispatch: buildDispatch(), - getState: jest.fn(), + getState: vi.fn(), }; }); @@ -58,7 +59,7 @@ describe('createRenewAccessTokenMiddleware', () => { const payload = buildExpiredTokenPayload(); const action = () => Promise.resolve(payload); const middleware = createRenewAccessTokenMiddleware(logger); - logger.warn = jest.fn(); + logger.warn = vi.fn(); const result = await callMiddleware(middleware, action); @@ -98,7 +99,7 @@ describe('createRenewAccessTokenMiddleware', () => { const payload = buildExpiredTokenPayload(); const action = () => Promise.resolve(payload); const renewFn = () => Promise.resolve('newToken'); - logger.warn = jest.fn(); + logger.warn = vi.fn(); const middleware = createRenewAccessTokenMiddleware(logger, renewFn); @@ -106,7 +107,7 @@ describe('createRenewAccessTokenMiddleware', () => { const promises = array.map(() => callMiddleware(middleware, action)); await Promise.all(promises); - (store.dispatch as jest.Mock).mockReset(); + (store.dispatch as Mock).mockReset(); await callMiddleware(middleware, action); }); @@ -131,14 +132,14 @@ describe('createRenewAccessTokenMiddleware', () => { const middleware = createRenewAccessTokenMiddleware(logger, renewFn); - jest.useFakeTimers(); + vi.useFakeTimers(); const array = buildArrayWithLengthEqualToNumberOfRetries(); const promises = array.map(() => callMiddleware(middleware, action)); await Promise.all(promises); - (store.dispatch as jest.Mock).mockReset(); + (store.dispatch as Mock).mockReset(); - jest.advanceTimersByTime(500); + vi.advanceTimersByTime(500); await callMiddleware(middleware, action); expect(store.dispatch).toHaveBeenCalled(); diff --git a/packages/headless/src/app/renew-access-token-middleware.ts b/packages/headless/src/app/renew-access-token-middleware.ts index aa29df61773..bc5f4c76ce9 100644 --- a/packages/headless/src/app/renew-access-token-middleware.ts +++ b/packages/headless/src/app/renew-access-token-middleware.ts @@ -1,8 +1,8 @@ import {Middleware, UnknownAction} from '@reduxjs/toolkit'; import {Logger} from 'pino'; import {debounce} from 'ts-debounce'; -import {updateBasicConfiguration} from '../features/configuration/configuration-actions'; -import {ExpiredTokenError} from '../utils/errors'; +import {updateBasicConfiguration} from '../features/configuration/configuration-actions.js'; +import {ExpiredTokenError} from '../utils/errors.js'; export function createRenewAccessTokenMiddleware( logger: Logger, diff --git a/packages/headless/src/app/search-engine/jwt-reducer.test.ts b/packages/headless/src/app/search-engine/jwt-reducer.test.ts index 3ea6db8a931..4db33a8795e 100644 --- a/packages/headless/src/app/search-engine/jwt-reducer.test.ts +++ b/packages/headless/src/app/search-engine/jwt-reducer.test.ts @@ -3,15 +3,15 @@ import { updateBasicConfiguration, updateAnalyticsConfiguration, updateSearchConfiguration, -} from '../../features/configuration/configuration-actions'; -import {getConfigurationInitialState} from '../../features/configuration/configuration-state'; -import {setPipeline} from '../../features/pipeline/pipeline-actions'; -import {getPipelineInitialState} from '../../features/pipeline/pipeline-state'; -import {setSearchHub} from '../../features/search-hub/search-hub-actions'; -import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state'; -import {SearchAppState} from '../../state/search-app-state'; -import {createMockState} from '../../test/mock-state'; -import {jwtReducer} from './jwt-reducer'; +} from '../../features/configuration/configuration-actions.js'; +import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js'; +import {setPipeline} from '../../features/pipeline/pipeline-actions.js'; +import {getPipelineInitialState} from '../../features/pipeline/pipeline-state.js'; +import {setSearchHub} from '../../features/search-hub/search-hub-actions.js'; +import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {createMockState} from '../../test/mock-state.js'; +import {jwtReducer} from './jwt-reducer.js'; function cloneDeep(value: T): T { return JSON.parse(JSON.stringify(value)); @@ -19,7 +19,7 @@ function cloneDeep(value: T): T { describe('jwt-reducer', () => { const logger = pino({level: 'silent'}); - const loggerSpy = jest.spyOn(logger, 'warn'); + const loggerSpy = vi.spyOn(logger, 'warn'); const reducer = jwtReducer(logger); const tokenPipeline = 'testing'; const tokenSearchHub = 'testing hub'; @@ -38,7 +38,7 @@ describe('jwt-reducer', () => { 'eyJhbGciOiJIUzI1NiJ9.eyJ2OCI6dHJ1ZSwib3JnYW5pemF0aW9uIjoic2VhcmNodWlzYW1wbGVzIiwidXNlcklkcyI6W3siYXV0aENvb2tpZSI6IiIsInByb3ZpZGVyIjoiRW1haWwgU2VjdXJpdHkgUHJvdmlkZXIiLCJuYW1lIjoiYXNtaXRoQGV4YW1wbGUuY29tIiwidHlwZSI6IlVzZXIiLCJpbmZvcyI6e319XSwicm9sZXMiOlsicXVlcnlFeGVjdXRvciJdLCJleHAiOjE2NDY3NjEyODUsImlhdCI6MTY0NjY3NDg4NX0.3wikhpJzJuoMeHDpokdkbIjf92DLxdsS4zRFSqt-niY'; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should handle access token not being JWT token', () => { const initialState = createMockState(); diff --git a/packages/headless/src/app/search-engine/jwt-reducer.ts b/packages/headless/src/app/search-engine/jwt-reducer.ts index 523cab76e47..21a6821fab3 100644 --- a/packages/headless/src/app/search-engine/jwt-reducer.ts +++ b/packages/headless/src/app/search-engine/jwt-reducer.ts @@ -5,13 +5,13 @@ import { updateAnalyticsConfiguration, updateBasicConfiguration, updateSearchConfiguration, -} from '../../features/configuration/configuration-actions'; -import {getConfigurationInitialState} from '../../features/configuration/configuration-state'; -import {setPipeline} from '../../features/pipeline/pipeline-actions'; -import {getPipelineInitialState} from '../../features/pipeline/pipeline-state'; -import {setSearchHub} from '../../features/search-hub/search-hub-actions'; -import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state'; -import {SearchAppState} from '../../state/search-app-state'; +} from '../../features/configuration/configuration-actions.js'; +import {getConfigurationInitialState} from '../../features/configuration/configuration-state.js'; +import {setPipeline} from '../../features/pipeline/pipeline-actions.js'; +import {getPipelineInitialState} from '../../features/pipeline/pipeline-state.js'; +import {setSearchHub} from '../../features/search-hub/search-hub-actions.js'; +import {getSearchHubInitialState} from '../../features/search-hub/search-hub-state.js'; +import {SearchAppState} from '../../state/search-app-state.js'; export interface CoveoJSONWebToken { searchHub?: string; diff --git a/packages/headless/src/app/search-engine/search-engine-configuration.ts b/packages/headless/src/app/search-engine/search-engine-configuration.ts index 56612b7735c..4e6ce41658d 100644 --- a/packages/headless/src/app/search-engine/search-engine-configuration.ts +++ b/packages/headless/src/app/search-engine/search-engine-configuration.ts @@ -3,16 +3,16 @@ import { PostprocessFacetSearchResponseMiddleware, PostprocessQuerySuggestResponseMiddleware, PostprocessSearchResponseMiddleware, -} from '../../api/search/search-api-client-middleware'; +} from '../../api/search/search-api-client-middleware.js'; import { nonEmptyString, requiredNonEmptyString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { engineConfigurationDefinitions, EngineConfiguration, getSampleEngineConfiguration, -} from '../engine-configuration'; +} from '../engine-configuration.js'; /** * The search engine configuration. diff --git a/packages/headless/src/app/search-engine/search-engine.ssr.test.ts b/packages/headless/src/app/search-engine/search-engine.ssr.test.ts index 6f2dc8dd701..12b083033d0 100644 --- a/packages/headless/src/app/search-engine/search-engine.ssr.test.ts +++ b/packages/headless/src/app/search-engine/search-engine.ssr.test.ts @@ -1,23 +1,23 @@ import {Middleware, UnknownAction} from '@reduxjs/toolkit'; -import {SearchResponseSuccess} from '../../api/search/search/search-response'; +import {SearchResponseSuccess} from '../../api/search/search/search-response.js'; import { buildController, Controller, -} from '../../controllers/controller/headless-controller'; -import {defineResultList} from '../../controllers/result-list/headless-result-list.ssr'; -import {loadPaginationActions} from '../../features/pagination/pagination-actions-loader'; -import {executeSearch} from '../../features/search/search-actions'; -import {buildMockResult} from '../../test/mock-result'; -import {ControllerDefinitionWithoutProps} from '../ssr-engine/types/common'; -import {InferHydratedState} from '../ssr-engine/types/core-engine'; -import {InferStaticState} from '../ssr-engine/types/core-engine'; -import {InferBuildResult} from '../ssr-engine/types/core-engine'; -import {getSampleSearchEngineConfiguration} from './search-engine'; +} from '../../controllers/controller/headless-controller.js'; +import {defineResultList} from '../../controllers/result-list/headless-result-list.ssr.js'; +import {loadPaginationActions} from '../../features/pagination/pagination-actions-loader.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {ControllerDefinitionWithoutProps} from '../ssr-engine/types/common.js'; +import {InferHydratedState} from '../ssr-engine/types/core-engine.js'; +import {InferStaticState} from '../ssr-engine/types/core-engine.js'; +import {InferBuildResult} from '../ssr-engine/types/core-engine.js'; +import {getSampleSearchEngineConfiguration} from './search-engine.js'; import { SSRSearchEngine, SearchEngineDefinition, defineSearchEngine, -} from './search-engine.ssr'; +} from './search-engine.ssr.js'; interface CustomEngineStateReader extends Controller { state: TState; @@ -112,10 +112,6 @@ describe('SSR', () => { ); } - function getResultsCount(state: AnyState) { - return state.controllers.resultList.state.results.length; - } - beforeEach(() => { engineDefinition = defineSearchEngine({ configuration: { @@ -147,27 +143,27 @@ describe('SSR', () => { }); it('fetches initial state of engine', async () => { - const {fetchStaticState} = engineDefinition; + const fetchStaticState = vi.mocked(engineDefinition.fetchStaticState); const staticState = await fetchStaticState(); expect(staticState).toBeTruthy(); - expect(getResultsCount(staticState)).toBe(defaultNumberOfResults); expect(getResultsPerPage(staticState)).toBe(defaultNumberOfResults); }); describe('with a static state', () => { let staticState: StaticState; beforeEach(async () => { - const {fetchStaticState} = engineDefinition; + const fetchStaticState = vi.mocked(engineDefinition.fetchStaticState); staticState = await fetchStaticState(); }); - it('hydrates engine and fetches results using hydrated engine', async () => { - const {hydrateStaticState} = engineDefinition; + it('hydrates engine', async () => { + const hydrateStaticState = vi.mocked( + engineDefinition.hydrateStaticState + ); const hydratedState = await hydrateStaticState(staticState); expect(hydratedState.engine.state.configuration.organizationId).toEqual( getSampleSearchEngineConfiguration().organizationId ); - expect(getResultsCount(hydratedState)).toBe(defaultNumberOfResults); expect(getResultsPerPage(hydratedState)).toBe(defaultNumberOfResults); }); }); @@ -176,7 +172,7 @@ describe('SSR', () => { const newNumberOfResults = 6; async function fetchBuildResultWithNewNumberOfResults() { - const {build} = engineDefinition; + const build = vi.mocked(engineDefinition.build); const buildResult = await build(); const {registerNumberOfResults} = loadPaginationActions( buildResult.engine @@ -189,33 +185,30 @@ describe('SSR', () => { } it('fetches initial state of engine from build result', async () => { - const {fetchStaticState} = engineDefinition; + const fetchStaticState = vi.mocked(engineDefinition.fetchStaticState); const staticState = await fetchStaticState.fromBuildResult({ buildResult: await fetchBuildResultWithNewNumberOfResults(), }); expect(staticState).toBeTruthy(); - expect(getResultsCount(staticState)).toBe(newNumberOfResults); expect(getResultsPerPage(staticState)).toBe(newNumberOfResults); }); describe('with the default static state', () => { let staticState: StaticState; beforeEach(async () => { - const {fetchStaticState} = engineDefinition; + const fetchStaticState = vi.mocked(engineDefinition.fetchStaticState); staticState = await fetchStaticState(); }); it('hydrates engine from build result', async () => { - const {hydrateStaticState} = engineDefinition; + const hydrateStaticState = vi.mocked( + engineDefinition.hydrateStaticState + ); const buildResult = await fetchBuildResultWithNewNumberOfResults(); const hydratedState = await hydrateStaticState.fromBuildResult({ buildResult: buildResult, searchAction: staticState.searchAction, }); - expect(getResultsCount(staticState)).toBe(defaultNumberOfResults); - expect(getResultsCount(hydratedState)).toBe( - getResultsCount(staticState) - ); expect(getResultsPerPage(hydratedState)).toBe(newNumberOfResults); }); }); diff --git a/packages/headless/src/app/search-engine/search-engine.ssr.ts b/packages/headless/src/app/search-engine/search-engine.ssr.ts index 062f9b431ce..82cce67a77d 100644 --- a/packages/headless/src/app/search-engine/search-engine.ssr.ts +++ b/packages/headless/src/app/search-engine/search-engine.ssr.ts @@ -2,30 +2,30 @@ * Utility functions to be used for Server Side Rendering. */ import {UnknownAction} from '@reduxjs/toolkit'; -import type {Controller} from '../../controllers/controller/headless-controller'; -import {LegacySearchAction} from '../../features/analytics/analytics-utils'; -import {createWaitForActionMiddleware} from '../../utils/utils'; -import {NavigatorContextProvider} from '../navigatorContextProvider'; +import type {Controller} from '../../controllers/controller/headless-controller.js'; +import {LegacySearchAction} from '../../features/analytics/analytics-utils.js'; +import {createWaitForActionMiddleware} from '../../utils/utils.js'; +import {NavigatorContextProvider} from '../navigatorContextProvider.js'; import { buildControllerDefinitions, composeFunction, createStaticState, -} from '../ssr-engine/common'; +} from '../ssr-engine/common.js'; import { ControllerDefinitionsMap, EngineStaticState, InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitions, -} from '../ssr-engine/types/common'; +} from '../ssr-engine/types/common.js'; import { EngineDefinition, EngineDefinitionOptions, -} from '../ssr-engine/types/core-engine'; +} from '../ssr-engine/types/core-engine.js'; import { SearchEngine, SearchEngineOptions, buildSearchEngine, -} from './search-engine'; +} from './search-engine.js'; /** * The SSR search engine. diff --git a/packages/headless/src/app/search-engine/search-engine.test.ts b/packages/headless/src/app/search-engine/search-engine.test.ts index dfa65366b6d..bb55efef8c2 100644 --- a/packages/headless/src/app/search-engine/search-engine.test.ts +++ b/packages/headless/src/app/search-engine/search-engine.test.ts @@ -1,11 +1,11 @@ -import {enableDebug} from '../../features/debug/debug-actions'; -import {setSearchHub} from '../../features/search-hub/search-hub-actions'; +import {enableDebug} from '../../features/debug/debug-actions.js'; +import {setSearchHub} from '../../features/search-hub/search-hub-actions.js'; +import {getSampleSearchEngineConfiguration} from './search-engine-configuration.js'; import { buildSearchEngine, SearchEngine, SearchEngineOptions, -} from './search-engine'; -import {getSampleSearchEngineConfiguration} from './search-engine-configuration'; +} from './search-engine.js'; describe('searchEngine', () => { let engine: SearchEngine; diff --git a/packages/headless/src/app/search-engine/search-engine.ts b/packages/headless/src/app/search-engine/search-engine.ts index b6fc21798c1..d54cb8ef4f8 100644 --- a/packages/headless/src/app/search-engine/search-engine.ts +++ b/packages/headless/src/app/search-engine/search-engine.ts @@ -1,14 +1,14 @@ import {StateFromReducersMapObject} from '@reduxjs/toolkit'; import {Logger} from 'pino'; -import {GeneratedAnswerAPIClient} from '../../api/generated-answer/generated-answer-client'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {NoopPreprocessRequest} from '../../api/preprocess-request'; -import {SearchAPIClient} from '../../api/search/search-api-client'; +import {GeneratedAnswerAPIClient} from '../../api/generated-answer/generated-answer-client.js'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {NoopPreprocessRequest} from '../../api/preprocess-request.js'; import { NoopPostprocessFacetSearchResponseMiddleware, NoopPostprocessQuerySuggestResponseMiddleware, NoopPostprocessSearchResponseMiddleware, -} from '../../api/search/search-api-client-middleware'; +} from '../../api/search/search-api-client-middleware.js'; +import {SearchAPIClient} from '../../api/search/search-api-client.js'; import { interfaceLoad, logInterfaceLoad, @@ -16,37 +16,37 @@ import { logSearchFromLink, omniboxFromLink, searchFromLink, -} from '../../features/analytics/analytics-actions'; -import {LegacySearchAction} from '../../features/analytics/analytics-utils'; +} from '../../features/analytics/analytics-actions.js'; +import {LegacySearchAction} from '../../features/analytics/analytics-utils.js'; import { updateSearchConfiguration, UpdateSearchConfigurationActionCreatorPayload, -} from '../../features/configuration/configuration-actions'; -import {ConfigurationState} from '../../features/configuration/configuration-state'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; -import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; -import {executeSearch} from '../../features/search/search-actions'; -import {firstSearchExecutedSelector} from '../../features/search/search-selectors'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {StandaloneSearchBoxAnalytics} from '../../features/standalone-search-box-set/standalone-search-box-set-state'; -import {SearchAppState} from '../../state/search-app-state'; +} from '../../features/configuration/configuration-actions.js'; +import {ConfigurationState} from '../../features/configuration/configuration-state.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; +import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {firstSearchExecutedSelector} from '../../features/search/search-selectors.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {StandaloneSearchBoxAnalytics} from '../../features/standalone-search-box-set/standalone-search-box-set-state.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { buildEngine, CoreEngine, EngineOptions, ExternalEngineOptions, -} from '../engine'; -import {buildLogger} from '../logger'; -import {SearchThunkExtraArguments} from '../search-thunk-extra-arguments'; -import {buildThunkExtraArguments} from '../thunk-extra-arguments'; -import {jwtReducer} from './jwt-reducer'; +} from '../engine.js'; +import {buildLogger} from '../logger.js'; +import {SearchThunkExtraArguments} from '../search-thunk-extra-arguments.js'; +import {buildThunkExtraArguments} from '../thunk-extra-arguments.js'; +import {jwtReducer} from './jwt-reducer.js'; import { SearchEngineConfiguration, SearchConfigurationOptions, searchEngineConfigurationSchema, getSampleSearchEngineConfiguration, -} from './search-engine-configuration'; +} from './search-engine-configuration.js'; export type {SearchEngineConfiguration, SearchConfigurationOptions}; export {getSampleSearchEngineConfiguration}; diff --git a/packages/headless/src/app/search-thunk-extra-arguments.ts b/packages/headless/src/app/search-thunk-extra-arguments.ts index 487a149486f..dd480581cf3 100644 --- a/packages/headless/src/app/search-thunk-extra-arguments.ts +++ b/packages/headless/src/app/search-thunk-extra-arguments.ts @@ -1,6 +1,6 @@ -import {GeneratedAnswerAPIClient} from '../api/generated-answer/generated-answer-client'; -import {SearchAPIClient} from '../api/search/search-api-client'; -import {ClientThunkExtraArguments} from './thunk-extra-arguments'; +import {GeneratedAnswerAPIClient} from '../api/generated-answer/generated-answer-client.js'; +import {SearchAPIClient} from '../api/search/search-api-client.js'; +import {ClientThunkExtraArguments} from './thunk-extra-arguments.js'; export interface SearchThunkExtraArguments extends ClientThunkExtraArguments< diff --git a/packages/headless/src/app/ssr-engine/common.ts b/packages/headless/src/app/ssr-engine/common.ts index 9901a5d8262..26b0503f1dd 100644 --- a/packages/headless/src/app/ssr-engine/common.ts +++ b/packages/headless/src/app/ssr-engine/common.ts @@ -1,7 +1,7 @@ import {UnknownAction} from '@reduxjs/toolkit'; -import {Controller} from '../../controllers/controller/headless-controller'; -import {clone, mapObject} from '../../utils/utils'; -import {CoreEngine, CoreEngineNext} from '../engine'; +import {Controller} from '../../controllers/controller/headless-controller.js'; +import {clone, mapObject} from '../../utils/utils.js'; +import {CoreEngine, CoreEngineNext} from '../engine.js'; import { ControllerDefinition, ControllerDefinitionsMap, @@ -12,7 +12,7 @@ import { InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromControllers, InferControllersMapFromDefinition, -} from './types/common'; +} from './types/common.js'; function buildControllerFromDefinition< TControllerDefinition extends ControllerDefinition, diff --git a/packages/headless/src/app/ssr-engine/types/build.ts b/packages/headless/src/app/ssr-engine/types/build.ts index 3f2733bf1fe..e7dcabba4dd 100644 --- a/packages/headless/src/app/ssr-engine/types/build.ts +++ b/packages/headless/src/app/ssr-engine/types/build.ts @@ -1,4 +1,4 @@ -import {CoreEngine, CoreEngineNext} from '../../engine'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; import { ControllersMap, ControllersPropsMap, @@ -6,7 +6,7 @@ import { EngineDefinitionControllersPropsOption, OptionsExtender, OptionsTuple, -} from './common'; +} from './common.js'; export interface BuildOptions { extend?: OptionsExtender; diff --git a/packages/headless/src/app/ssr-engine/types/common.ts b/packages/headless/src/app/ssr-engine/types/common.ts index 1789d1b86c2..831b23ec423 100644 --- a/packages/headless/src/app/ssr-engine/types/common.ts +++ b/packages/headless/src/app/ssr-engine/types/common.ts @@ -1,6 +1,6 @@ import {UnknownAction} from '@reduxjs/toolkit'; -import type {Controller} from '../../../controllers/controller/headless-controller'; -import {CoreEngine, CoreEngineNext} from '../../engine'; +import type {Controller} from '../../../controllers/controller/headless-controller.js'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; export type HasKey = T extends unknown ? K extends keyof T diff --git a/packages/headless/src/app/ssr-engine/types/core-engine.ts b/packages/headless/src/app/ssr-engine/types/core-engine.ts index ffabf9c9766..0976254ed28 100644 --- a/packages/headless/src/app/ssr-engine/types/core-engine.ts +++ b/packages/headless/src/app/ssr-engine/types/core-engine.ts @@ -1,17 +1,17 @@ import {AnyAction} from '@reduxjs/toolkit'; -import type {Controller} from '../../../controllers/controller/headless-controller'; -import {CoreEngine, CoreEngineNext} from '../../engine'; -import {EngineConfiguration} from '../../engine-configuration'; -import {NavigatorContextProvider} from '../../navigatorContextProvider'; -import {Build} from './build'; +import type {Controller} from '../../../controllers/controller/headless-controller.js'; +import {EngineConfiguration} from '../../engine-configuration.js'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; +import {NavigatorContextProvider} from '../../navigatorContextProvider.js'; +import {Build} from './build.js'; import { ControllerDefinitionsMap, InferControllerPropsMapFromDefinitions, InferControllerStaticStateMapFromDefinitions, InferControllersMapFromDefinition, -} from './common'; -import {FetchStaticState} from './fetch-static-state'; -import {HydrateStaticState} from './hydrate-static-state'; +} from './common.js'; +import {FetchStaticState} from './fetch-static-state.js'; +import {HydrateStaticState} from './hydrate-static-state.js'; export type EngineDefinitionOptions< TOptions extends {configuration: EngineConfiguration}, diff --git a/packages/headless/src/app/ssr-engine/types/fetch-static-state.ts b/packages/headless/src/app/ssr-engine/types/fetch-static-state.ts index aa566425c0f..a1f87a7781a 100644 --- a/packages/headless/src/app/ssr-engine/types/fetch-static-state.ts +++ b/packages/headless/src/app/ssr-engine/types/fetch-static-state.ts @@ -1,5 +1,5 @@ import {UnknownAction} from '@reduxjs/toolkit'; -import {CoreEngine, CoreEngineNext} from '../../engine'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; import { ControllersMap, ControllersPropsMap, @@ -7,8 +7,8 @@ import { EngineDefinitionControllersPropsOption, EngineStaticState, OptionsTuple, -} from './common'; -import {FromBuildResult} from './from-build-result'; +} from './common.js'; +import {FromBuildResult} from './from-build-result.js'; export type FetchStaticStateOptions = {}; diff --git a/packages/headless/src/app/ssr-engine/types/from-build-result.ts b/packages/headless/src/app/ssr-engine/types/from-build-result.ts index 2642fdfb6f2..5851651b59b 100644 --- a/packages/headless/src/app/ssr-engine/types/from-build-result.ts +++ b/packages/headless/src/app/ssr-engine/types/from-build-result.ts @@ -1,5 +1,5 @@ -import {CoreEngine, CoreEngineNext} from '../../engine'; -import {ControllersMap, EngineDefinitionBuildResult} from './common'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; +import {ControllersMap, EngineDefinitionBuildResult} from './common.js'; export interface FromBuildResultOptions< TEngine extends CoreEngine | CoreEngineNext, diff --git a/packages/headless/src/app/ssr-engine/types/hydrate-static-state.ts b/packages/headless/src/app/ssr-engine/types/hydrate-static-state.ts index 029c3892c1f..f7164fa0932 100644 --- a/packages/headless/src/app/ssr-engine/types/hydrate-static-state.ts +++ b/packages/headless/src/app/ssr-engine/types/hydrate-static-state.ts @@ -1,13 +1,13 @@ import {UnknownAction} from '@reduxjs/toolkit'; -import {CoreEngine, CoreEngineNext} from '../../engine'; +import {CoreEngine, CoreEngineNext} from '../../engine.js'; import { ControllersMap, ControllersPropsMap, EngineDefinitionControllersPropsOption, HydratedState, OptionsTuple, -} from './common'; -import {FromBuildResult} from './from-build-result'; +} from './common.js'; +import {FromBuildResult} from './from-build-result.js'; export interface HydrateStaticStateOptions { searchAction: TSearchAction; diff --git a/packages/headless/src/app/state-key.ts b/packages/headless/src/app/state-key.ts index 88112460b89..af6f8fa1285 100644 --- a/packages/headless/src/app/state-key.ts +++ b/packages/headless/src/app/state-key.ts @@ -1,4 +1,4 @@ -import type {CoreEngineNext} from './engine'; +import type {CoreEngineNext} from './engine.js'; const stateKeyDescription = 'coveo-headless-internal-state'; export const stateKey = Symbol.for(stateKeyDescription); diff --git a/packages/headless/src/app/store.ts b/packages/headless/src/app/store.ts index 07dbbb00d4c..be9e84f7c28 100644 --- a/packages/headless/src/app/store.ts +++ b/packages/headless/src/app/store.ts @@ -6,9 +6,9 @@ import { Middleware, Reducer, } from '@reduxjs/toolkit'; -import {logActionMiddleware} from './logger-middlewares'; -import {NavigatorContext} from './navigatorContextProvider'; -import {ThunkExtraArguments} from './thunk-extra-arguments'; +import {logActionMiddleware} from './logger-middlewares.js'; +import {NavigatorContext} from './navigatorContextProvider.js'; +import {ThunkExtraArguments} from './thunk-extra-arguments.js'; export interface CoreExtraArguments extends ThunkExtraArguments, diff --git a/packages/headless/src/app/thunk-extra-arguments.ts b/packages/headless/src/app/thunk-extra-arguments.ts index 218e7d7c3c5..54dd6173465 100644 --- a/packages/headless/src/app/thunk-extra-arguments.ts +++ b/packages/headless/src/app/thunk-extra-arguments.ts @@ -1,12 +1,12 @@ import {Relay} from '@coveo/relay'; import {AnalyticsClientSendEventHook} from 'coveo.analytics'; import {Logger} from 'pino'; -import {GeneratedAnswerAPIClient} from '../api/generated-answer/generated-answer-client'; -import {PreprocessRequest} from '../api/preprocess-request'; -import {NoopPreprocessRequest} from '../api/preprocess-request'; -import {validatePayloadAndThrow} from '../utils/validate-payload'; -import {EngineConfiguration} from './engine-configuration'; -import {NavigatorContext} from './navigatorContextProvider'; +import {GeneratedAnswerAPIClient} from '../api/generated-answer/generated-answer-client.js'; +import {PreprocessRequest} from '../api/preprocess-request.js'; +import {NoopPreprocessRequest} from '../api/preprocess-request.js'; +import {validatePayloadAndThrow} from '../utils/validate-payload.js'; +import {EngineConfiguration} from './engine-configuration.js'; +import {NavigatorContext} from './navigatorContextProvider.js'; export interface ClientThunkExtraArguments extends ThunkExtraArguments { diff --git a/packages/headless/src/app/undoable.test.ts b/packages/headless/src/app/undoable.test.ts index 01fcd518eaf..a8c998eb274 100644 --- a/packages/headless/src/app/undoable.test.ts +++ b/packages/headless/src/app/undoable.test.ts @@ -1,5 +1,5 @@ import {AnyAction, Reducer} from '@reduxjs/toolkit'; -import {makeHistory, undoable} from './undoable'; +import {makeHistory, undoable} from './undoable.js'; describe('undoable', () => { const reducer: Reducer = (state: string, action: AnyAction) => diff --git a/packages/headless/src/case-assist.index.ts b/packages/headless/src/case-assist.index.ts index 2474c371514..debea8a2b34 100644 --- a/packages/headless/src/case-assist.index.ts +++ b/packages/headless/src/case-assist.index.ts @@ -7,33 +7,33 @@ export type { CaseAssistEngine, CaseAssistEngineOptions, CaseAssistEngineConfiguration, -} from './app/case-assist-engine/case-assist-engine'; -export {buildCaseAssistEngine} from './app/case-assist-engine/case-assist-engine'; +} from './app/case-assist-engine/case-assist-engine.js'; +export {buildCaseAssistEngine} from './app/case-assist-engine/case-assist-engine.js'; -export type {CoreEngine, ExternalEngineOptions} from './app/engine'; +export type {CoreEngine, ExternalEngineOptions} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; -export type {LoggerOptions} from './app/logger'; +} from './app/engine-configuration.js'; +export type {LoggerOptions} from './app/logger.js'; -export type {LogLevel} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +export type {LogLevel} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; // Case Assist Action Loaders -export * from './features/case-input/case-input-actions-loader'; -export * from './features/case-field/case-field-actions-loader'; -export * from './features/document-suggestion/document-suggestion-actions-loader'; -export * from './features/case-assist/case-assist-analytics-actions-loader'; -export * from './features/analytics/generic-analytics-actions-loader'; +export * from './features/case-input/case-input-actions-loader.js'; +export * from './features/case-field/case-field-actions-loader.js'; +export * from './features/document-suggestion/document-suggestion-actions-loader.js'; +export * from './features/case-assist/case-assist-analytics-actions-loader.js'; +export * from './features/analytics/generic-analytics-actions-loader.js'; // Controllers export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; -export {buildController} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; +export {buildController} from './controllers/controller/headless-controller.js'; export type { CaseInputState, @@ -41,8 +41,8 @@ export type { CaseInputOptions, CaseInputProps, UpdateFetchOptions, -} from './controllers/case-input/headless-case-input'; -export {buildCaseInput} from './controllers/case-input/headless-case-input'; +} from './controllers/case-input/headless-case-input.js'; +export {buildCaseInput} from './controllers/case-input/headless-case-input.js'; export type { CaseFieldState, @@ -50,46 +50,46 @@ export type { CaseFieldOptions, CaseFieldProps, UpdateCaseFieldFetchOptions, -} from './controllers/case-field/headless-case-field'; -export {buildCaseField} from './controllers/case-field/headless-case-field'; +} from './controllers/case-field/headless-case-field.js'; +export {buildCaseField} from './controllers/case-field/headless-case-field.js'; -export type {CaseFieldSuggestion} from './features/case-field/case-field-state'; +export type {CaseFieldSuggestion} from './features/case-field/case-field-state.js'; export type { Quickview, QuickviewOptions, QuickviewProps, QuickviewState, -} from './controllers/core/quickview/headless-core-quickview'; +} from './controllers/core/quickview/headless-core-quickview.js'; export type { CaseAssistQuickviewState, CaseAssistQuickview, CaseAssistQuickviewOptions, CaseAssistQuickviewProps, -} from './controllers/quickview/case-assist-headless-quickview'; -export {buildCaseAssistQuickview as buildQuickview} from './controllers/quickview/case-assist-headless-quickview'; +} from './controllers/quickview/case-assist-headless-quickview.js'; +export {buildCaseAssistQuickview as buildQuickview} from './controllers/quickview/case-assist-headless-quickview.js'; -export type {Result} from './api/search/search/result'; -export type {Raw} from './api/search/search/raw'; -export type {HighlightKeyword} from './utils/highlight'; +export type {Result} from './api/search/search/result.js'; +export type {Raw} from './api/search/search/raw.js'; +export type {HighlightKeyword} from './utils/highlight.js'; -export type {DocumentSuggestionResponse} from './api/service/case-assist/get-document-suggestions/get-document-suggestions-response'; +export type {DocumentSuggestionResponse} from './api/service/case-assist/get-document-suggestions/get-document-suggestions-response.js'; export { getOrganizationEndpoint, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; +} from './api/platform-client.js'; export type { DocumentSuggestionList, DocumentSuggestionListState, -} from './controllers/document-suggestion-list/headless-document-suggestion-list'; -export {buildDocumentSuggestionList} from './controllers/document-suggestion-list/headless-document-suggestion-list'; +} from './controllers/document-suggestion-list/headless-document-suggestion-list.js'; +export {buildDocumentSuggestionList} from './controllers/document-suggestion-list/headless-document-suggestion-list.js'; -export {buildCaseAssistInteractiveResult as buildInteractiveResult} from './controllers/document-suggestion-list/case-assist-headless-interactive-result'; +export {buildCaseAssistInteractiveResult as buildInteractiveResult} from './controllers/document-suggestion-list/case-assist-headless-interactive-result.js'; -export {buildDocumentSuggestionList as buildDocumentSuggestion} from './controllers/document-suggestion-list/headless-document-suggestion-list'; +export {buildDocumentSuggestionList as buildDocumentSuggestion} from './controllers/document-suggestion-list/headless-document-suggestion-list.js'; export type { InteractiveResultCore, @@ -98,7 +98,7 @@ export type { CaseAssistInteractiveResult, CaseAssistInteractiveResultOptions, CaseAssistInteractiveResultProps, -} from './controllers/document-suggestion-list/case-assist-headless-interactive-result'; +} from './controllers/document-suggestion-list/case-assist-headless-interactive-result.js'; // Features -export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers'; +export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers.js'; diff --git a/packages/headless/src/commerce.index.ts b/packages/headless/src/commerce.index.ts index 16703e1b610..a1b9ace2b2c 100644 --- a/packages/headless/src/commerce.index.ts +++ b/packages/headless/src/commerce.index.ts @@ -1,12 +1,12 @@ -import * as Selectors from './selectors/commerce-selectors.index'; -import * as HighlightUtils from './utils/highlight'; +import * as Selectors from './selectors/commerce-selectors.index.js'; +import * as HighlightUtils from './utils/highlight.js'; export { getOrganizationEndpoint, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; -export {getCommerceApiBaseUrl} from './api/commerce/commerce-api-client'; -export type {HighlightKeyword} from './utils/highlight'; +} from './api/platform-client.js'; +export {getCommerceApiBaseUrl} from './api/commerce/commerce-api-client.js'; +export type {HighlightKeyword} from './utils/highlight.js'; export type {Unsubscribe, Middleware} from '@reduxjs/toolkit'; export type {Relay} from '@coveo/relay'; @@ -15,54 +15,54 @@ export type { CommerceEngine, CommerceEngineConfiguration, CommerceEngineOptions, -} from './app/commerce-engine/commerce-engine'; -export {buildCommerceEngine} from './app/commerce-engine/commerce-engine'; -export {getSampleCommerceEngineConfiguration} from './app/commerce-engine/commerce-engine-configuration'; +} from './app/commerce-engine/commerce-engine.js'; +export {buildCommerceEngine} from './app/commerce-engine/commerce-engine.js'; +export {getSampleCommerceEngineConfiguration} from './app/commerce-engine/commerce-engine-configuration.js'; export type { CoreEngine, ExternalEngineOptions, CoreEngineNext, -} from './app/engine'; +} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; -export type {LogLevel, LoggerOptions} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +} from './app/engine-configuration.js'; +export type {LogLevel, LoggerOptions} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; export type { BaseProduct, Product, ChildProduct, -} from './api/commerce/common/product'; -export type {PlatformEnvironment} from './utils/url-utils'; +} from './api/commerce/common/product.js'; +export type {PlatformEnvironment} from './utils/url-utils.js'; // Actions -export * from './features/commerce/context/context-actions-loader'; -export * from './features/commerce/search/search-actions-loader'; -export * from './features/commerce/product-listing/product-listing-actions-loader'; -export * from './features/commerce/recommendations/recommendations-actions-loader'; -export * from './features/commerce/pagination/pagination-actions-loader'; -export * from './features/commerce/product/product-actions-loaders'; -export * from './features/commerce/context/cart/cart-actions-loader'; -export * from './features/commerce/sort/sort-actions-loader'; -export * from './features/commerce/facets/core-facet/core-facet-actions-loader'; -export * from './features/commerce/facets/category-facet/category-facet-actions-loader'; -export * from './features/commerce/facets/regular-facet/regular-facet-actions-loader'; -export * from './features/commerce/facets/date-facet/date-facet-actions-loader'; -export * from './features/commerce/facets/numeric-facet/numeric-facet-actions-loader'; -export * from './features/commerce/query-set/query-set-actions-loader'; -export * from './features/commerce/query-suggest/query-suggest-actions-loader'; -export * from './features/commerce/configuration/configuration-actions-loader'; -export * from './features/commerce/query/query-actions-loader'; -export * from './features/commerce/search-parameters/search-parameters-actions-loader'; -export * from './features/commerce/product-listing-parameters/product-listing-parameters-actions-loader'; -export * from './features/commerce/triggers/triggers-actions-loader'; -export * from './features/commerce/instant-products/instant-products-actions-loader'; -export * from './features/commerce/recent-queries/recent-queries-actions-loader'; -export * from './features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader'; +export * from './features/commerce/context/context-actions-loader.js'; +export * from './features/commerce/search/search-actions-loader.js'; +export * from './features/commerce/product-listing/product-listing-actions-loader.js'; +export * from './features/commerce/recommendations/recommendations-actions-loader.js'; +export * from './features/commerce/pagination/pagination-actions-loader.js'; +export * from './features/commerce/product/product-actions-loaders.js'; +export * from './features/commerce/context/cart/cart-actions-loader.js'; +export * from './features/commerce/sort/sort-actions-loader.js'; +export * from './features/commerce/facets/core-facet/core-facet-actions-loader.js'; +export * from './features/commerce/facets/category-facet/category-facet-actions-loader.js'; +export * from './features/commerce/facets/regular-facet/regular-facet-actions-loader.js'; +export * from './features/commerce/facets/date-facet/date-facet-actions-loader.js'; +export * from './features/commerce/facets/numeric-facet/numeric-facet-actions-loader.js'; +export * from './features/commerce/query-set/query-set-actions-loader.js'; +export * from './features/commerce/query-suggest/query-suggest-actions-loader.js'; +export * from './features/commerce/configuration/configuration-actions-loader.js'; +export * from './features/commerce/query/query-actions-loader.js'; +export * from './features/commerce/search-parameters/search-parameters-actions-loader.js'; +export * from './features/commerce/product-listing-parameters/product-listing-parameters-actions-loader.js'; +export * from './features/commerce/triggers/triggers-actions-loader.js'; +export * from './features/commerce/instant-products/instant-products-actions-loader.js'; +export * from './features/commerce/recent-queries/recent-queries-actions-loader.js'; +export * from './features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader.js'; // Selectors export {Selectors}; @@ -71,8 +71,8 @@ export {Selectors}; export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; -export {buildController} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; +export {buildController} from './controllers/controller/headless-controller.js'; export type { ContextOptions, @@ -80,46 +80,46 @@ export type { ContextProps, Context, ContextState, -} from './controllers/commerce/context/headless-context'; -export {buildContext} from './controllers/commerce/context/headless-context'; +} from './controllers/commerce/context/headless-context.js'; +export {buildContext} from './controllers/commerce/context/headless-context.js'; export type { Search, SearchState, -} from './controllers/commerce/search/headless-search'; -export {buildSearch} from './controllers/commerce/search/headless-search'; +} from './controllers/commerce/search/headless-search.js'; +export {buildSearch} from './controllers/commerce/search/headless-search.js'; export type { ProductListing, ProductListingState, -} from './controllers/commerce/product-listing/headless-product-listing'; -export {buildProductListing} from './controllers/commerce/product-listing/headless-product-listing'; +} from './controllers/commerce/product-listing/headless-product-listing.js'; +export {buildProductListing} from './controllers/commerce/product-listing/headless-product-listing.js'; export type { Recommendations, RecommendationsState, RecommendationsProps, RecommendationsOptions, -} from './controllers/commerce/recommendations/headless-recommendations'; -export {buildRecommendations} from './controllers/commerce/recommendations/headless-recommendations'; +} from './controllers/commerce/recommendations/headless-recommendations.js'; +export {buildRecommendations} from './controllers/commerce/recommendations/headless-recommendations.js'; export type { Pagination, PaginationState, PaginationProps, PaginationOptions, -} from './controllers/commerce/core/pagination/headless-core-commerce-pagination'; +} from './controllers/commerce/core/pagination/headless-core-commerce-pagination.js'; export type { InteractiveProduct, InteractiveProductOptions, InteractiveProductProps, -} from './controllers/commerce/core/interactive-product/headless-core-interactive-product'; +} from './controllers/commerce/core/interactive-product/headless-core-interactive-product.js'; -export type {InteractiveResultCore} from './controllers/core/interactive-result/headless-core-interactive-result'; +export type {InteractiveResultCore} from './controllers/core/interactive-result/headless-core-interactive-result.js'; -export type {ProductView} from './controllers/commerce/product-view/headless-product-view'; -export {buildProductView} from './controllers/commerce/product-view/headless-product-view'; +export type {ProductView} from './controllers/commerce/product-view/headless-product-view.js'; +export {buildProductView} from './controllers/commerce/product-view/headless-product-view.js'; export type { CartInitialState, @@ -127,17 +127,17 @@ export type { CartProps, Cart, CartState, -} from './controllers/commerce/context/cart/headless-cart'; -export type {Transaction} from './features/commerce/context/cart/cart-selector'; -export type {CartItemWithMetadata} from './features/commerce/context/cart/cart-state'; -export type {CartItemParam} from './api/commerce/commerce-api-params'; -export {buildCart} from './controllers/commerce/context/cart/headless-cart'; +} from './controllers/commerce/context/cart/headless-cart.js'; +export type {Transaction} from './features/commerce/context/cart/cart-selector.js'; +export type {CartItemWithMetadata} from './features/commerce/context/cart/cart-state.js'; +export type {CartItemParam} from './api/commerce/commerce-api-params.js'; +export {buildCart} from './controllers/commerce/context/cart/headless-cart.js'; export type { BaseSolutionTypeSubControllers, SearchAndListingSubControllers, SearchSubControllers, -} from './controllers/commerce/core/sub-controller/headless-sub-controller'; +} from './controllers/commerce/core/sub-controller/headless-sub-controller.js'; export type { SortByRelevance, @@ -148,32 +148,32 @@ export type { SortInitialState, Sort, SortState, -} from './controllers/commerce/core/sort/headless-core-commerce-sort'; +} from './controllers/commerce/core/sort/headless-core-commerce-sort.js'; export { buildRelevanceSortCriterion, buildFieldsSortCriterion, SortBy, SortDirection, -} from './controllers/commerce/core/sort/headless-core-commerce-sort'; +} from './controllers/commerce/core/sort/headless-core-commerce-sort.js'; export type { CategoryFacet, CategoryFacetState, -} from './controllers/commerce/core/facets/category/headless-commerce-category-facet'; +} from './controllers/commerce/core/facets/category/headless-commerce-category-facet.js'; export type { RegularFacet, RegularFacetState, -} from './controllers/commerce/core/facets/regular/headless-commerce-regular-facet'; +} from './controllers/commerce/core/facets/regular/headless-commerce-regular-facet.js'; export type { NumericFacet, NumericFacetState, -} from './controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet'; -export {buildDateRange} from './controllers/commerce/core/facets/date/headless-commerce-date-facet'; +} from './controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.js'; +export {buildDateRange} from './controllers/commerce/core/facets/date/headless-commerce-date-facet.js'; export type { DateFacet, DateFacetState, -} from './controllers/commerce/core/facets/date/headless-commerce-date-facet'; -export type {DateFilterRange} from './controllers/core/facets/range-facet/date-facet/headless-core-date-filter'; +} from './controllers/commerce/core/facets/date/headless-commerce-date-facet.js'; +export type {DateFilterRange} from './controllers/core/facets/range-facet/date-facet/headless-core-date-filter.js'; export type { FacetType, FacetValueRequest, @@ -184,52 +184,52 @@ export type { DateFacetValue, CategoryFacetValueRequest, CategoryFacetValue, -} from './controllers/commerce/core/facets/headless-core-commerce-facet'; -export type {FacetGenerator} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator'; +} from './controllers/commerce/core/facets/headless-core-commerce-facet.js'; +export type {FacetGenerator} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator.js'; -export type {FacetGeneratorState} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator'; +export type {FacetGeneratorState} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator.js'; export type { RegularFacetSearch, RegularFacetSearchState, -} from './controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search'; -export type {SpecificFacetSearchResult as RegularFacetSearchResult} from './api/search/facet-search/specific-facet-search/specific-facet-search-response'; +} from './controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.js'; +export type {SpecificFacetSearchResult as RegularFacetSearchResult} from './api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; export type { CategoryFacetSearch, CategoryFacetSearchState, -} from './controllers/commerce/core/facets/category/headless-commerce-category-facet-search'; -export type {CategoryFacetSearchResult} from './api/search/facet-search/category-facet-search/category-facet-search-response'; +} from './controllers/commerce/core/facets/category/headless-commerce-category-facet-search.js'; +export type {CategoryFacetSearchResult} from './api/search/facet-search/category-facet-search/category-facet-search-response.js'; -export {buildSearchBox} from './controllers/commerce/search-box/headless-search-box'; +export {buildSearchBox} from './controllers/commerce/search-box/headless-search-box.js'; export type { SearchBox, SearchBoxState, SearchBoxProps, Suggestion, SearchBoxOptions, -} from './controllers/commerce/search-box/headless-search-box'; +} from './controllers/commerce/search-box/headless-search-box.js'; -export {buildRecentQueriesList} from './controllers/commerce/recent-queries-list/headless-recent-queries-list'; +export {buildRecentQueriesList} from './controllers/commerce/recent-queries-list/headless-recent-queries-list.js'; export type { RecentQueriesList, RecentQueriesListOptions, RecentQueriesListProps, RecentQueriesListInitialState, RecentQueriesState, -} from './controllers/commerce/recent-queries-list/headless-recent-queries-list'; +} from './controllers/commerce/recent-queries-list/headless-recent-queries-list.js'; -export {buildInstantProducts} from './controllers/commerce/instant-products/headless-instant-products'; +export {buildInstantProducts} from './controllers/commerce/instant-products/headless-instant-products.js'; export type { InstantProducts, InstantProductsState, InstantProductsOptions, InstantProductsProps, -} from './controllers/commerce/instant-products/headless-instant-products'; -export {buildStandaloneSearchBox} from './controllers/commerce/standalone-search-box/headless-standalone-search-box'; +} from './controllers/commerce/instant-products/headless-instant-products.js'; +export {buildStandaloneSearchBox} from './controllers/commerce/standalone-search-box/headless-standalone-search-box.js'; export type { StandaloneSearchBox, StandaloneSearchBoxState, -} from './controllers/commerce/standalone-search-box/headless-standalone-search-box'; +} from './controllers/commerce/standalone-search-box/headless-standalone-search-box.js'; export type { StandaloneSearchBoxProps, StandaloneSearchBoxOptions, @@ -240,15 +240,15 @@ export type { UrlManagerInitialState, UrlManagerState, UrlManager, -} from './controllers/commerce/core/url-manager/headless-core-url-manager'; +} from './controllers/commerce/core/url-manager/headless-core-url-manager.js'; export type {Template} from './features/templates/templates-manager.ts'; export type { ProductTemplate, ProductTemplateCondition, ProductTemplatesManager, -} from './features/commerce/product-templates/product-templates-manager'; -export {buildProductTemplatesManager} from './features/commerce/product-templates/product-templates-manager'; +} from './features/commerce/product-templates/product-templates-manager.js'; +export {buildProductTemplatesManager} from './features/commerce/product-templates/product-templates-manager.js'; export type { BreadcrumbManager, @@ -256,67 +256,67 @@ export type { BreadcrumbValue, DeselectableValue, BreadcrumbManagerState, -} from './controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager'; +} from './controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.js'; -export type {SearchSummaryState} from './controllers/commerce/search/summary/headless-search-summary'; -export type {ProductListingSummaryState} from './controllers/commerce/product-listing/summary/headless-product-listing-summary'; -export type {RecommendationsSummaryState} from './controllers/commerce/recommendations/summary/headless-recommendations-summary'; -export type {Summary} from './controllers/commerce/core/summary/headless-core-summary'; +export type {SearchSummaryState} from './controllers/commerce/search/summary/headless-search-summary.js'; +export type {ProductListingSummaryState} from './controllers/commerce/product-listing/summary/headless-product-listing-summary.js'; +export type {RecommendationsSummaryState} from './controllers/commerce/recommendations/summary/headless-recommendations-summary.js'; +export type {Summary} from './controllers/commerce/core/summary/headless-core-summary.js'; export type { DidYouMean, DidYouMeanState, QueryCorrection, WordCorrection, -} from './controllers/commerce/search/did-you-mean/headless-did-you-mean'; -export {ProductTemplatesHelpers} from './features/commerce/product-templates/product-templates-helpers'; +} from './controllers/commerce/search/did-you-mean/headless-did-you-mean.js'; +export {ProductTemplatesHelpers} from './features/commerce/product-templates/product-templates-helpers.js'; export type { NotifyTrigger, NotifyTriggerState, -} from './controllers/core/triggers/headless-core-notify-trigger'; -export {buildNotifyTrigger} from './controllers/commerce/triggers/headless-notify-trigger'; +} from './controllers/core/triggers/headless-core-notify-trigger.js'; +export {buildNotifyTrigger} from './controllers/commerce/triggers/headless-notify-trigger.js'; export type { RedirectionTrigger, RedirectionTriggerState, -} from './controllers/core/triggers/headless-core-redirection-trigger'; +} from './controllers/core/triggers/headless-core-redirection-trigger.js'; -export {buildRedirectionTrigger} from './controllers/commerce/triggers/headless-redirection-trigger'; +export {buildRedirectionTrigger} from './controllers/commerce/triggers/headless-redirection-trigger.js'; export type { QueryTrigger, QueryTriggerState, -} from './controllers/core/triggers/headless-core-query-trigger'; -export {buildQueryTrigger} from './controllers/commerce/triggers/headless-query-trigger'; +} from './controllers/core/triggers/headless-core-query-trigger.js'; +export {buildQueryTrigger} from './controllers/commerce/triggers/headless-query-trigger.js'; export type { FieldSuggestions, FieldSuggestionsState, -} from './controllers/commerce/field-suggestions/headless-field-suggestions'; +} from './controllers/commerce/field-suggestions/headless-field-suggestions.js'; export type { CategoryFieldSuggestions, CategoryFieldSuggestionsState, -} from './controllers/commerce/field-suggestions/headless-category-field-suggestions'; +} from './controllers/commerce/field-suggestions/headless-category-field-suggestions.js'; export type { FieldSuggestionsGenerator, GeneratedFieldSuggestionsControllers, -} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator'; +} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator.js'; export type {FieldSuggestionsFacet} from './features/commerce/facets/field-suggestions-order/field-suggestions-order-state.ts'; -export {buildFieldSuggestionsGenerator} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator'; +export {buildFieldSuggestionsGenerator} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator.js'; export type { ParameterManager, ParameterManagerState, ParameterManagerProps, ParameterManagerInitialState, -} from './controllers/commerce/core/parameter-manager/headless-core-parameter-manager'; -export type {Parameters} from './features/commerce/parameters/parameters-actions'; -export type {SearchParameters} from './features/search-parameters/search-parameter-actions'; +} from './controllers/commerce/core/parameter-manager/headless-core-parameter-manager.js'; +export type {Parameters} from './features/commerce/parameters/parameters-actions.js'; +export type {SearchParameters} from './features/search-parameters/search-parameter-actions.js'; // Types & Helpers export {HighlightUtils}; export { deserializeRelativeDate, validateRelativeDate, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; diff --git a/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.ts b/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.ts index 76693346147..39e9a8bef01 100644 --- a/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.ts +++ b/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.ts @@ -1,11 +1,11 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { BreadcrumbManager, buildBreadcrumbManager, -} from './headless-breadcrumb-manager'; +} from './headless-breadcrumb-manager.js'; -export * from './headless-breadcrumb-manager'; +export * from './headless-breadcrumb-manager.js'; export interface BreadcrumbManagerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.test.ts b/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.test.ts index c135d109b17..667153fcd58 100644 --- a/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.test.ts +++ b/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.test.ts @@ -1,60 +1,60 @@ -import {configuration} from '../../app/common-reducers'; -import {deselectAllBreadcrumbs} from '../../features/breadcrumb/breadcrumb-actions'; -import {toggleSelectAutomaticFacetValue} from '../../features/facets/automatic-facet-set/automatic-facet-set-actions'; -import {deselectAllCategoryFacetValues} from '../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../features/facets/category-facet-set/category-facet-set-slice'; -import {CategoryFacetValue} from '../../features/facets/category-facet-set/interfaces/response'; +import {configuration} from '../../app/common-reducers.js'; +import {deselectAllBreadcrumbs} from '../../features/breadcrumb/breadcrumb-actions.js'; +import {toggleSelectAutomaticFacetValue} from '../../features/facets/automatic-facet-set/automatic-facet-set-actions.js'; +import {deselectAllCategoryFacetValues} from '../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {CategoryFacetValue} from '../../features/facets/category-facet-set/interfaces/response.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, updateFreezeCurrentValues, -} from '../../features/facets/facet-set/facet-set-actions'; -import {facetSetReducer as facetSet} from '../../features/facets/facet-set/facet-set-slice'; -import {FacetValue} from '../../features/facets/facet-set/interfaces/response'; +} from '../../features/facets/facet-set/facet-set-actions.js'; +import {facetSetReducer as facetSet} from '../../features/facets/facet-set/facet-set-slice.js'; +import {FacetValue} from '../../features/facets/facet-set/interfaces/response.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {NumericFacetValue} from '../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +} from '../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {NumericFacetValue} from '../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {executeSearch} from '../../features/search/search-actions'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {getSearchInitialState} from '../../features/search/search-state'; +} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {getSearchInitialState} from '../../features/search/search-state.js'; import { toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from '../../features/static-filter-set/static-filter-set-actions'; -import {SearchAppState} from '../../state/search-app-state'; -import {buildMockAutomaticFacetResponse} from '../../test/mock-automatic-facet-response'; -import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice'; -import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../test/mock-category-facet-response'; -import {buildMockCategoryFacetValue} from '../../test/mock-category-facet-value'; -import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request'; -import {buildMockDateFacetResponse} from '../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../test/mock-date-facet-value'; +} from '../../features/static-filter-set/static-filter-set-actions.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {buildMockAutomaticFacetResponse} from '../../test/mock-automatic-facet-response.js'; +import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice.js'; +import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetValue} from '../../test/mock-category-facet-value.js'; +import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request.js'; +import {buildMockDateFacetResponse} from '../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../test/mock-facet-value'; -import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetResponse} from '../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../test/mock-numeric-facet-value'; -import {createMockState} from '../../test/mock-state'; -import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value'; +} from '../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../test/mock-facet-value.js'; +import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetResponse} from '../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value.js'; import { AutomaticFacetBreadcrumb, BreadcrumbManager, @@ -63,24 +63,20 @@ import { FacetBreadcrumb, NumericFacetBreadcrumb, buildBreadcrumbManager, -} from './headless-breadcrumb-manager'; +} from './headless-breadcrumb-manager.js'; -jest.mock('../../features/breadcrumb/breadcrumb-actions'); -jest.mock( +vi.mock('../../features/breadcrumb/breadcrumb-actions'); +vi.mock( '../../features/facets/automatic-facet-set/automatic-facet-set-actions' ); -jest.mock( - '../../features/facets/category-facet-set/category-facet-set-actions' -); -jest.mock('../../features/facets/facet-set/facet-set-actions'); -jest.mock( - '../../features/facets/range-facets/date-facet-set/date-facet-actions' -); -jest.mock( +vi.mock('../../features/facets/category-facet-set/category-facet-set-actions'); +vi.mock('../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../features/facets/range-facets/date-facet-set/date-facet-actions'); +vi.mock( '../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); -jest.mock('../../features/search/search-actions'); -jest.mock('../../features/static-filter-set/static-filter-set-actions'); +vi.mock('../../features/search/search-actions'); +vi.mock('../../features/static-filter-set/static-filter-set-actions'); describe('headless breadcrumb manager', () => { const facetId = 'abc123'; diff --git a/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ts b/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ts index f2115c99401..9df403e86ce 100644 --- a/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ts +++ b/packages/headless/src/controllers/breadcrumb-manager/headless-breadcrumb-manager.ts @@ -1,62 +1,62 @@ -import {configuration} from '../../app/common-reducers'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {toggleSelectAutomaticFacetValue} from '../../features/facets/automatic-facet-set/automatic-facet-set-actions'; -import {AutomaticFacetResponse} from '../../features/facets/automatic-facet-set/interfaces/response'; -import {deselectAllCategoryFacetValues} from '../../features/facets/category-facet-set/category-facet-set-actions'; +import {configuration} from '../../app/common-reducers.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {toggleSelectAutomaticFacetValue} from '../../features/facets/automatic-facet-set/automatic-facet-set-actions.js'; +import {AutomaticFacetResponse} from '../../features/facets/automatic-facet-set/interfaces/response.js'; +import {deselectAllCategoryFacetValues} from '../../features/facets/category-facet-set/category-facet-set-actions.js'; import { categoryBreadcrumbFacet, logCategoryFacetBreadcrumb, -} from '../../features/facets/category-facet-set/category-facet-set-analytics-actions'; -import {categoryFacetResponseSelectedValuesSelector} from '../../features/facets/category-facet-set/category-facet-set-selectors'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../features/facets/category-facet-set/category-facet-set-slice'; +} from '../../features/facets/category-facet-set/category-facet-set-analytics-actions.js'; +import {categoryFacetResponseSelectedValuesSelector} from '../../features/facets/category-facet-set/category-facet-set-selectors.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../features/facets/category-facet-set/category-facet-set-slice.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, updateFreezeCurrentValues, -} from '../../features/facets/facet-set/facet-set-actions'; +} from '../../features/facets/facet-set/facet-set-actions.js'; import { breadcrumbFacet, logFacetBreadcrumb, -} from '../../features/facets/facet-set/facet-set-analytics-actions'; -import {facetResponseActiveValuesSelector} from '../../features/facets/facet-set/facet-set-selectors'; -import {facetSetReducer as facetSet} from '../../features/facets/facet-set/facet-set-slice'; -import {FacetSlice} from '../../features/facets/facet-set/facet-set-state'; -import {FacetValue} from '../../features/facets/facet-set/interfaces/response'; -import {logClearBreadcrumbs} from '../../features/facets/generic/facet-generic-analytics-actions'; +} from '../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {facetResponseActiveValuesSelector} from '../../features/facets/facet-set/facet-set-selectors.js'; +import {facetSetReducer as facetSet} from '../../features/facets/facet-set/facet-set-slice.js'; +import {FacetSlice} from '../../features/facets/facet-set/facet-set-state.js'; +import {FacetValue} from '../../features/facets/facet-set/interfaces/response.js'; +import {logClearBreadcrumbs} from '../../features/facets/generic/facet-generic-analytics-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../../features/facets/range-facets/date-facet-set/date-facet-actions'; +} from '../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; import { dateBreadcrumbFacet, logDateFacetBreadcrumb, -} from '../../features/facets/range-facets/date-facet-set/date-facet-analytics-actions'; -import {dateFacetActiveValuesSelector} from '../../features/facets/range-facets/date-facet-set/date-facet-selectors'; -import {dateFacetSetReducer as dateFacetSet} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetSlice} from '../../features/facets/range-facets/date-facet-set/date-facet-set-state'; +} from '../../features/facets/range-facets/date-facet-set/date-facet-analytics-actions.js'; +import {dateFacetActiveValuesSelector} from '../../features/facets/range-facets/date-facet-set/date-facet-selectors.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetSlice} from '../../features/facets/range-facets/date-facet-set/date-facet-set-state.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; +} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; import { logNumericFacetBreadcrumb, numericBreadcrumbFacet, -} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions'; -import {numericFacetActiveValuesSelector} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-selectors'; -import {numericFacetSetReducer as numericFacetSet} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {NumericFacetSlice} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-state'; -import {executeSearch} from '../../features/search/search-actions'; -import {searchReducer as search} from '../../features/search/search-slice'; +} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.js'; +import {numericFacetActiveValuesSelector} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {NumericFacetSlice} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; import { logStaticFilterDeselect, staticFilterDeselect, toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from '../../features/static-filter-set/static-filter-set-actions'; +} from '../../features/static-filter-set/static-filter-set-actions.js'; import { StaticFilterSlice, StaticFilterValue, -} from '../../features/static-filter-set/static-filter-set-state'; +} from '../../features/static-filter-set/static-filter-set-state.js'; import { CategoryFacetSection, ConfigurationSection, @@ -64,8 +64,8 @@ import { FacetSection, NumericFacetSection, SearchSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { Breadcrumb, BreadcrumbManager as CoreBreadcrumbManager, @@ -80,7 +80,7 @@ import { GetBreadcrumbsConfiguration, NumericFacetBreadcrumb, StaticFilterBreadcrumb, -} from '../core/breadcrumb-manager/headless-core-breadcrumb-manager'; +} from '../core/breadcrumb-manager/headless-core-breadcrumb-manager.js'; export type { NumericFacetBreadcrumb, diff --git a/packages/headless/src/controllers/case-field/headless-case-field.test.ts b/packages/headless/src/controllers/case-field/headless-case-field.test.ts index 2f934f4e402..eea01d13b68 100644 --- a/packages/headless/src/controllers/case-field/headless-case-field.test.ts +++ b/packages/headless/src/controllers/case-field/headless-case-field.test.ts @@ -1,33 +1,33 @@ -import {configuration} from '../../app/common-reducers'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; import { logClassificationClick, logUpdateCaseField, -} from '../../features/case-assist/case-assist-analytics-actions'; +} from '../../features/case-assist/case-assist-analytics-actions.js'; import { fetchCaseClassifications, registerCaseField, updateCaseField, -} from '../../features/case-field/case-field-actions'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; -import {getCaseFieldInitialState} from '../../features/case-field/case-field-state'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; -import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; -import {buildMockCaseAssistState} from '../../test/mock-case-assist-state'; +} from '../../features/case-field/case-field-actions.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; +import {getCaseFieldInitialState} from '../../features/case-field/case-field-state.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; +import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; +import {buildMockCaseAssistState} from '../../test/mock-case-assist-state.js'; import { buildMockCaseAssistEngine, MockedCaseAssistEngine, -} from '../../test/mock-engine-v2'; +} from '../../test/mock-engine-v2.js'; import { buildCaseField, CaseField, CaseFieldOptions, -} from './headless-case-field'; +} from './headless-case-field.js'; -jest.mock('../../features/document-suggestion/document-suggestion-actions'); -jest.mock('../../features/case-field/case-field-actions'); -jest.mock('../../features/case-assist/case-assist-analytics-actions'); +vi.mock('../../features/document-suggestion/document-suggestion-actions'); +vi.mock('../../features/case-field/case-field-actions'); +vi.mock('../../features/case-assist/case-assist-analytics-actions'); describe('Case Field', () => { let engine: MockedCaseAssistEngine; @@ -45,7 +45,7 @@ describe('Case Field', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { field: testFieldName, }; @@ -64,7 +64,7 @@ describe('Case Field', () => { }); it('dispatch #registerCaseField on init if the field was not already registered', () => { - const mockedRegisterCaseField = jest.mocked(registerCaseField); + const mockedRegisterCaseField = vi.mocked(registerCaseField); initCaseField(); @@ -78,8 +78,8 @@ describe('Case Field', () => { }); it('does not dispatch #registerCaseField on init if the field is already registered', () => { - jest.resetAllMocks(); - const mockedRegisterCaseField = jest.mocked(registerCaseField); + vi.resetAllMocks(); + const mockedRegisterCaseField = vi.mocked(registerCaseField); const initialState = buildMockCaseAssistState(); initialState.caseField.fields[testFieldName] = {suggestions: [], value: ''}; @@ -116,7 +116,7 @@ describe('Case Field', () => { }); it('dispatches a #logClassificationClick action when value is a suggestion', () => { - const mockedLogClassificationClick = jest.mocked(logClassificationClick); + const mockedLogClassificationClick = vi.mocked(logClassificationClick); field.update('suggested value'); @@ -129,7 +129,7 @@ describe('Case Field', () => { }); it('does not dispatch a #logClassificationClick action when value is not a suggestion', () => { - const mockedLogClassificationClick = jest.mocked(logClassificationClick); + const mockedLogClassificationClick = vi.mocked(logClassificationClick); field.update(testValue); @@ -137,7 +137,7 @@ describe('Case Field', () => { }); it('dispatches a #updateCaseField action with the passed field value', () => { - const mockedUpdateCaseField = jest.mocked(updateCaseField); + const mockedUpdateCaseField = vi.mocked(updateCaseField); field.update(testValue); @@ -151,7 +151,7 @@ describe('Case Field', () => { }); it('dispatches a #logUpdateCaseField analytics action', () => { - const mockedLogUpdateCaseField = jest.mocked(logUpdateCaseField); + const mockedLogUpdateCaseField = vi.mocked(logUpdateCaseField); field.update(testValue); @@ -162,7 +162,7 @@ describe('Case Field', () => { }); it('does not dispatch a #logCaseFieldUpdate analytics action when the autoSelection parameter is set to true', () => { - const mockedLogUpdateCaseField = jest.mocked(logUpdateCaseField); + const mockedLogUpdateCaseField = vi.mocked(logUpdateCaseField); field.update(testValue, undefined, true); @@ -170,7 +170,7 @@ describe('Case Field', () => { }); it('dispatches a #fetchCaseClassifications action when required', () => { - const mockedFetchCaseClassifications = jest.mocked( + const mockedFetchCaseClassifications = vi.mocked( fetchCaseClassifications ); @@ -185,7 +185,7 @@ describe('Case Field', () => { }); it('dispatches a #fetchDocumentSuggestions action when required', () => { - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); @@ -200,10 +200,10 @@ describe('Case Field', () => { }); it('dispatches both #fetchCaseClassifications and #fetchDocumentSuggestions when required', () => { - const mockedFetchCaseClassifications = jest.mocked( + const mockedFetchCaseClassifications = vi.mocked( fetchCaseClassifications ); - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); @@ -223,10 +223,10 @@ describe('Case Field', () => { }); it('does not dispatch #fetchCaseClassifications nor #fetchDocumentSuggestions when not required', () => { - const mockedFetchCaseClassifications = jest.mocked( + const mockedFetchCaseClassifications = vi.mocked( fetchCaseClassifications ); - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); diff --git a/packages/headless/src/controllers/case-field/headless-case-field.ts b/packages/headless/src/controllers/case-field/headless-case-field.ts index 6f9d86627a2..e7d5f72524d 100644 --- a/packages/headless/src/controllers/case-field/headless-case-field.ts +++ b/packages/headless/src/controllers/case-field/headless-case-field.ts @@ -1,36 +1,39 @@ import {Schema} from '@coveo/bueno'; -import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {configuration} from '../../app/common-reducers'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; +import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client.js'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {configuration} from '../../app/common-reducers.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; import { logAutoSelectCaseField, logClassificationClick, logUpdateCaseField, -} from '../../features/case-assist/case-assist-analytics-actions'; +} from '../../features/case-assist/case-assist-analytics-actions.js'; import { fetchCaseClassifications, registerCaseField, updateCaseField, -} from '../../features/case-field/case-field-actions'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; -import {CaseFieldSuggestion} from '../../features/case-field/case-field-state'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; -import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; +} from '../../features/case-field/case-field-actions.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; +import {CaseFieldSuggestion} from '../../features/case-field/case-field-state.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; +import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; import { CaseAssistConfigurationSection, CaseFieldSection, CaseInputSection, ConfigurationSection, DocumentSuggestionSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { requiredNonEmptyString, validateOptions, -} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; export interface CaseFieldProps { options?: CaseFieldOptions; diff --git a/packages/headless/src/controllers/case-input/headless-case-input.test.ts b/packages/headless/src/controllers/case-input/headless-case-input.test.ts index 1f327936052..85c278d5d66 100644 --- a/packages/headless/src/controllers/case-input/headless-case-input.test.ts +++ b/packages/headless/src/controllers/case-input/headless-case-input.test.ts @@ -1,27 +1,27 @@ -import {configuration} from '../../app/common-reducers'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; -import {logUpdateCaseField} from '../../features/case-assist/case-assist-analytics-actions'; -import {fetchCaseClassifications} from '../../features/case-field/case-field-actions'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; -import {updateCaseInput} from '../../features/case-input/case-input-actions'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; -import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; -import {buildMockCaseAssistState} from '../../test/mock-case-assist-state'; +import {configuration} from '../../app/common-reducers.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; +import {logUpdateCaseField} from '../../features/case-assist/case-assist-analytics-actions.js'; +import {fetchCaseClassifications} from '../../features/case-field/case-field-actions.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; +import {updateCaseInput} from '../../features/case-input/case-input-actions.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; +import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; +import {buildMockCaseAssistState} from '../../test/mock-case-assist-state.js'; import { buildMockCaseAssistEngine, MockedCaseAssistEngine, -} from '../../test/mock-engine-v2'; +} from '../../test/mock-engine-v2.js'; import { CaseInput, CaseInputOptions, buildCaseInput, -} from './headless-case-input'; +} from './headless-case-input.js'; -jest.mock('../../features/case-input/case-input-actions'); -jest.mock('../../features/case-assist/case-assist-analytics-actions'); -jest.mock('../../features/case-field/case-field-actions'); -jest.mock('../../features/document-suggestion/document-suggestion-actions'); +vi.mock('../../features/case-input/case-input-actions'); +vi.mock('../../features/case-assist/case-assist-analytics-actions'); +vi.mock('../../features/case-field/case-field-actions'); +vi.mock('../../features/document-suggestion/document-suggestion-actions'); describe('Case Input', () => { let engine: MockedCaseAssistEngine; @@ -39,7 +39,7 @@ describe('Case Input', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { field: testFieldName, }; @@ -58,7 +58,7 @@ describe('Case Input', () => { }); it('dispatch #updateCaseInput on init if the field was not already registered', () => { - const mockedUpdateCaseInput = jest.mocked(updateCaseInput); + const mockedUpdateCaseInput = vi.mocked(updateCaseInput); expect(mockedUpdateCaseInput).toHaveBeenCalledWith({ fieldName: testFieldName, @@ -70,8 +70,8 @@ describe('Case Input', () => { }); it('do not dispatch #updateCaseInput on init if the field was already registered', () => { - jest.resetAllMocks(); - const mockedUpdateCaseInput = jest.mocked(updateCaseInput); + vi.resetAllMocks(); + const mockedUpdateCaseInput = vi.mocked(updateCaseInput); initEngine({ ...buildMockCaseAssistState(), caseInput: { @@ -97,8 +97,8 @@ describe('Case Input', () => { const testValue = 'test input value'; it('dispatches a #updateCaseInput action with the passed input value', () => { - jest.resetAllMocks(); - const mockedUpdateCaseInput = jest.mocked(updateCaseInput); + vi.resetAllMocks(); + const mockedUpdateCaseInput = vi.mocked(updateCaseInput); input.update(testValue); @@ -112,7 +112,7 @@ describe('Case Input', () => { }); it('dispatches a #logUpdateCaseField analytics action', () => { - const mockedlogUpdateCaseField = jest.mocked(logUpdateCaseField); + const mockedlogUpdateCaseField = vi.mocked(logUpdateCaseField); input.update(testValue); @@ -122,7 +122,7 @@ describe('Case Input', () => { }); it('dispatches a #fetchCaseClassifications action when required', () => { - const mockedFetchCaseClassifications = jest.mocked( + const mockedFetchCaseClassifications = vi.mocked( fetchCaseClassifications ); @@ -137,7 +137,7 @@ describe('Case Input', () => { }); it('dispatches a #fetchDocumentSuggestions action when required', () => { - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); @@ -152,10 +152,10 @@ describe('Case Input', () => { }); it('dispatches both #fetchCaseClassifications and #fetchDocumentSuggestions when required', () => { - const mockedFetchCaseClassifications = jest.mocked( + const mockedFetchCaseClassifications = vi.mocked( fetchCaseClassifications ); - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); @@ -175,10 +175,10 @@ describe('Case Input', () => { }); it('does not dispatch #fetchCaseClassifications nor #fetchDocumentSuggestions when not required', () => { - const mockedFetchCaseClassifications = jest.mocked( + const mockedFetchCaseClassifications = vi.mocked( fetchCaseClassifications ); - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); diff --git a/packages/headless/src/controllers/case-input/headless-case-input.ts b/packages/headless/src/controllers/case-input/headless-case-input.ts index 28a95c75944..408dd416481 100644 --- a/packages/headless/src/controllers/case-input/headless-case-input.ts +++ b/packages/headless/src/controllers/case-input/headless-case-input.ts @@ -1,27 +1,30 @@ import {Schema} from '@coveo/bueno'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {configuration} from '../../app/common-reducers'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; -import {logUpdateCaseField} from '../../features/case-assist/case-assist-analytics-actions'; -import {fetchCaseClassifications} from '../../features/case-field/case-field-actions'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; -import {updateCaseInput} from '../../features/case-input/case-input-actions'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; -import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {configuration} from '../../app/common-reducers.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; +import {logUpdateCaseField} from '../../features/case-assist/case-assist-analytics-actions.js'; +import {fetchCaseClassifications} from '../../features/case-field/case-field-actions.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; +import {updateCaseInput} from '../../features/case-input/case-input-actions.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; +import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; import { CaseAssistConfigurationSection, CaseFieldSection, CaseInputSection, ConfigurationSection, DocumentSuggestionSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { requiredNonEmptyString, validateOptions, -} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; export interface CaseInputOptions { field: string; diff --git a/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.test.ts b/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.test.ts index eb413243661..97d0f1bc08b 100644 --- a/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.test.ts +++ b/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.test.ts @@ -1,15 +1,15 @@ -import {itemsSelector} from '../../../../features/commerce/context/cart/cart-selector'; +import {itemsSelector} from '../../../../features/commerce/context/cart/cart-selector.js'; import { CartState, getCartInitialState, -} from '../../../../features/commerce/context/cart/cart-state'; -import {CartItemWithMetadata} from '../../../../features/commerce/context/cart/cart-state'; -import {createCartKey} from './headless-cart'; +} from '../../../../features/commerce/context/cart/cart-state.js'; +import {CartItemWithMetadata} from '../../../../features/commerce/context/cart/cart-state.js'; import { itemSelector, totalQuantitySelector, totalPriceSelector, -} from './headless-cart-selectors'; +} from './headless-cart-selectors.js'; +import {createCartKey} from './headless-cart.js'; describe('headless-cart-selectors', () => { let cartOptions: CartState; @@ -42,7 +42,7 @@ describe('headless-cart-selectors', () => { const item3Key = createCartKey(item3); beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); cartOptions = { cart: { diff --git a/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.ts b/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.ts index 48306f7125b..b085df1eb08 100644 --- a/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.ts +++ b/packages/headless/src/controllers/commerce/context/cart/headless-cart-selectors.ts @@ -1,7 +1,7 @@ import {createSelector} from '@reduxjs/toolkit'; -import {itemsSelector} from '../../../../features/commerce/context/cart/cart-selector'; -import {CartState} from '../../../../features/commerce/context/cart/cart-state'; -import {CartItem, createCartKey} from './headless-cart'; +import {itemsSelector} from '../../../../features/commerce/context/cart/cart-selector.js'; +import {CartState} from '../../../../features/commerce/context/cart/cart-state.js'; +import {CartItem, createCartKey} from './headless-cart.js'; export function itemSelector(cartState: CartState, item: CartItem) { return cartState.cart[createCartKey(item)]; diff --git a/packages/headless/src/controllers/commerce/context/cart/headless-cart.ssr.ts b/packages/headless/src/controllers/commerce/context/cart/headless-cart.ssr.ts index ae351da21e2..d13ee4df622 100644 --- a/packages/headless/src/controllers/commerce/context/cart/headless-cart.ssr.ts +++ b/packages/headless/src/controllers/commerce/context/cart/headless-cart.ssr.ts @@ -1,7 +1,7 @@ -import {UniversalControllerDefinitionWithoutProps} from '../../../../app/commerce-ssr-engine/types/common'; -import {Cart, buildCart, CartProps, CartInitialState} from './headless-cart'; +import {UniversalControllerDefinitionWithoutProps} from '../../../../app/commerce-ssr-engine/types/common.js'; +import {Cart, buildCart, CartProps, CartInitialState} from './headless-cart.js'; -export type {CartState, CartItem, CartProps} from './headless-cart'; +export type {CartState, CartItem, CartProps} from './headless-cart.js'; export type {Cart, CartInitialState}; export interface CartDefinition diff --git a/packages/headless/src/controllers/commerce/context/cart/headless-cart.test.ts b/packages/headless/src/controllers/commerce/context/cart/headless-cart.test.ts index 023f7ed8459..1a9e9258ad5 100644 --- a/packages/headless/src/controllers/commerce/context/cart/headless-cart.test.ts +++ b/packages/headless/src/controllers/commerce/context/cart/headless-cart.test.ts @@ -4,26 +4,26 @@ import { purchase, setItems, updateItemQuantity, -} from '../../../../features/commerce/context/cart/cart-actions'; -import {itemsSelector} from '../../../../features/commerce/context/cart/cart-selector'; -import {cartReducer} from '../../../../features/commerce/context/cart/cart-slice'; -import {CartItemWithMetadata} from '../../../../features/commerce/context/cart/cart-state'; -import {getContextInitialState} from '../../../../features/commerce/context/context-state'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +} from '../../../../features/commerce/context/cart/cart-actions.js'; +import {itemsSelector} from '../../../../features/commerce/context/cart/cart-selector.js'; +import {cartReducer} from '../../../../features/commerce/context/cart/cart-slice.js'; +import {CartItemWithMetadata} from '../../../../features/commerce/context/cart/cart-state.js'; +import {getContextInitialState} from '../../../../features/commerce/context/context-state.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {buildCart, Cart, CartInitialState} from './headless-cart'; +} from '../../../../test/mock-engine-v2.js'; import { itemSelector, totalPriceSelector, totalQuantitySelector, -} from './headless-cart-selectors'; +} from './headless-cart-selectors.js'; +import {buildCart, Cart, CartInitialState} from './headless-cart.js'; -jest.mock('../../../../features/commerce/context/cart/cart-actions'); -jest.mock('../../../../features/commerce/context/cart/cart-selector'); -jest.mock('./headless-cart-selectors'); +vi.mock('../../../../features/commerce/context/cart/cart-actions'); +vi.mock('../../../../features/commerce/context/cart/cart-selector'); +vi.mock('./headless-cart-selectors'); describe('headless commerce cart', () => { let engine: MockedCommerceEngine; @@ -40,7 +40,7 @@ describe('headless commerce cart', () => { beforeEach(() => { initEngine(); - jest.resetAllMocks(); + vi.resetAllMocks(); initialState = { items: [ { @@ -76,7 +76,7 @@ describe('headless commerce cart', () => { }); it('dispatches #setItems with correct payload if options include items', () => { - const mockedSetItems = jest.mocked(setItems); + const mockedSetItems = vi.mocked(setItems); expect(mockedSetItems).toHaveBeenCalledWith(initialState.items); expect(engine.dispatch).toHaveBeenCalledWith( @@ -85,8 +85,8 @@ describe('headless commerce cart', () => { }); it('does not dispatch #setItems if options do not include items', () => { - jest.resetAllMocks(); - const mockedSetItems = jest.mocked(setItems); + vi.resetAllMocks(); + const mockedSetItems = vi.mocked(setItems); initialState = {}; initCart(); @@ -95,8 +95,8 @@ describe('headless commerce cart', () => { }); it('#empty calls #updateItemQuantity with quantity of 0 for each item in the cart', () => { - const updateItemQuantitySpy = jest.spyOn(cart, 'updateItemQuantity'); - jest.mocked(itemsSelector).mockReturnValue(initialState.items!); + const updateItemQuantitySpy = vi.spyOn(cart, 'updateItemQuantity'); + vi.mocked(itemsSelector).mockReturnValue(initialState.items!); cart.empty(); @@ -118,12 +118,12 @@ describe('headless commerce cart', () => { }); afterEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); it('dispatches #emitPurchase with the transaction payload', () => { - jest.mocked(itemsSelector).mockReturnValue([]); - const mockedEmitPurchaseEvent = jest.mocked(emitPurchaseEvent); + vi.mocked(itemsSelector).mockReturnValue([]); + const mockedEmitPurchaseEvent = vi.mocked(emitPurchaseEvent); const transaction = {id: 'transaction-id', revenue: 0}; cart.purchase(transaction); @@ -131,7 +131,7 @@ describe('headless commerce cart', () => { }); it('dispatches #purchase', () => { - const mockedPurchase = jest.mocked(purchase); + const mockedPurchase = vi.mocked(purchase); const transaction = {id: 'transaction-id', revenue: 0}; cart.purchase(transaction); @@ -160,7 +160,7 @@ describe('headless commerce cart', () => { }); afterEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); const getExpectedCartActionPayload = ( @@ -176,7 +176,7 @@ describe('headless commerce cart', () => { action: 'add' | 'remove', quantity: number | undefined = undefined ) => { - const mockedEmitCartActionEvent = jest.mocked(emitCartActionEvent); + const mockedEmitCartActionEvent = vi.mocked(emitCartActionEvent); expect(mockedEmitCartActionEvent).toHaveBeenCalledTimes(1); expect(mockedEmitCartActionEvent).toHaveBeenCalledWith( getExpectedCartActionPayload(action, quantity) @@ -184,8 +184,8 @@ describe('headless commerce cart', () => { }; it('will not dispatch an action or emit an event if the item = cartItem', () => { - const mockedUpdateItem = jest.mocked(updateItemQuantity); - jest.mocked(itemSelector).mockReturnValue(productWithQuantity(3)); + const mockedUpdateItem = vi.mocked(updateItemQuantity); + vi.mocked(itemSelector).mockReturnValue(productWithQuantity(3)); cart.updateItemQuantity(productWithQuantity(3)); @@ -194,10 +194,10 @@ describe('headless commerce cart', () => { }); it('will not dispatch an action or emit an event if item does not exist in cart and item.quantity <= 0', () => { - const mockedUpdateItem = jest.mocked(updateItemQuantity); - jest - .mocked(itemSelector) - .mockReturnValue(undefined as unknown as CartItemWithMetadata); + const mockedUpdateItem = vi.mocked(updateItemQuantity); + vi.mocked(itemSelector).mockReturnValue( + undefined as unknown as CartItemWithMetadata + ); cart.updateItemQuantity(productWithQuantity(0)); @@ -206,8 +206,8 @@ describe('headless commerce cart', () => { }); it('dispatches #updateItemQuantity when the item != cartItem', () => { - const mockedUpdateItem = jest.mocked(updateItemQuantity); - jest.mocked(itemSelector).mockReturnValue(productWithQuantity(1)); + const mockedUpdateItem = vi.mocked(updateItemQuantity); + vi.mocked(itemSelector).mockReturnValue(productWithQuantity(1)); cart.updateItemQuantity(productWithQuantity(3)); @@ -215,10 +215,10 @@ describe('headless commerce cart', () => { }); it('dispatches #updateItemQuantity when the item does not exist in the cart state and item.quantity > 0', () => { - const mockedUpdateItem = jest.mocked(updateItemQuantity); - jest - .mocked(itemSelector) - .mockReturnValue(undefined as unknown as CartItemWithMetadata); + const mockedUpdateItem = vi.mocked(updateItemQuantity); + vi.mocked(itemSelector).mockReturnValue( + undefined as unknown as CartItemWithMetadata + ); cart.updateItemQuantity(productWithQuantity(3)); @@ -226,11 +226,12 @@ describe('headless commerce cart', () => { }); it('dispatches #updateItemQuantity but does not dispatch #emitCartAction when the item.quantity = cartItem.quantity but item != cartItem', () => { - const mockedUpdateItem = jest.mocked(updateItemQuantity); - const mockedEmitCartActionEvent = jest.mocked(emitCartActionEvent); - jest - .mocked(itemSelector) - .mockReturnValue({...productWithQuantity(3), name: 'bap'}); + const mockedUpdateItem = vi.mocked(updateItemQuantity); + const mockedEmitCartActionEvent = vi.mocked(emitCartActionEvent); + vi.mocked(itemSelector).mockReturnValue({ + ...productWithQuantity(3), + name: 'bap', + }); cart.updateItemQuantity(productWithQuantity(3)); @@ -239,9 +240,9 @@ describe('headless commerce cart', () => { }); it('dispatches #emitCartAction with "add" action and correct payload if quantity > 0 and item does not exist in cart', () => { - jest - .mocked(itemSelector) - .mockReturnValue(undefined as unknown as CartItemWithMetadata); + vi.mocked(itemSelector).mockReturnValue( + undefined as unknown as CartItemWithMetadata + ); cart.updateItemQuantity(productWithQuantity(3)); @@ -249,7 +250,7 @@ describe('headless commerce cart', () => { }); it('dispatches #emitCartAction with "add" action and correct payload if item exists in cart and new quantity > current', () => { - jest.mocked(itemSelector).mockReturnValue(productWithQuantity(1)); + vi.mocked(itemSelector).mockReturnValue(productWithQuantity(1)); cart.updateItemQuantity(productWithQuantity(5)); @@ -257,7 +258,7 @@ describe('headless commerce cart', () => { }); it('dispatches #emitCartAction with "remove" action and correct payload if item exists in cart and new quantity < current', () => { - jest.mocked(itemSelector).mockReturnValue(productWithQuantity(3)); + vi.mocked(itemSelector).mockReturnValue(productWithQuantity(3)); cart.updateItemQuantity(productWithQuantity(1)); @@ -267,19 +268,19 @@ describe('headless commerce cart', () => { describe('#state', () => { it('#items calls #itemsSelector', () => { - jest.mocked(itemsSelector).mockReturnValue(initialState.items!); + vi.mocked(itemsSelector).mockReturnValue(initialState.items!); expect(cart.state.items).toEqual(initialState.items!); }); it('#totalQuantity calls #totalPriceSelector', () => { - jest.mocked(totalQuantitySelector).mockReturnValue(6); + vi.mocked(totalQuantitySelector).mockReturnValue(6); expect(cart.state.totalQuantity).toBe(6); }); it('#totalPrice calls #totalPriceSelector', () => { - jest.mocked(totalPriceSelector).mockReturnValue(200); + vi.mocked(totalPriceSelector).mockReturnValue(200); expect(cart.state.totalPrice).toBe(200); }); diff --git a/packages/headless/src/controllers/commerce/context/cart/headless-cart.ts b/packages/headless/src/controllers/commerce/context/cart/headless-cart.ts index 855f59c054c..e1b09848bec 100644 --- a/packages/headless/src/controllers/commerce/context/cart/headless-cart.ts +++ b/packages/headless/src/controllers/commerce/context/cart/headless-cart.ts @@ -1,5 +1,5 @@ -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; import { CartActionPayload, emitCartActionEvent, @@ -7,26 +7,26 @@ import { purchase, setItems, updateItemQuantity, -} from '../../../../features/commerce/context/cart/cart-actions'; +} from '../../../../features/commerce/context/cart/cart-actions.js'; import { Transaction, itemsSelector, -} from '../../../../features/commerce/context/cart/cart-selector'; -import {cartReducer as cart} from '../../../../features/commerce/context/cart/cart-slice'; -import {CartItemWithMetadata} from '../../../../features/commerce/context/cart/cart-state'; -import {cartSchema} from '../../../../features/commerce/context/cart/cart-validation'; -import {CartSection} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; -import {validateInitialState} from '../../../../utils/validate-payload'; +} from '../../../../features/commerce/context/cart/cart-selector.js'; +import {cartReducer as cart} from '../../../../features/commerce/context/cart/cart-slice.js'; +import {CartItemWithMetadata} from '../../../../features/commerce/context/cart/cart-state.js'; +import {cartSchema} from '../../../../features/commerce/context/cart/cart-validation.js'; +import {CartSection} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {validateInitialState} from '../../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../../controller/headless-controller'; +} from '../../../controller/headless-controller.js'; import { itemSelector, totalPriceSelector, totalQuantitySelector, -} from './headless-cart-selectors'; +} from './headless-cart-selectors.js'; export interface CartInitialState { items?: CartItemWithMetadata[]; diff --git a/packages/headless/src/controllers/commerce/context/headless-context.ssr.ts b/packages/headless/src/controllers/commerce/context/headless-context.ssr.ts index 28b1ea67d9d..4a215dce86f 100644 --- a/packages/headless/src/controllers/commerce/context/headless-context.ssr.ts +++ b/packages/headless/src/controllers/commerce/context/headless-context.ssr.ts @@ -1,13 +1,13 @@ -import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; +import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; import { Context, buildContext, ContextProps, ContextOptions, View, -} from './headless-context'; +} from './headless-context.js'; -export type {ContextState, Context, ContextProps} from './headless-context'; +export type {ContextState, Context, ContextProps} from './headless-context.js'; export type {View, ContextOptions}; export interface ContextDefinition diff --git a/packages/headless/src/controllers/commerce/context/headless-context.test.ts b/packages/headless/src/controllers/commerce/context/headless-context.test.ts index ce1b2321e8d..edceb9a756e 100644 --- a/packages/headless/src/controllers/commerce/context/headless-context.test.ts +++ b/packages/headless/src/controllers/commerce/context/headless-context.test.ts @@ -1,17 +1,17 @@ import { setContext, setView, -} from '../../../features/commerce/context/context-actions'; -import {contextReducer} from '../../../features/commerce/context/context-slice'; -import {CommerceContextState} from '../../../features/commerce/context/context-state'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/context/context-actions.js'; +import {contextReducer} from '../../../features/commerce/context/context-slice.js'; +import {CommerceContextState} from '../../../features/commerce/context/context-state.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildContext, Context} from './headless-context'; +} from '../../../test/mock-engine-v2.js'; +import {buildContext, Context} from './headless-context.js'; -jest.mock('../../../features/commerce/context/context-actions'); +vi.mock('../../../features/commerce/context/context-actions'); describe('headless commerce context', () => { const options: CommerceContextState = { @@ -27,7 +27,7 @@ describe('headless commerce context', () => { let engine: MockedCommerceEngine; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockCommerceEngine({ ...buildMockCommerceState(), commerceContext: { @@ -48,7 +48,7 @@ describe('headless commerce context', () => { }); it('when context is not provided, does not dispatch #setContext on load', () => { - jest.resetAllMocks(); + vi.resetAllMocks(); context = buildContext(engine); diff --git a/packages/headless/src/controllers/commerce/context/headless-context.ts b/packages/headless/src/controllers/commerce/context/headless-context.ts index 54fa11520f0..a0a3cfb6323 100644 --- a/packages/headless/src/controllers/commerce/context/headless-context.ts +++ b/packages/headless/src/controllers/commerce/context/headless-context.ts @@ -1,18 +1,18 @@ import {CurrencyCodeISO4217} from '@coveo/relay-event-types'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; import { setContext, setView, -} from '../../../features/commerce/context/context-actions'; -import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice'; -import {contextSchema} from '../../../features/commerce/context/context-validation'; -import {loadReducerError} from '../../../utils/errors'; -import {validateOptions} from '../../../utils/validate-payload'; +} from '../../../features/commerce/context/context-actions.js'; +import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice.js'; +import {contextSchema} from '../../../features/commerce/context/context-validation.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateOptions} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface ContextOptions { language: string; diff --git a/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts b/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts index 6721f623b63..513c11e6103 100644 --- a/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts +++ b/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts @@ -3,12 +3,12 @@ import { clearAllCoreFacets, deselectAllValuesInCoreFacet, updateCoreFacetFreezeCurrentValues, -} from '../../../../features/commerce/facets/core-facet/core-facet-actions'; +} from '../../../../features/commerce/facets/core-facet/core-facet-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../../../../features/commerce/facets/date-facet/date-facet-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice'; +} from '../../../../features/commerce/facets/date-facet/date-facet-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice.js'; import { AnyFacetResponse, AnyFacetValueResponse, @@ -16,47 +16,47 @@ import { DateFacetValue, NumericFacetValue, RegularFacetValue, -} from '../../../../features/commerce/facets/facet-set/interfaces/response'; +} from '../../../../features/commerce/facets/facet-set/interfaces/response.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../../../../features/commerce/facets/numeric-facet/numeric-facet-actions'; +} from '../../../../features/commerce/facets/numeric-facet/numeric-facet-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../../../../features/commerce/facets/regular-facet/regular-facet-actions'; -import {FacetValueState} from '../../../../features/facets/facet-api/value'; -import {facetOrderReducer as facetOrder} from '../../../../features/facets/facet-order/facet-order-slice'; -import {CommerceAppState} from '../../../../state/commerce-app-state'; -import {buildMockCommerceFacetRequest} from '../../../../test/mock-commerce-facet-request'; +} from '../../../../features/commerce/facets/regular-facet/regular-facet-actions.js'; +import {FacetValueState} from '../../../../features/facets/facet-api/value.js'; +import {facetOrderReducer as facetOrder} from '../../../../features/facets/facet-order/facet-order-slice.js'; +import {CommerceAppState} from '../../../../state/commerce-app-state.js'; +import {buildMockCommerceFacetRequest} from '../../../../test/mock-commerce-facet-request.js'; import { buildMockCategoryFacetResponse, buildMockCommerceDateFacetResponse, buildMockCommerceNumericFacetResponse, buildMockCommerceRegularFacetResponse, -} from '../../../../test/mock-commerce-facet-response'; +} from '../../../../test/mock-commerce-facet-response.js'; import { buildMockCategoryFacetValue, buildMockCommerceRegularFacetValue, -} from '../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +} from '../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; +} from '../../../../test/mock-engine-v2.js'; import { BreadcrumbManager, buildCoreBreadcrumbManager, CoreBreadcrumbManagerOptions, -} from './headless-core-breadcrumb-manager'; +} from './headless-core-breadcrumb-manager.js'; -jest.mock('../../../../features/commerce/facets/core-facet/core-facet-actions'); -jest.mock( +vi.mock('../../../../features/commerce/facets/core-facet/core-facet-actions'); +vi.mock( '../../../../features/commerce/facets/numeric-facet/numeric-facet-actions' ); -jest.mock('../../../../features/commerce/facets/date-facet/date-facet-actions'); +vi.mock('../../../../features/commerce/facets/date-facet/date-facet-actions'); -jest.mock( +vi.mock( '../../../../features/commerce/facets/regular-facet/regular-facet-actions' ); @@ -67,8 +67,8 @@ describe('core breadcrumb manager', () => { let state: CommerceAppState; const facetId = 'some_facet_id'; - const facetResponseSelector = jest.fn(); - const fetchProductsActionCreator = jest.fn(); + const facetResponseSelector = vi.fn(); + const fetchProductsActionCreator = vi.fn(); function initEngine() { engine = buildMockCommerceEngine(state); @@ -87,7 +87,7 @@ describe('core breadcrumb manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetResponseSelector, fetchProductsActionCreator, diff --git a/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts b/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts index 63ec172b02d..d0155a170e0 100644 --- a/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts +++ b/packages/headless/src/controllers/commerce/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts @@ -2,19 +2,19 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceEngine, CommerceEngineState, -} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; +} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; import { clearAllCoreFacets, deselectAllValuesInCoreFacet, updateCoreFacetFreezeCurrentValues, -} from '../../../../features/commerce/facets/core-facet/core-facet-actions'; +} from '../../../../features/commerce/facets/core-facet/core-facet-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../../../../features/commerce/facets/date-facet/date-facet-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice'; -import {FacetType} from '../../../../features/commerce/facets/facet-set/interfaces/common'; +} from '../../../../features/commerce/facets/date-facet/date-facet-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {FacetType} from '../../../../features/commerce/facets/facet-set/interfaces/common.js'; import { AnyFacetResponse, AnyFacetValueResponse, @@ -23,30 +23,30 @@ import { DateFacetResponse, NumericFacetResponse, RegularFacetResponse, -} from '../../../../features/commerce/facets/facet-set/interfaces/response'; +} from '../../../../features/commerce/facets/facet-set/interfaces/response.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../../../../features/commerce/facets/numeric-facet/numeric-facet-actions'; +} from '../../../../features/commerce/facets/numeric-facet/numeric-facet-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../../../../features/commerce/facets/regular-facet/regular-facet-actions'; -import {findActiveValueAncestry} from '../../../../features/facets/category-facet-set/category-facet-utils'; -import {facetOrderReducer as facetOrder} from '../../../../features/facets/facet-order/facet-order-slice'; +} from '../../../../features/commerce/facets/regular-facet/regular-facet-actions.js'; +import {findActiveValueAncestry} from '../../../../features/facets/category-facet-set/category-facet-utils.js'; +import {facetOrderReducer as facetOrder} from '../../../../features/facets/facet-order/facet-order-slice.js'; import { CommerceFacetSetSection, FacetOrderSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; import { BreadcrumbValue, CoreBreadcrumbManager, DeselectableValue, -} from '../../../breadcrumb-manager/headless-breadcrumb-manager'; -import {buildController} from '../../../controller/headless-controller'; -import {ToggleActionCreator} from '../common'; -import {CoreCommerceFacetOptions} from '../facets/headless-core-commerce-facet'; +} from '../../../breadcrumb-manager/headless-breadcrumb-manager.js'; +import {buildController} from '../../../controller/headless-controller.js'; +import {ToggleActionCreator} from '../common.js'; +import {CoreCommerceFacetOptions} from '../facets/headless-core-commerce-facet.js'; export type {BreadcrumbValue, DeselectableValue}; diff --git a/packages/headless/src/controllers/commerce/core/common.ts b/packages/headless/src/controllers/commerce/core/common.ts index 5b2b59183d1..f0a5a96d27a 100644 --- a/packages/headless/src/controllers/commerce/core/common.ts +++ b/packages/headless/src/controllers/commerce/core/common.ts @@ -3,7 +3,7 @@ import { PayloadActionCreator, PrepareAction, } from '@reduxjs/toolkit'; -import {AsyncThunkOptions} from '../../../app/async-thunk-options'; +import {AsyncThunkOptions} from '../../../app/async-thunk-options.js'; export type FetchProductsActionCreator = () => AsyncThunkAction< unknown, diff --git a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.test.ts b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.test.ts index 5bbebe66247..005a5eaebb9 100644 --- a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.test.ts @@ -1,22 +1,22 @@ -import {stateKey} from '../../../../../app/state-key'; +import {stateKey} from '../../../../../app/state-key.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, -} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; -import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; +import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../../test/mock-engine-v2'; +} from '../../../../../test/mock-engine-v2.js'; import { CategoryFacetSearch, CategoryFacetSearchProps, buildCategoryFacetSearch, -} from './headless-commerce-category-facet-search'; +} from './headless-commerce-category-facet-search.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions' ); @@ -40,10 +40,10 @@ describe('CategoryFacetSearch', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); props = { - select: jest.fn(), + select: vi.fn(), isForFieldSuggestions: false, options: { facetId, diff --git a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.ts b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.ts index f67a798d854..c927abedb3d 100644 --- a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.ts +++ b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet-search.ts @@ -1,19 +1,19 @@ -import {FacetSearchType} from '../../../../../api/commerce/facet-search/facet-search-request'; -import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; +import {FacetSearchType} from '../../../../../api/commerce/facet-search/facet-search-request.js'; +import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, -} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; -import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options'; -import {CategoryFacetSearchSection} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; +import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options.js'; +import {CategoryFacetSearchSection} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { CategoryFacetSearchProps as CoreCategoryFacetSearchProps, buildCoreCategoryFacetSearch, -} from '../../../../core/facets/facet-search/category/headless-category-facet-search'; -import {CoreFacetSearchState} from '../searchable/headless-commerce-searchable-facet'; +} from '../../../../core/facets/facet-search/category/headless-category-facet-search.js'; +import {CoreFacetSearchState} from '../searchable/headless-commerce-searchable-facet.js'; export type CategoryFacetSearchProps = Omit< CoreCategoryFacetSearchProps, diff --git a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.test.ts b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.test.ts index e802765c2fe..400c3c4c758 100644 --- a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.test.ts @@ -1,26 +1,26 @@ import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, -} from '../../../../../features/commerce/facets/category-facet/category-facet-actions'; -import {CategoryFacetResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../features/commerce/facets/category-facet/category-facet-actions.js'; +import {CategoryFacetResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice.js'; +import {buildMockCategoryFacetValue} from '../../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../../test/mock-engine-v2'; +} from '../../../../../test/mock-engine-v2.js'; import { CategoryFacet, CategoryFacetOptions, buildCategoryFacet, -} from './headless-commerce-category-facet'; +} from './headless-commerce-category-facet.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/category-facet/category-facet-actions' ); @@ -30,9 +30,9 @@ describe('CategoryFacet', () => { let state: CommerceAppState; let options: CategoryFacetOptions; let facet: CategoryFacet; - const mockFetchProductsActionCreator = jest.fn(); - const mockFacetResponseSelector = jest.fn(); - const mockIsFacetLoadingResponseSelector = jest.fn(); + const mockFetchProductsActionCreator = vi.fn(); + const mockFacetResponseSelector = vi.fn(); + const mockIsFacetLoadingResponseSelector = vi.fn(); function initEngine(preloadedState = buildMockCommerceState()) { engine = buildMockCommerceEngine(preloadedState); @@ -65,7 +65,7 @@ describe('CategoryFacet', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetId, diff --git a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.ts b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.ts index 6922d117958..ee64c27a3d5 100644 --- a/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.ts +++ b/packages/headless/src/controllers/commerce/core/facets/category/headless-commerce-category-facet.ts @@ -1,13 +1,13 @@ -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../../app/state-key'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../../app/state-key.js'; import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, -} from '../../../../../features/commerce/facets/category-facet/category-facet-actions'; -import {CategoryFacetValueRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request'; -import {defaultNumberOfValuesIncrement} from '../../../../../features/facets/category-facet-set/category-facet-set-actions'; -import {findActiveValueAncestry} from '../../../../../features/facets/category-facet-set/category-facet-utils'; -import {categoryFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/category/category-facet-search-state-selector'; +} from '../../../../../features/commerce/facets/category-facet/category-facet-actions.js'; +import {CategoryFacetValueRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request.js'; +import {defaultNumberOfValuesIncrement} from '../../../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {findActiveValueAncestry} from '../../../../../features/facets/category-facet-set/category-facet-utils.js'; +import {categoryFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/category/category-facet-search-state-selector.js'; import { CategoryFacetValue, CoreCommerceFacet, @@ -15,13 +15,13 @@ import { CoreCommerceFacetState, FacetControllerType, buildCoreCommerceFacet, -} from '../headless-core-commerce-facet'; -import {SearchableFacetOptions} from '../searchable/headless-commerce-searchable-facet'; +} from '../headless-core-commerce-facet.js'; +import {SearchableFacetOptions} from '../searchable/headless-commerce-searchable-facet.js'; import { CategoryFacetSearch, CategoryFacetSearchState, buildCategoryFacetSearch, -} from './headless-commerce-category-facet-search'; +} from './headless-commerce-category-facet-search.js'; export type CategoryFacetOptions = Omit< CoreCommerceFacetOptions, diff --git a/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.test.ts b/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.test.ts index e05e6265c03..877820d2305 100644 --- a/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.test.ts @@ -2,27 +2,27 @@ import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from '../../../../../features/commerce/facets/date-facet/date-facet-actions'; -import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common'; -import {DateFacetRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; -import {buildMockCommerceDateFacetResponse} from '../../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice'; -import {buildMockCommerceDateFacetValue} from '../../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../features/commerce/facets/date-facet/date-facet-actions.js'; +import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common.js'; +import {DateFacetRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceDateFacetResponse} from '../../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice.js'; +import {buildMockCommerceDateFacetValue} from '../../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../../test/mock-engine-v2'; -import {DateRangeRequest} from '../headless-core-commerce-facet'; +} from '../../../../../test/mock-engine-v2.js'; +import {DateRangeRequest} from '../headless-core-commerce-facet.js'; import { DateFacet, DateFacetOptions, buildCommerceDateFacet, -} from './headless-commerce-date-facet'; +} from './headless-commerce-date-facet.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/date-facet/date-facet-actions' ); @@ -31,7 +31,7 @@ describe('DateFacet', () => { const type: FacetType = 'dateRange'; const start = '2023-01-01'; const end = '2024-01-01'; - const fetchProductsActionCreator = jest.fn(); + const fetchProductsActionCreator = vi.fn(); let options: DateFacetOptions; let state: CommerceAppState; let engine: MockedCommerceEngine; @@ -52,13 +52,13 @@ describe('DateFacet', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetId, fetchProductsActionCreator, - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), }; state = buildMockCommerceState(); diff --git a/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.ts b/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.ts index 3cd9385696a..a964a5612ff 100644 --- a/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.ts +++ b/packages/headless/src/controllers/commerce/core/facets/date/headless-commerce-date-facet.ts @@ -1,10 +1,10 @@ -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from '../../../../../features/commerce/facets/date-facet/date-facet-actions'; -import {buildDateRange} from '../../../../core/facets/range-facet/date-facet/date-range'; +} from '../../../../../features/commerce/facets/date-facet/date-facet-actions.js'; +import {buildDateRange} from '../../../../core/facets/range-facet/date-facet/date-range.js'; import { CoreCommerceFacet, CoreCommerceFacetOptions, @@ -13,7 +13,7 @@ import { DateRangeRequest, FacetControllerType, buildCoreCommerceFacet, -} from '../headless-core-commerce-facet'; +} from '../headless-core-commerce-facet.js'; export type DateFacetOptions = Omit< CoreCommerceFacetOptions, diff --git a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.test.ts b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.test.ts index 2c5c40fb653..169cb4e7c7e 100644 --- a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.test.ts @@ -1,29 +1,29 @@ -import {SolutionType} from '../../../../../app/commerce-ssr-engine/types/common'; -import {AnyFacetResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; +import {SolutionType} from '../../../../../app/commerce-ssr-engine/types/common.js'; +import {AnyFacetResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; import { buildMockCategoryFacetResponse, buildMockCommerceDateFacetResponse, buildMockCommerceNumericFacetResponse, buildMockCommerceRegularFacetResponse, -} from '../../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { buildMockSSRCommerceEngine, MockedCommerceEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../../../test/mock-facet-search'; -import {buildProductListing} from '../../../product-listing/headless-product-listing'; -import {buildSearch} from '../../../search/headless-search'; -import {FacetType} from '../headless-core-commerce-facet'; -import {GeneratedFacetControllers} from './headless-commerce-facet-generator'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockFacetSearch} from '../../../../../test/mock-facet-search.js'; +import {buildProductListing} from '../../../product-listing/headless-product-listing.js'; +import {buildSearch} from '../../../search/headless-search.js'; +import {FacetType} from '../headless-core-commerce-facet.js'; +import {GeneratedFacetControllers} from './headless-commerce-facet-generator.js'; import { buildFacetGenerator, FacetGenerator, FacetGeneratorOptions, -} from './headless-commerce-facet-generator.ssr'; +} from './headless-commerce-facet-generator.ssr.js'; describe('SSR FacetGenerator', () => { let engine: MockedCommerceEngine; @@ -81,7 +81,7 @@ describe('SSR FacetGenerator', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); describe.each([ { diff --git a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.ts b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.ts index 88e9bba9ac3..6074be97668 100644 --- a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.ts +++ b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.ts @@ -1,63 +1,63 @@ -import {BaseFacetSearchResult} from '../../../../../api/search/facet-search/base/base-facet-search-response'; -import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; -import {ensureAtLeastOneSolutionType} from '../../../../../app/commerce-ssr-engine/common'; +import {BaseFacetSearchResult} from '../../../../../api/search/facet-search/base/base-facet-search-response.js'; +import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; +import {ensureAtLeastOneSolutionType} from '../../../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps, -} from '../../../../../app/commerce-ssr-engine/types/common'; -import {stateKey} from '../../../../../app/state-key'; -import {facetRequestSelector} from '../../../../../features/commerce/facets/facet-set/facet-set-selector'; +} from '../../../../../app/commerce-ssr-engine/types/common.js'; +import {stateKey} from '../../../../../app/state-key.js'; +import {facetRequestSelector} from '../../../../../features/commerce/facets/facet-set/facet-set-selector.js'; import { AnyFacetResponse, RegularFacetValue, -} from '../../../../../features/commerce/facets/facet-set/interfaces/response'; -import {manualNumericFacetSelector} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-selectors'; -import {manualNumericFacetReducer as manualNumericFacetSet} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice'; -import {categoryFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/category/category-facet-search-state-selector'; -import {specificFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-state-selector'; -import {ManualRangeSection} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {manualNumericFacetSelector} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-selectors.js'; +import {manualNumericFacetReducer as manualNumericFacetSet} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice.js'; +import {categoryFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/category/category-facet-search-state-selector.js'; +import {specificFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-state-selector.js'; +import {ManualRangeSection} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { isFacetLoadingResponseSelector as listingIsFacetLoadingResponseSelector, facetResponseSelector as listingFacetResponseSelector, -} from '../../../product-listing/facets/headless-product-listing-facet-options'; -import {buildProductListing} from '../../../product-listing/headless-product-listing'; +} from '../../../product-listing/facets/headless-product-listing-facet-options.js'; +import {buildProductListing} from '../../../product-listing/headless-product-listing.js'; import { isFacetLoadingResponseSelector as searchIsFacetLoadingResponseSelector, facetResponseSelector as searchFacetResponseSelector, -} from '../../../search/facets/headless-search-facet-options'; -import {buildSearch} from '../../../search/headless-search'; +} from '../../../search/facets/headless-search-facet-options.js'; +import {buildSearch} from '../../../search/headless-search.js'; import { CategoryFacet, CategoryFacetState, getCategoryFacetState, -} from '../category/headless-commerce-category-facet'; +} from '../category/headless-commerce-category-facet.js'; import { DateFacet, DateFacetState, getDateFacetState, -} from '../date/headless-commerce-date-facet'; +} from '../date/headless-commerce-date-facet.js'; import { CategoryFacetValue, FacetType, getCoreFacetState, -} from '../headless-core-commerce-facet'; +} from '../headless-core-commerce-facet.js'; import { getNumericFacetState, NumericFacet, NumericFacetState, -} from '../numeric/headless-commerce-numeric-facet'; +} from '../numeric/headless-commerce-numeric-facet.js'; import { getRegularFacetState, RegularFacet, RegularFacetState, -} from '../regular/headless-commerce-regular-facet'; +} from '../regular/headless-commerce-regular-facet.js'; import { FacetGenerator as CSRFacetGenerator, MappedGeneratedFacetController, -} from './headless-commerce-facet-generator'; +} from './headless-commerce-facet-generator.js'; export type { BaseFacetSearchResult, @@ -177,6 +177,7 @@ export function buildFacetGenerator( const createFacetState = (facetResponseSelector: AnyFacetResponse) => { const facetId = facetResponseSelector.facetId; return getCoreFacetState( + facetId, facetRequestSelector(getEngineState(), facetId), facetResponseSelector, isFacetLoadingResponseSelector diff --git a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.test.ts b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.test.ts index fedd39df896..a22288403df 100644 --- a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.test.ts @@ -1,23 +1,23 @@ -import {clearAllCoreFacets} from '../../../../../features/commerce/facets/core-facet/core-facet-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../../features/commerce/facets/facet-set/facet-set-slice'; -import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common'; -import {facetOrderReducer as facetOrder} from '../../../../../features/facets/facet-order/facet-order-slice'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +import {clearAllCoreFacets} from '../../../../../features/commerce/facets/core-facet/core-facet-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common.js'; +import {facetOrderReducer as facetOrder} from '../../../../../features/facets/facet-order/facet-order-slice.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../../../test/mock-facet-search'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockFacetSearch} from '../../../../../test/mock-facet-search.js'; import { buildFacetGenerator, FacetGenerator, FacetGeneratorOptions, -} from './headless-commerce-facet-generator'; +} from './headless-commerce-facet-generator.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/core-facet/core-facet-actions' ); @@ -26,11 +26,11 @@ describe('CSR FacetGenerator', () => { let state: CommerceAppState; let options: FacetGeneratorOptions; let facetGenerator: FacetGenerator; - const mockBuildNumericFacet = jest.fn(); - const mockBuildRegularFacet = jest.fn(); - const mockBuildDateFacet = jest.fn(); - const mockBuildCategoryFacet = jest.fn(); - const mockFetchProductsActionCreator = jest.fn(); + const mockBuildNumericFacet = vi.fn(); + const mockBuildRegularFacet = vi.fn(); + const mockBuildDateFacet = vi.fn(); + const mockBuildCategoryFacet = vi.fn(); + const mockFetchProductsActionCreator = vi.fn(); function initEngine(preloadedState = buildMockCommerceState()) { engine = buildMockCommerceEngine(preloadedState); @@ -56,7 +56,7 @@ describe('CSR FacetGenerator', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { buildNumericFacet: mockBuildNumericFacet, diff --git a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ts b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ts index 8a145e325ce..42e30440e2f 100644 --- a/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ts +++ b/packages/headless/src/controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ts @@ -2,34 +2,34 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceEngine, CommerceEngineState, -} from '../../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../../app/state-key'; -import {clearAllCoreFacets} from '../../../../../features/commerce/facets/core-facet/core-facet-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../../features/commerce/facets/facet-set/facet-set-slice'; -import {CommerceFacetSetState} from '../../../../../features/commerce/facets/facet-set/facet-set-state'; -import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common'; -import {AnyFacetValueResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response'; -import {facetOrderReducer as facetOrder} from '../../../../../features/facets/facet-order/facet-order-slice'; -import {AnyFacetValueRequest} from '../../../../../features/facets/generic/interfaces/generic-facet-request'; +} from '../../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../../app/state-key.js'; +import {clearAllCoreFacets} from '../../../../../features/commerce/facets/core-facet/core-facet-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {CommerceFacetSetState} from '../../../../../features/commerce/facets/facet-set/facet-set-state.js'; +import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common.js'; +import {AnyFacetValueResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {facetOrderReducer as facetOrder} from '../../../../../features/facets/facet-order/facet-order-slice.js'; +import {AnyFacetValueRequest} from '../../../../../features/facets/generic/interfaces/generic-facet-request.js'; import { CommerceFacetSetSection, FacetOrderSection, -} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { Controller, buildController, -} from '../../../../controller/headless-controller'; -import {FetchProductsActionCreator} from '../../common'; -import {CategoryFacet} from '../category/headless-commerce-category-facet'; -import {DateFacet} from '../date/headless-commerce-date-facet'; +} from '../../../../controller/headless-controller.js'; +import {FetchProductsActionCreator} from '../../common.js'; +import {CategoryFacet} from '../category/headless-commerce-category-facet.js'; +import {DateFacet} from '../date/headless-commerce-date-facet.js'; import { CommerceFacetOptions, CoreCommerceFacet, -} from '../headless-core-commerce-facet'; -import {NumericFacet} from '../numeric/headless-commerce-numeric-facet'; -import {RegularFacet} from '../regular/headless-commerce-regular-facet'; -import {SearchableFacetOptions} from '../searchable/headless-commerce-searchable-facet'; +} from '../headless-core-commerce-facet.js'; +import {NumericFacet} from '../numeric/headless-commerce-numeric-facet.js'; +import {RegularFacet} from '../regular/headless-commerce-regular-facet.js'; +import {SearchableFacetOptions} from '../searchable/headless-commerce-searchable-facet.js'; /** * The `FacetGenerator` headless sub-controller creates commerce facet sub-controllers from the Commerce API search or diff --git a/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.test.ts b/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.test.ts index 5529c42f4f4..97ac5f42b86 100644 --- a/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.test.ts @@ -2,38 +2,38 @@ import { deselectAllValuesInCoreFacet, updateCoreFacetIsFieldExpanded, updateCoreFacetNumberOfValues, -} from '../../../../features/commerce/facets/core-facet/core-facet-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice'; -import {AnyFacetRequest} from '../../../../features/commerce/facets/facet-set/interfaces/request'; -import {RegularFacetResponse} from '../../../../features/commerce/facets/facet-set/interfaces/response'; +} from '../../../../features/commerce/facets/core-facet/core-facet-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {AnyFacetRequest} from '../../../../features/commerce/facets/facet-set/interfaces/request.js'; +import {RegularFacetResponse} from '../../../../features/commerce/facets/facet-set/interfaces/response.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../../../../features/commerce/facets/regular-facet/regular-facet-actions'; -import {CommerceAppState} from '../../../../state/commerce-app-state'; -import {buildMockCommerceFacetRequest} from '../../../../test/mock-commerce-facet-request'; -import {buildMockCommerceRegularFacetResponse} from '../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceFacetSlice} from '../../../../test/mock-commerce-facet-slice'; -import {buildMockCommerceRegularFacetValue} from '../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +} from '../../../../features/commerce/facets/regular-facet/regular-facet-actions.js'; +import {CommerceAppState} from '../../../../state/commerce-app-state.js'; +import {buildMockCommerceFacetRequest} from '../../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceRegularFacetResponse} from '../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceFacetSlice} from '../../../../test/mock-commerce-facet-slice.js'; +import {buildMockCommerceRegularFacetValue} from '../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {FacetValueState} from '../../../core/facets/facet/headless-core-facet'; +} from '../../../../test/mock-engine-v2.js'; +import {FacetValueState} from '../../../core/facets/facet/headless-core-facet.js'; import { buildCoreCommerceFacet, CoreCommerceFacetOptions, -} from './headless-core-commerce-facet'; +} from './headless-core-commerce-facet.js'; -jest.mock('../../../../features/commerce/facets/core-facet/core-facet-actions'); -jest.mock( +vi.mock('../../../../features/commerce/facets/core-facet/core-facet-actions'); +vi.mock( '../../../../features/commerce/facets/regular-facet/regular-facet-actions' ); describe('CoreCommerceFacet', () => { const facetId = 'facet_id'; - const fetchProductsActionCreator = jest.fn(); + const fetchProductsActionCreator = vi.fn(); const toggleExcludeActionCreator = toggleExcludeFacetValue; const toggleSelectActionCreator = toggleSelectFacetValue; const field = 'some_field'; @@ -67,14 +67,14 @@ describe('CoreCommerceFacet', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetId, toggleExcludeActionCreator, toggleSelectActionCreator, fetchProductsActionCreator, - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), }; state = buildMockCommerceState(); @@ -138,15 +138,15 @@ describe('CoreCommerceFacet', () => { facetId, toggleSelectActionCreator, fetchProductsActionCreator, - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), }; initFacet(); }); it('logs a warning', () => { - jest.spyOn(engine.logger, 'warn'); + vi.spyOn(engine.logger, 'warn'); facet.toggleExclude(facetValue()); expect(engine.logger.warn).toHaveBeenCalledTimes(1); @@ -185,7 +185,7 @@ describe('CoreCommerceFacet', () => { }); it('calls #toggleSelect', () => { - jest.spyOn(facet, 'toggleSelect'); + vi.spyOn(facet, 'toggleSelect'); facet.toggleSingleSelect(facetValue()); expect(facet.toggleSelect).toHaveBeenCalled(); @@ -203,7 +203,7 @@ describe('CoreCommerceFacet', () => { const facetValue = () => buildMockCommerceRegularFacetValue({state}); it('calls #toggleSelect', () => { - jest.spyOn(facet, 'toggleSelect'); + vi.spyOn(facet, 'toggleSelect'); facet.toggleSingleSelect(facetValue()); expect(facet.toggleSelect).toHaveBeenCalled(); @@ -225,15 +225,15 @@ describe('CoreCommerceFacet', () => { facetId, toggleSelectActionCreator, fetchProductsActionCreator, - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), }; initFacet(); }); it('logs a warning', () => { - jest.spyOn(engine.logger, 'warn'); + vi.spyOn(engine.logger, 'warn'); facet.toggleSingleExclude(facetValue()); expect(engine.logger.warn).toHaveBeenCalledTimes(1); @@ -245,7 +245,7 @@ describe('CoreCommerceFacet', () => { }); it('does not call #toggleExclude', () => { - jest.spyOn(facet, 'toggleExclude'); + vi.spyOn(facet, 'toggleExclude'); facet.toggleSingleExclude(facetValue()); expect(facet.toggleExclude).not.toHaveBeenCalled(); @@ -261,7 +261,7 @@ describe('CoreCommerceFacet', () => { }); it('calls #toggleExclude', () => { - jest.spyOn(facet, 'toggleExclude'); + vi.spyOn(facet, 'toggleExclude'); facet.toggleSingleExclude(facetValue()); expect(facet.toggleExclude).toHaveBeenCalled(); @@ -277,7 +277,7 @@ describe('CoreCommerceFacet', () => { }, ])('when toggled facet value state is $state', ({state}) => { it('calls #toggleExclude', () => { - jest.spyOn(facet, 'toggleExclude'); + vi.spyOn(facet, 'toggleExclude'); const excludedFacetValue = buildMockCommerceRegularFacetValue({ state, }); @@ -428,7 +428,9 @@ describe('CoreCommerceFacet', () => { }); describe('#state', () => { - it('#facetId exposes the facetId', () => { + it('#facetId exposes the facetId passed as an option to the controller', () => { + state.commerceFacetSet = {}; + options.facetResponseSelector = vi.fn(); expect(facet.state.facetId).toBe(facetId); }); diff --git a/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.ts b/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.ts index afdc447ae71..63a3a8b33a2 100644 --- a/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.ts +++ b/packages/headless/src/controllers/commerce/core/facets/headless-core-commerce-facet.ts @@ -1,17 +1,17 @@ -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; import { deselectAllValuesInCoreFacet, updateCoreFacetIsFieldExpanded, updateCoreFacetNumberOfValues, -} from '../../../../features/commerce/facets/core-facet/core-facet-actions'; -import {facetRequestSelector} from '../../../../features/commerce/facets/facet-set/facet-set-selector'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice'; -import {FacetType} from '../../../../features/commerce/facets/facet-set/interfaces/common'; +} from '../../../../features/commerce/facets/core-facet/core-facet-actions.js'; +import {facetRequestSelector} from '../../../../features/commerce/facets/facet-set/facet-set-selector.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {FacetType} from '../../../../features/commerce/facets/facet-set/interfaces/common.js'; import { AnyFacetRequest, CategoryFacetValueRequest, -} from '../../../../features/commerce/facets/facet-set/interfaces/request'; +} from '../../../../features/commerce/facets/facet-set/interfaces/request.js'; import { AnyFacetResponse, AnyFacetValueResponse, @@ -19,19 +19,19 @@ import { DateFacetValue, NumericFacetValue, RegularFacetValue, -} from '../../../../features/commerce/facets/facet-set/interfaces/response'; -import {FacetValueRequest} from '../../../../features/facets/facet-set/interfaces/request'; -import {AnyFacetValueRequest} from '../../../../features/facets/generic/interfaces/generic-facet-request'; -import {CommerceFacetSetSection} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; -import {buildController} from '../../../controller/headless-controller'; +} from '../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {FacetValueRequest} from '../../../../features/facets/facet-set/interfaces/request.js'; +import {AnyFacetValueRequest} from '../../../../features/facets/generic/interfaces/generic-facet-request.js'; +import {CommerceFacetSetSection} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {buildController} from '../../../controller/headless-controller.js'; import { CoreFacet as HeadlessCoreFacet, CoreFacetState, -} from '../../../core/facets/facet/headless-core-facet'; -import {DateRangeRequest} from '../../../core/facets/range-facet/date-facet/headless-core-date-facet'; -import {NumericRangeRequest} from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet'; -import {FetchProductsActionCreator, ToggleActionCreator} from '../common'; +} from '../../../core/facets/facet/headless-core-facet.js'; +import {DateRangeRequest} from '../../../core/facets/range-facet/date-facet/headless-core-date-facet.js'; +import {NumericRangeRequest} from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet.js'; +import {FetchProductsActionCreator, ToggleActionCreator} from '../common.js'; export type { FacetType, @@ -280,7 +280,12 @@ export function buildCoreCommerceFacet< }, get state(): CoreCommerceFacetState { - return getCoreFacetState(getRequest(), getResponse(), getIsLoading()); + return getCoreFacetState( + facetId, + getRequest(), + getResponse(), + getIsLoading() + ); }, }; } @@ -307,6 +312,7 @@ const canShowLessValues = (request: AnyFacetRequest | undefined) => { }; export const getCoreFacetState = ( + facetId: string, request: AnyFacetRequest | undefined, response: AnyFacetResponse | undefined, isLoading: boolean @@ -315,7 +321,7 @@ export const getCoreFacetState = ( canShowLessValues: canShowLessValues(request), canShowMoreValues: response?.moreValuesAvailable ?? false, displayName: response?.displayName ?? '', - facetId: response?.facetId ?? '', + facetId: facetId, field: response?.field ?? '', hasActiveValues: !response || response.type === 'hierarchical' diff --git a/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.test.ts b/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.test.ts index ee4c5c1f32d..c62f87d58fb 100644 --- a/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.test.ts @@ -1,32 +1,32 @@ -import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common'; -import {NumericFacetRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request'; +import {FacetType} from '../../../../../features/commerce/facets/facet-set/interfaces/common.js'; +import {NumericFacetRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateManualNumericFacetRange, -} from '../../../../../features/commerce/facets/numeric-facet/numeric-facet-actions'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; -import {buildMockCommerceNumericFacetResponse} from '../../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice'; -import {buildMockCommerceNumericFacetValue} from '../../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../features/commerce/facets/numeric-facet/numeric-facet-actions.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceNumericFacetResponse} from '../../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice.js'; +import {buildMockCommerceNumericFacetValue} from '../../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../../test/mock-engine-v2'; -import {NumericRangeRequest} from '../headless-core-commerce-facet'; +} from '../../../../../test/mock-engine-v2.js'; +import {NumericRangeRequest} from '../headless-core-commerce-facet.js'; import { NumericFacet, NumericFacetOptions, buildCommerceNumericFacet, -} from './headless-commerce-numeric-facet'; +} from './headless-commerce-numeric-facet.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/numeric-facet/numeric-facet-actions' ); -jest.mock( +vi.mock( '../../../../../features/commerce/product-listing/product-listing-actions' ); @@ -35,8 +35,8 @@ describe('NumericFacet', () => { const type: FacetType = 'numericalRange'; const start = 0; const end = 100; - const facetResponseSelector = jest.fn(); - const fetchProductsActionCreator = jest.fn(); + const facetResponseSelector = vi.fn(); + const fetchProductsActionCreator = vi.fn(); let options: NumericFacetOptions; let state: CommerceAppState; let engine: MockedCommerceEngine; @@ -57,13 +57,13 @@ describe('NumericFacet', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetId, fetchProductsActionCreator, facetResponseSelector, - isFacetLoadingResponseSelector: jest.fn(), + isFacetLoadingResponseSelector: vi.fn(), }; state = buildMockCommerceState(); diff --git a/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.ts b/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.ts index 99d7cfb7efa..4e6f21834ae 100644 --- a/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.ts +++ b/packages/headless/src/controllers/commerce/core/facets/numeric/headless-commerce-numeric-facet.ts @@ -1,15 +1,15 @@ -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../../app/state-key'; -import {NumericFacetResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response'; -import {manualNumericFacetSelector} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-selectors'; -import {manualNumericFacetReducer as manualNumericFacetSet} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../../app/state-key.js'; +import {NumericFacetResponse} from '../../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {manualNumericFacetSelector} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-selectors.js'; +import {manualNumericFacetReducer as manualNumericFacetSet} from '../../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateManualNumericFacetRange, -} from '../../../../../features/commerce/facets/numeric-facet/numeric-facet-actions'; -import {ManualRangeSection} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../features/commerce/facets/numeric-facet/numeric-facet-actions.js'; +import {ManualRangeSection} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { CoreCommerceFacet, CoreCommerceFacetOptions, @@ -18,7 +18,7 @@ import { NumericFacetValue, NumericRangeRequest, buildCoreCommerceFacet, -} from '../headless-core-commerce-facet'; +} from '../headless-core-commerce-facet.js'; export type NumericFacetOptions = Omit< CoreCommerceFacetOptions, diff --git a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.test.ts b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.test.ts index 26f0883a739..fe839c90468 100644 --- a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.test.ts @@ -1,22 +1,22 @@ -import {stateKey} from '../../../../../app/state-key'; +import {stateKey} from '../../../../../app/state-key.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, -} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../../../test/mock-facet-search'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockFacetSearch} from '../../../../../test/mock-facet-search.js'; import { RegularFacetSearch, buildRegularFacetSearch, RegularFacetSearchProps, -} from './headless-commerce-regular-facet-search'; +} from './headless-commerce-regular-facet-search.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions' ); @@ -39,11 +39,11 @@ describe('RegularFacetSearch', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); props = { - exclude: jest.fn(), - select: jest.fn(), + exclude: vi.fn(), + select: vi.fn(), isForFieldSuggestions: false, options: { facetId, diff --git a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.ts b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.ts index 373afc16495..2a54e18fa18 100644 --- a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.ts +++ b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet-search.ts @@ -1,19 +1,19 @@ -import {FacetSearchType} from '../../../../../api/commerce/facet-search/facet-search-request'; -import {SpecificFacetSearchResult} from '../../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; +import {FacetSearchType} from '../../../../../api/commerce/facet-search/facet-search-request.js'; +import {SpecificFacetSearchResult} from '../../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, -} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; -import {FacetSearchSection} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; +import {FacetSearchSection} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { FacetSearchProps, buildFacetSearch, -} from '../../../../core/facets/facet-search/specific/headless-facet-search'; -import {CoreFacetSearchState} from '../searchable/headless-commerce-searchable-facet'; +} from '../../../../core/facets/facet-search/specific/headless-facet-search.js'; +import {CoreFacetSearchState} from '../searchable/headless-commerce-searchable-facet.js'; export type RegularFacetSearchState = CoreFacetSearchState; diff --git a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.test.ts b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.test.ts index 3325f0dac03..fe49afaf860 100644 --- a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.test.ts +++ b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.test.ts @@ -1,26 +1,26 @@ -import {RegularFacetRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request'; +import {RegularFacetRequest} from '../../../../../features/commerce/facets/facet-set/interfaces/request.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../../../../../features/commerce/facets/regular-facet/regular-facet-actions'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; -import {buildMockCommerceRegularFacetResponse} from '../../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice'; -import {buildMockCommerceRegularFacetValue} from '../../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; +} from '../../../../../features/commerce/facets/regular-facet/regular-facet-actions.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceRegularFacetResponse} from '../../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice.js'; +import {buildMockCommerceRegularFacetValue} from '../../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../../../test/mock-facet-search'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockFacetSearch} from '../../../../../test/mock-facet-search.js'; import { RegularFacet, RegularFacetOptions, buildCommerceRegularFacet, -} from './headless-commerce-regular-facet'; +} from './headless-commerce-regular-facet.js'; -jest.mock( +vi.mock( '../../../../../features/commerce/facets/regular-facet/regular-facet-actions' ); @@ -30,7 +30,7 @@ describe('RegularFacet', () => { let state: CommerceAppState; let options: RegularFacetOptions; let facet: RegularFacet; - const facetResponseSelector = jest.fn(); + const facetResponseSelector = vi.fn(); function initEngine(preloadedState = buildMockCommerceState()) { engine = buildMockCommerceEngine(preloadedState); @@ -54,13 +54,13 @@ describe('RegularFacet', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetId, - fetchProductsActionCreator: jest.fn(), + fetchProductsActionCreator: vi.fn(), facetResponseSelector, - isFacetLoadingResponseSelector: jest.fn(), + isFacetLoadingResponseSelector: vi.fn(), facetSearch: {type: 'SEARCH'}, }; diff --git a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.ts b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.ts index 71d0601e993..723032299f7 100644 --- a/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.ts +++ b/packages/headless/src/controllers/commerce/core/facets/regular/headless-commerce-regular-facet.ts @@ -1,10 +1,10 @@ -import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../../app/state-key'; +import {CommerceEngine} from '../../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../../app/state-key.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../../../../../features/commerce/facets/regular-facet/regular-facet-actions'; -import {specificFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-state-selector'; +} from '../../../../../features/commerce/facets/regular-facet/regular-facet-actions.js'; +import {specificFacetSearchStateSelector} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-state-selector.js'; import { CoreCommerceFacet, CoreCommerceFacetOptions, @@ -13,13 +13,13 @@ import { FacetValueRequest, RegularFacetValue, buildCoreCommerceFacet, -} from '../headless-core-commerce-facet'; -import {SearchableFacetOptions} from '../searchable/headless-commerce-searchable-facet'; +} from '../headless-core-commerce-facet.js'; +import {SearchableFacetOptions} from '../searchable/headless-commerce-searchable-facet.js'; import { RegularFacetSearch, RegularFacetSearchState, buildRegularFacetSearch, -} from './headless-commerce-regular-facet-search'; +} from './headless-commerce-regular-facet-search.js'; export type RegularFacetOptions = Omit< CoreCommerceFacetOptions, diff --git a/packages/headless/src/controllers/commerce/core/facets/searchable/headless-commerce-searchable-facet.ts b/packages/headless/src/controllers/commerce/core/facets/searchable/headless-commerce-searchable-facet.ts index f7ad416b3cb..ef86b5bad6e 100644 --- a/packages/headless/src/controllers/commerce/core/facets/searchable/headless-commerce-searchable-facet.ts +++ b/packages/headless/src/controllers/commerce/core/facets/searchable/headless-commerce-searchable-facet.ts @@ -1,6 +1,6 @@ -import {FacetSearchType} from '../../../../../api/commerce/facet-search/facet-search-request'; -import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; -import {SpecificFacetSearchResult} from '../../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; +import {FacetSearchType} from '../../../../../api/commerce/facet-search/facet-search-request.js'; +import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; +import {SpecificFacetSearchResult} from '../../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; export type SearchableFacetOptions = { facetSearch: {facetQuery?: string; type: FacetSearchType}; diff --git a/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.test.ts b/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.test.ts index 684b41b4294..7d8fadceb32 100644 --- a/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.test.ts +++ b/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.test.ts @@ -1,17 +1,17 @@ -import {configuration} from '../../../../app/common-reducers'; -import {productClick} from '../../../../features/commerce/product/product-actions'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {configuration} from '../../../../app/common-reducers.js'; +import {productClick} from '../../../../features/commerce/product/product-actions.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockProduct} from '../../../../test/mock-product'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockProduct} from '../../../../test/mock-product.js'; import { buildCoreInteractiveProduct, InteractiveProduct, -} from './headless-core-interactive-product'; +} from './headless-core-interactive-product.js'; -jest.mock('../../../../features/commerce/product/product-actions'); +vi.mock('../../../../features/commerce/product/product-actions'); describe('core interactive result', () => { let engine: MockedCommerceEngine; diff --git a/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.ts b/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.ts index b1b290fd64c..12a66d99e0a 100644 --- a/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.ts +++ b/packages/headless/src/controllers/commerce/core/interactive-product/headless-core-interactive-product.ts @@ -1,16 +1,16 @@ -import {Product} from '../../../../api/commerce/common/product'; +import {Product} from '../../../../api/commerce/common/product.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; -import {productClick} from '../../../../features/commerce/product/product-actions'; +} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; +import {productClick} from '../../../../features/commerce/product/product-actions.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions as InteractiveProductCoreOptions, InteractiveResultCoreProps as InteractiveResultHeadlessCoreProps, -} from '../../../core/interactive-result/headless-core-interactive-result'; +} from '../../../core/interactive-result/headless-core-interactive-result.js'; export interface InteractiveProductOptions extends InteractiveProductCoreOptions { diff --git a/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.ts b/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.ts index 1830c78c28d..bc11a011418 100644 --- a/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.ts +++ b/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.ts @@ -1,16 +1,16 @@ -import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common'; +import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps, -} from '../../../../app/commerce-ssr-engine/types/common'; -import {buildProductListing} from '../../product-listing/headless-product-listing'; -import {buildSearch} from '../../search/headless-search'; +} from '../../../../app/commerce-ssr-engine/types/common.js'; +import {buildProductListing} from '../../product-listing/headless-product-listing.js'; +import {buildSearch} from '../../search/headless-search.js'; import { Pagination, PaginationProps, PaginationState, -} from './headless-core-commerce-pagination'; +} from './headless-core-commerce-pagination.js'; export type {Pagination, PaginationProps, PaginationState}; diff --git a/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.test.ts b/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.test.ts index 8283ed6513b..aae5356a164 100644 --- a/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.test.ts +++ b/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.test.ts @@ -1,30 +1,30 @@ -import {stateKey} from '../../../../app/state-key'; +import {stateKey} from '../../../../app/state-key.js'; import { selectPage, nextPage, previousPage, setPageSize, registerRecommendationsSlotPagination, -} from '../../../../features/commerce/pagination/pagination-actions'; -import {paginationReducer as commercePagination} from '../../../../features/commerce/pagination/pagination-slice'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +} from '../../../../features/commerce/pagination/pagination-actions.js'; +import {paginationReducer as commercePagination} from '../../../../features/commerce/pagination/pagination-slice.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../test/mock-engine-v2'; +} from '../../../../test/mock-engine-v2.js'; import { buildCorePagination, CorePaginationOptions, Pagination, -} from './headless-core-commerce-pagination'; +} from './headless-core-commerce-pagination.js'; -jest.mock('../../../../features/commerce/pagination/pagination-actions'); +vi.mock('../../../../features/commerce/pagination/pagination-actions'); describe('core pagination', () => { let engine: MockedCommerceEngine; let pagination: Pagination; - const fetchProductsActionCreator = jest.fn(); - const fetchMoreProductsActionCreator = jest.fn(); + const fetchProductsActionCreator = vi.fn(); + const fetchMoreProductsActionCreator = vi.fn(); const slotId = 'recommendations-slot-id'; function initPagination(options: CorePaginationOptions = {}) { diff --git a/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ts b/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ts index 4225ad41d9f..62c9de4458f 100644 --- a/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ts +++ b/packages/headless/src/controllers/commerce/core/pagination/headless-core-commerce-pagination.ts @@ -3,23 +3,23 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceEngine, CommerceEngineState, -} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; +} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; import { nextPage, previousPage, registerRecommendationsSlotPagination, selectPage, setPageSize, -} from '../../../../features/commerce/pagination/pagination-actions'; -import {paginationReducer as commercePagination} from '../../../../features/commerce/pagination/pagination-slice'; -import {loadReducerError} from '../../../../utils/errors'; -import {validateOptions} from '../../../../utils/validate-payload'; +} from '../../../../features/commerce/pagination/pagination-actions.js'; +import {paginationReducer as commercePagination} from '../../../../features/commerce/pagination/pagination-slice.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {validateOptions} from '../../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../../controller/headless-controller'; -import {FetchProductsActionCreator} from '../common'; +} from '../../../controller/headless-controller.js'; +import {FetchProductsActionCreator} from '../common.js'; /** * The `Pagination` sub-controller is responsible for navigating between pages of results in a commerce interface. diff --git a/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.ts b/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.ts index 17e2dc5b1c7..fc01375942c 100644 --- a/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.ts +++ b/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.ts @@ -1,28 +1,28 @@ -import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common'; +import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithProps, -} from '../../../../app/commerce-ssr-engine/types/common'; -import {CoreEngineNext} from '../../../../app/engine'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice'; -import {manualNumericFacetReducer as manualNumericFacetSet} from '../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice'; -import {paginationReducer as commercePagination} from '../../../../features/commerce/pagination/pagination-slice'; -import {Parameters} from '../../../../features/commerce/parameters/parameters-actions'; -import {ProductListingParameters} from '../../../../features/commerce/product-listing-parameters/product-listing-parameters-actions'; -import {queryReducer as query} from '../../../../features/commerce/query/query-slice'; -import {CommerceSearchParameters} from '../../../../features/commerce/search-parameters/search-parameters-actions'; -import {sortReducer as commerceSort} from '../../../../features/commerce/sort/sort-slice'; -import {facetOrderReducer as facetOrder} from '../../../../features/facets/facet-order/facet-order-slice'; -import {querySetReducer as querySet} from '../../../../features/query-set/query-set-slice'; -import {loadReducerError} from '../../../../utils/errors'; -import {buildProductListing} from '../../product-listing/headless-product-listing'; -import {buildSearch} from '../../search/headless-search'; +} from '../../../../app/commerce-ssr-engine/types/common.js'; +import {CoreEngineNext} from '../../../../app/engine.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {manualNumericFacetReducer as manualNumericFacetSet} from '../../../../features/commerce/facets/numeric-facet/manual-numeric-facet-slice.js'; +import {paginationReducer as commercePagination} from '../../../../features/commerce/pagination/pagination-slice.js'; +import {Parameters} from '../../../../features/commerce/parameters/parameters-actions.js'; +import {ProductListingParameters} from '../../../../features/commerce/product-listing-parameters/product-listing-parameters-actions.js'; +import {queryReducer as query} from '../../../../features/commerce/query/query-slice.js'; +import {CommerceSearchParameters} from '../../../../features/commerce/search-parameters/search-parameters-actions.js'; +import {sortReducer as commerceSort} from '../../../../features/commerce/sort/sort-slice.js'; +import {facetOrderReducer as facetOrder} from '../../../../features/facets/facet-order/facet-order-slice.js'; +import {querySetReducer as querySet} from '../../../../features/query-set/query-set-slice.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {buildProductListing} from '../../product-listing/headless-product-listing.js'; +import {buildSearch} from '../../search/headless-search.js'; import { ParameterManager, ParameterManagerProps, ParameterManagerState, -} from './headless-core-parameter-manager'; +} from './headless-core-parameter-manager.js'; export type { ParameterManager, diff --git a/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.test.ts b/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.test.ts index 0622a68de94..415a31e5dc8 100644 --- a/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.test.ts +++ b/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.test.ts @@ -1,26 +1,26 @@ import {SchemaValidationError} from '@coveo/bueno'; -import {Parameters} from '../../../../features/commerce/parameters/parameters-actions'; -import {parametersDefinition} from '../../../../features/commerce/parameters/parameters-schema'; -import {FacetValueState} from '../../../../features/facets/facet-api/value'; -import {buildRelevanceSortCriterion} from '../../../../features/sort/sort'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {Parameters} from '../../../../features/commerce/parameters/parameters-actions.js'; +import {parametersDefinition} from '../../../../features/commerce/parameters/parameters-schema.js'; +import {FacetValueState} from '../../../../features/facets/facet-api/value.js'; +import {buildRelevanceSortCriterion} from '../../../../features/sort/sort.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; +} from '../../../../test/mock-engine-v2.js'; import { buildCoreParameterManager, CoreParameterManagerProps, ParameterManager, -} from './headless-core-parameter-manager'; +} from './headless-core-parameter-manager.js'; describe('parameter manager', () => { let engine: MockedCommerceEngine; let parameterManager: ParameterManager; - const mockActiveParametersSelector = jest.fn(); - const mockRestoreActionCreator = jest.fn(); - const mockFetchProductsActionCreator = jest.fn(); - const mockEnrichParameters = jest.fn(); + const mockActiveParametersSelector = vi.fn(); + const mockRestoreActionCreator = vi.fn(); + const mockFetchProductsActionCreator = vi.fn(); + const mockEnrichParameters = vi.fn(); function initEngine(preloadedState = buildMockCommerceState()) { engine = buildMockCommerceEngine(preloadedState); @@ -41,7 +41,7 @@ describe('parameter manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initEngine(); initParameterManager(); }); diff --git a/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ts b/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ts index 2e744f87377..76318de19d8 100644 --- a/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ts +++ b/packages/headless/src/controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ts @@ -1,15 +1,15 @@ import {RecordValue, Schema, SchemaDefinition} from '@coveo/bueno'; import {UnknownAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; -import {Parameters} from '../../../../features/commerce/parameters/parameters-actions'; -import {deepEqualAnyOrder} from '../../../../utils/compare-utils'; -import {validateInitialState} from '../../../../utils/validate-payload'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; +import {Parameters} from '../../../../features/commerce/parameters/parameters-actions.js'; +import {deepEqualAnyOrder} from '../../../../utils/compare-utils.js'; +import {validateInitialState} from '../../../../utils/validate-payload.js'; import { Controller, buildController, -} from '../../../controller/headless-controller'; -import {FetchProductsActionCreator} from '../common'; +} from '../../../controller/headless-controller.js'; +import {FetchProductsActionCreator} from '../common.js'; export interface ParameterManagerProps { /** diff --git a/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ssr.ts b/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ssr.ts index 9f12e24db2e..5f98bb17da7 100644 --- a/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ssr.ts +++ b/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ssr.ts @@ -1,12 +1,12 @@ -import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common'; +import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps, -} from '../../../../app/commerce-ssr-engine/types/common'; -import {buildProductListing} from '../../product-listing/headless-product-listing'; -import {buildSearch} from '../../search/headless-search'; -import {Sort, SortProps, SortState} from './headless-core-commerce-sort'; +} from '../../../../app/commerce-ssr-engine/types/common.js'; +import {buildProductListing} from '../../product-listing/headless-product-listing.js'; +import {buildSearch} from '../../search/headless-search.js'; +import {Sort, SortProps, SortState} from './headless-core-commerce-sort.js'; export type {Sort, SortProps, SortState}; diff --git a/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.test.ts b/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.test.ts index 15758e1becc..749910dbdda 100644 --- a/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.test.ts +++ b/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.test.ts @@ -1,21 +1,21 @@ -import {fetchProductListing} from '../../../../features/commerce/product-listing/product-listing-actions'; -import {applySort} from '../../../../features/commerce/sort/sort-actions'; -import {sortReducer} from '../../../../features/commerce/sort/sort-slice'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {fetchProductListing} from '../../../../features/commerce/product-listing/product-listing-actions.js'; +import {applySort} from '../../../../features/commerce/sort/sort-actions.js'; +import {sortReducer} from '../../../../features/commerce/sort/sort-slice.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; +} from '../../../../test/mock-engine-v2.js'; import { buildRelevanceSortCriterion, buildCoreSort, Sort, SortBy, -} from './headless-core-commerce-sort'; +} from './headless-core-commerce-sort.js'; -jest.mock('../../../../features/commerce/sort/sort-actions'); -jest.mock('../../../../features/pagination/pagination-actions'); -jest.mock( +vi.mock('../../../../features/commerce/sort/sort-actions'); +vi.mock('../../../../features/pagination/pagination-actions'); +vi.mock( '../../../../features/commerce/product-listing/product-listing-actions' ); diff --git a/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ts b/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ts index c805d57139f..22e61932428 100644 --- a/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ts +++ b/packages/headless/src/controllers/commerce/core/sort/headless-core-commerce-sort.ts @@ -1,6 +1,8 @@ import {Schema} from '@coveo/bueno'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; +import {applySort} from '../../../../features/commerce/sort/sort-actions.js'; +import {sortReducer as commerceSort} from '../../../../features/commerce/sort/sort-slice.js'; import { buildFieldsSortCriterion, buildRelevanceSortCriterion, @@ -11,16 +13,14 @@ import { SortCriterion, SortDirection, sortCriterionDefinition, -} from '../../../../features/commerce/sort/sort'; -import {applySort} from '../../../../features/commerce/sort/sort-actions'; -import {sortReducer as commerceSort} from '../../../../features/commerce/sort/sort-slice'; -import {loadReducerError} from '../../../../utils/errors'; -import {validateInitialState} from '../../../../utils/validate-payload'; +} from '../../../../features/commerce/sort/sort.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {validateInitialState} from '../../../../utils/validate-payload.js'; import { Controller, buildController, -} from '../../../controller/headless-controller'; -import {FetchProductsActionCreator} from '../common'; +} from '../../../controller/headless-controller.js'; +import {FetchProductsActionCreator} from '../common.js'; export type {SortByRelevance, SortByFields, SortByFieldsFields, SortCriterion}; export { diff --git a/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ssr.ts b/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ssr.ts index 6311df72ca3..066a3f38690 100644 --- a/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ssr.ts +++ b/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ssr.ts @@ -1,14 +1,14 @@ -import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common'; +import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps, -} from '../../../../app/commerce-ssr-engine/types/common'; -import type {Summary} from '../../core/summary/headless-core-summary'; -import {buildProductListing} from '../../product-listing/headless-product-listing'; -import type {ProductListingSummaryState} from '../../product-listing/summary/headless-product-listing-summary'; -import {buildSearch} from '../../search/headless-search'; -import {SearchSummaryState} from '../../search/summary/headless-search-summary'; +} from '../../../../app/commerce-ssr-engine/types/common.js'; +import type {Summary} from '../../core/summary/headless-core-summary.js'; +import {buildProductListing} from '../../product-listing/headless-product-listing.js'; +import type {ProductListingSummaryState} from '../../product-listing/summary/headless-product-listing-summary.js'; +import {buildSearch} from '../../search/headless-search.js'; +import {SearchSummaryState} from '../../search/summary/headless-search-summary.js'; export type {ProductListingSummaryState, Summary}; diff --git a/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.test.ts b/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.test.ts index f98f93fbe4d..ed3929d2f48 100644 --- a/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.test.ts +++ b/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.test.ts @@ -1,21 +1,21 @@ import {SchemaDefinition} from '@coveo/bueno'; -import {Parameters} from '../../../../features/commerce/parameters/parameters-actions'; -import {CommerceSearchParameters} from '../../../../features/commerce/search-parameters/search-parameters-actions'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {Parameters} from '../../../../features/commerce/parameters/parameters-actions.js'; +import {CommerceSearchParameters} from '../../../../features/commerce/search-parameters/search-parameters-actions.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockProduct} from '../../../../test/mock-product'; -import * as DidYouMean from '../../search/did-you-mean/headless-did-you-mean'; -import {SearchSummaryState} from '../../search/summary/headless-search-summary'; -import * as CoreBreadcrumbManager from '../breadcrumb-manager/headless-core-breadcrumb-manager'; -import * as CoreFacetGenerator from '../facets/generator/headless-commerce-facet-generator'; -import * as CoreInteractiveProduct from '../interactive-product/headless-core-interactive-product'; -import * as CorePagination from '../pagination/headless-core-commerce-pagination'; -import * as CoreParameterManager from '../parameter-manager/headless-core-parameter-manager'; -import * as CoreSort from '../sort/headless-core-commerce-sort'; -import * as CoreUrlManager from '../url-manager/headless-core-url-manager'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockProduct} from '../../../../test/mock-product.js'; +import * as DidYouMean from '../../search/did-you-mean/headless-did-you-mean.js'; +import {SearchSummaryState} from '../../search/summary/headless-search-summary.js'; +import * as CoreBreadcrumbManager from '../breadcrumb-manager/headless-core-breadcrumb-manager.js'; +import * as CoreFacetGenerator from '../facets/generator/headless-commerce-facet-generator.js'; +import * as CoreInteractiveProduct from '../interactive-product/headless-core-interactive-product.js'; +import * as CorePagination from '../pagination/headless-core-commerce-pagination.js'; +import * as CoreParameterManager from '../parameter-manager/headless-core-parameter-manager.js'; +import * as CoreSort from '../sort/headless-core-commerce-sort.js'; +import * as CoreUrlManager from '../url-manager/headless-core-url-manager.js'; import { BaseSolutionTypeSubControllers, buildBaseSubControllers, @@ -23,30 +23,30 @@ import { buildSearchSubControllers, SearchAndListingSubControllers, SearchSubControllers, -} from './headless-sub-controller'; +} from './headless-sub-controller.js'; describe('sub-controllers', () => { let engine: MockedCommerceEngine; - const mockResponseIdSelector = jest.fn(); - const mockIsLoadingSelector = jest.fn(); - const mockNumberOfProductsSelector = jest.fn(); - const mockErrorSelector = jest.fn(); - const mockPageSelector = jest.fn(); - const mockPerPageSelector = jest.fn(); - const mockTotalEntriesSelector = jest.fn(); - const mockAugmentSummary = jest.fn(); - const mockFetchProductsActionCreator = jest.fn(); - const mockFetchMoreProductsActionCreator = jest.fn(); - const mockFacetResponseSelector = jest.fn(); - const mockIsFacetLoadingResponseSelector = jest.fn(); - const mockRequestIdSelector = jest.fn(); + const mockResponseIdSelector = vi.fn(); + const mockIsLoadingSelector = vi.fn(); + const mockNumberOfProductsSelector = vi.fn(); + const mockErrorSelector = vi.fn(); + const mockPageSelector = vi.fn(); + const mockPerPageSelector = vi.fn(); + const mockTotalEntriesSelector = vi.fn(); + const mockAugmentSummary = vi.fn(); + const mockFetchProductsActionCreator = vi.fn(); + const mockFetchMoreProductsActionCreator = vi.fn(); + const mockFacetResponseSelector = vi.fn(); + const mockIsFacetLoadingResponseSelector = vi.fn(); + const mockRequestIdSelector = vi.fn(); const mockParametersDefinition = {}; - const mockActiveParametersSelector = jest.fn(); - const mockRestoreActionCreator = jest.fn(); - const mockEnrichParameters = jest.fn(); + const mockActiveParametersSelector = vi.fn(); + const mockRestoreActionCreator = vi.fn(); + const mockEnrichParameters = vi.fn(); const mockSerializer = { - serialize: jest.fn(), - deserialize: jest.fn(), + serialize: vi.fn(), + deserialize: vi.fn(), }; beforeEach(() => { @@ -54,7 +54,7 @@ describe('sub-controllers', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('#buildSearchSubControllers', () => { @@ -99,7 +99,7 @@ describe('sub-controllers', () => { }); it('#didYouMean builds did you mean controller', () => { - const buildDidYouMean = jest.spyOn(DidYouMean, 'buildDidYouMean'); + const buildDidYouMean = vi.spyOn(DidYouMean, 'buildDidYouMean'); const didYouMean = subControllers.didYouMean(); @@ -146,7 +146,7 @@ describe('sub-controllers', () => { }); it('#sort builds sort controller', () => { - const buildCoreSortMock = jest.spyOn(CoreSort, 'buildCoreSort'); + const buildCoreSortMock = vi.spyOn(CoreSort, 'buildCoreSort'); const sort = subControllers.sort(); @@ -154,7 +154,7 @@ describe('sub-controllers', () => { }); it('#facetGenerator builds facet generator', () => { - const buildCoreFacetGenerator = jest.spyOn( + const buildCoreFacetGenerator = vi.spyOn( CoreFacetGenerator, 'buildFacetGenerator' ); @@ -167,7 +167,7 @@ describe('sub-controllers', () => { }); it('#breadcrumbManager builds breadcrumb manager', () => { - const buildCoreBreadcrumbManager = jest.spyOn( + const buildCoreBreadcrumbManager = vi.spyOn( CoreBreadcrumbManager, 'buildCoreBreadcrumbManager' ); @@ -181,7 +181,7 @@ describe('sub-controllers', () => { it('#urlManager builds url manager', () => { mockSerializer.deserialize.mockReturnValue({}); - const buildCoreUrlManager = jest.spyOn( + const buildCoreUrlManager = vi.spyOn( CoreUrlManager, 'buildCoreUrlManager' ); @@ -202,7 +202,7 @@ describe('sub-controllers', () => { }); it('#parameterManager builds parameter manager', () => { - const buildCoreParameterManager = jest.spyOn( + const buildCoreParameterManager = vi.spyOn( CoreParameterManager, 'buildCoreParameterManager' ); @@ -249,7 +249,7 @@ describe('sub-controllers', () => { }); it('#interactiveProduct builds interactive product controller', () => { - const buildCoreInteractiveProductMock = jest.spyOn( + const buildCoreInteractiveProductMock = vi.spyOn( CoreInteractiveProduct, 'buildCoreInteractiveProduct' ); @@ -278,7 +278,7 @@ describe('sub-controllers', () => { }); it('#pagination builds pagination controller with slot id', () => { - const buildCorePaginationMock = jest.spyOn( + const buildCorePaginationMock = vi.spyOn( CorePagination, 'buildCorePagination' ); diff --git a/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ts b/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ts index 06fce8ba715..b84ea80e63e 100644 --- a/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ts +++ b/packages/headless/src/controllers/commerce/core/sub-controller/headless-sub-controller.ts @@ -1,66 +1,66 @@ import {SchemaDefinition} from '@coveo/bueno'; import {UnknownAction} from '@reduxjs/toolkit'; -import {CommerceAPIErrorStatusResponse} from '../../../../api/commerce/commerce-api-error-response'; -import {FacetSearchType} from '../../../../api/commerce/facet-search/facet-search-request'; +import {CommerceAPIErrorStatusResponse} from '../../../../api/commerce/commerce-api-error-response.js'; +import {FacetSearchType} from '../../../../api/commerce/facet-search/facet-search-request.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; -import {AnyFacetResponse} from '../../../../features/commerce/facets/facet-set/interfaces/response'; -import {Parameters} from '../../../../features/commerce/parameters/parameters-actions'; -import {Serializer} from '../../../../features/commerce/parameters/parameters-serializer'; -import {ProductListingParameters} from '../../../../features/commerce/product-listing-parameters/product-listing-parameters-actions'; -import {CommerceSearchParameters} from '../../../../features/commerce/search-parameters/search-parameters-actions'; -import {ProductListingSummaryState} from '../../product-listing/summary/headless-product-listing-summary'; +} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; +import {AnyFacetResponse} from '../../../../features/commerce/facets/facet-set/interfaces/response.js'; +import {Parameters} from '../../../../features/commerce/parameters/parameters-actions.js'; +import {Serializer} from '../../../../features/commerce/parameters/parameters-serializer.js'; +import {ProductListingParameters} from '../../../../features/commerce/product-listing-parameters/product-listing-parameters-actions.js'; +import {CommerceSearchParameters} from '../../../../features/commerce/search-parameters/search-parameters-actions.js'; +import {ProductListingSummaryState} from '../../product-listing/summary/headless-product-listing-summary.js'; import { buildDidYouMean, DidYouMean, -} from '../../search/did-you-mean/headless-did-you-mean'; -import {SearchSummaryState} from '../../search/summary/headless-search-summary'; +} from '../../search/did-you-mean/headless-did-you-mean.js'; +import {SearchSummaryState} from '../../search/summary/headless-search-summary.js'; import { BreadcrumbManager, buildCoreBreadcrumbManager, -} from '../breadcrumb-manager/headless-core-breadcrumb-manager'; -import {FetchProductsActionCreator} from '../common'; -import {buildCategoryFacet} from '../facets/category/headless-commerce-category-facet'; -import {buildCommerceDateFacet} from '../facets/date/headless-commerce-date-facet'; +} from '../breadcrumb-manager/headless-core-breadcrumb-manager.js'; +import {FetchProductsActionCreator} from '../common.js'; +import {buildCategoryFacet} from '../facets/category/headless-commerce-category-facet.js'; +import {buildCommerceDateFacet} from '../facets/date/headless-commerce-date-facet.js'; import { buildFacetGenerator, FacetGenerator, -} from '../facets/generator/headless-commerce-facet-generator'; -import {buildCommerceNumericFacet} from '../facets/numeric/headless-commerce-numeric-facet'; -import {buildCommerceRegularFacet} from '../facets/regular/headless-commerce-regular-facet'; +} from '../facets/generator/headless-commerce-facet-generator.js'; +import {buildCommerceNumericFacet} from '../facets/numeric/headless-commerce-numeric-facet.js'; +import {buildCommerceRegularFacet} from '../facets/regular/headless-commerce-regular-facet.js'; import { buildCoreInteractiveProduct, InteractiveProduct, InteractiveProductProps, -} from '../interactive-product/headless-core-interactive-product'; +} from '../interactive-product/headless-core-interactive-product.js'; import { buildCorePagination, Pagination, PaginationProps, -} from '../pagination/headless-core-commerce-pagination'; +} from '../pagination/headless-core-commerce-pagination.js'; import { buildCoreParameterManager, ParameterManager, ParameterManagerProps, -} from '../parameter-manager/headless-core-parameter-manager'; +} from '../parameter-manager/headless-core-parameter-manager.js'; import { buildCoreSort, Sort, SortProps, -} from '../sort/headless-core-commerce-sort'; +} from '../sort/headless-core-commerce-sort.js'; import { buildCoreSummary, Summary, SummaryState, -} from '../summary/headless-core-summary'; +} from '../summary/headless-core-summary.js'; import { buildCoreUrlManager, UrlManager, type UrlManagerProps, -} from '../url-manager/headless-core-url-manager'; +} from '../url-manager/headless-core-url-manager.js'; export interface BaseSolutionTypeSubControllers { /** diff --git a/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ssr.ts b/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ssr.ts index ace73ffa7f0..423006dcfc6 100644 --- a/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ssr.ts +++ b/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ssr.ts @@ -1,15 +1,15 @@ -import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common'; +import {ensureAtLeastOneSolutionType} from '../../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps, -} from '../../../../app/commerce-ssr-engine/types/common'; -import {buildProductListing} from '../../product-listing/headless-product-listing'; -import {ProductListingSummaryState} from '../../product-listing/summary/headless-product-listing-summary'; -import {RecommendationsSummaryState} from '../../recommendations/summary/headless-recommendations-summary'; -import {buildSearch} from '../../search/headless-search'; -import {SearchSummaryState} from '../../search/summary/headless-search-summary'; -import {Summary, SummaryState} from './headless-core-summary'; +} from '../../../../app/commerce-ssr-engine/types/common.js'; +import {buildProductListing} from '../../product-listing/headless-product-listing.js'; +import {ProductListingSummaryState} from '../../product-listing/summary/headless-product-listing-summary.js'; +import {RecommendationsSummaryState} from '../../recommendations/summary/headless-recommendations-summary.js'; +import {buildSearch} from '../../search/headless-search.js'; +import {SearchSummaryState} from '../../search/summary/headless-search-summary.js'; +import {Summary, SummaryState} from './headless-core-summary.js'; export type { Summary, diff --git a/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.test.ts b/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.test.ts index b9356467ee2..9e7db5e8dac 100644 --- a/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.test.ts +++ b/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.test.ts @@ -1,30 +1,30 @@ -import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine'; -import {CommerceAppState} from '../../../../state/commerce-app-state'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine.js'; +import {CommerceAppState} from '../../../../state/commerce-app-state.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {SearchSummaryState} from '../../search/summary/headless-search-summary'; +} from '../../../../test/mock-engine-v2.js'; +import {SearchSummaryState} from '../../search/summary/headless-search-summary.js'; import { buildCoreSummary, Summary, SummaryOptions, SummaryState, -} from './headless-core-summary'; +} from './headless-core-summary.js'; describe('commerce core summary', () => { let state: CommerceAppState; let engine: MockedCommerceEngine; let summary: Summary; let options = { - responseIdSelector: jest.fn(), - isLoadingSelector: jest.fn(), - errorSelector: jest.fn(), - numberOfProductsSelector: jest.fn(), - pageSelector: jest.fn(), - perPageSelector: jest.fn(), - totalEntriesSelector: jest.fn(), + responseIdSelector: vi.fn(), + isLoadingSelector: vi.fn(), + errorSelector: vi.fn(), + numberOfProductsSelector: vi.fn(), + pageSelector: vi.fn(), + perPageSelector: vi.fn(), + totalEntriesSelector: vi.fn(), }; function initSummary( @@ -35,15 +35,15 @@ describe('commerce core summary', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { - responseIdSelector: jest.fn(), - isLoadingSelector: jest.fn(), - errorSelector: jest.fn(), - numberOfProductsSelector: jest.fn(), - pageSelector: jest.fn(), - perPageSelector: jest.fn(), - totalEntriesSelector: jest.fn(), + responseIdSelector: vi.fn(), + isLoadingSelector: vi.fn(), + errorSelector: vi.fn(), + numberOfProductsSelector: vi.fn(), + pageSelector: vi.fn(), + perPageSelector: vi.fn(), + totalEntriesSelector: vi.fn(), }; state = buildMockCommerceState(); diff --git a/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ts b/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ts index f1a6f823714..b2d58431604 100644 --- a/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ts +++ b/packages/headless/src/controllers/commerce/core/summary/headless-core-summary.ts @@ -1,11 +1,11 @@ -import {CommerceAPIErrorStatusResponse} from '../../../../api/commerce/commerce-api-error-response'; -import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; +import {CommerceAPIErrorStatusResponse} from '../../../../api/commerce/commerce-api-error-response.js'; +import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine.js'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; import { Controller, buildController, -} from '../../../controller/headless-controller'; +} from '../../../controller/headless-controller.js'; export interface SummaryState { /** diff --git a/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.test.ts b/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.test.ts index 63a72bb2993..0cefbc7e222 100644 --- a/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.test.ts +++ b/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.test.ts @@ -1,19 +1,20 @@ -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {Mock} from 'vitest'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {buildCoreUrlManager, UrlManager} from './headless-core-url-manager'; +} from '../../../../test/mock-engine-v2.js'; +import {buildCoreUrlManager, UrlManager} from './headless-core-url-manager.js'; describe('core url manager', () => { let engine: MockedCommerceEngine; let manager: UrlManager; - const mockRequestIdSelector = jest.fn(); - const mockExecuteSearchAction = jest.fn(); - const mockParameterManagerBuilder = jest.fn(); + const mockRequestIdSelector = vi.fn(); + const mockExecuteSearchAction = vi.fn(); + const mockParameterManagerBuilder = vi.fn(); const mockSerializer = { - serialize: jest.fn(), - deserialize: jest.fn(), + serialize: vi.fn(), + deserialize: vi.fn(), }; function initEngine(preloadedState = buildMockCommerceState()) { @@ -32,7 +33,7 @@ describe('core url manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initEngine(); initUrlManager(); }); @@ -81,7 +82,7 @@ describe('core url manager', () => { it('#synchronize calls #synchronize on parameter manager', () => { mockSerializer.deserialize.mockReturnValue({page: 0}); - const mockSynchronize = jest.fn(); + const mockSynchronize = vi.fn(); mockParameterManagerBuilder.mockReturnValue({ synchronize: mockSynchronize, }); @@ -94,9 +95,7 @@ describe('core url manager', () => { describe('#subscribe', () => { function callListener() { - return (engine.subscribe as jest.Mock).mock.calls.map( - (args) => args[0] - )[0](); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0])[0](); } beforeEach(() => { @@ -108,14 +107,14 @@ describe('core url manager', () => { describe('should not call listener', () => { it('when initially subscribing', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); expect(listener).not.toHaveBeenCalled(); }); it('when only the requestId changes', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); mockRequestIdSelector.mockReturnValue('abcde'); @@ -125,7 +124,7 @@ describe('core url manager', () => { }); it('when only a fragment value is modified', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); mockSerializer.serialize.mockReturnValue('q=albums'); @@ -141,7 +140,7 @@ describe('core url manager', () => { mockSerializer.serialize.mockReturnValueOnce('q=new-fragment'); mockSerializer.deserialize.mockImplementation((fragment) => fragment); - const listener = jest.fn(); + const listener = vi.fn(); initUrlManager('q=old-fragment'); manager.subscribe(listener); @@ -157,7 +156,7 @@ describe('core url manager', () => { initUrlManager('q=fragment-to-remove'); - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); callListener(); diff --git a/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.ts b/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.ts index ca87974c049..1c2eaadc2f3 100644 --- a/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.ts +++ b/packages/headless/src/controllers/commerce/core/url-manager/headless-core-url-manager.ts @@ -1,21 +1,21 @@ -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; -import {Parameters} from '../../../../features/commerce/parameters/parameters-actions'; -import {Serializer} from '../../../../features/commerce/parameters/parameters-serializer'; -import {deepEqualAnyOrder} from '../../../../utils/compare-utils'; -import {validateInitialState} from '../../../../utils/validate-payload'; -import {buildController} from '../../../controller/headless-controller'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; +import {Parameters} from '../../../../features/commerce/parameters/parameters-actions.js'; +import {Serializer} from '../../../../features/commerce/parameters/parameters-serializer.js'; +import {deepEqualAnyOrder} from '../../../../utils/compare-utils.js'; +import {validateInitialState} from '../../../../utils/validate-payload.js'; +import {buildController} from '../../../controller/headless-controller.js'; import { initialStateSchema, UrlManager, UrlManagerInitialState, type UrlManagerProps, UrlManagerState, -} from '../../../url-manager/headless-url-manager'; +} from '../../../url-manager/headless-url-manager.js'; import { ParameterManager, ParameterManagerProps, -} from '../parameter-manager/headless-core-parameter-manager'; +} from '../parameter-manager/headless-core-parameter-manager.js'; export type { UrlManagerProps, diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.test.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.test.ts index 342a7e0a898..da3f2364786 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.test.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.test.ts @@ -1,31 +1,31 @@ import { executeCommerceFieldSuggest, getFacetIdWithCommerceFieldSuggestionNamespace, -} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice'; -import {CategoryFacetRequest} from '../../../features/commerce/facets/facet-set/interfaces/request'; -import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; -import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search'; -import {buildMockCommerceFacetRequest} from '../../../test/mock-commerce-facet-request'; -import {buildMockCommerceFacetSlice} from '../../../test/mock-commerce-facet-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {CategoryFacetRequest} from '../../../features/commerce/facets/facet-set/interfaces/request.js'; +import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; +import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search.js'; +import {buildMockCommerceFacetRequest} from '../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceFacetSlice} from '../../../test/mock-commerce-facet-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {CategoryFacetOptions} from '../core/facets/category/headless-commerce-category-facet'; +} from '../../../test/mock-engine-v2.js'; +import {CategoryFacetOptions} from '../core/facets/category/headless-commerce-category-facet.js'; import { buildCategoryFieldSuggestions, CategoryFieldSuggestions, -} from './headless-category-field-suggestions'; +} from './headless-category-field-suggestions.js'; -jest.mock( +vi.mock( '../../../features/facets/facet-search-set/specific/specific-facet-search-actions' ); -jest.mock( +vi.mock( '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions' ); @@ -54,9 +54,9 @@ describe('categoryFieldSuggestions', () => { beforeEach(() => { options = { facetId, - fetchProductsActionCreator: jest.fn(), - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + fetchProductsActionCreator: vi.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), facetSearch: {type: 'SEARCH'}, }; diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.ts index 091e1627d5a..02195a22cba 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-category-field-suggestions.ts @@ -1,32 +1,32 @@ import {createSelector} from '@reduxjs/toolkit'; -import {FieldSuggestionsFacet} from '../../../api/commerce/search/query-suggest/query-suggest-response'; +import {FieldSuggestionsFacet} from '../../../api/commerce/search/query-suggest/query-suggest-response.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice'; -import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; +} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; import { CategoryFacetSearchSection, CommerceFacetSetSection, FacetSearchSection, FieldSuggestionsOrderSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { CategoryFieldSuggestionsState as CoreCategoryFieldSuggestionsState, CategoryFieldSuggestionsValue, -} from '../../field-suggestions/category-facet/headless-category-field-suggestions'; -import {CategoryFacetOptions} from '../core/facets/category/headless-commerce-category-facet'; -import {buildCategoryFacetSearch} from '../core/facets/category/headless-commerce-category-facet-search'; -import {FacetControllerType} from '../core/facets/headless-core-commerce-facet'; +} from '../../field-suggestions/category-facet/headless-category-field-suggestions.js'; +import {buildCategoryFacetSearch} from '../core/facets/category/headless-commerce-category-facet-search.js'; +import {CategoryFacetOptions} from '../core/facets/category/headless-commerce-category-facet.js'; +import {FacetControllerType} from '../core/facets/headless-core-commerce-facet.js'; export type {CategoryFieldSuggestionsValue}; diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.ts index 6a4bc765bf6..fbe7e28c07e 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.ts @@ -1,19 +1,19 @@ -import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; +import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; import { FieldSuggestionsGenerator, buildFieldSuggestionsGenerator, -} from './headless-field-suggestions-generator'; +} from './headless-field-suggestions-generator.js'; export type { FieldSuggestions, FieldSuggestionsState, -} from '../field-suggestions/headless-field-suggestions'; +} from '../field-suggestions/headless-field-suggestions.js'; export type { CategoryFieldSuggestions, CategoryFieldSuggestionsState, -} from '../field-suggestions/headless-category-field-suggestions'; -export type {FieldSuggestionsFacet} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-state'; -export type {GeneratedFieldSuggestionsControllers} from './headless-field-suggestions-generator'; +} from '../field-suggestions/headless-category-field-suggestions.js'; +export type {FieldSuggestionsFacet} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-state.js'; +export type {GeneratedFieldSuggestionsControllers} from './headless-field-suggestions-generator.js'; export type {FieldSuggestionsGenerator}; export interface FieldSuggestionsGeneratorDefinition diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.test.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.test.ts index b75ac8d9ff8..a83d20f0f35 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.test.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.test.ts @@ -1,31 +1,31 @@ -import {FacetSearchType} from '../../../api/commerce/facet-search/facet-search-request'; -import {FieldSuggestionsFacet} from '../../../api/commerce/search/query-suggest/query-suggest-response'; -import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search'; -import {buildMockCommerceFacetRequest} from '../../../test/mock-commerce-facet-request'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {FacetSearchType} from '../../../api/commerce/facet-search/facet-search-request.js'; +import {FieldSuggestionsFacet} from '../../../api/commerce/search/query-suggest/query-suggest-response.js'; +import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search.js'; +import {buildMockCommerceFacetRequest} from '../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../test/mock-facet-search'; -import {buildCategoryFieldSuggestions} from './headless-category-field-suggestions'; -import {buildFieldSuggestions} from './headless-field-suggestions'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetSearch} from '../../../test/mock-facet-search.js'; +import {buildCategoryFieldSuggestions} from './headless-category-field-suggestions.js'; import { buildFieldSuggestionsGenerator, FieldSuggestionsGenerator, -} from './headless-field-suggestions-generator'; +} from './headless-field-suggestions-generator.js'; +import {buildFieldSuggestions} from './headless-field-suggestions.js'; describe('fieldSuggestionsGenerator', () => { let engine: MockedCommerceEngine; let state: CommerceAppState; let fieldSuggestionsGenerator: FieldSuggestionsGenerator; const commonOptions = { - fetchProductsActionCreator: jest.fn(), - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + fetchProductsActionCreator: vi.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), facetSearch: {type: 'SEARCH' as FacetSearchType}, }; @@ -59,7 +59,7 @@ describe('fieldSuggestionsGenerator', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); state = buildMockCommerceState(); setFacetState(); diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ts index 92719e8fe1e..affa1ec733e 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions-generator.ts @@ -1,31 +1,31 @@ import {createSelector} from '@reduxjs/toolkit'; -import {FacetSearchType} from '../../../api/commerce/facet-search/facet-search-request'; +import {FacetSearchType} from '../../../api/commerce/facet-search/facet-search-request.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {FieldSuggestionsFacet} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-state'; -import {executeSearch} from '../../../features/commerce/search/search-actions'; -import {FieldSuggestionsOrderSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {FieldSuggestionsFacet} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-state.js'; +import {executeSearch} from '../../../features/commerce/search/search-actions.js'; +import {FieldSuggestionsOrderSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { facetResponseSelector, isFacetLoadingResponseSelector, -} from '../search/facets/headless-search-facet-options'; +} from '../search/facets/headless-search-facet-options.js'; import { buildCategoryFieldSuggestions, CategoryFieldSuggestions, -} from './headless-category-field-suggestions'; +} from './headless-category-field-suggestions.js'; import { buildFieldSuggestions, FieldSuggestions, -} from './headless-field-suggestions'; +} from './headless-field-suggestions.js'; export type GeneratedFieldSuggestionsControllers = Array< FieldSuggestions | CategoryFieldSuggestions diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.test.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.test.ts index 52bd0fd8b90..038f8909d05 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.test.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.test.ts @@ -1,28 +1,28 @@ import { executeCommerceFieldSuggest, getFacetIdWithCommerceFieldSuggestionNamespace, -} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice'; -import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../test/mock-facet-search'; -import {RegularFacetOptions} from '../core/facets/regular/headless-commerce-regular-facet'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetSearch} from '../../../test/mock-facet-search.js'; +import {RegularFacetOptions} from '../core/facets/regular/headless-commerce-regular-facet.js'; import { buildFieldSuggestions, FieldSuggestions, -} from './headless-field-suggestions'; +} from './headless-field-suggestions.js'; -jest.mock( +vi.mock( '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions' ); -jest.mock( +vi.mock( '../../../features/facets/facet-search-set/specific/specific-facet-search-actions' ); @@ -47,12 +47,12 @@ describe('fieldSuggestions', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facetId, - fetchProductsActionCreator: jest.fn(), - facetResponseSelector: jest.fn(), - isFacetLoadingResponseSelector: jest.fn(), + fetchProductsActionCreator: vi.fn(), + facetResponseSelector: vi.fn(), + isFacetLoadingResponseSelector: vi.fn(), facetSearch: {type: 'SEARCH'}, }; diff --git a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.ts b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.ts index 5a68ad16e5f..4e8829128bb 100644 --- a/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.ts +++ b/packages/headless/src/controllers/commerce/field-suggestions/headless-field-suggestions.ts @@ -1,31 +1,31 @@ import {createSelector} from '@reduxjs/toolkit'; -import {FieldSuggestionsFacet} from '../../../api/commerce/search/query-suggest/query-suggest-response'; -import {SpecificFacetSearchResult} from '../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; +import {FieldSuggestionsFacet} from '../../../api/commerce/search/query-suggest/query-suggest-response.js'; +import {SpecificFacetSearchResult} from '../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice'; -import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; +} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../../features/commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../../../features/commerce/facets/facet-set/facet-set-slice.js'; +import {fieldSuggestionsOrderReducer as fieldSuggestionsOrder} from '../../../features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; import { CommerceFacetSetSection, FacetSearchSection, FieldSuggestionsOrderSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; -import {FacetControllerType} from '../core/facets/headless-core-commerce-facet'; -import {RegularFacetOptions} from '../core/facets/regular/headless-commerce-regular-facet'; +} from '../../controller/headless-controller.js'; +import {FacetControllerType} from '../core/facets/headless-core-commerce-facet.js'; import { buildRegularFacetSearch, RegularFacetSearchState, -} from '../core/facets/regular/headless-commerce-regular-facet-search'; +} from '../core/facets/regular/headless-commerce-regular-facet-search.js'; +import {RegularFacetOptions} from '../core/facets/regular/headless-commerce-regular-facet.js'; export type {SpecificFacetSearchResult}; diff --git a/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ssr.ts b/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ssr.ts index bc8396a0bd1..dc9568e4f1c 100644 --- a/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ssr.ts +++ b/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ssr.ts @@ -1,14 +1,14 @@ -import {SearchAndListingControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; +import {SearchAndListingControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; import { InstantProducts, InstantProductsProps, buildInstantProducts, -} from './headless-instant-products'; +} from './headless-instant-products.js'; export type { InstantProductsOptions, InstantProductsState, -} from './headless-instant-products'; +} from './headless-instant-products.js'; export type {InstantProducts, InstantProductsProps}; export interface InstantProductsDefinition diff --git a/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.test.ts b/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.test.ts index 4b31577d1dc..c03ba23737a 100644 --- a/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.test.ts +++ b/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.test.ts @@ -1,24 +1,22 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; -import {stateKey} from '../../../app/state-key'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {stateKey} from '../../../app/state-key.js'; import { registerInstantProducts, promoteChildToParent, -} from '../../../features/commerce/instant-products/instant-products-actions'; -import {instantProductsReducer} from '../../../features/commerce/instant-products/instant-products-slice'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/instant-products/instant-products-actions.js'; +import {instantProductsReducer} from '../../../features/commerce/instant-products/instant-products-slice.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; +} from '../../../test/mock-engine-v2.js'; import { InstantProducts, buildInstantProducts, -} from './headless-instant-products'; +} from './headless-instant-products.js'; -jest.mock( - '../../../features/commerce/instant-products/instant-products-actions' -); +vi.mock('../../../features/commerce/instant-products/instant-products-actions'); describe('instant products', () => { let engine: MockedCommerceEngine; @@ -27,8 +25,8 @@ describe('instant products', () => { const searchBoxId = 'search_box_1'; beforeEach(() => { - jest.clearAllMocks(); - jest.useFakeTimers(); + vi.clearAllMocks(); + vi.useFakeTimers(); state = buildMockCommerceState(); engine = buildMockCommerceEngine(state); instantProducts = buildInstantProducts(engine, {options: {searchBoxId}}); diff --git a/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ts b/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ts index bf5f0d52c19..c7f059097fe 100644 --- a/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ts +++ b/packages/headless/src/controllers/commerce/instant-products/headless-instant-products.ts @@ -1,31 +1,34 @@ import {NumberValue, Schema} from '@coveo/bueno'; import {SerializedError} from '@reduxjs/toolkit'; -import {CommerceAPIErrorResponse} from '../../../api/commerce/commerce-api-error-response'; -import {ChildProduct, Product} from '../../../api/commerce/common/product'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; +import {CommerceAPIErrorResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {ChildProduct, Product} from '../../../api/commerce/common/product.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; import { clearExpiredProducts, promoteChildToParent, registerInstantProducts, updateInstantProductsQuery, -} from '../../../features/commerce/instant-products/instant-products-actions'; -import {instantProductsReducer} from '../../../features/commerce/instant-products/instant-products-slice'; -import {fetchInstantProducts} from '../../../features/commerce/search/search-actions'; -import {hasExpired} from '../../../features/instant-items/instant-items-state'; -import {InstantProductsSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {randomID} from '../../../utils/utils'; -import {nonEmptyString, validateOptions} from '../../../utils/validate-payload'; +} from '../../../features/commerce/instant-products/instant-products-actions.js'; +import {instantProductsReducer} from '../../../features/commerce/instant-products/instant-products-slice.js'; +import {fetchInstantProducts} from '../../../features/commerce/search/search-actions.js'; +import {hasExpired} from '../../../features/instant-items/instant-items-state.js'; +import {InstantProductsSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {randomID} from '../../../utils/utils.js'; +import { + nonEmptyString, + validateOptions, +} from '../../../utils/validate-payload.js'; import { Controller, buildController, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { InteractiveProduct, InteractiveProductProps, buildCoreInteractiveProduct, -} from '../core/interactive-product/headless-core-interactive-product'; +} from '../core/interactive-product/headless-core-interactive-product.js'; export interface InstantProductsOptions { /** diff --git a/packages/headless/src/controllers/commerce/product-listing/facets/headless-product-listing-facet-options.ts b/packages/headless/src/controllers/commerce/product-listing/facets/headless-product-listing-facet-options.ts index 5403f9a929d..28659f7861f 100644 --- a/packages/headless/src/controllers/commerce/product-listing/facets/headless-product-listing-facet-options.ts +++ b/packages/headless/src/controllers/commerce/product-listing/facets/headless-product-listing-facet-options.ts @@ -2,7 +2,7 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceFacetSetSection, ProductListingSection, -} from '../../../../state/state-sections'; +} from '../../../../state/state-sections.js'; export const facetResponseSelector = createSelector( ( diff --git a/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ssr.ts b/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ssr.ts index 5dd2e6f6e79..40f5a9678ab 100644 --- a/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ssr.ts +++ b/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ssr.ts @@ -1,13 +1,16 @@ -import {ensureAtLeastOneSolutionType} from '../../../app/commerce-ssr-engine/common'; +import {ensureAtLeastOneSolutionType} from '../../../app/commerce-ssr-engine/common.js'; import { ControllerDefinitionOption, SolutionType, SubControllerDefinitionWithoutProps, -} from '../../../app/commerce-ssr-engine/types/common'; -import {buildSearch, Search} from '../search/headless-search'; -import {ProductListing, buildProductListing} from './headless-product-listing'; +} from '../../../app/commerce-ssr-engine/types/common.js'; +import {buildSearch, Search} from '../search/headless-search.js'; +import { + ProductListing, + buildProductListing, +} from './headless-product-listing.js'; -export type {ProductListingState as ProductListState} from './headless-product-listing'; +export type {ProductListingState as ProductListState} from './headless-product-listing.js'; export type ProductList = Pick< ProductListing | Search, 'state' | 'subscribe' | 'interactiveProduct' diff --git a/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.test.ts b/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.test.ts index 409c9b0d880..24580b86c4e 100644 --- a/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.test.ts +++ b/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.test.ts @@ -1,38 +1,41 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; -import {configuration} from '../../../app/common-reducers'; -import {contextReducer} from '../../../features/commerce/context/context-slice'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {contextReducer} from '../../../features/commerce/context/context-slice.js'; import { pagePrincipalSelector, perPagePrincipalSelector, totalEntriesPrincipalSelector, -} from '../../../features/commerce/pagination/pagination-selectors'; -import {parametersDefinition} from '../../../features/commerce/parameters/parameters-schema'; +} from '../../../features/commerce/pagination/pagination-selectors.js'; +import {parametersDefinition} from '../../../features/commerce/parameters/parameters-schema.js'; import { activeParametersSelector, enrichedParametersSelector, -} from '../../../features/commerce/parameters/parameters-selectors'; -import {productListingSerializer} from '../../../features/commerce/parameters/parameters-serializer'; -import {restoreProductListingParameters} from '../../../features/commerce/product-listing-parameters/product-listing-parameters-actions'; -import * as ProductListingActions from '../../../features/commerce/product-listing/product-listing-actions'; +} from '../../../features/commerce/parameters/parameters-selectors.js'; +import {productListingSerializer} from '../../../features/commerce/parameters/parameters-serializer.js'; +import {restoreProductListingParameters} from '../../../features/commerce/product-listing-parameters/product-listing-parameters-actions.js'; +import * as ProductListingActions from '../../../features/commerce/product-listing/product-listing-actions.js'; import { errorSelector, isLoadingSelector, numberOfProductsSelector, requestIdSelector, responseIdSelector, -} from '../../../features/commerce/product-listing/product-listing-selectors'; -import {productListingReducer} from '../../../features/commerce/product-listing/product-listing-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/product-listing/product-listing-selectors.js'; +import {productListingReducer} from '../../../features/commerce/product-listing/product-listing-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import * as SubControllers from '../core/sub-controller/headless-sub-controller'; +} from '../../../test/mock-engine-v2.js'; +import * as SubControllers from '../core/sub-controller/headless-sub-controller.js'; import { facetResponseSelector, isFacetLoadingResponseSelector, -} from './facets/headless-product-listing-facet-options'; -import {buildProductListing, ProductListing} from './headless-product-listing'; +} from './facets/headless-product-listing-facet-options.js'; +import { + buildProductListing, + ProductListing, +} from './headless-product-listing.js'; describe('headless product-listing', () => { let productListing: ProductListing; @@ -44,11 +47,11 @@ describe('headless product-listing', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('uses sub-controllers', () => { - const buildProductListingSubControllers = jest.spyOn( + const buildProductListingSubControllers = vi.spyOn( SubControllers, 'buildProductListingSubControllers' ); @@ -85,7 +88,7 @@ describe('headless product-listing', () => { }); it('#promoteChildToParent dispatches #promoteChildToParent with the correct arguments', () => { - const promoteChildToParent = jest.spyOn( + const promoteChildToParent = vi.spyOn( ProductListingActions, 'promoteChildToParent' ); @@ -99,7 +102,7 @@ describe('headless product-listing', () => { }); it('#refresh dispatches #fetchProductListing', () => { - const fetchProductListing = jest.spyOn( + const fetchProductListing = vi.spyOn( ProductListingActions, 'fetchProductListing' ); @@ -110,7 +113,7 @@ describe('headless product-listing', () => { }); it('#executeFirstRequest dispatches #fetchProductListing', () => { - const executeRequest = jest.spyOn( + const executeRequest = vi.spyOn( ProductListingActions, 'fetchProductListing' ); diff --git a/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ts b/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ts index b842565f8d1..03f1f12f7bb 100644 --- a/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ts +++ b/packages/headless/src/controllers/commerce/product-listing/headless-product-listing.ts @@ -1,49 +1,49 @@ -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {ChildProduct, Product} from '../../../api/commerce/common/product'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {configuration} from '../../../app/common-reducers'; -import {stateKey} from '../../../app/state-key'; -import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {ChildProduct, Product} from '../../../api/commerce/common/product.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {stateKey} from '../../../app/state-key.js'; +import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice.js'; import { pagePrincipalSelector, perPagePrincipalSelector, totalEntriesPrincipalSelector, -} from '../../../features/commerce/pagination/pagination-selectors'; -import {Parameters} from '../../../features/commerce/parameters/parameters-actions'; -import {parametersDefinition} from '../../../features/commerce/parameters/parameters-schema'; +} from '../../../features/commerce/pagination/pagination-selectors.js'; +import {Parameters} from '../../../features/commerce/parameters/parameters-actions.js'; +import {parametersDefinition} from '../../../features/commerce/parameters/parameters-schema.js'; import { activeParametersSelector, enrichedParametersSelector, -} from '../../../features/commerce/parameters/parameters-selectors'; -import {productListingSerializer} from '../../../features/commerce/parameters/parameters-serializer'; -import {restoreProductListingParameters} from '../../../features/commerce/product-listing-parameters/product-listing-parameters-actions'; +} from '../../../features/commerce/parameters/parameters-selectors.js'; +import {productListingSerializer} from '../../../features/commerce/parameters/parameters-serializer.js'; +import {restoreProductListingParameters} from '../../../features/commerce/product-listing-parameters/product-listing-parameters-actions.js'; import { fetchProductListing, fetchMoreProducts, promoteChildToParent, -} from '../../../features/commerce/product-listing/product-listing-actions'; +} from '../../../features/commerce/product-listing/product-listing-actions.js'; import { errorSelector, isLoadingSelector, numberOfProductsSelector, requestIdSelector, responseIdSelector, -} from '../../../features/commerce/product-listing/product-listing-selectors'; -import {productListingReducer as productListing} from '../../../features/commerce/product-listing/product-listing-slice'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../features/commerce/product-listing/product-listing-selectors.js'; +import {productListingReducer as productListing} from '../../../features/commerce/product-listing/product-listing-slice.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { buildProductListingSubControllers, SearchAndListingSubControllers, -} from '../core/sub-controller/headless-sub-controller'; +} from '../core/sub-controller/headless-sub-controller.js'; import { facetResponseSelector, isFacetLoadingResponseSelector, -} from './facets/headless-product-listing-facet-options'; -import {ProductListingSummaryState} from './summary/headless-product-listing-summary'; +} from './facets/headless-product-listing-facet-options.js'; +import {ProductListingSummaryState} from './summary/headless-product-listing-summary.js'; /** * The `ProductListing` controller exposes a method for retrieving product listing content in a commerce interface. diff --git a/packages/headless/src/controllers/commerce/product-listing/summary/headless-product-listing-summary.ts b/packages/headless/src/controllers/commerce/product-listing/summary/headless-product-listing-summary.ts index c53bdcb7545..4d08cd8b4f4 100644 --- a/packages/headless/src/controllers/commerce/product-listing/summary/headless-product-listing-summary.ts +++ b/packages/headless/src/controllers/commerce/product-listing/summary/headless-product-listing-summary.ts @@ -1,3 +1,3 @@ -import {SummaryState} from '../../core/summary/headless-core-summary'; +import {SummaryState} from '../../core/summary/headless-core-summary.js'; export interface ProductListingSummaryState extends SummaryState {} diff --git a/packages/headless/src/controllers/commerce/product-listing/utils/load-product-listing-reducers.ts b/packages/headless/src/controllers/commerce/product-listing/utils/load-product-listing-reducers.ts index a873f69d842..c0554deaabf 100644 --- a/packages/headless/src/controllers/commerce/product-listing/utils/load-product-listing-reducers.ts +++ b/packages/headless/src/controllers/commerce/product-listing/utils/load-product-listing-reducers.ts @@ -1,6 +1,6 @@ -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {productListingReducer as productListing} from '../../../../features/commerce/product-listing/product-listing-slice'; -import {ProductListingSection} from '../../../../state/state-sections'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {productListingReducer as productListing} from '../../../../features/commerce/product-listing/product-listing-slice.js'; +import {ProductListingSection} from '../../../../state/state-sections.js'; export function loadProductListingReducer( engine: CommerceEngine diff --git a/packages/headless/src/controllers/commerce/product-view/headless-product-view.ssr.ts b/packages/headless/src/controllers/commerce/product-view/headless-product-view.ssr.ts index b99d51d185c..5882b96c6bb 100644 --- a/packages/headless/src/controllers/commerce/product-view/headless-product-view.ssr.ts +++ b/packages/headless/src/controllers/commerce/product-view/headless-product-view.ssr.ts @@ -1,13 +1,13 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { buildProductView, ProductView as BaseProductView, -} from './headless-product-view'; +} from './headless-product-view.js'; export interface ProductViewDefinition extends UniversalControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/commerce/product-view/headless-product-view.test.ts b/packages/headless/src/controllers/commerce/product-view/headless-product-view.test.ts index 76c2cf733a6..35530bd13f0 100644 --- a/packages/headless/src/controllers/commerce/product-view/headless-product-view.test.ts +++ b/packages/headless/src/controllers/commerce/product-view/headless-product-view.test.ts @@ -1,13 +1,14 @@ import {Product} from '@coveo/relay-event-types'; -import {productView} from '../../../features/commerce/product/product-actions'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {describe, vi, beforeEach, it, expect} from 'vitest'; +import {productView} from '../../../features/commerce/product/product-actions.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildProductView, ProductView} from './headless-product-view'; +} from '../../../test/mock-engine-v2.js'; +import {buildProductView, ProductView} from './headless-product-view.js'; -jest.mock('../../../features/commerce/product/product-actions'); +vi.mock('../../../features/commerce/product/product-actions'); describe('ProductView', () => { let engine: MockedCommerceEngine; diff --git a/packages/headless/src/controllers/commerce/product-view/headless-product-view.ts b/packages/headless/src/controllers/commerce/product-view/headless-product-view.ts index ae8fae5ddd1..ffd516a952c 100644 --- a/packages/headless/src/controllers/commerce/product-view/headless-product-view.ts +++ b/packages/headless/src/controllers/commerce/product-view/headless-product-view.ts @@ -1,6 +1,6 @@ import {Product} from '@coveo/relay-event-types'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {productView} from '../../../features/commerce/product/product-actions'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {productView} from '../../../features/commerce/product/product-actions.js'; /** * The `ProductView` controller provides an interface for triggering an analytics event for a product view. diff --git a/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.ts b/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.ts index 4a0ff672826..bb490eaead9 100644 --- a/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.ts +++ b/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.ts @@ -1,15 +1,15 @@ -import {SearchAndListingControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; +import {SearchAndListingControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; import { RecentQueriesList, RecentQueriesListProps, buildRecentQueriesList, -} from './headless-recent-queries-list'; +} from './headless-recent-queries-list.js'; export type { RecentQueriesState, RecentQueriesListInitialState, RecentQueriesListOptions, -} from './headless-recent-queries-list'; +} from './headless-recent-queries-list.js'; export type {RecentQueriesList, RecentQueriesListProps}; export interface RecentQueriesListDefinition diff --git a/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.test.ts b/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.test.ts index e73e6923f9a..81410a08dd7 100644 --- a/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.test.ts +++ b/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.test.ts @@ -1,27 +1,27 @@ import {NumberValue} from '@coveo/bueno'; -import {stateKey} from '../../../app/state-key'; -import {clearAllCoreFacets} from '../../../features/commerce/facets/core-facet/core-facet-actions'; +import {stateKey} from '../../../app/state-key.js'; +import {clearAllCoreFacets} from '../../../features/commerce/facets/core-facet/core-facet-actions.js'; import { clearRecentQueries, registerRecentQueries, -} from '../../../features/commerce/recent-queries/recent-queries-actions'; -import {recentQueriesReducer as recentQueries} from '../../../features/commerce/recent-queries/recent-queries-slice'; -import {prepareForSearchWithQuery} from '../../../features/commerce/search/search-actions'; -import {commerceSearchReducer as search} from '../../../features/commerce/search/search-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/recent-queries/recent-queries-actions.js'; +import {recentQueriesReducer as recentQueries} from '../../../features/commerce/recent-queries/recent-queries-slice.js'; +import {prepareForSearchWithQuery} from '../../../features/commerce/search/search-actions.js'; +import {commerceSearchReducer as search} from '../../../features/commerce/search/search-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockQueryState} from '../../../test/mock-query-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockQueryState} from '../../../test/mock-query-state.js'; import { buildRecentQueriesList, RecentQueriesList, -} from './headless-recent-queries-list'; +} from './headless-recent-queries-list.js'; -jest.mock('../../../features/commerce/facets/core-facet/core-facet-actions'); -jest.mock('../../../features/commerce/search/search-actions'); -jest.mock('../../../features/commerce/recent-queries/recent-queries-actions'); +vi.mock('../../../features/commerce/facets/core-facet/core-facet-actions'); +vi.mock('../../../features/commerce/search/search-actions'); +vi.mock('../../../features/commerce/recent-queries/recent-queries-actions'); describe('recent queries list', () => { let engine: MockedCommerceEngine; @@ -70,7 +70,7 @@ describe('recent queries list', () => { initialState: testInitialState, options: testOptions, }; - const mockedPrepareForSearchWithQuery = jest.mocked( + const mockedPrepareForSearchWithQuery = vi.mocked( prepareForSearchWithQuery ); @@ -97,7 +97,7 @@ describe('recent queries list', () => { }); it('#executeRecentQuery should validate the given index parameter', () => { - const validationSpy = jest.spyOn(NumberValue.prototype, 'validate'); + const validationSpy = vi.spyOn(NumberValue.prototype, 'validate'); engine[stateKey].recentQueries = {...testInitialState, ...testOptions}; expect(() => recentQueriesList.executeRecentQuery(100)).toThrow(); diff --git a/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ts b/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ts index a03453f571f..d177360d6e3 100644 --- a/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ts +++ b/packages/headless/src/controllers/commerce/recent-queries-list/headless-recent-queries-list.ts @@ -1,33 +1,33 @@ import {ArrayValue, BooleanValue, NumberValue, Schema} from '@coveo/bueno'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {UpdateQueryPayload} from '../../../features/commerce/query/query-actions'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {UpdateQueryPayload} from '../../../features/commerce/query/query-actions.js'; import { clearRecentQueries, registerRecentQueries, -} from '../../../features/commerce/recent-queries/recent-queries-actions'; -import {recentQueriesReducer as recentQueries} from '../../../features/commerce/recent-queries/recent-queries-slice'; +} from '../../../features/commerce/recent-queries/recent-queries-actions.js'; +import {recentQueriesReducer as recentQueries} from '../../../features/commerce/recent-queries/recent-queries-slice.js'; import { PrepareForSearchWithQueryOptions, executeSearch, prepareForSearchWithQuery, -} from '../../../features/commerce/search/search-actions'; -import {commerceSearchReducer as search} from '../../../features/commerce/search/search-slice'; -import {RecentQueriesSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../features/commerce/search/search-actions.js'; +import {commerceSearchReducer as search} from '../../../features/commerce/search/search-slice.js'; +import {RecentQueriesSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { validateInitialState, validateOptions, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import type { RecentQueriesListInitialState, RecentQueriesListOptions, RecentQueriesListProps, -} from '../../recent-queries-list/headless-recent-queries-list'; +} from '../../recent-queries-list/headless-recent-queries-list.js'; export type { RecentQueriesListProps, diff --git a/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ssr.ts b/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ssr.ts index 5fdeb03e747..07a63fe6527 100644 --- a/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ssr.ts +++ b/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ssr.ts @@ -1,10 +1,10 @@ -import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; -import {RecommendationsState} from '../recommendations/headless-recommendations'; +import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; +import {RecommendationsState} from '../recommendations/headless-recommendations.js'; import { RecommendationsProps, Recommendations, buildRecommendations, -} from './headless-recommendations'; +} from './headless-recommendations.js'; export type {Recommendations, RecommendationsState}; diff --git a/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.test.ts b/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.test.ts index 2716dba146d..b0a46156409 100644 --- a/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.test.ts +++ b/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.test.ts @@ -1,20 +1,20 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; import { fetchRecommendations, promoteChildToParent, -} from '../../../features/commerce/recommendations/recommendations-actions'; -import {recommendationsReducer} from '../../../features/commerce/recommendations/recommendations-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/recommendations/recommendations-actions.js'; +import {recommendationsReducer} from '../../../features/commerce/recommendations/recommendations-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; +} from '../../../test/mock-engine-v2.js'; import { Recommendations, buildRecommendations, -} from './headless-recommendations'; +} from './headless-recommendations.js'; -jest.mock('../../../features/commerce/recommendations/recommendations-actions'); +vi.mock('../../../features/commerce/recommendations/recommendations-actions'); describe('headless recommendations', () => { let recommendations: Recommendations; diff --git a/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ts b/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ts index 8c9b667c11a..3e2c2f69af8 100644 --- a/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ts +++ b/packages/headless/src/controllers/commerce/recommendations/headless-recommendations.ts @@ -1,40 +1,40 @@ import {createSelector} from '@reduxjs/toolkit'; -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {ChildProduct, Product} from '../../../api/commerce/common/product'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {ChildProduct, Product} from '../../../api/commerce/common/product.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; +} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; import { pageRecommendationSelector, perPageRecommendationSelector, totalEntriesRecommendationSelector, -} from '../../../features/commerce/pagination/pagination-selectors'; -import {recommendationsOptionsSchema} from '../../../features/commerce/recommendations/recommendations'; +} from '../../../features/commerce/pagination/pagination-selectors.js'; import { fetchMoreRecommendations, fetchRecommendations, promoteChildToParent, registerRecommendationsSlot, -} from '../../../features/commerce/recommendations/recommendations-actions'; +} from '../../../features/commerce/recommendations/recommendations-actions.js'; import { isLoadingSelector, numberOfRecommendationsSelector, -} from '../../../features/commerce/recommendations/recommendations-selectors'; -import {recommendationsReducer as recommendations} from '../../../features/commerce/recommendations/recommendations-slice'; -import {loadReducerError} from '../../../utils/errors'; -import {validateInitialState} from '../../../utils/validate-payload'; +} from '../../../features/commerce/recommendations/recommendations-selectors.js'; +import {recommendationsReducer as recommendations} from '../../../features/commerce/recommendations/recommendations-slice.js'; +import {recommendationsOptionsSchema} from '../../../features/commerce/recommendations/recommendations.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateInitialState} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { BaseSolutionTypeSubControllers, buildBaseSubControllers, -} from '../core/sub-controller/headless-sub-controller'; -import {SummaryState} from '../core/summary/headless-core-summary'; -import {RecommendationsSummaryState} from './summary/headless-recommendations-summary'; +} from '../core/sub-controller/headless-sub-controller.js'; +import {SummaryState} from '../core/summary/headless-core-summary.js'; +import {RecommendationsSummaryState} from './summary/headless-recommendations-summary.js'; /** * The `Recommendations` controller exposes a method for retrieving recommendations content in a commerce interface. diff --git a/packages/headless/src/controllers/commerce/recommendations/summary/headless-recommendations-summary.ts b/packages/headless/src/controllers/commerce/recommendations/summary/headless-recommendations-summary.ts index 1141bd5988c..c5113c278e2 100644 --- a/packages/headless/src/controllers/commerce/recommendations/summary/headless-recommendations-summary.ts +++ b/packages/headless/src/controllers/commerce/recommendations/summary/headless-recommendations-summary.ts @@ -1,3 +1,3 @@ -import {SummaryState} from '../../core/summary/headless-core-summary'; +import {SummaryState} from '../../core/summary/headless-core-summary.js'; export interface RecommendationsSummaryState extends SummaryState {} diff --git a/packages/headless/src/controllers/commerce/search-box/headless-search-box-options.ts b/packages/headless/src/controllers/commerce/search-box/headless-search-box-options.ts index 43fde612a33..a5dcc0109ae 100644 --- a/packages/headless/src/controllers/commerce/search-box/headless-search-box-options.ts +++ b/packages/headless/src/controllers/commerce/search-box/headless-search-box-options.ts @@ -2,7 +2,7 @@ import {Schema} from '@coveo/bueno'; import { searchBoxOptionDefinitions as coreSearchBoxOptionDefinitions, SearchBoxOptions as CoreSearchBoxOptions, -} from '../../core/search-box/headless-core-search-box-options'; +} from '../../core/search-box/headless-core-search-box-options.js'; export type SearchBoxOptions = Pick< CoreSearchBoxOptions, diff --git a/packages/headless/src/controllers/commerce/search-box/headless-search-box.ssr.ts b/packages/headless/src/controllers/commerce/search-box/headless-search-box.ssr.ts index a6b706f0310..6b736954364 100644 --- a/packages/headless/src/controllers/commerce/search-box/headless-search-box.ssr.ts +++ b/packages/headless/src/controllers/commerce/search-box/headless-search-box.ssr.ts @@ -1,17 +1,17 @@ -import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; +import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; import { SearchBox, buildSearchBox, SearchBoxProps, SearchBoxOptions, Suggestion, -} from './headless-search-box'; +} from './headless-search-box.js'; export type { SearchBoxState, SearchBox, SearchBoxProps, -} from './headless-search-box'; +} from './headless-search-box.js'; export type {SearchBoxOptions, Suggestion}; export interface SearchBoxDefinition diff --git a/packages/headless/src/controllers/commerce/search-box/headless-search-box.test.ts b/packages/headless/src/controllers/commerce/search-box/headless-search-box.test.ts index dd72cd61eed..4eeb08a05db 100644 --- a/packages/headless/src/controllers/commerce/search-box/headless-search-box.test.ts +++ b/packages/headless/src/controllers/commerce/search-box/headless-search-box.test.ts @@ -1,43 +1,43 @@ -import {configuration} from '../../../app/common-reducers'; -import {clearAllCoreFacets} from '../../../features/commerce/facets/core-facet/core-facet-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {clearAllCoreFacets} from '../../../features/commerce/facets/core-facet/core-facet-actions.js'; import { registerQuerySetQuery, updateQuerySetQuery, -} from '../../../features/commerce/query-set/query-set-actions'; +} from '../../../features/commerce/query-set/query-set-actions.js'; import { clearQuerySuggest, fetchQuerySuggestions, registerQuerySuggest, selectQuerySuggestion, -} from '../../../features/commerce/query-suggest/query-suggest-actions'; -import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice'; +} from '../../../features/commerce/query-suggest/query-suggest-actions.js'; +import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice.js'; import { executeSearch, prepareForSearchWithQuery, -} from '../../../features/commerce/search/search-actions'; -import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice'; -import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice'; -import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/search/search-actions.js'; +import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice.js'; +import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice.js'; +import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockQuerySuggest} from '../../../test/mock-query-suggest'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockQuerySuggest} from '../../../test/mock-query-suggest.js'; import { SearchBox, SearchBoxProps, SearchBoxOptions, buildSearchBox, -} from './headless-search-box'; +} from './headless-search-box.js'; -jest.mock('../../../features/commerce/query-suggest/query-suggest-actions'); -jest.mock('../../../features/commerce/search/search-actions'); -jest.mock('../../../features/commerce/query-set/query-set-actions'); -jest.mock('../../../features/commerce/facets/core-facet/core-facet-actions'); -jest.mock('../../../features/commerce/pagination/pagination-actions'); -jest.mock('../../../features/commerce/query/query-actions'); +vi.mock('../../../features/commerce/query-suggest/query-suggest-actions'); +vi.mock('../../../features/commerce/search/search-actions'); +vi.mock('../../../features/commerce/query-set/query-set-actions'); +vi.mock('../../../features/commerce/facets/core-facet/core-facet-actions'); +vi.mock('../../../features/commerce/pagination/pagination-actions'); +vi.mock('../../../features/commerce/query/query-actions'); describe('headless search box', () => { const id = 'search-box-123'; @@ -48,7 +48,7 @@ describe('headless search box', () => { let props: SearchBoxProps; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); const options: SearchBoxOptions = { id, highlightOptions: { @@ -72,7 +72,7 @@ describe('headless search box', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); function initState() { @@ -138,6 +138,7 @@ describe('headless search box', () => { describe('#state', () => { it('is as expected', () => { expect(searchBox.state).toEqual({ + searchBoxId: id, value: state.querySet[id], suggestions: state.querySuggest[id]!.completions.map((completion) => ({ highlightedValue: 'hilighted', @@ -178,7 +179,7 @@ describe('headless search box', () => { }); it('calls #showSuggestions', () => { - jest.spyOn(searchBox, 'showSuggestions'); + vi.spyOn(searchBox, 'showSuggestions'); searchBox.updateText('how can i fix'); expect(searchBox.showSuggestions).toHaveBeenCalled(); @@ -233,7 +234,7 @@ describe('headless search box', () => { }); it('when clearFilters option is false, does not dispatch #clearAllCoreFacets', () => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockCommerceEngine(state); searchBox = buildSearchBox(engine, { ...props, diff --git a/packages/headless/src/controllers/commerce/search-box/headless-search-box.ts b/packages/headless/src/controllers/commerce/search-box/headless-search-box.ts index 77b9356b362..be1682353e5 100644 --- a/packages/headless/src/controllers/commerce/search-box/headless-search-box.ts +++ b/packages/headless/src/controllers/commerce/search-box/headless-search-box.ts @@ -1,52 +1,52 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {configuration} from '../../../app/common-reducers'; -import {stateKey} from '../../../app/state-key'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {stateKey} from '../../../app/state-key.js'; import { registerQuerySetQuery, updateQuerySetQuery, -} from '../../../features/commerce/query-set/query-set-actions'; +} from '../../../features/commerce/query-set/query-set-actions.js'; import { clearQuerySuggest, fetchQuerySuggestions, registerQuerySuggest, selectQuerySuggestion, -} from '../../../features/commerce/query-suggest/query-suggest-actions'; -import {UpdateQueryPayload} from '../../../features/commerce/query/query-actions'; -import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice'; -import {executeSearch} from '../../../features/commerce/search/search-actions'; +} from '../../../features/commerce/query-suggest/query-suggest-actions.js'; +import {UpdateQueryPayload} from '../../../features/commerce/query/query-actions.js'; +import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice.js'; +import {executeSearch} from '../../../features/commerce/search/search-actions.js'; import { PrepareForSearchWithQueryOptions, prepareForSearchWithQuery, -} from '../../../features/commerce/search/search-actions'; -import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice'; -import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice'; -import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice'; +} from '../../../features/commerce/search/search-actions.js'; +import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice.js'; +import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice.js'; +import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice.js'; import { CommerceQuerySection, CommerceSearchSection, ConfigurationSection, QuerySetSection, QuerySuggestionSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { Delimiters, SuggestionHighlightingOptions, -} from '../../../utils/highlight'; -import {randomID} from '../../../utils/utils'; -import {validateOptions} from '../../../utils/validate-payload'; -import {buildController} from '../../controller/headless-controller'; +} from '../../../utils/highlight.js'; +import {randomID} from '../../../utils/utils.js'; +import {validateOptions} from '../../../utils/validate-payload.js'; +import {buildController} from '../../controller/headless-controller.js'; import { getSuggestions, SearchBoxState, SearchBox as CoreSearchBox, Suggestion, -} from '../../core/search-box/headless-core-search-box'; +} from '../../core/search-box/headless-core-search-box.js'; import { defaultSearchBoxOptions, SearchBoxOptions, searchBoxOptionsSchema, -} from './headless-search-box-options'; +} from './headless-search-box-options.js'; export type { SearchBoxOptions, @@ -160,6 +160,7 @@ export function buildSearchBox( : false; return { + searchBoxId: id, value: getValue(), suggestions, isLoading: getState().commerceSearch.isLoading, diff --git a/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.ts b/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.ts index 73844ef12e2..4d45151bc2a 100644 --- a/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.ts +++ b/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.ts @@ -1,6 +1,6 @@ -import {SearchOnlyControllerDefinitionWithoutProps} from '../../../../app/commerce-ssr-engine/types/common'; -import {buildSearch} from '../headless-search'; -import {DidYouMean, DidYouMeanState} from './headless-did-you-mean'; +import {SearchOnlyControllerDefinitionWithoutProps} from '../../../../app/commerce-ssr-engine/types/common.js'; +import {buildSearch} from '../headless-search.js'; +import {DidYouMean, DidYouMeanState} from './headless-did-you-mean.js'; export type {DidYouMean, DidYouMeanState}; diff --git a/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.test.ts b/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.test.ts index fdbf8c8ae78..c12250c3ae1 100644 --- a/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.test.ts +++ b/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.test.ts @@ -1,11 +1,11 @@ -import {stateKey} from '../../../../app/state-key'; -import {didYouMeanReducer} from '../../../../features/commerce/did-you-mean/did-you-mean-slice'; -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; +import {stateKey} from '../../../../app/state-key.js'; +import {didYouMeanReducer} from '../../../../features/commerce/did-you-mean/did-you-mean-slice.js'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../../test/mock-engine-v2'; -import {buildDidYouMean, DidYouMean} from './headless-did-you-mean'; +} from '../../../../test/mock-engine-v2.js'; +import {buildDidYouMean, DidYouMean} from './headless-did-you-mean.js'; describe('did you mean', () => { let didYouMean: DidYouMean; diff --git a/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ts b/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ts index 11dcb8b0f55..1112cc10903 100644 --- a/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ts +++ b/packages/headless/src/controllers/commerce/search/did-you-mean/headless-did-you-mean.ts @@ -1,18 +1,18 @@ import { QueryCorrection, WordCorrection, -} from '../../../../api/search/search/query-corrections'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../../app/state-key'; -import {didYouMeanReducer as didYouMean} from '../../../../features/commerce/did-you-mean/did-you-mean-slice'; -import {hasQueryCorrectionSelector} from '../../../../features/did-you-mean/did-you-mean-selectors'; -import {CommerceDidYouMeanSection} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; +} from '../../../../api/search/search/query-corrections.js'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../../app/state-key.js'; +import {didYouMeanReducer as didYouMean} from '../../../../features/commerce/did-you-mean/did-you-mean-slice.js'; +import {hasQueryCorrectionSelector} from '../../../../features/did-you-mean/did-you-mean-selectors.js'; +import {CommerceDidYouMeanSection} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; import { buildController, Controller, -} from '../../../controller/headless-controller'; -import {DidYouMeanState} from '../../../did-you-mean/headless-did-you-mean'; +} from '../../../controller/headless-controller.js'; +import {DidYouMeanState} from '../../../did-you-mean/headless-did-you-mean.js'; export type {QueryCorrection, WordCorrection, DidYouMeanState}; diff --git a/packages/headless/src/controllers/commerce/search/facets/headless-search-facet-options.ts b/packages/headless/src/controllers/commerce/search/facets/headless-search-facet-options.ts index dcc8e7a78fd..b1fbc9a186d 100644 --- a/packages/headless/src/controllers/commerce/search/facets/headless-search-facet-options.ts +++ b/packages/headless/src/controllers/commerce/search/facets/headless-search-facet-options.ts @@ -2,7 +2,7 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceFacetSetSection, CommerceSearchSection, -} from '../../../../state/state-sections'; +} from '../../../../state/state-sections.js'; export const facetResponseSelector = createSelector( ( diff --git a/packages/headless/src/controllers/commerce/search/headless-search.test.ts b/packages/headless/src/controllers/commerce/search/headless-search.test.ts index 723f4f57384..288b803c86b 100644 --- a/packages/headless/src/controllers/commerce/search/headless-search.test.ts +++ b/packages/headless/src/controllers/commerce/search/headless-search.test.ts @@ -1,16 +1,16 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; -import {configuration} from '../../../app/common-reducers'; -import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice.js'; import { pagePrincipalSelector, perPagePrincipalSelector, totalEntriesPrincipalSelector, -} from '../../../features/commerce/pagination/pagination-selectors'; -import {searchSerializer} from '../../../features/commerce/parameters/parameters-serializer'; -import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice'; -import {restoreSearchParameters} from '../../../features/commerce/search-parameters/search-parameters-actions'; -import {searchParametersDefinition} from '../../../features/commerce/search-parameters/search-parameters-schema'; -import * as SearchActions from '../../../features/commerce/search/search-actions'; +} from '../../../features/commerce/pagination/pagination-selectors.js'; +import {searchSerializer} from '../../../features/commerce/parameters/parameters-serializer.js'; +import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice.js'; +import {restoreSearchParameters} from '../../../features/commerce/search-parameters/search-parameters-actions.js'; +import {searchParametersDefinition} from '../../../features/commerce/search-parameters/search-parameters-schema.js'; +import * as SearchActions from '../../../features/commerce/search/search-actions.js'; import { activeParametersSelector, enrichedParametersSelector, @@ -20,19 +20,19 @@ import { numberOfProductsSelector, requestIdSelector, responseIdSelector, -} from '../../../features/commerce/search/search-selectors'; -import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +} from '../../../features/commerce/search/search-selectors.js'; +import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import * as SubControllers from '../core/sub-controller/headless-sub-controller'; +} from '../../../test/mock-engine-v2.js'; +import * as SubControllers from '../core/sub-controller/headless-sub-controller.js'; import { facetResponseSelector, isFacetLoadingResponseSelector, -} from './facets/headless-search-facet-options'; -import {buildSearch, Search} from './headless-search'; +} from './facets/headless-search-facet-options.js'; +import {buildSearch, Search} from './headless-search.js'; describe('headless search', () => { let search: Search; @@ -44,7 +44,7 @@ describe('headless search', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('adds the correct reducers to engine', () => { @@ -57,7 +57,7 @@ describe('headless search', () => { }); it('uses sub-controllers', () => { - const buildSearchSubControllers = jest.spyOn( + const buildSearchSubControllers = vi.spyOn( SubControllers, 'buildSearchSubControllers' ); @@ -87,7 +87,7 @@ describe('headless search', () => { }); it('#promoteChildToParent dispatches #promoteChildToParent with the correct arguments', () => { - const promoteChildToParent = jest.spyOn( + const promoteChildToParent = vi.spyOn( SearchActions, 'promoteChildToParent' ); @@ -99,7 +99,7 @@ describe('headless search', () => { }); it('executeFirstSearch dispatches #executeSearch', () => { - const executeSearch = jest.spyOn(SearchActions, 'executeSearch'); + const executeSearch = vi.spyOn(SearchActions, 'executeSearch'); search.executeFirstSearch(); diff --git a/packages/headless/src/controllers/commerce/search/headless-search.ts b/packages/headless/src/controllers/commerce/search/headless-search.ts index 1808478f752..12dc5f1b2b3 100644 --- a/packages/headless/src/controllers/commerce/search/headless-search.ts +++ b/packages/headless/src/controllers/commerce/search/headless-search.ts @@ -1,23 +1,23 @@ -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {ChildProduct, Product} from '../../../api/commerce/common/product'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {configuration} from '../../../app/common-reducers'; -import {stateKey} from '../../../app/state-key'; -import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {ChildProduct, Product} from '../../../api/commerce/common/product.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {stateKey} from '../../../app/state-key.js'; +import {contextReducer as commerceContext} from '../../../features/commerce/context/context-slice.js'; import { pagePrincipalSelector, perPagePrincipalSelector, totalEntriesPrincipalSelector, -} from '../../../features/commerce/pagination/pagination-selectors'; -import {searchSerializer} from '../../../features/commerce/parameters/parameters-serializer'; -import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice'; -import {restoreSearchParameters} from '../../../features/commerce/search-parameters/search-parameters-actions'; -import {searchParametersDefinition} from '../../../features/commerce/search-parameters/search-parameters-schema'; +} from '../../../features/commerce/pagination/pagination-selectors.js'; +import {searchSerializer} from '../../../features/commerce/parameters/parameters-serializer.js'; +import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice.js'; +import {restoreSearchParameters} from '../../../features/commerce/search-parameters/search-parameters-actions.js'; +import {searchParametersDefinition} from '../../../features/commerce/search-parameters/search-parameters-schema.js'; import { executeSearch, fetchMoreProducts, promoteChildToParent, -} from '../../../features/commerce/search/search-actions'; +} from '../../../features/commerce/search/search-actions.js'; import { activeParametersSelector, enrichedParametersSelector, @@ -27,21 +27,21 @@ import { numberOfProductsSelector, requestIdSelector, responseIdSelector, -} from '../../../features/commerce/search/search-selectors'; -import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../features/commerce/search/search-selectors.js'; +import {commerceSearchReducer as commerceSearch} from '../../../features/commerce/search/search-slice.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { buildSearchSubControllers, SearchSubControllers, -} from '../core/sub-controller/headless-sub-controller'; +} from '../core/sub-controller/headless-sub-controller.js'; import { facetResponseSelector, isFacetLoadingResponseSelector, -} from './facets/headless-search-facet-options'; +} from './facets/headless-search-facet-options.js'; /** * The `Search` controller lets you create a commerce search page. diff --git a/packages/headless/src/controllers/commerce/search/summary/headless-search-summary.ts b/packages/headless/src/controllers/commerce/search/summary/headless-search-summary.ts index 4a8105fc9f5..61186bcebd4 100644 --- a/packages/headless/src/controllers/commerce/search/summary/headless-search-summary.ts +++ b/packages/headless/src/controllers/commerce/search/summary/headless-search-summary.ts @@ -1,4 +1,4 @@ -import {SummaryState} from '../../core/summary/headless-core-summary'; +import {SummaryState} from '../../core/summary/headless-core-summary.js'; export interface SearchSummaryState extends SummaryState { /** diff --git a/packages/headless/src/controllers/commerce/search/utils/load-search-reducers.ts b/packages/headless/src/controllers/commerce/search/utils/load-search-reducers.ts index 43580662ef7..054443f1436 100644 --- a/packages/headless/src/controllers/commerce/search/utils/load-search-reducers.ts +++ b/packages/headless/src/controllers/commerce/search/utils/load-search-reducers.ts @@ -1,6 +1,6 @@ -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {commerceSearchReducer as commerceSearch} from '../../../../features/commerce/search/search-slice'; -import {CommerceSearchSection} from '../../../../state/state-sections'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {commerceSearchReducer as commerceSearch} from '../../../../features/commerce/search/search-slice.js'; +import {CommerceSearchSection} from '../../../../state/state-sections.js'; export function loadSearchReducer( engine: CommerceEngine diff --git a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box-options.ts b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box-options.ts index 894393f1ad8..dad557608d2 100644 --- a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box-options.ts +++ b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box-options.ts @@ -2,7 +2,7 @@ import {BooleanValue, Schema, StringValue} from '@coveo/bueno'; import { searchBoxOptionDefinitions, SearchBoxOptions, -} from '../search-box/headless-search-box-options'; +} from '../search-box/headless-search-box-options.js'; export interface StandaloneSearchBoxOptions extends SearchBoxOptions { /** diff --git a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.ts b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.ts index 6d639d9ca4b..eb2a02ee19b 100644 --- a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.ts +++ b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.ts @@ -1,12 +1,12 @@ -import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; -import {StandaloneSearchBoxProps} from '../../standalone-search-box/headless-standalone-search-box'; +import {UniversalControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; +import {StandaloneSearchBoxProps} from '../../standalone-search-box/headless-standalone-search-box.js'; import { StandaloneSearchBox, buildStandaloneSearchBox, -} from './headless-standalone-search-box'; +} from './headless-standalone-search-box.js'; -export type {StandaloneSearchBoxOptions} from './headless-standalone-search-box-options'; -export type {StandaloneSearchBoxState} from './headless-standalone-search-box'; +export type {StandaloneSearchBoxOptions} from './headless-standalone-search-box-options.js'; +export type {StandaloneSearchBoxState} from './headless-standalone-search-box.js'; export type {StandaloneSearchBox, StandaloneSearchBoxProps}; export interface StandaloneSearchBoxDefinition diff --git a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.test.ts b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.test.ts index 5f73b128e94..e89057e5649 100644 --- a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.test.ts +++ b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.test.ts @@ -1,38 +1,38 @@ -import {configuration} from '../../../app/common-reducers'; -import {stateKey} from '../../../app/state-key'; +import {configuration} from '../../../app/common-reducers.js'; +import {stateKey} from '../../../app/state-key.js'; import { registerQuerySetQuery, updateQuerySetQuery, -} from '../../../features/commerce/query-set/query-set-actions'; -import {selectQuerySuggestion} from '../../../features/commerce/query-suggest/query-suggest-actions'; -import {updateQuery} from '../../../features/commerce/query/query-actions'; -import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice'; +} from '../../../features/commerce/query-set/query-set-actions.js'; +import {selectQuerySuggestion} from '../../../features/commerce/query-suggest/query-suggest-actions.js'; +import {updateQuery} from '../../../features/commerce/query/query-actions.js'; +import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice.js'; import { fetchRedirectUrl, registerStandaloneSearchBox, resetStandaloneSearchBox, -} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-actions'; -import {commerceStandaloneSearchBoxSetReducer as commerceStandaloneSearchBoxSet} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-slice'; +} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-actions.js'; +import {commerceStandaloneSearchBoxSetReducer as commerceStandaloneSearchBoxSet} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-slice.js'; // TODO: KIT-3127: import from commerce -import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { buildMockCommerceEngine, MockedCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockQuerySuggest} from '../../../test/mock-query-suggest'; -import {buildMockStandaloneSearchBoxEntry} from '../../../test/mock-standalone-search-box-entry'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockQuerySuggest} from '../../../test/mock-query-suggest.js'; +import {buildMockStandaloneSearchBoxEntry} from '../../../test/mock-standalone-search-box-entry.js'; +import {StandaloneSearchBoxOptions} from './headless-standalone-search-box-options.js'; import { StandaloneSearchBox, buildStandaloneSearchBox, -} from './headless-standalone-search-box'; -import {StandaloneSearchBoxOptions} from './headless-standalone-search-box-options'; +} from './headless-standalone-search-box.js'; -jest.mock('../../../features/commerce/query-set/query-set-actions'); -jest.mock('../../../features/commerce/query-suggest/query-suggest-actions'); -jest.mock('../../../features/commerce/query/query-actions'); -jest.mock( +vi.mock('../../../features/commerce/query-set/query-set-actions'); +vi.mock('../../../features/commerce/query-suggest/query-suggest-actions'); +vi.mock('../../../features/commerce/query/query-actions'); +vi.mock( '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-actions' ); @@ -102,6 +102,7 @@ describe('headless standalone searchBox', () => { it('should return the right state', () => { expect(searchBox.state).toEqual({ + searchBoxId: id, value: state.querySet[id], suggestions: state.querySuggest[id]!.completions.map((completion) => ({ value: completion.expression, @@ -140,7 +141,7 @@ describe('headless standalone searchBox', () => { }); it('calls #submit', () => { - jest.spyOn(searchBox, 'submit'); + vi.spyOn(searchBox, 'submit'); searchBox.selectSuggestion('a'); expect(searchBox.submit).toHaveBeenCalledTimes(1); diff --git a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ts b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ts index ece51239576..7a8f61e7b14 100644 --- a/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ts +++ b/packages/headless/src/controllers/commerce/standalone-search-box/headless-standalone-search-box.ts @@ -1,37 +1,37 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {configuration} from '../../../app/common-reducers'; -import {stateKey} from '../../../app/state-key'; -import {selectQuerySuggestion} from '../../../features/commerce/query-suggest/query-suggest-actions'; -import {updateQuery} from '../../../features/commerce/query/query-actions'; -import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {stateKey} from '../../../app/state-key.js'; +import {selectQuerySuggestion} from '../../../features/commerce/query-suggest/query-suggest-actions.js'; +import {updateQuery} from '../../../features/commerce/query/query-actions.js'; +import {queryReducer as commerceQuery} from '../../../features/commerce/query/query-slice.js'; import { fetchRedirectUrl, registerStandaloneSearchBox, resetStandaloneSearchBox, updateStandaloneSearchBoxRedirectionUrl, -} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-actions'; -import {commerceStandaloneSearchBoxSetReducer as commerceStandaloneSearchBoxSet} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-slice'; -import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice'; +} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-actions.js'; +import {commerceStandaloneSearchBoxSetReducer as commerceStandaloneSearchBoxSet} from '../../../features/commerce/standalone-search-box-set/standalone-search-box-set-slice.js'; +import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice.js'; import { CommerceQuerySection, ConfigurationSection, QuerySuggestionSection, CommerceStandaloneSearchBoxSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {randomID} from '../../../utils/utils'; -import {validateOptions} from '../../../utils/validate-payload'; -import {StandaloneSearchBoxProps} from '../../standalone-search-box/headless-standalone-search-box'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {randomID} from '../../../utils/utils.js'; +import {validateOptions} from '../../../utils/validate-payload.js'; +import {StandaloneSearchBoxProps} from '../../standalone-search-box/headless-standalone-search-box.js'; +import {defaultSearchBoxOptions} from '../search-box/headless-search-box-options.js'; import { SearchBox, SearchBoxState, buildSearchBox, -} from '../search-box/headless-search-box'; -import {defaultSearchBoxOptions} from '../search-box/headless-search-box-options'; +} from '../search-box/headless-search-box.js'; import { StandaloneSearchBoxOptions, standaloneSearchBoxSchema, -} from './headless-standalone-search-box-options'; +} from './headless-standalone-search-box-options.js'; export interface StandaloneSearchBox extends SearchBox { /** diff --git a/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ssr.ts b/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ssr.ts index 1f8483d6fac..ad53283a289 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ssr.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ssr.ts @@ -1,8 +1,8 @@ -import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; -import {NotifyTrigger} from '../../core/triggers/headless-core-notify-trigger'; -import {buildNotifyTrigger} from './headless-notify-trigger'; +import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; +import {NotifyTrigger} from '../../core/triggers/headless-core-notify-trigger.js'; +import {buildNotifyTrigger} from './headless-notify-trigger.js'; -export type {NotifyTriggerState} from '../../core/triggers/headless-core-notify-trigger'; +export type {NotifyTriggerState} from '../../core/triggers/headless-core-notify-trigger.js'; export type {NotifyTrigger}; export interface NotifyTriggerDefinition extends SearchOnlyControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.test.ts b/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.test.ts index ee3a1e97935..9e33eab6663 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.test.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.test.ts @@ -1,12 +1,13 @@ -import {stateKey} from '../../../app/state-key'; -import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {Mock} from 'vitest'; +import {stateKey} from '../../../app/state-key.js'; +import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {NotifyTrigger} from '../../core/triggers/headless-core-notify-trigger'; -import {buildNotifyTrigger} from './headless-notify-trigger'; +} from '../../../test/mock-engine-v2.js'; +import {NotifyTrigger} from '../../core/triggers/headless-core-notify-trigger.js'; +import {buildNotifyTrigger} from './headless-notify-trigger.js'; describe('commerce notify trigger', () => { let engine: MockedCommerceEngine; @@ -21,11 +22,11 @@ describe('commerce notify trigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockCommerceEngine(buildMockCommerceState()); initNotifyTrigger(); }); @@ -45,7 +46,7 @@ describe('commerce notify trigger', () => { }); it('when the #engine.state.triggers.notifications is not updated, does not call the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); engine = buildMockCommerceEngine(buildMockCommerceState()); initNotifyTrigger(); @@ -58,7 +59,7 @@ describe('commerce notify trigger', () => { }); it('when the #engine.state.triggers.notifications is updated, calls the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); engine = buildMockCommerceEngine(buildMockCommerceState()); initNotifyTrigger(); @@ -72,7 +73,7 @@ describe('commerce notify trigger', () => { }); it('when the #engine.state.triggers.notifications is updated with an empty array, does not call the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); engine = buildMockCommerceEngine(buildMockCommerceState()); initNotifyTrigger(); @@ -86,7 +87,7 @@ describe('commerce notify trigger', () => { }); it('when a non-empty #engine.state.triggers.notifications is updated with an empty array, calls the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); engine = buildMockCommerceEngine(buildMockCommerceState()); setEngineTriggersState(['hello', 'world']); @@ -100,8 +101,8 @@ describe('commerce notify trigger', () => { expect(listener).toHaveBeenCalledTimes(1); }); - describe('when a non-empty #engine.state.triggers.notifications is updated with the same array, does not call the listener', () => { - const listener = jest.fn(); + it('when a non-empty #engine.state.triggers.notifications is updated with the same array, does not call the listener', () => { + const listener = vi.fn(); engine = buildMockCommerceEngine(buildMockCommerceState()); setEngineTriggersState(['hello', 'world']); diff --git a/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ts b/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ts index 085fa7d3104..cc51dfc694e 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-notify-trigger.ts @@ -1,11 +1,11 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice'; -import {TriggerSection} from '../../../state/state-sections'; -import {arrayEqual} from '../../../utils/compare-utils'; -import {loadReducerError} from '../../../utils/errors'; -import {buildController} from '../../controller/headless-controller'; -import {NotifyTrigger} from '../../core/triggers/headless-core-notify-trigger'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice.js'; +import {TriggerSection} from '../../../state/state-sections.js'; +import {arrayEqual} from '../../../utils/compare-utils.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {buildController} from '../../controller/headless-controller.js'; +import {NotifyTrigger} from '../../core/triggers/headless-core-notify-trigger.js'; /** * Creates a `NotifyTrigger` controller instance. diff --git a/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ssr.ts b/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ssr.ts index 458cdd87306..94f7c82add5 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ssr.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ssr.ts @@ -1,8 +1,8 @@ -import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; -import {QueryTrigger} from '../../core/triggers/headless-core-query-trigger'; -import {buildQueryTrigger} from './headless-query-trigger'; +import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; +import {QueryTrigger} from '../../core/triggers/headless-core-query-trigger.js'; +import {buildQueryTrigger} from './headless-query-trigger.js'; -export type {QueryTriggerState} from '../../core/triggers/headless-core-query-trigger'; +export type {QueryTriggerState} from '../../core/triggers/headless-core-query-trigger.js'; export type {QueryTrigger}; export interface QueryTriggerDefinition extends SearchOnlyControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.test.ts b/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.test.ts index 172493c2583..5d1c63e9466 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.test.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.test.ts @@ -1,18 +1,19 @@ -import {stateKey} from '../../../app/state-key'; -import {updateQuery} from '../../../features/commerce/query/query-actions'; -import {queryReducer as query} from '../../../features/commerce/query/query-slice'; -import {executeSearch} from '../../../features/commerce/search/search-actions'; -import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {Mock} from 'vitest'; +import {stateKey} from '../../../app/state-key.js'; +import {updateQuery} from '../../../features/commerce/query/query-actions.js'; +import {queryReducer as query} from '../../../features/commerce/query/query-slice.js'; +import {executeSearch} from '../../../features/commerce/search/search-actions.js'; +import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {QueryTrigger} from '../../core/triggers/headless-core-query-trigger'; -import {buildQueryTrigger} from './headless-query-trigger'; +} from '../../../test/mock-engine-v2.js'; +import {QueryTrigger} from '../../core/triggers/headless-core-query-trigger.js'; +import {buildQueryTrigger} from './headless-query-trigger.js'; -jest.mock('../../../features/commerce/query/query-actions'); -jest.mock('../../../features/commerce/search/search-actions'); +vi.mock('../../../features/commerce/query/query-actions'); +vi.mock('../../../features/commerce/search/search-actions'); describe('commerce query trigger', () => { let engine: MockedCommerceEngine; @@ -23,7 +24,7 @@ describe('commerce query trigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { @@ -47,7 +48,7 @@ describe('commerce query trigger', () => { }); describe('when a search without a trigger is performed', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockCommerceEngine(buildMockCommerceState()); initQueryTrigger(); diff --git a/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ts b/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ts index f6eac0125fb..483afbe2a1d 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-query-trigger.ts @@ -1,14 +1,14 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {updateQuery} from '../../../features/commerce/query/query-actions'; -import {queryReducer as query} from '../../../features/commerce/query/query-slice'; -import {executeSearch} from '../../../features/commerce/search/search-actions'; -import {updateIgnoreQueryTrigger} from '../../../features/commerce/triggers/triggers-actions'; -import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice'; -import {TriggerSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {buildController} from '../../controller/headless-controller'; -import {QueryTrigger} from '../../core/triggers/headless-core-query-trigger'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {updateQuery} from '../../../features/commerce/query/query-actions.js'; +import {queryReducer as query} from '../../../features/commerce/query/query-slice.js'; +import {executeSearch} from '../../../features/commerce/search/search-actions.js'; +import {updateIgnoreQueryTrigger} from '../../../features/commerce/triggers/triggers-actions.js'; +import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice.js'; +import {TriggerSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {buildController} from '../../controller/headless-controller.js'; +import {QueryTrigger} from '../../core/triggers/headless-core-query-trigger.js'; /** * Creates a `QueryTrigger` controller instance. diff --git a/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ssr.ts b/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ssr.ts index c6f6857beda..a575345336e 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ssr.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ssr.ts @@ -1,8 +1,8 @@ -import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common'; -import {RedirectionTrigger} from '../../core/triggers/headless-core-redirection-trigger'; -import {buildRedirectionTrigger} from './headless-redirection-trigger'; +import {SearchOnlyControllerDefinitionWithoutProps} from '../../../app/commerce-ssr-engine/types/common.js'; +import {RedirectionTrigger} from '../../core/triggers/headless-core-redirection-trigger.js'; +import {buildRedirectionTrigger} from './headless-redirection-trigger.js'; -export type {RedirectionTriggerState} from '../../core/triggers/headless-core-redirection-trigger'; +export type {RedirectionTriggerState} from '../../core/triggers/headless-core-redirection-trigger.js'; export type {RedirectionTrigger}; export interface RedirectionTriggerDefinition extends SearchOnlyControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.test.ts b/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.test.ts index d3628dfb31f..37e768cfa4b 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.test.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.test.ts @@ -1,12 +1,13 @@ -import {stateKey} from '../../../app/state-key'; -import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {Mock} from 'vitest'; +import {stateKey} from '../../../app/state-key.js'; +import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { MockedCommerceEngine, buildMockCommerceEngine, -} from '../../../test/mock-engine-v2'; -import {RedirectionTrigger} from '../../core/triggers/headless-core-redirection-trigger'; -import {buildRedirectionTrigger} from './headless-redirection-trigger'; +} from '../../../test/mock-engine-v2.js'; +import {RedirectionTrigger} from '../../core/triggers/headless-core-redirection-trigger.js'; +import {buildRedirectionTrigger} from './headless-redirection-trigger.js'; describe('RedirectionTrigger', () => { let engine: MockedCommerceEngine; @@ -17,7 +18,7 @@ describe('RedirectionTrigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { @@ -40,7 +41,7 @@ describe('RedirectionTrigger', () => { }); it('when the #engine.state.triggers.redirectTo is already initialized, does not call the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); const state = buildMockCommerceState(); state.triggers.redirectTo = 'https://www.google.com'; engine = buildMockCommerceEngine(state); @@ -51,7 +52,7 @@ describe('RedirectionTrigger', () => { }); it('when the #engine.state.triggers.redirectTo is not updated, does not call the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); redirectionTrigger.subscribe(listener); const [firstListener] = registeredListeners(); firstListener(); @@ -60,7 +61,7 @@ describe('RedirectionTrigger', () => { }); it('when the #engine.state.triggers.redirectTo is updated to the empty string, does not call the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); redirectionTrigger.subscribe(listener); engine[stateKey].triggers!.redirectTo = ''; const [firstListener] = registeredListeners(); @@ -70,7 +71,7 @@ describe('RedirectionTrigger', () => { }); it('when the #engine.state.triggers.redirectTo is updated, calls the listener', () => { - const listener = jest.fn(); + const listener = vi.fn(); redirectionTrigger.subscribe(listener); engine[stateKey].triggers!.redirectTo = 'https://www.coveo.com'; diff --git a/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ts b/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ts index cde06f4f0b2..de85b201317 100644 --- a/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ts +++ b/packages/headless/src/controllers/commerce/triggers/headless-redirection-trigger.ts @@ -1,10 +1,10 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice'; -import {TriggerSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {buildController} from '../../controller/headless-controller'; -import {RedirectionTrigger} from '../../core/triggers/headless-core-redirection-trigger'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {commerceTriggersReducer as triggers} from '../../../features/commerce/triggers/triggers-slice.js'; +import {TriggerSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {buildController} from '../../controller/headless-controller.js'; +import {RedirectionTrigger} from '../../core/triggers/headless-core-redirection-trigger.js'; /** * Creates a `RedirectionTrigger` controller instance. diff --git a/packages/headless/src/controllers/context/headless-context.ssr.test.ts b/packages/headless/src/controllers/context/headless-context.ssr.test.ts index 8c0d8d0f348..5c490efae8f 100644 --- a/packages/headless/src/controllers/context/headless-context.ssr.test.ts +++ b/packages/headless/src/controllers/context/headless-context.ssr.test.ts @@ -1,12 +1,12 @@ -import {SSRSearchEngine} from '../../app/search-engine/search-engine.ssr'; -import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common'; -import {buildMockSSRSearchEngine} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {Context, buildContext} from './headless-context'; -import {ContextProps, defineContext} from './headless-context.ssr'; - -jest.mock('./headless-context'); -const buildContextMock = jest.mocked(buildContext); +import {SSRSearchEngine} from '../../app/search-engine/search-engine.ssr.js'; +import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common.js'; +import {buildMockSSRSearchEngine} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {Context, buildContext} from './headless-context.js'; +import {ContextProps, defineContext} from './headless-context.ssr.js'; + +vi.mock('./headless-context'); +const buildContextMock = vi.mocked(buildContext); type contextDefinitionType = ControllerDefinitionWithProps< SSRSearchEngine, diff --git a/packages/headless/src/controllers/context/headless-context.ssr.ts b/packages/headless/src/controllers/context/headless-context.ssr.ts index 2d35de0b01f..25f13e4fe68 100644 --- a/packages/headless/src/controllers/context/headless-context.ssr.ts +++ b/packages/headless/src/controllers/context/headless-context.ssr.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common'; -import {ContextProps} from '../core/context/headless-core-context'; -import {Context, buildContext} from './headless-context'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common.js'; +import {ContextProps} from '../core/context/headless-core-context.js'; +import {Context, buildContext} from './headless-context.js'; -export * from './headless-context'; +export * from './headless-context.js'; export interface ContextDefinition extends ControllerDefinitionWithProps {} diff --git a/packages/headless/src/controllers/context/headless-context.test.ts b/packages/headless/src/controllers/context/headless-context.test.ts index 9321001d552..c79a6de8955 100644 --- a/packages/headless/src/controllers/context/headless-context.test.ts +++ b/packages/headless/src/controllers/context/headless-context.test.ts @@ -1,12 +1,17 @@ -import {setContext} from '../../features/context/context-actions'; +import {describe, it, expect, vi, beforeEach} from 'vitest'; +import {setContext} from '../../features/context/context-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildContext, Context, ContextInitialState} from './headless-context'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import { + buildContext, + Context, + ContextInitialState, +} from './headless-context.js'; -jest.mock('../../features/context/context-actions'); +vi.mock('../../features/context/context-actions'); describe('Context', () => { let context: Context; diff --git a/packages/headless/src/controllers/context/headless-context.ts b/packages/headless/src/controllers/context/headless-context.ts index d961518a803..e07563fd564 100644 --- a/packages/headless/src/controllers/context/headless-context.ts +++ b/packages/headless/src/controllers/context/headless-context.ts @@ -1,15 +1,15 @@ -import {CoreEngine} from '../../app/engine'; +import {CoreEngine} from '../../app/engine.js'; import { ContextPayload, ContextValue, -} from '../../features/context/context-state'; +} from '../../features/context/context-state.js'; import { buildCoreContext, Context, ContextProps, ContextState, -} from '../core/context/headless-core-context'; -import {ContextInitialState} from './../core/context/headless-core-context'; +} from '../core/context/headless-core-context.js'; +import {ContextInitialState} from './../core/context/headless-core-context.js'; export type { Context, diff --git a/packages/headless/src/controllers/controller/headless-controller.test.ts b/packages/headless/src/controllers/controller/headless-controller.test.ts index 5250ee6ad52..0d71e5b5697 100644 --- a/packages/headless/src/controllers/controller/headless-controller.test.ts +++ b/packages/headless/src/controllers/controller/headless-controller.test.ts @@ -1,20 +1,21 @@ +import {Mock} from 'vitest'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildController, Controller} from './headless-controller'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildController, Controller} from './headless-controller.js'; describe('Controller', () => { let engine: MockedSearchEngine; let cmp: Controller; function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } function updateControllerState(state: object) { - jest.spyOn(cmp, 'state', 'get').mockReturnValue(state); + vi.spyOn(cmp, 'state', 'get').mockReturnValue(state); } beforeEach(() => { @@ -24,28 +25,28 @@ describe('Controller', () => { }); it('calling #subscribe invokes the passed listener immediately', () => { - const listener = jest.fn(); + const listener = vi.fn(); cmp.subscribe(listener); expect(listener).toHaveBeenCalledTimes(1); }); it('calling #subscribe registers a handler on the engine', () => { - const listener = jest.fn(); + const listener = vi.fn(); cmp.subscribe(listener); expect(registeredListeners().length).toBe(1); }); it('the #subscribe method returns a function', () => { - const listener = jest.fn(); + const listener = vi.fn(); const returnValue = cmp.subscribe(listener); expect(typeof returnValue).toBe('function'); }); it('invoking the registered #subscribe handler calls the listener if the state has changed', () => { - const listener = jest.fn(); + const listener = vi.fn(); cmp.subscribe(listener); updateControllerState({property: 'new value'}); @@ -56,7 +57,7 @@ describe('Controller', () => { }); it('invoking the registered #subscribe handler does not call the listener if the state has not changed', () => { - const listener = jest.fn(); + const listener = vi.fn(); cmp.subscribe(listener); const [firstListener] = registeredListeners(); @@ -66,8 +67,8 @@ describe('Controller', () => { }); it('allows subscribing twice to same instance when there is a state change', () => { - const firstListener = jest.fn(); - const secondListener = jest.fn(); + const firstListener = vi.fn(); + const secondListener = vi.fn(); cmp.subscribe(firstListener); cmp.subscribe(secondListener); diff --git a/packages/headless/src/controllers/controller/headless-controller.ts b/packages/headless/src/controllers/controller/headless-controller.ts index c9ce2df0aa6..4b9a8f3de26 100644 --- a/packages/headless/src/controllers/controller/headless-controller.ts +++ b/packages/headless/src/controllers/controller/headless-controller.ts @@ -1,5 +1,5 @@ import {Unsubscribe} from '@reduxjs/toolkit'; -import type {CoreEngine, CoreEngineNext} from '../../app/engine'; +import type {CoreEngine, CoreEngineNext} from '../../app/engine.js'; export interface Subscribable { /** diff --git a/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts b/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts index e773c0bbcdf..0410520ae7b 100644 --- a/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts +++ b/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.test.ts @@ -1,15 +1,16 @@ -import {deselectAllBreadcrumbs} from '../../../features/breadcrumb/breadcrumb-actions'; +import {describe, it, vi, expect, beforeEach} from 'vitest'; +import {deselectAllBreadcrumbs} from '../../../features/breadcrumb/breadcrumb-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { BreadcrumbManager, buildCoreBreadcrumbManager, -} from './headless-core-breadcrumb-manager'; +} from './headless-core-breadcrumb-manager.js'; -jest.mock('../../../features/breadcrumb/breadcrumb-actions'); +vi.mock('../../../features/breadcrumb/breadcrumb-actions'); describe('headless breadcrumb manager', () => { let engine: MockedSearchEngine; @@ -21,7 +22,7 @@ describe('headless breadcrumb manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initController(); }); diff --git a/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts b/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts index 2ce1b4c90ad..0a4038a410a 100644 --- a/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts +++ b/packages/headless/src/controllers/core/breadcrumb-manager/headless-core-breadcrumb-manager.ts @@ -1,14 +1,14 @@ -import {CoreEngine} from '../../../app/engine'; -import {deselectAllBreadcrumbs} from '../../../features/breadcrumb/breadcrumb-actions'; -import {CategoryFacetValue} from '../../../features/facets/category-facet-set/interfaces/response'; -import {BaseFacetValue} from '../../../features/facets/facet-api/response'; -import {FacetValueRequest} from '../../../features/facets/facet-set/interfaces/request'; -import {FacetValue} from '../../../features/facets/facet-set/interfaces/response'; -import {AnyFacetSetState} from '../../../features/facets/generic/interfaces/generic-facet-section'; -import {DateRangeRequest} from '../../../features/facets/range-facets/date-facet-set/interfaces/request'; -import {DateFacetValue} from '../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {NumericRangeRequest} from '../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; -import {NumericFacetValue} from '../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +import {CoreEngine} from '../../../app/engine.js'; +import {deselectAllBreadcrumbs} from '../../../features/breadcrumb/breadcrumb-actions.js'; +import {CategoryFacetValue} from '../../../features/facets/category-facet-set/interfaces/response.js'; +import {BaseFacetValue} from '../../../features/facets/facet-api/response.js'; +import {FacetValueRequest} from '../../../features/facets/facet-set/interfaces/request.js'; +import {FacetValue} from '../../../features/facets/facet-set/interfaces/response.js'; +import {AnyFacetSetState} from '../../../features/facets/generic/interfaces/generic-facet-section.js'; +import {DateRangeRequest} from '../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; +import {DateFacetValue} from '../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {NumericRangeRequest} from '../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {NumericFacetValue} from '../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { CategoryFacetSection, ConfigurationSection, @@ -16,12 +16,12 @@ import { FacetSection, NumericFacetSection, SearchSection, -} from '../../../state/state-sections'; +} from '../../../state/state-sections.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; -import {StaticFilterValue} from '../../static-filter/headless-static-filter'; +} from '../../controller/headless-controller.js'; +import {StaticFilterValue} from '../../static-filter/headless-static-filter.js'; /** * The `BreadcrumbManager` headless controller manages a summary of the currently active facet filters. diff --git a/packages/headless/src/controllers/core/context/example-deleteme-headless-case-context.ts b/packages/headless/src/controllers/core/context/example-deleteme-headless-case-context.ts index 7dd8a172dc5..9c73d137015 100644 --- a/packages/headless/src/controllers/core/context/example-deleteme-headless-case-context.ts +++ b/packages/headless/src/controllers/core/context/example-deleteme-headless-case-context.ts @@ -1,14 +1,14 @@ /** * This is an example of how to generate a strict context provider */ -import {CoreEngine} from '../../../app/engine'; +import {CoreEngine} from '../../../app/engine.js'; import { Context as CoreContext, ContextState as CoreContextState, ContextProps as CoreContextProps, -} from './headless-core-context'; -import {buildInternalCoreContext} from './headless-core-internal-context'; -import {generateStrictContextFunctions} from './headless-strict-context-factory'; +} from './headless-core-context.js'; +import {buildInternalCoreContext} from './headless-core-internal-context.js'; +import {generateStrictContextFunctions} from './headless-strict-context-factory.js'; export interface ContextProps extends CoreContextProps {} diff --git a/packages/headless/src/controllers/core/context/headless-core-context.test.ts b/packages/headless/src/controllers/core/context/headless-core-context.test.ts index e29b232a4ae..ee120c08d0f 100644 --- a/packages/headless/src/controllers/core/context/headless-core-context.test.ts +++ b/packages/headless/src/controllers/core/context/headless-core-context.test.ts @@ -2,23 +2,23 @@ import { addContext, removeContext, setContext, -} from '../../../features/context/context-actions'; -import {contextReducer} from '../../../features/context/context-slice'; +} from '../../../features/context/context-actions.js'; +import {contextReducer} from '../../../features/context/context-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; -import {buildCoreContext, Context} from './headless-core-context'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildCoreContext, Context} from './headless-core-context.js'; -jest.mock('../../../features/context/context-actions'); +vi.mock('../../../features/context/context-actions'); describe('Context', () => { let context: Context; let engine: MockedSearchEngine; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); context = buildCoreContext(engine); }); diff --git a/packages/headless/src/controllers/core/context/headless-core-context.ts b/packages/headless/src/controllers/core/context/headless-core-context.ts index ba5c7837225..716c0fc9627 100644 --- a/packages/headless/src/controllers/core/context/headless-core-context.ts +++ b/packages/headless/src/controllers/core/context/headless-core-context.ts @@ -1,30 +1,30 @@ import {RecordValue, Schema} from '@coveo/bueno'; import type {AnyAction, Dispatch} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../../app/engine'; +import {CoreEngine} from '../../../app/engine.js'; import { setContext, addContext, removeContext, -} from '../../../features/context/context-actions'; -import {contextReducer as context} from '../../../features/context/context-slice'; +} from '../../../features/context/context-actions.js'; +import {contextReducer as context} from '../../../features/context/context-slice.js'; import { ContextPayload, ContextValue, -} from '../../../features/context/context-state'; +} from '../../../features/context/context-state.js'; import { ConfigurationSection, ContextSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {validateInitialState} from '../../../utils/validate-payload'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateInitialState} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { ReservedContextKeyError, isReservedContextKey, -} from './headless-context-reserved-keys'; +} from './headless-context-reserved-keys.js'; export type {ContextPayload, ContextValue}; diff --git a/packages/headless/src/controllers/core/context/headless-core-internal-context.ts b/packages/headless/src/controllers/core/context/headless-core-internal-context.ts index cdea9305528..3355d8e73d4 100644 --- a/packages/headless/src/controllers/core/context/headless-core-internal-context.ts +++ b/packages/headless/src/controllers/core/context/headless-core-internal-context.ts @@ -1,17 +1,17 @@ -import {CoreEngine} from '../../../app/engine'; +import {CoreEngine} from '../../../app/engine.js'; import { addContext, removeContext, -} from '../../../features/context/context-actions'; -import {contextReducer as context} from '../../../features/context/context-slice'; -import {ContextValue} from '../../../features/context/context-state'; -import {ContextSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../features/context/context-actions.js'; +import {contextReducer as context} from '../../../features/context/context-slice.js'; +import {ContextValue} from '../../../features/context/context-state.js'; +import {ContextSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { ReservedContextKey, UnreservedContextKeyError, isReservedContextKey, -} from './headless-context-reserved-keys'; +} from './headless-context-reserved-keys.js'; /** * The `InternalContext` controller injects reserved [custom contextual information](https://docs.coveo.com/en/3389/) key-values. diff --git a/packages/headless/src/controllers/core/context/headless-strict-context-factory.ts b/packages/headless/src/controllers/core/context/headless-strict-context-factory.ts index 4147bff0a81..37448d9a0ed 100644 --- a/packages/headless/src/controllers/core/context/headless-strict-context-factory.ts +++ b/packages/headless/src/controllers/core/context/headless-strict-context-factory.ts @@ -1,11 +1,11 @@ -import {CoreEngine} from '../../../app/engine'; -import {caseContextReducer as insightCaseContext} from '../../../features/case-context/case-context-slice'; -import {loadReducerError} from '../../../utils/errors'; +import {CoreEngine} from '../../../app/engine.js'; +import {caseContextReducer as insightCaseContext} from '../../../features/case-context/case-context-slice.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { Context as CoreContext, ContextProps as CoreContextProps, buildContext as buildCoreContext, -} from '../../context/headless-context'; +} from '../../context/headless-context.js'; type AdditionalProperties = Omit< AdditionalContext, diff --git a/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.test.ts b/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.test.ts index 4990cd4695a..4f2fff17d0b 100644 --- a/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.test.ts +++ b/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.test.ts @@ -1,33 +1,36 @@ -import {configuration} from '../../../app/common-reducers'; +import {configuration} from '../../../app/common-reducers.js'; import { applyDidYouMeanCorrection, disableAutomaticQueryCorrection, enableDidYouMean, -} from '../../../features/did-you-mean/did-you-mean-actions'; -import {didYouMeanReducer as didYouMean} from '../../../features/did-you-mean/did-you-mean-slice'; +} from '../../../features/did-you-mean/did-you-mean-actions.js'; +import {didYouMeanReducer as didYouMean} from '../../../features/did-you-mean/did-you-mean-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCoreDidYouMean, DidYouMean, DidYouMeanProps, -} from './headless-core-did-you-mean'; +} from './headless-core-did-you-mean.js'; -jest.mock('pino', () => ({ - ...jest.requireActual('pino'), - __esModule: true, - default: () => ({ - info: jest.fn(), - error: jest.fn(), - warn: jest.fn(), - debug: jest.fn(), - }), -})); +vi.mock('pino', async () => { + const actual = await vi.importActual('pino'); + return { + ...actual, + __esModule: true, + default: () => ({ + info: vi.fn(), + error: vi.fn(), + warn: vi.fn(), + debug: vi.fn(), + }), + }; +}); -jest.mock('../../../features/did-you-mean/did-you-mean-actions'); +vi.mock('../../../features/did-you-mean/did-you-mean-actions'); describe('did you mean', () => { let dym: DidYouMean; @@ -42,7 +45,7 @@ describe('did you mean', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initDidYouMean(); }); diff --git a/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.ts b/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.ts index 2161b437c99..5ddc6e2dbfb 100644 --- a/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.ts +++ b/packages/headless/src/controllers/core/did-you-mean/headless-core-did-you-mean.ts @@ -1,26 +1,26 @@ import { QueryCorrection, WordCorrection, -} from '../../../api/search/search/query-corrections'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; +} from '../../../api/search/search/query-corrections.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; import { applyDidYouMeanCorrection, disableAutomaticQueryCorrection, enableDidYouMean, setCorrectionMode, -} from '../../../features/did-you-mean/did-you-mean-actions'; -import {hasQueryCorrectionSelector} from '../../../features/did-you-mean/did-you-mean-selectors'; -import {didYouMeanReducer as didYouMean} from '../../../features/did-you-mean/did-you-mean-slice'; +} from '../../../features/did-you-mean/did-you-mean-actions.js'; +import {hasQueryCorrectionSelector} from '../../../features/did-you-mean/did-you-mean-selectors.js'; +import {didYouMeanReducer as didYouMean} from '../../../features/did-you-mean/did-you-mean-slice.js'; import { ConfigurationSection, DidYouMeanSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export type {QueryCorrection, WordCorrection}; diff --git a/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.test.ts b/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.test.ts index 1509e7598bb..30c086d5e35 100644 --- a/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.test.ts +++ b/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.test.ts @@ -1,16 +1,16 @@ -import {facetOptionsReducer as facetOptions} from '../../../features/facet-options/facet-options-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; +import {facetOptionsReducer as facetOptions} from '../../../features/facet-options/facet-options-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCoreFacetManager, FacetManager, FacetManagerPayload, -} from './headless-core-facet-manager'; +} from './headless-core-facet-manager.js'; describe('facet manager', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.ts b/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.ts index b20e8c504fa..b022bba4842 100644 --- a/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.ts +++ b/packages/headless/src/controllers/core/facet-manager/headless-core-facet-manager.ts @@ -1,13 +1,13 @@ -import {CoreEngine} from '../../../app/engine'; -import {facetOptionsReducer as facetOptions} from '../../../features/facet-options/facet-options-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {sortFacets} from '../../../utils/facet-utils'; +import {CoreEngine} from '../../../app/engine.js'; +import {facetOptionsReducer as facetOptions} from '../../../features/facet-options/facet-options-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {sortFacets} from '../../../utils/facet-utils.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; /** * A facet payload object to be sorted by the manager. diff --git a/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.test.ts b/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.test.ts index 1049130284a..1a5e5677450 100644 --- a/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.test.ts +++ b/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.test.ts @@ -1,11 +1,11 @@ import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockFacetIdConfig} from '../../../../test/mock-facet-id-config'; -import {createMockState} from '../../../../test/mock-state'; -import {determineFacetId} from './facet-id-determinor'; -import * as FacetIdGenerator from './facet-id-generator'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockFacetIdConfig} from '../../../../test/mock-facet-id-config.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import {determineFacetId} from './facet-id-determinor.js'; +import * as FacetIdGenerator from './facet-id-generator.js'; describe('#determineFacetId', () => { let engine: MockedSearchEngine; @@ -20,7 +20,7 @@ describe('#determineFacetId', () => { }); it('when a #facetId key is empty, it calls #generateFacetId', () => { - jest.spyOn(FacetIdGenerator, 'generateFacetId'); + vi.spyOn(FacetIdGenerator, 'generateFacetId'); determineFacetId(engine, {facetId: '', field: 'author'}); const {state, logger} = engine; @@ -32,7 +32,7 @@ describe('#determineFacetId', () => { }); it('when the #facetId key is not passed, it calls #generateFacetId', () => { - jest.spyOn(FacetIdGenerator, 'generateFacetId'); + vi.spyOn(FacetIdGenerator, 'generateFacetId'); determineFacetId(engine, {field: 'author'}); const {state, logger} = engine; diff --git a/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.ts b/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.ts index 09d5deed171..8ec925277b6 100644 --- a/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.ts +++ b/packages/headless/src/controllers/core/facets/_common/facet-id-determinor.ts @@ -1,6 +1,6 @@ -import {CoreEngine} from '../../../../app/engine'; -import {AllFacetSections} from '../../../../features/facets/generic/interfaces/generic-facet-section'; -import {generateFacetId} from './facet-id-generator'; +import {CoreEngine} from '../../../../app/engine.js'; +import {AllFacetSections} from '../../../../features/facets/generic/interfaces/generic-facet-section.js'; +import {generateFacetId} from './facet-id-generator.js'; interface FacetIdConfig { facetId?: string; diff --git a/packages/headless/src/controllers/core/facets/_common/facet-id-generator.test.ts b/packages/headless/src/controllers/core/facets/_common/facet-id-generator.test.ts index 12b3e471fee..a682c3e2876 100644 --- a/packages/headless/src/controllers/core/facets/_common/facet-id-generator.test.ts +++ b/packages/headless/src/controllers/core/facets/_common/facet-id-generator.test.ts @@ -1,9 +1,9 @@ import pino, {Logger} from 'pino'; -import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice'; -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {generateFacetId, FacetIdConfig} from './facet-id-generator'; +import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice.js'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {generateFacetId, FacetIdConfig} from './facet-id-generator.js'; describe('#generateFacetId', () => { let config: FacetIdConfig; @@ -20,7 +20,7 @@ describe('#generateFacetId', () => { function initLogger() { logger = pino({level: 'silent'}); - logger.warn = jest.fn(); + logger.warn = vi.fn(); } beforeEach(() => { diff --git a/packages/headless/src/controllers/core/facets/_common/facet-id-generator.ts b/packages/headless/src/controllers/core/facets/_common/facet-id-generator.ts index 1212ef7190c..c27e5a15688 100644 --- a/packages/headless/src/controllers/core/facets/_common/facet-id-generator.ts +++ b/packages/headless/src/controllers/core/facets/_common/facet-id-generator.ts @@ -1,5 +1,5 @@ import {Logger} from 'pino'; -import {AllFacetSections} from '../../../../features/facets/generic/interfaces/generic-facet-section'; +import {AllFacetSections} from '../../../../features/facets/generic/interfaces/generic-facet-section.js'; export interface FacetIdConfig { field: string; diff --git a/packages/headless/src/controllers/core/facets/_common/facet-option-definitions.ts b/packages/headless/src/controllers/core/facets/_common/facet-option-definitions.ts index 0c057ae0f13..b443473799e 100644 --- a/packages/headless/src/controllers/core/facets/_common/facet-option-definitions.ts +++ b/packages/headless/src/controllers/core/facets/_common/facet-option-definitions.ts @@ -6,7 +6,7 @@ import { SchemaDefinition, StringValue, } from '@coveo/bueno'; -import {FacetSearchRequestOptions} from '../../../../api/search/facet-search/base/base-facet-search-request'; +import {FacetSearchRequestOptions} from '../../../../api/search/facet-search/base/base-facet-search-request.js'; export const facetId = new StringValue({ regex: /^[a-zA-Z0-9-_]+$/, diff --git a/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet-options.ts b/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet-options.ts index 26c6a909e49..b3fdbc8415c 100644 --- a/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet-options.ts +++ b/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet-options.ts @@ -2,7 +2,7 @@ import {ArrayValue, RecordValue, Schema, StringValue} from '@coveo/bueno'; import { categoryFacetSortCriteria, CategoryFacetSortCriterion, -} from '../../../../features/facets/category-facet-set/interfaces/request'; +} from '../../../../features/facets/category-facet-set/interfaces/request.js'; import { facetId, field, @@ -13,7 +13,7 @@ import { injectionDepth, numberOfValues, facetSearch, -} from '../_common/facet-option-definitions'; +} from '../_common/facet-option-definitions.js'; export interface CategoryFacetOptions { /** diff --git a/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.test.ts b/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.test.ts index 5f845e135cd..9ec9be8526e 100644 --- a/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.test.ts +++ b/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.test.ts @@ -1,6 +1,6 @@ -import {configuration} from '../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; -import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice'; +import {configuration} from '../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; +import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice.js'; import { defaultNumberOfValuesIncrement, deselectAllCategoryFacetValues, @@ -8,52 +8,52 @@ import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, updateCategoryFacetSortCriterion, -} from '../../../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../../features/facets/category-facet-set/category-facet-set-slice'; -import {defaultCategoryFacetOptions} from '../../../../features/facets/category-facet-set/category-facet-set-slice'; +} from '../../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import { + categoryFacetSetReducer as categoryFacetSet, + defaultCategoryFacetOptions, +} from '../../../../features/facets/category-facet-set/category-facet-set-slice.js'; import { findActiveValueAncestry, partitionIntoParentsAndValues, -} from '../../../../features/facets/category-facet-set/category-facet-utils'; +} from '../../../../features/facets/category-facet-set/category-facet-utils.js'; import { CategoryFacetRequest, CategoryFacetSortCriterion, -} from '../../../../features/facets/category-facet-set/interfaces/request'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; -import {searchReducer as search} from '../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockCategoryFacetRequest} from '../../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../../test/mock-category-facet-response'; -import {buildMockCategoryFacetSearch} from '../../../../test/mock-category-facet-search'; -import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../../test/mock-category-facet-value'; +} from '../../../../features/facets/category-facet-set/interfaces/request.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetSearch} from '../../../../test/mock-category-facet-search.js'; +import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValue} from '../../../../test/mock-category-facet-value.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../test/mock-state'; -import * as FacetIdDeterminor from '../_common/facet-id-determinor'; +} from '../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../_common/facet-id-determinor.js'; import { buildCoreCategoryFacet, CategoryFacetOptions, CategoryFacetValue, CoreCategoryFacet, -} from './headless-core-category-facet'; +} from './headless-core-category-facet.js'; -jest.mock( - '../../../../features/facets/category-facet-set/category-facet-utils' -); +vi.mock('../../../../features/facets/category-facet-set/category-facet-utils'); -jest.mock( +vi.mock( '../../../../features/facets/category-facet-set/category-facet-set-actions' ); -jest.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); const { findActiveValueAncestry: actualFindActiveValueAncestry, partitionIntoParentsAndValues: actualPartitionIntoParentsAndValues, -} = jest.requireActual( +} = await vi.importActual( '../../../../features/facets/category-facet-set/category-facet-utils' ); @@ -63,8 +63,8 @@ describe('category facet', () => { let state: SearchAppState; let engine: MockedSearchEngine; let categoryFacet: CoreCategoryFacet; - const findActiveValueAncestryMock = jest.mocked(findActiveValueAncestry); - const partitionIntoParentsAndValuesMock = jest.mocked( + const findActiveValueAncestryMock = vi.mocked(findActiveValueAncestry); + const partitionIntoParentsAndValuesMock = vi.mocked( partitionIntoParentsAndValues ); @@ -106,7 +106,7 @@ describe('category facet', () => { }); it('it calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initCategoryFacet(); diff --git a/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.ts b/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.ts index dd171b44584..e340c6e5952 100644 --- a/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.ts +++ b/packages/headless/src/controllers/core/facets/category-facet/headless-core-category-facet.ts @@ -1,55 +1,55 @@ -import {configuration} from '../../../../app/common-reducers'; -import {CoreEngine} from '../../../../app/engine'; +import {configuration} from '../../../../app/common-reducers.js'; +import {CoreEngine} from '../../../../app/engine.js'; import { disableFacet, enableFacet, updateFacetOptions, -} from '../../../../features/facet-options/facet-options-actions'; -import {isFacetEnabledSelector} from '../../../../features/facet-options/facet-options-selectors'; -import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice'; +} from '../../../../features/facet-options/facet-options-actions.js'; +import {isFacetEnabledSelector} from '../../../../features/facet-options/facet-options-selectors.js'; +import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice.js'; import { deselectAllCategoryFacetValues, registerCategoryFacet, toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, updateCategoryFacetSortCriterion, -} from '../../../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryFacetResponseSelector} from '../../../../features/facets/category-facet-set/category-facet-set-selectors'; -import {categoryFacetRequestSelector} from '../../../../features/facets/category-facet-set/category-facet-set-selectors'; -import {defaultCategoryFacetOptions} from '../../../../features/facets/category-facet-set/category-facet-set-slice'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../../features/facets/category-facet-set/category-facet-set-slice'; +} from '../../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryFacetResponseSelector} from '../../../../features/facets/category-facet-set/category-facet-set-selectors.js'; +import {categoryFacetRequestSelector} from '../../../../features/facets/category-facet-set/category-facet-set-selectors.js'; +import {defaultCategoryFacetOptions} from '../../../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../../features/facets/category-facet-set/category-facet-set-slice.js'; import { findActiveValueAncestry, partitionIntoParentsAndValues, -} from '../../../../features/facets/category-facet-set/category-facet-utils'; -import {CategoryFacetValueCommon} from '../../../../features/facets/category-facet-set/interfaces/commons'; -import {CategoryFacetSortCriterion} from '../../../../features/facets/category-facet-set/interfaces/request'; -import {CategoryFacetValue} from '../../../../features/facets/category-facet-set/interfaces/response'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; -import {defaultFacetSearchOptions} from '../../../../features/facets/facet-search-set/facet-search-reducer-helpers'; -import {isFacetLoadingResponseSelector} from '../../../../features/facets/facet-set/facet-set-selectors'; -import {searchReducer as search} from '../../../../features/search/search-slice'; -import {selectActiveTab} from '../../../../features/tab-set/tab-set-selectors'; +} from '../../../../features/facets/category-facet-set/category-facet-utils.js'; +import {CategoryFacetValueCommon} from '../../../../features/facets/category-facet-set/interfaces/commons.js'; +import {CategoryFacetSortCriterion} from '../../../../features/facets/category-facet-set/interfaces/request.js'; +import {CategoryFacetValue} from '../../../../features/facets/category-facet-set/interfaces/response.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; +import {defaultFacetSearchOptions} from '../../../../features/facets/facet-search-set/facet-search-reducer-helpers.js'; +import {isFacetLoadingResponseSelector} from '../../../../features/facets/facet-set/facet-set-selectors.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; +import {selectActiveTab} from '../../../../features/tab-set/tab-set-selectors.js'; import { CategoryFacetSearchSection, CategoryFacetSection, ConfigurationSection, FacetOptionsSection, SearchSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; -import {omit} from '../../../../utils/utils'; -import {validateOptions} from '../../../../utils/validate-payload'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {omit} from '../../../../utils/utils.js'; +import {validateOptions} from '../../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../../controller/headless-controller'; -import {determineFacetId} from '../_common/facet-id-determinor'; +} from '../../../controller/headless-controller.js'; +import {determineFacetId} from '../_common/facet-id-determinor.js'; import { CategoryFacetOptions, categoryFacetOptionsSchema, CategoryFacetSearchOptions, -} from './headless-core-category-facet-options'; +} from './headless-core-category-facet-options.js'; export type { CategoryFacetValueCommon, diff --git a/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.test.ts b/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.test.ts index 847cf664e09..28d1487e59b 100644 --- a/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.test.ts +++ b/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.test.ts @@ -1,44 +1,45 @@ +import {Mock} from 'vitest'; import { disableFacet, enableFacet, -} from '../../../../features/facet-options/facet-options-actions'; -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValueRequest} from '../../../../test/mock-category-facet-value-request'; -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; +} from '../../../../features/facet-options/facet-options-actions.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../../../test/mock-category-facet-value-request.js'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildFacetOptionsSlice} from '../../../../test/mock-facet-options-slice'; -import {buildMockFacetRequest} from '../../../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {buildMockFacetValueRequest} from '../../../../test/mock-facet-value-request'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../test/mock-state'; -import {FacetValueState} from '../facet/headless-core-facet'; +} from '../../../../test/mock-engine-v2.js'; +import {buildFacetOptionsSlice} from '../../../../test/mock-facet-options-slice.js'; +import {buildMockFacetRequest} from '../../../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../../test/mock-facet-value-request.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import {FacetValueState} from '../facet/headless-core-facet.js'; import { buildCoreFacetConditionsManager, FacetConditionsManager, -} from './headless-facet-conditions-manager'; +} from './headless-facet-conditions-manager.js'; -jest.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); describe('facet conditions manager', () => { let state: SearchAppState; let engine: MockedSearchEngine; let engineListener: Function; - let engineUnsubscriber: jest.Mock; + let engineUnsubscriber: Mock; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); state = createMockState(); engine = buildMockSearchEngine(state); - engine.subscribe = jest.fn((listener) => { + engine.subscribe = vi.fn((listener) => { engineListener = listener; - return (engineUnsubscriber = jest.fn()); + return (engineUnsubscriber = vi.fn()); }); }); @@ -46,7 +47,7 @@ describe('facet conditions manager', () => { const facetId = 'abc'; const parentFacetId = 'def'; let facetConditionsManager: FacetConditionsManager; - let condition: jest.Mock; + let condition: Mock; function initCondition() { state.facetSet[facetId] = buildMockFacetSlice(); @@ -56,7 +57,7 @@ describe('facet conditions manager', () => { conditions: [ { parentFacetId, - condition: (condition = jest.fn(() => false)), + condition: (condition = vi.fn(() => false)), }, ], }); @@ -224,11 +225,11 @@ describe('facet conditions manager', () => { conditions: [ { parentFacetId: parentFacetAId, - condition: jest.fn(() => getConditionIsMet(parentFacetAId)), + condition: vi.fn(() => getConditionIsMet(parentFacetAId)), }, { parentFacetId: parentFacetBId, - condition: jest.fn(() => getConditionIsMet(parentFacetBId)), + condition: vi.fn(() => getConditionIsMet(parentFacetBId)), }, ], }); diff --git a/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.ts b/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.ts index 8b846f12fb1..d87b7cc45e8 100644 --- a/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.ts +++ b/packages/headless/src/controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.ts @@ -1,21 +1,21 @@ -import {CoreEngine} from '../../../../app/engine'; +import {CoreEngine} from '../../../../app/engine.js'; import { disableFacet, enableFacet, -} from '../../../../features/facet-options/facet-options-actions'; -import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice'; -import {updateFreezeCurrentValues} from '../../../../features/facets/facet-set/facet-set-actions'; -import {AnyFacetValueRequest} from '../../../../features/facets/generic/interfaces/generic-facet-request'; -import {AnyFacetValue} from '../../../../features/facets/generic/interfaces/generic-facet-response'; +} from '../../../../features/facet-options/facet-options-actions.js'; +import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice.js'; +import {updateFreezeCurrentValues} from '../../../../features/facets/facet-set/facet-set-actions.js'; +import {AnyFacetValueRequest} from '../../../../features/facets/generic/interfaces/generic-facet-request.js'; +import {AnyFacetValue} from '../../../../features/facets/generic/interfaces/generic-facet-response.js'; import { CategoryFacetSection, DateFacetSection, FacetOptionsSection, FacetSection, NumericFacetSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; -import {getObjectHash} from '../../../../utils/utils'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {getObjectHash} from '../../../../utils/utils.js'; export interface AnyFacetValuesCondition { /** diff --git a/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.test.ts b/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.test.ts index b074198d9c6..cddd4264f6f 100644 --- a/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.test.ts +++ b/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.test.ts @@ -1,27 +1,28 @@ -import {CoreEngine} from '../../../../../app/engine'; +import {describe, it, vi, expect, beforeEach} from 'vitest'; +import {CoreEngine} from '../../../../../app/engine.js'; import { registerCategoryFacetSearch, selectCategoryFacetSearchResult, -} from '../../../../../features/facets/facet-search-set/category/category-facet-search-actions'; -import {defaultFacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-reducer-helpers'; +} from '../../../../../features/facets/facet-search-set/category/category-facet-search-actions.js'; +import {defaultFacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-reducer-helpers.js'; import { CategoryFacetSearchSection, ConfigurationSection, -} from '../../../../../state/state-sections'; -import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search'; -import {buildMockCategoryFacetSearchResult} from '../../../../../test/mock-category-facet-search-result'; +} from '../../../../../state/state-sections.js'; +import {buildMockCategoryFacetSearchResult} from '../../../../../test/mock-category-facet-search-result.js'; +import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../../test/mock-state'; +} from '../../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../../test/mock-state.js'; import { CategoryFacetSearchProps, CategoryFacetSearch, buildCoreCategoryFacetSearch, -} from './headless-category-facet-search'; +} from './headless-category-facet-search.js'; -jest.mock( +vi.mock( '../../../../../features/facets/facet-search-set/category/category-facet-search-actions' ); @@ -50,9 +51,9 @@ describe('CategoryFacetSearch', () => { ...defaultFacetSearchOptions, facetId, }, - executeFacetSearchActionCreator: jest.fn(), - executeFieldSuggestActionCreator: jest.fn(), - select: jest.fn(), + executeFacetSearchActionCreator: vi.fn(), + executeFieldSuggestActionCreator: vi.fn(), + select: vi.fn(), isForFieldSuggestions: false, }; diff --git a/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.ts b/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.ts index 92064e84ae9..3edc6d8f417 100644 --- a/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.ts +++ b/packages/headless/src/controllers/core/facets/facet-search/category/headless-category-facet-search.ts @@ -1,20 +1,20 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; -import {AsyncThunkOptions} from '../../../../../app/async-thunk-options'; -import {CoreEngine, CoreEngineNext} from '../../../../../app/engine'; -import {stateKey} from '../../../../../app/state-key'; -import {ThunkExtraArguments} from '../../../../../app/thunk-extra-arguments'; +import {CategoryFacetSearchResult} from '../../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; +import {AsyncThunkOptions} from '../../../../../app/async-thunk-options.js'; +import {CoreEngine, CoreEngineNext} from '../../../../../app/engine.js'; +import {stateKey} from '../../../../../app/state-key.js'; +import {ThunkExtraArguments} from '../../../../../app/thunk-extra-arguments.js'; import { registerCategoryFacetSearch, selectCategoryFacetSearchResult, -} from '../../../../../features/facets/facet-search-set/category/category-facet-search-actions'; -import {defaultFacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-reducer-helpers'; -import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options'; +} from '../../../../../features/facets/facet-search-set/category/category-facet-search-actions.js'; +import {defaultFacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-reducer-helpers.js'; +import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options.js'; import { CategoryFacetSearchSection, ConfigurationSection, -} from '../../../../../state/state-sections'; -import {buildGenericFacetSearch} from '../facet-search'; +} from '../../../../../state/state-sections.js'; +import {buildGenericFacetSearch} from '../facet-search.js'; export interface CategoryFacetSearchProps { options: FacetSearchOptions; diff --git a/packages/headless/src/controllers/core/facets/facet-search/facet-search.test.ts b/packages/headless/src/controllers/core/facets/facet-search/facet-search.test.ts index 6cf4302ee07..04c774778f8 100644 --- a/packages/headless/src/controllers/core/facets/facet-search/facet-search.test.ts +++ b/packages/headless/src/controllers/core/facets/facet-search/facet-search.test.ts @@ -1,33 +1,33 @@ -import {CoreEngine} from '../../../../app/engine'; +import {CoreEngine} from '../../../../app/engine.js'; import { clearFacetSearch, executeFacetSearch, executeFieldSuggest, -} from '../../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; -import {updateFacetSearch} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {SpecificFacetSearchState} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-state'; +} from '../../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; +import {updateFacetSearch} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {SpecificFacetSearchState} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-state.js'; import { ConfigurationSection, FacetSearchSection, -} from '../../../../state/state-sections'; +} from '../../../../state/state-sections.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../../test/mock-facet-search'; -import {buildMockFacetSearchRequestOptions} from '../../../../test/mock-facet-search-request-options'; -import {buildMockFacetSearchResponse} from '../../../../test/mock-facet-search-response'; -import {createMockState} from '../../../../test/mock-state'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockFacetSearchRequestOptions} from '../../../../test/mock-facet-search-request-options.js'; +import {buildMockFacetSearchResponse} from '../../../../test/mock-facet-search-response.js'; +import {buildMockFacetSearch} from '../../../../test/mock-facet-search.js'; +import {createMockState} from '../../../../test/mock-state.js'; import { buildGenericFacetSearch, GenericFacetSearch, GenericFacetSearchProps, -} from './facet-search'; +} from './facet-search.js'; -jest.mock( +vi.mock( '../../../../features/facets/facet-search-set/generic/generic-facet-search-actions' ); -jest.mock( +vi.mock( '../../../../features/facets/facet-search-set/specific/specific-facet-search-actions' ); diff --git a/packages/headless/src/controllers/core/facets/facet-search/facet-search.ts b/packages/headless/src/controllers/core/facets/facet-search/facet-search.ts index 9104d676c2c..0b06719226b 100644 --- a/packages/headless/src/controllers/core/facets/facet-search/facet-search.ts +++ b/packages/headless/src/controllers/core/facets/facet-search/facet-search.ts @@ -1,20 +1,20 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {FacetSearchAPIClient} from '../../../../api/search/search-api-client'; -import {AsyncThunkOptions} from '../../../../app/async-thunk-options'; -import {CoreEngine, CoreEngineNext} from '../../../../app/engine'; +import {FacetSearchAPIClient} from '../../../../api/search/search-api-client.js'; +import {AsyncThunkOptions} from '../../../../app/async-thunk-options.js'; +import {CoreEngine, CoreEngineNext} from '../../../../app/engine.js'; import { ClientThunkExtraArguments, ThunkExtraArguments, -} from '../../../../app/thunk-extra-arguments'; -import {CategoryFacetSearchState} from '../../../../features/facets/facet-search-set/category/category-facet-search-set-state'; -import {FacetSearchOptions} from '../../../../features/facets/facet-search-set/facet-search-request-options'; -import {clearFacetSearch} from '../../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; -import {updateFacetSearch} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {SpecificFacetSearchState} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-state'; +} from '../../../../app/thunk-extra-arguments.js'; +import {CategoryFacetSearchState} from '../../../../features/facets/facet-search-set/category/category-facet-search-set-state.js'; +import {FacetSearchOptions} from '../../../../features/facets/facet-search-set/facet-search-request-options.js'; +import {clearFacetSearch} from '../../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; +import {updateFacetSearch} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {SpecificFacetSearchState} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-state.js'; import { CategoryFacetSearchSection, FacetSearchSection, -} from '../../../../state/state-sections'; +} from '../../../../state/state-sections.js'; type FacetSearchState = SpecificFacetSearchState | CategoryFacetSearchState; diff --git a/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.test.ts b/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.test.ts index 9412514b04c..0c60fcd0287 100644 --- a/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.test.ts +++ b/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.test.ts @@ -1,36 +1,37 @@ -import {CoreEngine} from '../../../../../app/engine'; +import {describe, it, vi, expect, beforeEach} from 'vitest'; +import {CoreEngine} from '../../../../../app/engine.js'; import { executeFacetSearch, executeFieldSuggest, -} from '../../../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; +} from '../../../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; import { excludeFacetSearchResult, registerFacetSearch, selectFacetSearchResult, -} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; +} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; import { ConfigurationSection, FacetSearchSection, -} from '../../../../../state/state-sections'; +} from '../../../../../state/state-sections.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockFacetSearch} from '../../../../../test/mock-facet-search'; -import {buildMockFacetSearchResult} from '../../../../../test/mock-facet-search-result'; -import {createMockState} from '../../../../../test/mock-state'; -import {CategoryFacetSearchResult} from '../../../../facets/category-facet/headless-category-facet'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockFacetSearchResult} from '../../../../../test/mock-facet-search-result.js'; +import {buildMockFacetSearch} from '../../../../../test/mock-facet-search.js'; +import {createMockState} from '../../../../../test/mock-state.js'; +import {CategoryFacetSearchResult} from '../../../../facets/category-facet/headless-category-facet.js'; import { buildFacetSearch, FacetSearch, FacetSearchProps, -} from './headless-facet-search'; +} from './headless-facet-search.js'; -jest.mock( +vi.mock( '../../../../../features/facets/facet-search-set/specific/specific-facet-search-actions' ); -jest.mock('../../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../../features/facets/facet-set/facet-set-actions'); describe('FacetSearch', () => { const facetId = '1'; @@ -54,8 +55,8 @@ describe('FacetSearch', () => { beforeEach(() => { props = { options: {facetId}, - select: jest.fn(), - exclude: jest.fn(), + select: vi.fn(), + exclude: vi.fn(), isForFieldSuggestions: false, executeFacetSearchActionCreator: executeFacetSearch, executeFieldSuggestActionCreator: executeFieldSuggest, diff --git a/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.ts b/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.ts index 567c6433ea7..3df2a000fa4 100644 --- a/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.ts +++ b/packages/headless/src/controllers/core/facets/facet-search/specific/headless-facet-search.ts @@ -1,18 +1,18 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {SpecificFacetSearchResult} from '../../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; -import {AsyncThunkOptions} from '../../../../../app/async-thunk-options'; -import {CoreEngine, CoreEngineNext} from '../../../../../app/engine'; -import {stateKey} from '../../../../../app/state-key'; -import {ThunkExtraArguments} from '../../../../../app/thunk-extra-arguments'; -import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options'; +import {SpecificFacetSearchResult} from '../../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; +import {AsyncThunkOptions} from '../../../../../app/async-thunk-options.js'; +import {CoreEngine, CoreEngineNext} from '../../../../../app/engine.js'; +import {stateKey} from '../../../../../app/state-key.js'; +import {ThunkExtraArguments} from '../../../../../app/thunk-extra-arguments.js'; +import {FacetSearchOptions} from '../../../../../features/facets/facet-search-set/facet-search-request-options.js'; import { excludeFacetSearchResult, registerFacetSearch, selectFacetSearchResult, -} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; -import {FacetSearchSection} from '../../../../../state/state-sections'; -import {buildGenericFacetSearch} from '../facet-search'; +} from '../../../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; +import {FacetSearchSection} from '../../../../../state/state-sections.js'; +import {buildGenericFacetSearch} from '../facet-search.js'; export interface FacetSearchProps { options: FacetSearchOptions; diff --git a/packages/headless/src/controllers/core/facets/facet/headless-core-facet-options.ts b/packages/headless/src/controllers/core/facets/facet/headless-core-facet-options.ts index 3d5eb49d7e6..1d64c8f3a58 100644 --- a/packages/headless/src/controllers/core/facets/facet/headless-core-facet-options.ts +++ b/packages/headless/src/controllers/core/facets/facet/headless-core-facet-options.ts @@ -2,11 +2,11 @@ import {ArrayValue, RecordValue, Schema, StringValue} from '@coveo/bueno'; import { FacetResultsMustMatch, facetResultsMustMatch, -} from '../../../../features/facets/facet-api/request'; +} from '../../../../features/facets/facet-api/request.js'; import { facetSortCriteria, FacetSortCriterion, -} from '../../../../features/facets/facet-set/interfaces/request'; +} from '../../../../features/facets/facet-set/interfaces/request.js'; import { facetId, field, @@ -14,7 +14,7 @@ import { injectionDepth, numberOfValues, facetSearch, -} from '../_common/facet-option-definitions'; +} from '../_common/facet-option-definitions.js'; export interface FacetOptions { /** diff --git a/packages/headless/src/controllers/core/facets/facet/headless-core-facet.test.ts b/packages/headless/src/controllers/core/facets/facet/headless-core-facet.test.ts index c2cf4752281..3356b9ca465 100644 --- a/packages/headless/src/controllers/core/facets/facet/headless-core-facet.test.ts +++ b/packages/headless/src/controllers/core/facets/facet/headless-core-facet.test.ts @@ -1,38 +1,42 @@ -import {configuration} from '../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; -import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; +import {configuration} from '../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; +import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; import { registerFacet, deselectAllFacetValues, updateFacetSortCriterion, updateFacetNumberOfValues, updateFacetIsFieldExpanded, -} from '../../../../features/facets/facet-set/facet-set-actions'; +} from '../../../../features/facets/facet-set/facet-set-actions.js'; import { executeToggleFacetExclude, executeToggleFacetSelect, -} from '../../../../features/facets/facet-set/facet-set-controller-actions'; -import {facetSetReducer as facetSet} from '../../../../features/facets/facet-set/facet-set-slice'; -import {FacetRequest} from '../../../../features/facets/facet-set/interfaces/request'; -import {FacetValue} from '../../../../features/facets/facet-set/interfaces/response'; -import {SearchAppState} from '../../../../state/search-app-state'; +} from '../../../../features/facets/facet-set/facet-set-controller-actions.js'; +import {facetSetReducer as facetSet} from '../../../../features/facets/facet-set/facet-set-slice.js'; +import {FacetRequest} from '../../../../features/facets/facet-set/interfaces/request.js'; +import {FacetValue} from '../../../../features/facets/facet-set/interfaces/response.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../../test/mock-facet-response'; -import {buildMockFacetSearch} from '../../../../test/mock-facet-search'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../../test/mock-facet-value'; -import {createMockState} from '../../../../test/mock-state'; -import * as FacetIdDeterminor from '../_common/facet-id-determinor'; -import {buildCoreFacet, CoreFacet, FacetOptions} from './headless-core-facet'; - -jest.mock('../../../../features/facets/facet-set/facet-set-actions'); -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../features/facets/facet-set/facet-set-controller-actions'); +} from '../../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../../test/mock-facet-response.js'; +import {buildMockFacetSearch} from '../../../../test/mock-facet-search.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../../../test/mock-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../_common/facet-id-determinor.js'; +import { + buildCoreFacet, + CoreFacet, + FacetOptions, +} from './headless-core-facet.js'; + +vi.mock('../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facets/facet-set/facet-set-controller-actions'); describe('facet', () => { const facetId = '1'; @@ -85,7 +89,7 @@ describe('facet', () => { }); it('it calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initFacet(); diff --git a/packages/headless/src/controllers/core/facets/facet/headless-core-facet.ts b/packages/headless/src/controllers/core/facets/facet/headless-core-facet.ts index 6e0ed9b59af..eb826ebcfea 100644 --- a/packages/headless/src/controllers/core/facets/facet/headless-core-facet.ts +++ b/packages/headless/src/controllers/core/facets/facet/headless-core-facet.ts @@ -1,60 +1,60 @@ -import {configuration} from '../../../../app/common-reducers'; -import {CoreEngine} from '../../../../app/engine'; -import {SearchThunkExtraArguments} from '../../../../app/search-thunk-extra-arguments'; +import {configuration} from '../../../../app/common-reducers.js'; +import {CoreEngine} from '../../../../app/engine.js'; +import {SearchThunkExtraArguments} from '../../../../app/search-thunk-extra-arguments.js'; import { disableFacet, enableFacet, updateFacetOptions, -} from '../../../../features/facet-options/facet-options-actions'; -import {isFacetEnabledSelector} from '../../../../features/facet-options/facet-options-selectors'; -import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice'; -import {FacetValueState} from '../../../../features/facets/facet-api/value'; -import {defaultFacetSearchOptions} from '../../../../features/facets/facet-search-set/facet-search-reducer-helpers'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; +} from '../../../../features/facet-options/facet-options-actions.js'; +import {isFacetEnabledSelector} from '../../../../features/facet-options/facet-options-selectors.js'; +import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice.js'; +import {FacetValueState} from '../../../../features/facets/facet-api/value.js'; +import {defaultFacetSearchOptions} from '../../../../features/facets/facet-search-set/facet-search-reducer-helpers.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; import { registerFacet, deselectAllFacetValues, updateFacetSortCriterion, updateFacetNumberOfValues, updateFacetIsFieldExpanded, -} from '../../../../features/facets/facet-set/facet-set-actions'; +} from '../../../../features/facets/facet-set/facet-set-actions.js'; import { executeToggleFacetExclude, executeToggleFacetSelect, -} from '../../../../features/facets/facet-set/facet-set-controller-actions'; +} from '../../../../features/facets/facet-set/facet-set-controller-actions.js'; import { facetRequestSelector, facetResponseSelector, isFacetLoadingResponseSelector, -} from '../../../../features/facets/facet-set/facet-set-selectors'; -import {facetSetReducer as facetSet} from '../../../../features/facets/facet-set/facet-set-slice'; -import {defaultFacetOptions} from '../../../../features/facets/facet-set/facet-set-slice'; +} from '../../../../features/facets/facet-set/facet-set-selectors.js'; +import {facetSetReducer as facetSet} from '../../../../features/facets/facet-set/facet-set-slice.js'; +import {defaultFacetOptions} from '../../../../features/facets/facet-set/facet-set-slice.js'; import { isFacetValueExcluded, isFacetValueSelected, -} from '../../../../features/facets/facet-set/facet-set-utils'; -import {FacetSortCriterion} from '../../../../features/facets/facet-set/interfaces/request'; -import {selectActiveTab} from '../../../../features/tab-set/tab-set-selectors'; +} from '../../../../features/facets/facet-set/facet-set-utils.js'; +import {FacetSortCriterion} from '../../../../features/facets/facet-set/interfaces/request.js'; +import {selectActiveTab} from '../../../../features/tab-set/tab-set-selectors.js'; import { ConfigurationSection, FacetOptionsSection, FacetSearchSection, FacetSection, SearchSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; -import {omit} from '../../../../utils/utils'; -import {validateOptions} from '../../../../utils/validate-payload'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; +import {omit} from '../../../../utils/utils.js'; +import {validateOptions} from '../../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../../controller/headless-controller'; -import {determineFacetId} from '../_common/facet-id-determinor'; +} from '../../../controller/headless-controller.js'; +import {determineFacetId} from '../_common/facet-id-determinor.js'; import { FacetOptions, facetOptionsSchema, FacetSearchOptions, -} from './headless-core-facet-options'; +} from './headless-core-facet-options.js'; export type {FacetOptions, FacetSearchOptions, FacetValueState}; diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.test.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.test.ts index 7ad85709c97..9302b53dfa5 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.test.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.test.ts @@ -1,13 +1,14 @@ +import {describe, it, expect} from 'vitest'; import { formatDateForSearchApi, parseDate, -} from '../../../../../api/search/date/date-format'; +} from '../../../../../api/search/date/date-format.js'; import { RelativeDate, serializeRelativeDate, -} from '../../../../../api/search/date/relative-date'; -import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request'; -import {buildDateRange} from './date-range'; +} from '../../../../../api/search/date/relative-date.js'; +import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; +import {buildDateRange} from './date-range.js'; describe('date range', () => { describe('#buildDateRange', () => { diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.ts index 32f9ba546fc..eb4b855b4d0 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/date-range.ts @@ -3,16 +3,16 @@ import { AbsoluteDate, validateAbsoluteDate, parseDate, -} from '../../../../../api/search/date/date-format'; +} from '../../../../../api/search/date/date-format.js'; import { serializeRelativeDate, isRelativeDate, isRelativeDateFormat, RelativeDate, validateRelativeDate, -} from '../../../../../api/search/date/relative-date'; -import {FacetValueState} from '../../../../../features/facets/facet-api/value'; -import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request'; +} from '../../../../../api/search/date/relative-date.js'; +import {FacetValueState} from '../../../../../features/facets/facet-api/value.js'; +import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; export type DateRangeInput = AbsoluteDate | RelativeDate; diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.test.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.test.ts index 5883f795dda..98362e592cc 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.test.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.test.ts @@ -1,41 +1,41 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; import { deselectAllDateFacetValues, registerDateFacet, validateManualDateRanges, -} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; +} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; import { executeToggleDateFacetExclude, executeToggleDateFacetSelect, -} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../../state/search-app-state'; -import {buildMockDateFacetResponse} from '../../../../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value'; +} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../../state/search-app-state.js'; +import {buildMockDateFacetResponse} from '../../../../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../_common/facet-id-determinor'; +} from '../../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../_common/facet-id-determinor.js'; import { DateFacet, buildCoreDateFacet, DateFacetOptions, buildDateRange, -} from './headless-core-date-facet'; +} from './headless-core-date-facet.js'; -jest.mock('../../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../../features/facet-options/facet-options-actions'); -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions' ); -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); @@ -93,7 +93,7 @@ describe('date facet', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initDateFacet(); diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.ts index 292df2bbab3..72484a68b7f 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-facet.ts @@ -1,45 +1,49 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {CoreEngine} from '../../../../../app/engine'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {CoreEngine} from '../../../../../app/engine.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; import { RegisterDateFacetActionCreatorPayload, registerDateFacet, -} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; +} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; import { executeToggleDateFacetExclude, executeToggleDateFacetSelect, -} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; +} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; import { DateFacetRequest, DateRangeRequest, -} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request'; +} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; import { DateFacetResponse, DateFacetValue, -} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors'; +} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors.js'; import { ConfigurationSection, DateFacetSection, FacetOptionsSection, SearchSection, -} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; -import {Controller} from '../../../../controller/headless-controller'; -import {determineFacetId} from '../../_common/facet-id-determinor'; +} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; +import {Controller} from '../../../../controller/headless-controller.js'; +import {determineFacetId} from '../../_common/facet-id-determinor.js'; import { assertRangeFacetOptions, buildCoreRangeFacet, -} from '../headless-core-range-facet'; -import {DateRangeOptions, DateRangeInput, buildDateRange} from './date-range'; +} from '../headless-core-range-facet.js'; +import { + DateRangeOptions, + DateRangeInput, + buildDateRange, +} from './date-range.js'; import { DateFacetOptions, validateDateFacetOptions, -} from './headless-date-facet-options'; +} from './headless-date-facet-options.js'; export type { DateFacetOptions, diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.test.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.test.ts index ec70b36bafa..5f7dac5260a 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.test.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.test.ts @@ -1,36 +1,37 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; +import {Mock} from 'vitest'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; import { registerDateFacet, updateDateFacetValues, validateManualDateRanges, -} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../../state/search-app-state'; -import {buildMockDateFacetResponse} from '../../../../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value'; +} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../../state/search-app-state.js'; +import {buildMockDateFacetResponse} from '../../../../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../_common/facet-id-determinor'; -import {buildDateRange} from './date-range'; +} from '../../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../_common/facet-id-determinor.js'; +import {buildDateRange} from './date-range.js'; import { buildCoreDateFilter, DateFilter, DateFilterInitialState, DateFilterOptions, -} from './headless-core-date-filter'; +} from './headless-core-date-filter.js'; -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); -jest.mock('../../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../../features/facet-options/facet-options-actions'); describe('date filter', () => { const facetId = '1'; @@ -46,7 +47,7 @@ describe('date filter', () => { } beforeEach(() => { - (updateDateFacetValues as unknown as jest.Mock).mockImplementation( + (updateDateFacetValues as unknown as Mock).mockImplementation( () => () => {} ); initialState = undefined; @@ -69,14 +70,12 @@ describe('date filter', () => { initDateFilter(); expect(validateManualDateRanges).toHaveBeenCalledWith( expect.objectContaining({ - currentValues: [ - { - end: '2021/03/24@22:16:31', - endInclusive: true, + currentValues: expect.arrayContaining([ + expect.objectContaining({ start: '2021/03/25@22:16:31', - state: 'selected', - }, - ], + end: '2021/03/24@22:16:31', + }), + ]), }) ); }); @@ -91,7 +90,7 @@ describe('date filter', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initDateFilter(); @@ -147,13 +146,11 @@ describe('date filter', () => { }); it('should return false when range start value is greater than range end value', () => { - (updateDateFacetValues as unknown as jest.Mock).mockImplementationOnce( - () => { - return { - error: 'oh no', - }; - } - ); + (updateDateFacetValues as unknown as Mock).mockImplementationOnce(() => { + return { + error: 'oh no', + }; + }); const value = buildMockDateFacetValue( buildDateRange({start: 1616679091000, end: 1616592691000}) ); diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.ts index 825c349089a..c2d379394a1 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-core-date-filter.ts @@ -1,36 +1,36 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {CoreEngine} from '../../../../../app/engine'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {CoreEngine} from '../../../../../app/engine.js'; import { disableFacet, enableFacet, updateFacetOptions, -} from '../../../../../features/facet-options/facet-options-actions'; -import {isFacetEnabledSelector} from '../../../../../features/facet-options/facet-options-selectors'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; -import {isFacetLoadingResponseSelector} from '../../../../../features/facets/facet-set/facet-set-selectors'; +} from '../../../../../features/facet-options/facet-options-actions.js'; +import {isFacetEnabledSelector} from '../../../../../features/facet-options/facet-options-selectors.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; +import {isFacetLoadingResponseSelector} from '../../../../../features/facets/facet-set/facet-set-selectors.js'; import { registerDateFacet, RegisterDateFacetActionCreatorPayload, updateDateFacetValues, -} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetSelectedValuesSelector} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-selectors'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors'; +} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetSelectedValuesSelector} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-selectors.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors.js'; import { ConfigurationSection, DateFacetSection, FacetOptionsSection, SearchSection, -} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { buildController, Controller, -} from '../../../../controller/headless-controller'; -import {determineFacetId} from '../../_common/facet-id-determinor'; -import {validateDateFacetOptions} from './headless-date-facet-options'; +} from '../../../../controller/headless-controller.js'; +import {determineFacetId} from '../../_common/facet-id-determinor.js'; +import {validateDateFacetOptions} from './headless-date-facet-options.js'; /** * The options defining a `DateFilter`. diff --git a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-date-facet-options.ts b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-date-facet-options.ts index 97367b72d43..eec9b560624 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-date-facet-options.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/date-facet/headless-date-facet-options.ts @@ -6,22 +6,22 @@ import { SchemaDefinition, StringValue, } from '@coveo/bueno'; -import {CoreEngine} from '../../../../../app/engine'; -import {facetValueStates} from '../../../../../features/facets/facet-api/value'; -import {validateManualDateRanges} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request'; +import {CoreEngine} from '../../../../../app/engine.js'; +import {facetValueStates} from '../../../../../features/facets/facet-api/value.js'; +import {validateManualDateRanges} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; import { rangeFacetRangeAlgorithm, RangeFacetRangeAlgorithm, rangeFacetSortCriteria, RangeFacetSortCriterion, -} from '../../../../../features/facets/range-facets/generic/interfaces/request'; +} from '../../../../../features/facets/range-facets/generic/interfaces/request.js'; import { ConfigurationSection, DateFacetSection, SearchSection, -} from '../../../../../state/state-sections'; -import {validateOptions} from '../../../../../utils/validate-payload'; +} from '../../../../../state/state-sections.js'; +import {validateOptions} from '../../../../../utils/validate-payload.js'; import { field, facetId, @@ -29,7 +29,7 @@ import { filterFacetCount, injectionDepth, numberOfValues, -} from '../../../../core/facets/_common/facet-option-definitions'; +} from '../../../../core/facets/_common/facet-option-definitions.js'; export interface DateFacetOptions { /** diff --git a/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.test.ts b/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.test.ts index 758dcbd06c6..fb101b64f77 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.test.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.test.ts @@ -1,33 +1,31 @@ -import {CoreEngine} from '../../../../app/engine'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; -import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions'; -import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions'; -import {NumericFacetRequest} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; -import {SearchAppState} from '../../../../state/search-app-state'; +import {CoreEngine} from '../../../../app/engine.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; +import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions.js'; +import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions.js'; +import {NumericFacetRequest} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; import { ConfigurationSection, FacetOptionsSection, SearchSection, -} from '../../../../state/state-sections'; +} from '../../../../state/state-sections.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../test/mock-state'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; import { buildCoreRangeFacet, RangeFacet, RangeFacetProps, -} from './headless-core-range-facet'; +} from './headless-core-range-facet.js'; -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../features/facets/facet-set/facet-set-actions'); -jest.mock( - '../../../../features/facets/range-facets/generic/range-facet-actions' -); +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../features/facets/range-facets/generic/range-facet-actions'); describe('range facet', () => { const facetId = '1'; diff --git a/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.ts b/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.ts index 0aad588a61a..f8bfbd8a04b 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/headless-core-range-facet.ts @@ -1,31 +1,31 @@ -import {CoreEngine} from '../../../../app/engine'; +import {CoreEngine} from '../../../../app/engine.js'; import { disableFacet, enableFacet, updateFacetOptions, -} from '../../../../features/facet-options/facet-options-actions'; -import {isFacetEnabledSelector} from '../../../../features/facet-options/facet-options-selectors'; -import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions'; +} from '../../../../features/facet-options/facet-options-actions.js'; +import {isFacetEnabledSelector} from '../../../../features/facet-options/facet-options-selectors.js'; +import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions.js'; import { baseFacetResponseSelector, isFacetLoadingResponseSelector, -} from '../../../../features/facets/facet-set/facet-set-selectors'; +} from '../../../../features/facets/facet-set/facet-set-selectors.js'; import { RangeFacetResponse, RangeFacetRequest, -} from '../../../../features/facets/range-facets/generic/interfaces/range-facet'; -import {RangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/interfaces/request'; -import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions'; +} from '../../../../features/facets/range-facets/generic/interfaces/range-facet.js'; +import {RangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/interfaces/request.js'; +import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions.js'; import { isRangeFacetValueExcluded, isRangeFacetValueSelected, -} from '../../../../features/facets/range-facets/generic/range-facet-utils'; +} from '../../../../features/facets/range-facets/generic/range-facet-utils.js'; import { ConfigurationSection, FacetOptionsSection, SearchSection, -} from '../../../../state/state-sections'; -import {buildController} from '../../../controller/headless-controller'; +} from '../../../../state/state-sections.js'; +import {buildController} from '../../../controller/headless-controller.js'; export type RangeFacet = ReturnType; diff --git a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.test.ts b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.test.ts index 0eb58fa2874..32e72482bdb 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.test.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.test.ts @@ -1,43 +1,43 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; -import {NumericFacetValue} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; +import {NumericFacetValue} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { deselectAllNumericFacetValues, registerNumericFacet, validateManualNumericRanges, -} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {executeToggleNumericFacetSelect} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../../state/search-app-state'; +} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {executeToggleNumericFacetSelect} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockNumericFacetResponse} from '../../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../_common/facet-id-determinor'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockNumericFacetResponse} from '../../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../_common/facet-id-determinor.js'; import { NumericFacet, buildCoreNumericFacet, NumericFacetOptions, buildNumericRange, -} from './headless-core-numeric-facet'; +} from './headless-core-numeric-facet.js'; -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); -jest.mock('../../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../../features/facet-options/facet-options-actions'); -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions' ); -jest.mock('../../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../../features/facets/facet-set/facet-set-actions'); describe('numeric facet', () => { const facetId = '1'; @@ -96,7 +96,7 @@ describe('numeric facet', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initNumericFacet(); diff --git a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.ts b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.ts index 7a15b297cc5..41fcda1f694 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-facet.ts @@ -1,42 +1,42 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {CoreEngine} from '../../../../../app/engine'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; -import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {CoreEngine} from '../../../../../app/engine.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; +import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request.js'; import { NumericFacetRequest, NumericRangeRequest, -} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; +} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; import { NumericFacetResponse, NumericFacetValue, -} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { RegisterNumericFacetActionCreatorPayload, registerNumericFacet, -} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {executeToggleNumericFacetSelect} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors'; +} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {executeToggleNumericFacetSelect} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors.js'; import { ConfigurationSection, FacetOptionsSection, NumericFacetSection, SearchSection, -} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; -import {Controller} from '../../../../controller/headless-controller'; -import {determineFacetId} from '../../_common/facet-id-determinor'; +} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; +import {Controller} from '../../../../controller/headless-controller.js'; +import {determineFacetId} from '../../_common/facet-id-determinor.js'; import { assertRangeFacetOptions, buildCoreRangeFacet, -} from '../headless-core-range-facet'; +} from '../headless-core-range-facet.js'; import { NumericFacetOptions, validateNumericFacetOptions, -} from './headless-numeric-facet-options'; -import {buildNumericRange, NumericRangeOptions} from './numeric-range'; +} from './headless-numeric-facet-options.js'; +import {buildNumericRange, NumericRangeOptions} from './numeric-range.js'; export type { NumericRangeOptions, diff --git a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.test.ts b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.test.ts index 3906137ba64..f8753ec5140 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.test.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.test.ts @@ -1,31 +1,32 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; +import {Mock} from 'vitest'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; import { registerNumericFacet, updateNumericFacetValues, validateManualNumericRanges, -} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../../state/search-app-state'; +} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockNumericFacetResponse} from '../../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../_common/facet-id-determinor'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockNumericFacetResponse} from '../../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../_common/facet-id-determinor.js'; import { buildCoreNumericFilter, NumericFilter, NumericFilterInitialState, NumericFilterOptions, -} from './headless-core-numeric-filter'; -import {buildNumericRange} from './numeric-range'; +} from './headless-core-numeric-filter.js'; +import {buildNumericRange} from './numeric-range.js'; -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); @@ -43,7 +44,7 @@ describe('numeric filter', () => { } beforeEach(() => { - (updateNumericFacetValues as unknown as jest.Mock).mockImplementation( + (updateNumericFacetValues as unknown as Mock).mockImplementation( () => () => {} ); initialState = undefined; @@ -86,7 +87,7 @@ describe('numeric filter', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initNumericFilter(); @@ -136,7 +137,7 @@ describe('numeric filter', () => { it('should return false when range start value is greater than range end value', () => { const value = buildMockNumericFacetValue({start: 10, end: 5}); - (updateNumericFacetValues as unknown as jest.Mock).mockImplementationOnce( + (updateNumericFacetValues as unknown as Mock).mockImplementationOnce( () => { return { error: 'oh no', diff --git a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.ts b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.ts index 80b02ec3c49..3c6dd51a9ae 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-core-numeric-filter.ts @@ -1,36 +1,36 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {CoreEngine} from '../../../../../app/engine'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {CoreEngine} from '../../../../../app/engine.js'; import { disableFacet, enableFacet, updateFacetOptions, -} from '../../../../../features/facet-options/facet-options-actions'; -import {isFacetEnabledSelector} from '../../../../../features/facet-options/facet-options-selectors'; -import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice'; -import {isFacetLoadingResponseSelector} from '../../../../../features/facets/facet-set/facet-set-selectors'; -import {NumericFacetValue} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +} from '../../../../../features/facet-options/facet-options-actions.js'; +import {isFacetEnabledSelector} from '../../../../../features/facet-options/facet-options-selectors.js'; +import {facetOptionsReducer as facetOptions} from '../../../../../features/facet-options/facet-options-slice.js'; +import {isFacetLoadingResponseSelector} from '../../../../../features/facets/facet-set/facet-set-selectors.js'; +import {NumericFacetValue} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { registerNumericFacet, RegisterNumericFacetActionCreatorPayload, updateNumericFacetValues, -} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericFacetSelectedValuesSelector} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-selectors'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; -import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors'; +} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericFacetSelectedValuesSelector} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; +import {selectActiveTab} from '../../../../../features/tab-set/tab-set-selectors.js'; import { ConfigurationSection, FacetOptionsSection, NumericFacetSection, SearchSection, -} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { buildController, Controller, -} from '../../../../controller/headless-controller'; -import {determineFacetId} from '../../_common/facet-id-determinor'; -import {validateNumericFacetOptions} from './headless-numeric-facet-options'; +} from '../../../../controller/headless-controller.js'; +import {determineFacetId} from '../../_common/facet-id-determinor.js'; +import {validateNumericFacetOptions} from './headless-numeric-facet-options.js'; /** * The options defining a `NumericFilter`. diff --git a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-numeric-facet-options.ts b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-numeric-facet-options.ts index ef21d82e9f0..721602d9725 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-numeric-facet-options.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/headless-numeric-facet-options.ts @@ -7,26 +7,26 @@ import { SchemaDefinition, StringValue, } from '@coveo/bueno'; -import {CoreEngine} from '../../../../../app/engine'; +import {CoreEngine} from '../../../../../app/engine.js'; import { FacetResultsMustMatch, facetResultsMustMatch, -} from '../../../../../features/facets/facet-api/request'; -import {facetValueStates} from '../../../../../features/facets/facet-api/value'; +} from '../../../../../features/facets/facet-api/request.js'; +import {facetValueStates} from '../../../../../features/facets/facet-api/value.js'; import { rangeFacetRangeAlgorithm, RangeFacetRangeAlgorithm, rangeFacetSortCriteria, RangeFacetSortCriterion, -} from '../../../../../features/facets/range-facets/generic/interfaces/request'; -import {NumericRangeRequest} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; -import {validateManualNumericRanges} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; +} from '../../../../../features/facets/range-facets/generic/interfaces/request.js'; +import {NumericRangeRequest} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {validateManualNumericRanges} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; import { ConfigurationSection, NumericFacetSection, SearchSection, -} from '../../../../../state/state-sections'; -import {validateOptions} from '../../../../../utils/validate-payload'; +} from '../../../../../state/state-sections.js'; +import {validateOptions} from '../../../../../utils/validate-payload.js'; import { facetId, field, @@ -34,7 +34,7 @@ import { filterFacetCount, injectionDepth, numberOfValues, -} from '../../../../core/facets/_common/facet-option-definitions'; +} from '../../../../core/facets/_common/facet-option-definitions.js'; /** * The options defining a `NumericFacet`. diff --git a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/numeric-range.ts b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/numeric-range.ts index e1d1c06e313..95afd5abe6a 100644 --- a/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/numeric-range.ts +++ b/packages/headless/src/controllers/core/facets/range-facet/numeric-facet/numeric-range.ts @@ -1,5 +1,5 @@ -import {NumericRangeRequest} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; -import {FacetValueState} from '../../facet/headless-core-facet'; +import {NumericRangeRequest} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {FacetValueState} from '../../facet/headless-core-facet.js'; export interface NumericRangeOptions { /** diff --git a/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.test.ts b/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.test.ts index 525743253d9..6a60abc61d3 100644 --- a/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.test.ts +++ b/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.test.ts @@ -1,37 +1,37 @@ -import {Raw} from '../../../api/search/search/raw'; -import {Result} from '../../../api/search/search/result'; -import {configurationReducer as configuration} from '../../../features/configuration/configuration-slice'; +import {Raw} from '../../../api/search/search/raw.js'; +import {Result} from '../../../api/search/search/result.js'; +import {configurationReducer as configuration} from '../../../features/configuration/configuration-slice.js'; import { loadCollection, registerFolding, -} from '../../../features/folding/folding-actions'; +} from '../../../features/folding/folding-actions.js'; import { foldedResultAnalyticsClient, logShowMoreFoldedResults, -} from '../../../features/folding/folding-analytics-actions'; -import {foldingReducer as folding} from '../../../features/folding/folding-slice'; +} from '../../../features/folding/folding-analytics-actions.js'; +import {foldingReducer as folding} from '../../../features/folding/folding-slice.js'; import { FoldedCollection, getFoldingInitialState, -} from '../../../features/folding/folding-state'; -import {queryReducer as query} from '../../../features/query/query-slice'; -import {fetchMoreResults} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/folding/folding-state.js'; +import {queryReducer as query} from '../../../features/query/query-slice.js'; +import {fetchMoreResults} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockResult} from '../../../test/mock-result'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCoreFoldedResultList, FoldedResultList, CoreFoldedResultListProps, FoldedResultListOptions, -} from './headless-core-folded-result-list'; +} from './headless-core-folded-result-list.js'; -jest.mock('../../../features/folding/folding-actions'); -jest.mock('../../../features/folding/folding-analytics-actions'); +vi.mock('../../../features/folding/folding-actions'); +vi.mock('../../../features/folding/folding-analytics-actions'); describe('FoldedResultList', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.ts b/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.ts index db5b98a9972..8582715baa1 100644 --- a/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.ts +++ b/packages/headless/src/controllers/core/folded-result-list/headless-core-folded-result-list.ts @@ -1,38 +1,38 @@ import {Schema} from '@coveo/bueno'; import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {Result} from '../../../api/search/search/result'; -import {CoreEngine} from '../../../app/engine'; +import {Result} from '../../../api/search/search/result.js'; +import {CoreEngine} from '../../../app/engine.js'; import { ClickAction, CustomAction, -} from '../../../features/analytics/analytics-utils'; -import {configurationReducer as configuration} from '../../../features/configuration/configuration-slice'; +} from '../../../features/analytics/analytics-utils.js'; +import {configurationReducer as configuration} from '../../../features/configuration/configuration-slice.js'; import { foldingOptionsSchemaDefinition, registerFolding, -} from '../../../features/folding/folding-actions'; -import {foldingReducer as folding} from '../../../features/folding/folding-slice'; +} from '../../../features/folding/folding-actions.js'; +import {foldingReducer as folding} from '../../../features/folding/folding-slice.js'; import { CollectionId, FoldedCollection, FoldedResult, -} from '../../../features/folding/folding-state'; -import {queryReducer as query} from '../../../features/query/query-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/folding/folding-state.js'; +import {queryReducer as query} from '../../../features/query/query-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { ConfigurationSection, FoldingSection, QuerySection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {validateOptions} from '../../../utils/validate-payload'; -import {Controller} from '../../controller/headless-controller'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateOptions} from '../../../utils/validate-payload.js'; +import {Controller} from '../../controller/headless-controller.js'; import { ResultListOptions, buildCoreResultList, -} from '../result-list/headless-core-result-list'; -import {SearchStatusState} from '../status/headless-core-status'; +} from '../result-list/headless-core-result-list.js'; +import {SearchStatusState} from '../status/headless-core-status.js'; export type {FoldedCollection, FoldedResult}; diff --git a/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.test.ts b/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.test.ts index 9a99b829293..6ecc295dd93 100644 --- a/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.test.ts +++ b/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.test.ts @@ -9,7 +9,8 @@ import { registerFieldsToIncludeInCitations, expandGeneratedAnswer, collapseGeneratedAnswer, -} from '../../../features/generated-answer/generated-answer-actions'; + setIsEnabled, +} from '../../../features/generated-answer/generated-answer-actions.js'; import { generatedAnswerAnalyticsClient, logCopyGeneratedAnswer, @@ -23,28 +24,28 @@ import { logGeneratedAnswerExpand, logGeneratedAnswerCollapse, GeneratedAnswerFeedback, -} from '../../../features/generated-answer/generated-answer-analytics-actions'; -import {generatedAnswerReducer} from '../../../features/generated-answer/generated-answer-slice'; +} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; +import {generatedAnswerReducer} from '../../../features/generated-answer/generated-answer-slice.js'; import { GeneratedAnswerState, getGeneratedAnswerInitialState, -} from '../../../features/generated-answer/generated-answer-state'; -import {GeneratedResponseFormat} from '../../../features/generated-answer/generated-response-format'; -import {SearchAppState} from '../../../state/search-app-state'; -import {buildMockCitation} from '../../../test/mock-citation'; +} from '../../../features/generated-answer/generated-answer-state.js'; +import {GeneratedResponseFormat} from '../../../features/generated-answer/generated-response-format.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {buildMockCitation} from '../../../test/mock-citation.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCoreGeneratedAnswer, GeneratedAnswer, GeneratedAnswerProps, -} from './headless-core-generated-answer'; +} from './headless-core-generated-answer.js'; -jest.mock('../../../features/generated-answer/generated-answer-actions'); -jest.mock( +vi.mock('../../../features/generated-answer/generated-answer-actions'); +vi.mock( '../../../features/generated-answer/generated-answer-analytics-actions' ); @@ -74,7 +75,7 @@ describe('generated answer', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildEngineWithGeneratedAnswer(); initGeneratedAnswer(); }); @@ -224,6 +225,52 @@ describe('generated answer', () => { }); }); + describe('#enable', () => { + describe('when already enabled', () => { + it('should not make any changes', () => { + engine = buildEngineWithGeneratedAnswer({isEnabled: true}); + initGeneratedAnswer(); + + generatedAnswer.enable(); + expect(setIsEnabled).not.toHaveBeenCalled(); + }); + }); + + describe('when not enabled', () => { + it('should dispatch the setIsEnabled action', () => { + engine = buildEngineWithGeneratedAnswer({isEnabled: false}); + initGeneratedAnswer(); + + generatedAnswer.enable(); + + expect(setIsEnabled).toHaveBeenCalledWith(true); + }); + }); + }); + + describe('#disable', () => { + describe('when already disabled', () => { + it('should not make any changes', () => { + engine = buildEngineWithGeneratedAnswer({isEnabled: false}); + initGeneratedAnswer(); + + generatedAnswer.disable(); + expect(setIsEnabled).not.toHaveBeenCalled(); + }); + }); + + describe('when not disabled', () => { + it('should dispatch the setIsEnabled action', () => { + engine = buildEngineWithGeneratedAnswer({isEnabled: true}); + initGeneratedAnswer(); + + generatedAnswer.disable(); + + expect(setIsEnabled).toHaveBeenCalledWith(false); + }); + }); + }); + describe('#expand', () => { describe('when already expanded', () => { it('should not make any changes', () => { diff --git a/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.ts b/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.ts index 641c5ab000d..cab1573225f 100644 --- a/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.ts +++ b/packages/headless/src/controllers/core/generated-answer/headless-core-generated-answer.ts @@ -1,9 +1,9 @@ -import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload'; -import {CoreEngine} from '../../../app/engine'; +import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload.js'; +import {CoreEngine} from '../../../app/engine.js'; import { CustomAction, LegacySearchAction, -} from '../../../features/analytics/analytics-utils'; +} from '../../../features/analytics/analytics-utils.js'; import { likeGeneratedAnswer, dislikeGeneratedAnswer, @@ -15,21 +15,22 @@ import { registerFieldsToIncludeInCitations, expandGeneratedAnswer, collapseGeneratedAnswer, -} from '../../../features/generated-answer/generated-answer-actions'; -import {GeneratedAnswerFeedback} from '../../../features/generated-answer/generated-answer-analytics-actions'; -import {generatedAnswerReducer as generatedAnswer} from '../../../features/generated-answer/generated-answer-slice'; -import {GeneratedAnswerState} from '../../../features/generated-answer/generated-answer-state'; -import {GeneratedResponseFormat} from '../../../features/generated-answer/generated-response-format'; + setIsEnabled, +} from '../../../features/generated-answer/generated-answer-actions.js'; +import {GeneratedAnswerFeedback} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; +import {generatedAnswerReducer as generatedAnswer} from '../../../features/generated-answer/generated-answer-slice.js'; +import {GeneratedAnswerState} from '../../../features/generated-answer/generated-answer-state.js'; +import {GeneratedResponseFormat} from '../../../features/generated-answer/generated-response-format.js'; import { DebugSection, GeneratedAnswerSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { Controller, buildController, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export type { GeneratedAnswerCitation, @@ -88,6 +89,14 @@ export interface GeneratedAnswer extends Controller { * Collapses the generated answer. */ collapse(): void; + /** + * Enables the generated answer. + */ + enable(): void; + /** + * Disables the generated answer. + */ + disable(): void; /** * Logs a custom event indicating the generated answer was copied to the clipboard. */ @@ -125,6 +134,10 @@ export interface GeneratedAnswerPropsInitialState { * Sets the component visibility state on load. */ isVisible?: boolean; + /** + * Sets the component enabled state on load. + */ + isEnabled?: boolean; /** * The initial formatting options applied to generated answers when the controller first loads. */ @@ -258,6 +271,18 @@ export function buildCoreGeneratedAnswer( } }, + enable() { + if (!this.state.isEnabled) { + dispatch(setIsEnabled(true)); + } + }, + + disable() { + if (this.state.isEnabled) { + dispatch(setIsEnabled(false)); + } + }, + logCopyToClipboard() { dispatch(analyticsClient.logCopyGeneratedAnswer()); }, diff --git a/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.test.ts b/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.test.ts index dff22e8ed56..5ca291acf41 100644 --- a/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.test.ts +++ b/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.test.ts @@ -1,21 +1,21 @@ -import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload'; -import {configuration} from '../../../app/common-reducers'; +import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload.js'; +import {configuration} from '../../../app/common-reducers.js'; import { generatedAnswerAnalyticsClient, logOpenGeneratedAnswerSource, -} from '../../../features/generated-answer/generated-answer-analytics-actions'; -import {buildMockCitation} from '../../../test/mock-citation'; +} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; +import {buildMockCitation} from '../../../test/mock-citation.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildInteractiveCitationCore, InteractiveCitation, -} from './headless-core-interactive-citation'; +} from './headless-core-interactive-citation.js'; -jest.mock( +vi.mock( '../../../features/generated-answer/generated-answer-analytics-actions' ); diff --git a/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.ts b/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.ts index 9f90ff7742d..a0932049673 100644 --- a/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.ts +++ b/packages/headless/src/controllers/core/generated-answer/headless-core-interactive-citation.ts @@ -1,12 +1,12 @@ -import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload'; -import {CoreEngine} from '../../../app/engine'; -import {CustomAction} from '../../../features/analytics/analytics-utils'; +import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {CustomAction} from '../../../features/analytics/analytics-utils.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from '../../core/interactive-result/headless-core-interactive-result'; +} from '../../core/interactive-result/headless-core-interactive-result.js'; export interface InteractiveCitationOptions extends InteractiveResultCoreOptions { diff --git a/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.test.ts b/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.test.ts index f54f9a27051..fa30cd273a4 100644 --- a/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.test.ts +++ b/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.test.ts @@ -5,35 +5,40 @@ import { likeGeneratedAnswer, openGeneratedAnswerFeedbackModal, registerFieldsToIncludeInCitations, + resetAnswer, sendGeneratedAnswerFeedback, setIsVisible, + streamAnswer, updateResponseFormat, -} from '../../../features/generated-answer/generated-answer-actions'; +} from '../../../features/generated-answer/generated-answer-actions.js'; import { generatedAnswerAnalyticsClient, GeneratedAnswerFeedback, -} from '../../../features/generated-answer/generated-answer-analytics-actions'; +} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; import { GeneratedAnswerState, getGeneratedAnswerInitialState, -} from '../../../features/generated-answer/generated-answer-state'; -import {executeSearch} from '../../../features/search/search-actions'; +} from '../../../features/generated-answer/generated-answer-state.js'; +import {executeSearch} from '../../../features/search/search-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { GeneratedAnswerProps, GeneratedResponseFormat, -} from '../../generated-answer/headless-generated-answer'; -import {buildSearchAPIGeneratedAnswer} from './headless-searchapi-generated-answer'; +} from '../../generated-answer/headless-generated-answer.js'; +import { + buildSearchAPIGeneratedAnswer, + subscribeStateManager, +} from './headless-searchapi-generated-answer.js'; -jest.mock('../../../features/generated-answer/generated-answer-actions'); -jest.mock( +vi.mock('../../../features/generated-answer/generated-answer-actions'); +vi.mock( '../../../features/generated-answer/generated-answer-analytics-actions' ); -jest.mock('../../../features/search/search-actions'); +vi.mock('../../../features/search/search-actions'); describe('searchapi-generated-answer', () => { let engine: MockedSearchEngine; @@ -58,7 +63,7 @@ describe('searchapi-generated-answer', () => { } beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); engine = buildEngineWithGeneratedAnswer(); }); @@ -293,4 +298,87 @@ describe('searchapi-generated-answer', () => { expect(engine.dispatch).not.toHaveBeenCalled(); }); }); + + describe('#enable', () => { + let subscribeStateManagerMock: any; + + const setupEngine = (isEnabled: boolean) => { + engine = buildEngineWithGeneratedAnswer({ + id: 'genQaEngineId', + isEnabled, + }); + createGeneratedAnswer({ + initialState: {isEnabled}, + }); + + engine.state.search = { + ...engine.state.search, + extendedResults: { + generativeQuestionAnsweringId: 'streamId', + }, + }; + + subscribeStateManagerMock.subscribeToSearchRequests(engine); + }; + + beforeEach(() => { + vi.clearAllMocks(); + + subscribeStateManagerMock = { + engines: { + genQaEngineId: { + lastStreamId: '', + }, + }, + subscribeToSearchRequests: + subscribeStateManager.subscribeToSearchRequests, + }; + + subscribeStateManager.engines = subscribeStateManagerMock.engines; + }); + + it('should stream answer when generated answer is enabled', () => { + setupEngine(true); + + expect(engine.subscribe).toHaveBeenCalled(); + + const listener = engine.subscribe.mock.calls[0][0]; + listener(); + + expect(streamAnswer).toHaveBeenCalled(); + }); + + it('should not stream answer when generated answer is disabled', () => { + setupEngine(false); + + expect(engine.subscribe).toHaveBeenCalled(); + + const listener = engine.subscribe.mock.calls[0][0]; + listener(); + + expect(streamAnswer).not.toHaveBeenCalled(); + }); + + it('should reset answer when generated answer is enabled', () => { + setupEngine(true); + + expect(engine.subscribe).toHaveBeenCalled(); + + const listener = engine.subscribe.mock.calls[0][0]; + listener(); + + expect(resetAnswer).toHaveBeenCalled(); + }); + + it('should not reset answer when generated answer is disabled', () => { + setupEngine(false); + + expect(engine.subscribe).toHaveBeenCalled(); + + const listener = engine.subscribe.mock.calls[0][0]; + listener(); + + expect(resetAnswer).not.toHaveBeenCalled(); + }); + }); }); diff --git a/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.ts b/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.ts index 9e51ab4d904..40024b65ce4 100644 --- a/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.ts +++ b/packages/headless/src/controllers/core/generated-answer/headless-searchapi-generated-answer.ts @@ -1,30 +1,30 @@ import {Unsubscribe} from '@reduxjs/toolkit'; -import {GeneratedAnswerAPIClient} from '../../../api/generated-answer/generated-answer-client'; -import {CoreEngine} from '../../../app/engine'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {ConfigurationState} from '../../../features/configuration/configuration-state'; +import {GeneratedAnswerAPIClient} from '../../../api/generated-answer/generated-answer-client.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {ConfigurationState} from '../../../features/configuration/configuration-state.js'; import { resetAnswer, setId, streamAnswer, -} from '../../../features/generated-answer/generated-answer-actions'; -import {generatedAnswerReducer as generatedAnswer} from '../../../features/generated-answer/generated-answer-slice'; -import {executeSearch} from '../../../features/search/search-actions'; +} from '../../../features/generated-answer/generated-answer-actions.js'; +import {generatedAnswerReducer as generatedAnswer} from '../../../features/generated-answer/generated-answer-slice.js'; +import {executeSearch} from '../../../features/search/search-actions.js'; import { DebugSection, GeneratedAnswerSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {randomID} from '../../../utils/utils'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {randomID} from '../../../utils/utils.js'; import { buildCoreGeneratedAnswer, GeneratedAnswer, GeneratedAnswerAnalyticsClient, GeneratedAnswerProps, -} from './headless-core-generated-answer'; +} from './headless-core-generated-answer.js'; export interface SearchAPIGeneratedAnswer extends GeneratedAnswer {} export interface SearchAPIGeneratedAnswerProps extends GeneratedAnswerProps {} @@ -49,7 +49,7 @@ interface SubscribeStateManager { ) => Unsubscribe; } -const subscribeStateManager: SubscribeStateManager = { +export const subscribeStateManager: SubscribeStateManager = { engines: {}, setAbortControllerRef: (ref: AbortController, genQaEngineId: string) => { @@ -82,6 +82,10 @@ const subscribeStateManager: SubscribeStateManager = { ) { subscribeStateManager.engines[genQaEngineId].lastRequestId = requestId; subscribeStateManager.engines[genQaEngineId].abortController?.abort(); + if (state.generatedAnswer.isEnabled === false) { + return; + } + engine.dispatch(resetAnswer()); } @@ -93,6 +97,9 @@ const subscribeStateManager: SubscribeStateManager = { streamId !== subscribeStateManager.engines[genQaEngineId].lastStreamId ) { subscribeStateManager.engines[genQaEngineId].lastStreamId = streamId; + if (state.generatedAnswer.isEnabled === false) { + return; + } engine.dispatch( streamAnswer({ setAbortControllerRef: (ref: AbortController) => diff --git a/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.test.ts b/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.test.ts index 3fc00bc3e33..9538d84547a 100644 --- a/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.test.ts +++ b/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.test.ts @@ -1,18 +1,19 @@ -import {configuration} from '../../../app/common-reducers'; +import {Mock} from 'vitest'; +import {configuration} from '../../../app/common-reducers.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildInteractiveResultCore, InteractiveResultCore, -} from './headless-core-interactive-result'; +} from './headless-core-interactive-result.js'; describe('InteractiveResultCore', () => { let engine: MockedSearchEngine; let interactiveResultCore: InteractiveResultCore; - let actionSpy: jest.Mock; + let actionSpy: Mock; function initializeInteractiveResultCore(delay?: number) { interactiveResultCore = buildInteractiveResultCore( @@ -25,14 +26,14 @@ describe('InteractiveResultCore', () => { } beforeEach(() => { - actionSpy = jest.fn(); + actionSpy = vi.fn(); engine = buildMockSearchEngine(createMockState()); initializeInteractiveResultCore(); - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('it adds the correct reducers to engine', () => { @@ -53,23 +54,23 @@ describe('InteractiveResultCore', () => { it("when calling beginDelayedSelect(), doesn't execute action before the delay", () => { interactiveResultCore.beginDelayedSelect(); - jest.advanceTimersByTime(selectDelay - 1); + vi.advanceTimersByTime(selectDelay - 1); expect(actionSpy).not.toHaveBeenCalled(); }); it('when calling beginDelayedSelect(), executes action after the delay', () => { interactiveResultCore.beginDelayedSelect(); - jest.advanceTimersByTime(selectDelay); + vi.advanceTimersByTime(selectDelay); expect(actionSpy).toHaveBeenCalled(); }); it("when calling beginDelayedSelect(), doesn't execute action after the delay if cancelPendingSelect() was called", () => { interactiveResultCore.beginDelayedSelect(); - jest.advanceTimersByTime(selectDelay - 1); + vi.advanceTimersByTime(selectDelay - 1); interactiveResultCore.cancelPendingSelect(); - jest.advanceTimersByTime(1); + vi.advanceTimersByTime(1); expect(actionSpy).not.toHaveBeenCalled(); }); diff --git a/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.ts b/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.ts index 24f61640eb1..8f2442fd72f 100644 --- a/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.ts +++ b/packages/headless/src/controllers/core/interactive-result/headless-core-interactive-result.ts @@ -1,8 +1,8 @@ import {debounce} from 'ts-debounce'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine, CoreEngineNext} from '../../../app/engine'; -import {ConfigurationSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine, CoreEngineNext} from '../../../app/engine.js'; +import {ConfigurationSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; export interface InteractiveResultCoreOptions { /** diff --git a/packages/headless/src/controllers/core/pager/headless-core-pager.test.ts b/packages/headless/src/controllers/core/pager/headless-core-pager.test.ts index 8c31e716c1f..32af2943bdd 100644 --- a/packages/headless/src/controllers/core/pager/headless-core-pager.test.ts +++ b/packages/headless/src/controllers/core/pager/headless-core-pager.test.ts @@ -1,30 +1,30 @@ -import {configuration} from '../../../app/common-reducers'; +import {configuration} from '../../../app/common-reducers.js'; import { nextPage, previousPage, registerPage, updatePage, -} from '../../../features/pagination/pagination-actions'; +} from '../../../features/pagination/pagination-actions.js'; import { currentPageSelector, currentPagesSelector, maxPageSelector, -} from '../../../features/pagination/pagination-selectors'; -import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice'; +} from '../../../features/pagination/pagination-selectors.js'; +import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { Pager, PagerOptions, PagerInitialState, buildCorePager, -} from './headless-core-pager'; +} from './headless-core-pager.js'; -jest.mock('../../../features/pagination/pagination-actions'); -jest.mock('../../../features/pagination/pagination-selectors'); +vi.mock('../../../features/pagination/pagination-actions'); +vi.mock('../../../features/pagination/pagination-selectors'); describe('Pager', () => { let engine: MockedSearchEngine; @@ -45,7 +45,7 @@ describe('Pager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initEngine(); initPager(); }); @@ -96,7 +96,7 @@ describe('Pager', () => { }); it('when #initialState.page is defined, it registers the page', () => { - const mockedRegisterPageAction = jest.mocked(registerPage); + const mockedRegisterPageAction = vi.mocked(registerPage); initPager({initialState: {page: 2}}); @@ -107,7 +107,7 @@ describe('Pager', () => { }); it('#selectPage dispatches #updatePage with the passed page', () => { - const mockedUpdatePageAction = jest.mocked(updatePage); + const mockedUpdatePageAction = vi.mocked(updatePage); pager.selectPage(2); @@ -115,7 +115,7 @@ describe('Pager', () => { }); it('#nextPage dispatches a #nextPage action', () => { - const mockedNextPage = jest.mocked(nextPage); + const mockedNextPage = vi.mocked(nextPage); pager.nextPage(); @@ -123,7 +123,7 @@ describe('Pager', () => { }); it('#previousPage dispatches a #previousPage action', () => { - const mockedPreviousPage = jest.mocked(previousPage); + const mockedPreviousPage = vi.mocked(previousPage); pager.previousPage(); @@ -131,7 +131,7 @@ describe('Pager', () => { }); it('calling #isCurrentPage with a page number not equal to the one in state returns false', () => { - jest.mocked(currentPageSelector).mockReturnValue(2); + vi.mocked(currentPageSelector).mockReturnValue(2); initPager(); @@ -139,7 +139,7 @@ describe('Pager', () => { }); it('calling #isCurrentPage with a page number equal to the one in state returns true', () => { - jest.mocked(currentPageSelector).mockReturnValue(2); + vi.mocked(currentPageSelector).mockReturnValue(2); initPager(); @@ -148,42 +148,42 @@ describe('Pager', () => { }); it('state exposes a maxPage property', () => { - jest.mocked(maxPageSelector).mockReturnValue(10); + vi.mocked(maxPageSelector).mockReturnValue(10); expect(pager.state.maxPage).toBe(10); }); it('when on page 1 and maxPage is 10, #state.hasNextPage is true', () => { - jest.mocked(maxPageSelector).mockReturnValue(10); - jest.mocked(currentPageSelector).mockReturnValue(1); + vi.mocked(maxPageSelector).mockReturnValue(10); + vi.mocked(currentPageSelector).mockReturnValue(1); expect(pager.state.hasNextPage).toBe(true); }); it('when on page 10 and maxPage is 10, #state.hasNextPage returns false', () => { - jest.mocked(maxPageSelector).mockReturnValue(10); - jest.mocked(currentPageSelector).mockReturnValue(10); + vi.mocked(maxPageSelector).mockReturnValue(10); + vi.mocked(currentPageSelector).mockReturnValue(10); expect(pager.state.hasNextPage).toBe(false); }); it('when on page 10 and maxPage is 10, #state.hasPreviousPage returns true', () => { - jest.mocked(maxPageSelector).mockReturnValue(10); - jest.mocked(currentPageSelector).mockReturnValue(10); + vi.mocked(maxPageSelector).mockReturnValue(10); + vi.mocked(currentPageSelector).mockReturnValue(10); expect(pager.state.hasPreviousPage).toBe(true); }); it('when on page 1 and maxPage is 10, #state.hasPreviousPage returns false', () => { - jest.mocked(maxPageSelector).mockReturnValue(10); - jest.mocked(currentPageSelector).mockReturnValue(1); + vi.mocked(maxPageSelector).mockReturnValue(10); + vi.mocked(currentPageSelector).mockReturnValue(1); expect(pager.state.hasPreviousPage).toBe(false); }); it('when maxPage is 0 and page 1 is selected, #state.hasPreviousPage should returns false', () => { - jest.mocked(maxPageSelector).mockReturnValue(0); - jest.mocked(currentPageSelector).mockReturnValue(1); + vi.mocked(maxPageSelector).mockReturnValue(0); + vi.mocked(currentPageSelector).mockReturnValue(1); expect(pager.state.hasPreviousPage).toBe(false); }); diff --git a/packages/headless/src/controllers/core/pager/headless-core-pager.ts b/packages/headless/src/controllers/core/pager/headless-core-pager.ts index cc74502425b..5f097cac23d 100644 --- a/packages/headless/src/controllers/core/pager/headless-core-pager.ts +++ b/packages/headless/src/controllers/core/pager/headless-core-pager.ts @@ -1,32 +1,32 @@ import {NumberValue, Schema} from '@coveo/bueno'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; import { nextPage, previousPage, registerPage, updatePage, -} from '../../../features/pagination/pagination-actions'; -import {minimumPage} from '../../../features/pagination/pagination-constants'; +} from '../../../features/pagination/pagination-actions.js'; +import {minimumPage} from '../../../features/pagination/pagination-constants.js'; import { currentPageSelector, currentPagesSelector, maxPageSelector, -} from '../../../features/pagination/pagination-selectors'; -import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice'; +} from '../../../features/pagination/pagination-selectors.js'; +import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice.js'; import { ConfigurationSection, PaginationSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { validateInitialState, validateOptions, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface PagerInitialState { /** diff --git a/packages/headless/src/controllers/core/query-error/headless-core-query-error.ts b/packages/headless/src/controllers/core/query-error/headless-core-query-error.ts index c7a91a09bcc..d4893327714 100644 --- a/packages/headless/src/controllers/core/query-error/headless-core-query-error.ts +++ b/packages/headless/src/controllers/core/query-error/headless-core-query-error.ts @@ -1,12 +1,12 @@ -import {CoreEngine} from '../../../app/engine'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {ErrorPayload} from '../../controller/error-payload'; +import {CoreEngine} from '../../../app/engine.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {ErrorPayload} from '../../controller/error-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; /** * The `QueryError` controller allows to retrieve information about the current error returned by the search API, if any. diff --git a/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.test.ts b/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.test.ts index 27485b42d89..96610f87b5b 100644 --- a/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.test.ts +++ b/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.test.ts @@ -1,16 +1,16 @@ -import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchAppState} from '../../../state/search-app-state'; +import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockResult} from '../../../test/mock-result'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCoreQuerySummary, QuerySummary, -} from './headless-core-query-summary'; +} from './headless-core-query-summary.js'; describe('CoreQuerySummary', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.ts b/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.ts index 5138b81277b..9d7dab3d963 100644 --- a/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.ts +++ b/packages/headless/src/controllers/core/query-summary/headless-core-query-summary.ts @@ -1,16 +1,19 @@ -import {CoreEngine} from '../../../app/engine'; -import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {PaginationSection, SearchSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +import {CoreEngine} from '../../../app/engine.js'; +import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import { + PaginationSection, + SearchSection, +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { buildCoreStatus, SearchStatusState, -} from '../status/headless-core-status'; +} from '../status/headless-core-status.js'; /** * The `QuerySummary` headless controller offers a high-level interface for designing a common query summary UI controller. diff --git a/packages/headless/src/controllers/core/quickview/headless-core-quickview.test.ts b/packages/headless/src/controllers/core/quickview/headless-core-quickview.test.ts index 99588cdeb0d..42499ea1703 100644 --- a/packages/headless/src/controllers/core/quickview/headless-core-quickview.test.ts +++ b/packages/headless/src/controllers/core/quickview/headless-core-quickview.test.ts @@ -1,26 +1,26 @@ -import {configuration} from '../../../app/common-reducers'; +import {configuration} from '../../../app/common-reducers.js'; import { fetchResultContent, nextPreview, previousPreview, updateContentURL, -} from '../../../features/result-preview/result-preview-actions'; -import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice'; +} from '../../../features/result-preview/result-preview-actions.js'; +import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildMockResultPreviewRequest} from '../../../test/mock-result-preview-request-builder'; -import {buildMockResultPreviewState} from '../../../test/mock-result-preview-state'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockResultPreviewRequest} from '../../../test/mock-result-preview-request-builder.js'; +import {buildMockResultPreviewState} from '../../../test/mock-result-preview-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCoreQuickview, QuickviewOptions, Quickview, -} from './headless-core-quickview'; +} from './headless-core-quickview.js'; -jest.mock('../../../features/result-preview/result-preview-actions'); +vi.mock('../../../features/result-preview/result-preview-actions'); describe('QuickviewCore', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/quickview/headless-core-quickview.ts b/packages/headless/src/controllers/core/quickview/headless-core-quickview.ts index 2174f04693d..055af75fe1a 100644 --- a/packages/headless/src/controllers/core/quickview/headless-core-quickview.ts +++ b/packages/headless/src/controllers/core/quickview/headless-core-quickview.ts @@ -1,29 +1,29 @@ -import {HtmlApiClient} from '../../../api/search/html/html-api-client'; +import {HtmlApiClient} from '../../../api/search/html/html-api-client.js'; import { HtmlRequest, HtmlRequestOptions, -} from '../../../api/search/html/html-request'; -import {Result} from '../../../api/search/search/result'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; +} from '../../../api/search/html/html-request.js'; +import {Result} from '../../../api/search/search/result.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; import { fetchResultContent, nextPreview, previousPreview, updateContentURL, -} from '../../../features/result-preview/result-preview-actions'; -import {StateNeededByHtmlEndpoint} from '../../../features/result-preview/result-preview-request-builder'; -import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice'; +} from '../../../features/result-preview/result-preview-actions.js'; +import {StateNeededByHtmlEndpoint} from '../../../features/result-preview/result-preview-request-builder.js'; +import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice.js'; import { ConfigurationSection, ResultPreviewSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface QuickviewProps { /** diff --git a/packages/headless/src/controllers/core/result-list/headless-core-result-list.test.ts b/packages/headless/src/controllers/core/result-list/headless-core-result-list.test.ts index d0cc0dc5fef..3a9e4132fb2 100644 --- a/packages/headless/src/controllers/core/result-list/headless-core-result-list.test.ts +++ b/packages/headless/src/controllers/core/result-list/headless-core-result-list.test.ts @@ -1,19 +1,20 @@ import {SchemaValidationError} from '@coveo/bueno'; -import {configuration} from '../../../app/common-reducers'; -import {registerFieldsToInclude} from '../../../features/fields/fields-actions'; -import {fieldsReducer as fields} from '../../../features/fields/fields-slice'; -import {fetchMoreResults} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +import {Mock} from 'vitest'; +import {configuration} from '../../../app/common-reducers.js'; +import {registerFieldsToInclude} from '../../../features/fields/fields-actions.js'; +import {fieldsReducer as fields} from '../../../features/fields/fields-slice.js'; +import {fetchMoreResults} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockResult} from '../../../test/mock-result'; -import {createMockState} from '../../../test/mock-state'; -import {buildCoreResultList, ResultList} from './headless-core-result-list'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildCoreResultList, ResultList} from './headless-core-result-list.js'; -jest.mock('../../../features/fields/fields-actions'); -jest.mock('../../../features/search/search-actions'); +vi.mock('../../../features/fields/fields-actions'); +vi.mock('../../../features/search/search-actions'); describe('CoreResultList', () => { const testProps = { @@ -22,17 +23,17 @@ describe('CoreResultList', () => { let engine: MockedSearchEngine; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); const state = createMockState(); const results = new Array(10).fill(buildMockResult()); state.search.results = results; state.search.response.totalCountFiltered = 1000; engine = buildMockSearchEngine(state); - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('it adds the correct reducers to engine', () => { @@ -89,7 +90,7 @@ describe('CoreResultList', () => { describe('fetchMoreResults "infinite" fetches prevention', () => { let resultList: ResultList; - let mockDispatch: jest.Mock; + let mockDispatch: Mock; const fetchMoreResultsAndWait = async ( iterations: number, @@ -98,13 +99,13 @@ describe('CoreResultList', () => { for (let i = 0; i < iterations; i++) { resultList.fetchMoreResults(); await Promise.resolve(); - jest.advanceTimersByTime(delay); + vi.advanceTimersByTime(delay); await Promise.resolve(); } }; beforeEach(() => { - mockDispatch = jest.fn().mockResolvedValue({}); + mockDispatch = vi.fn().mockResolvedValue({}); resultList = buildCoreResultList( { ...engine, @@ -112,8 +113,8 @@ describe('CoreResultList', () => { }, testProps ); - jest.spyOn(engine.logger, 'error'); - jest.spyOn(engine.logger, 'info'); + vi.spyOn(engine.logger, 'error'); + vi.spyOn(engine.logger, 'info'); }); it(`when calling fetchMoreResults consecutively many times with a small delay diff --git a/packages/headless/src/controllers/core/result-list/headless-core-result-list.ts b/packages/headless/src/controllers/core/result-list/headless-core-result-list.ts index aa6059d2e53..6a3d947adaf 100644 --- a/packages/headless/src/controllers/core/result-list/headless-core-result-list.ts +++ b/packages/headless/src/controllers/core/result-list/headless-core-result-list.ts @@ -1,26 +1,26 @@ import {ArrayValue, Schema, StringValue} from '@coveo/bueno'; import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {Result} from '../../../api/search/search/result'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {registerFieldsToInclude} from '../../../features/fields/fields-actions'; -import {fieldsReducer as fields} from '../../../features/fields/fields-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; +import {Result} from '../../../api/search/search/result.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {registerFieldsToInclude} from '../../../features/fields/fields-actions.js'; +import {fieldsReducer as fields} from '../../../features/fields/fields-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { ConfigurationSection, FieldsSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {validateOptions} from '../../../utils/validate-payload'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateOptions} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { buildCoreStatus, SearchStatusState, -} from '../status/headless-core-status'; +} from '../status/headless-core-status.js'; const optionsSchema = new Schema({ fieldsToInclude: new ArrayValue({ diff --git a/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.test.ts b/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.test.ts index baecd72ee9e..2399a1c0179 100644 --- a/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.test.ts +++ b/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.test.ts @@ -1,22 +1,22 @@ -import {configuration} from '../../../app/common-reducers'; +import {configuration} from '../../../app/common-reducers.js'; import { registerNumberOfResults, updateNumberOfResults, -} from '../../../features/pagination/pagination-actions'; -import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice'; +} from '../../../features/pagination/pagination-actions.js'; +import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockPagination} from '../../../test/mock-pagination'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockPagination} from '../../../test/mock-pagination.js'; +import {createMockState} from '../../../test/mock-state.js'; import { ResultsPerPage, ResultsPerPageProps, buildCoreResultsPerPage, -} from './headless-core-results-per-page'; +} from './headless-core-results-per-page.js'; -jest.mock('../../../features/pagination/pagination-actions'); +vi.mock('../../../features/pagination/pagination-actions'); describe('ResultsPerPage', () => { let engine: MockedSearchEngine; @@ -28,7 +28,7 @@ describe('ResultsPerPage', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); const state = createMockState(); engine = buildMockSearchEngine(state); props = { diff --git a/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.ts b/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.ts index 626f8b0dd15..21f47d28a6e 100644 --- a/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.ts +++ b/packages/headless/src/controllers/core/results-per-page/headless-core-results-per-page.ts @@ -1,21 +1,21 @@ import {NumberValue, Schema} from '@coveo/bueno'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; import { registerNumberOfResults, updateNumberOfResults, -} from '../../../features/pagination/pagination-actions'; -import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice'; +} from '../../../features/pagination/pagination-actions.js'; +import {paginationReducer as pagination} from '../../../features/pagination/pagination-slice.js'; import { ConfigurationSection, PaginationSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {validateInitialState} from '../../../utils/validate-payload'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateInitialState} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; const initialStateSchema = new Schema({ numberOfResults: new NumberValue({min: 0}), diff --git a/packages/headless/src/controllers/core/search-box/headless-core-search-box-options.ts b/packages/headless/src/controllers/core/search-box/headless-core-search-box-options.ts index 075dbec53db..d9e9a20ecef 100644 --- a/packages/headless/src/controllers/core/search-box/headless-core-search-box-options.ts +++ b/packages/headless/src/controllers/core/search-box/headless-core-search-box-options.ts @@ -5,8 +5,8 @@ import { StringValue, RecordValue, } from '@coveo/bueno'; -import {SuggestionHighlightingOptions} from '../../../utils/highlight'; -import {requiredNonEmptyString} from '../../../utils/validate-payload'; +import {SuggestionHighlightingOptions} from '../../../utils/highlight.js'; +import {requiredNonEmptyString} from '../../../utils/validate-payload.js'; export interface SearchBoxOptions { /** diff --git a/packages/headless/src/controllers/core/search-box/headless-core-search-box.test.ts b/packages/headless/src/controllers/core/search-box/headless-core-search-box.test.ts index 906ef82777b..5053ef972d2 100644 --- a/packages/headless/src/controllers/core/search-box/headless-core-search-box.test.ts +++ b/packages/headless/src/controllers/core/search-box/headless-core-search-box.test.ts @@ -1,43 +1,43 @@ -import {configuration} from '../../../app/common-reducers'; +import {configuration} from '../../../app/common-reducers.js'; import { registerQuerySetQuery, updateQuerySetQuery, -} from '../../../features/query-set/query-set-actions'; -import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice'; +} from '../../../features/query-set/query-set-actions.js'; +import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice.js'; import { registerQuerySuggest, clearQuerySuggest, fetchQuerySuggestions, selectQuerySuggestion, -} from '../../../features/query-suggest/query-suggest-actions'; -import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice'; -import {logSearchboxSubmit} from '../../../features/query/query-analytics-actions'; -import {queryReducer as query} from '../../../features/query/query-slice'; +} from '../../../features/query-suggest/query-suggest-actions.js'; +import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice.js'; +import {logSearchboxSubmit} from '../../../features/query/query-analytics-actions.js'; +import {queryReducer as query} from '../../../features/query/query-slice.js'; import { executeSearch, prepareForSearchWithQuery, -} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchAppState} from '../../../state/search-app-state'; +} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockQuerySuggest} from '../../../test/mock-query-suggest'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockQuerySuggest} from '../../../test/mock-query-suggest.js'; +import {createMockState} from '../../../test/mock-state.js'; import { SearchBox, SearchBoxProps, SearchBoxOptions, buildCoreSearchBox, -} from './headless-core-search-box'; +} from './headless-core-search-box.js'; -jest.mock('../../../features/query/query-analytics-actions', () => ({ - logSearchboxSubmit: jest.fn(() => () => {}), +vi.mock('../../../features/query/query-analytics-actions', () => ({ + logSearchboxSubmit: vi.fn(() => () => {}), })); -jest.mock('../../../features/query-suggest/query-suggest-actions'); -jest.mock('../../../features/query-set/query-set-actions'); -jest.mock('../../../features/search/search-actions'); +vi.mock('../../../features/query-suggest/query-suggest-actions'); +vi.mock('../../../features/query-set/query-set-actions'); +vi.mock('../../../features/search/search-actions'); describe('headless CoreSearchBox', () => { const id = 'search-box-123'; @@ -75,7 +75,7 @@ describe('headless CoreSearchBox', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); function initState() { @@ -143,6 +143,7 @@ describe('headless CoreSearchBox', () => { it('should return the right state', () => { expect(searchBox.state).toEqual({ + searchBoxId: id, value: state.querySet[id], suggestions: state.querySuggest[id]!.completions.map((completion) => ({ highlightedValue: 'hilighted', @@ -175,7 +176,7 @@ describe('headless CoreSearchBox', () => { }); it('should call the showSuggestions method', () => { - jest.spyOn(searchBox, 'showSuggestions'); + vi.spyOn(searchBox, 'showSuggestions'); searchBox.updateText('how can i fix'); expect(searchBox.showSuggestions).toHaveBeenCalled(); diff --git a/packages/headless/src/controllers/core/search-box/headless-core-search-box.ts b/packages/headless/src/controllers/core/search-box/headless-core-search-box.ts index fd4e7f07628..85779ac8a4f 100644 --- a/packages/headless/src/controllers/core/search-box/headless-core-search-box.ts +++ b/packages/headless/src/controllers/core/search-box/headless-core-search-box.ts @@ -1,59 +1,59 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; import { InsightAction, LegacySearchAction, -} from '../../../features/analytics/analytics-utils'; +} from '../../../features/analytics/analytics-utils.js'; import { registerQuerySetQuery, updateQuerySetQuery, -} from '../../../features/query-set/query-set-actions'; -import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice'; +} from '../../../features/query-set/query-set-actions.js'; +import {querySetReducer as querySet} from '../../../features/query-set/query-set-slice.js'; import { clearQuerySuggest, FetchQuerySuggestionsActionCreatorPayload, registerQuerySuggest, selectQuerySuggestion, -} from '../../../features/query-suggest/query-suggest-actions'; +} from '../../../features/query-suggest/query-suggest-actions.js'; import { logQuerySuggestionClick, omniboxAnalytics, -} from '../../../features/query-suggest/query-suggest-analytics-actions'; -import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice'; -import {QuerySuggestState} from '../../../features/query-suggest/query-suggest-state'; -import {logSearchboxSubmit} from '../../../features/query/query-analytics-actions'; -import {queryReducer as query} from '../../../features/query/query-slice'; +} from '../../../features/query-suggest/query-suggest-analytics-actions.js'; +import {querySuggestReducer as querySuggest} from '../../../features/query-suggest/query-suggest-slice.js'; +import {QuerySuggestState} from '../../../features/query-suggest/query-suggest-state.js'; +import {logSearchboxSubmit} from '../../../features/query/query-analytics-actions.js'; +import {queryReducer as query} from '../../../features/query/query-slice.js'; import { SearchAction, TransitiveSearchAction, prepareForSearchWithQuery, -} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { ConfigurationSection, QuerySection, QuerySetSection, QuerySuggestionSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { SuggestionHighlightingOptions, Delimiters, getHighlightedSuggestion, -} from '../../../utils/highlight'; -import {randomID} from '../../../utils/utils'; -import {validateOptions} from '../../../utils/validate-payload'; +} from '../../../utils/highlight.js'; +import {randomID} from '../../../utils/utils.js'; +import {validateOptions} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; import { defaultSearchBoxOptions, SearchBoxOptions, searchBoxOptionsSchema, -} from './headless-core-search-box-options'; +} from './headless-core-search-box-options.js'; export type {SearchBoxOptions, SuggestionHighlightingOptions, Delimiters}; @@ -137,6 +137,11 @@ export interface SearchBoxState { * Determines if a query suggest request is in progress. */ isLoadingSuggestions: boolean; + + /** + * The search box ID. + */ + searchBoxId: string; } export interface Suggestion { @@ -306,6 +311,7 @@ export function buildCoreSearchBox( : false; return { + searchBoxId: id, value: getValue(), suggestions, isLoading: state.search.isLoading, diff --git a/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.test.ts b/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.test.ts index 9d7502c5068..4361c6f1ecb 100644 --- a/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.test.ts +++ b/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.test.ts @@ -1,37 +1,37 @@ -import {restoreSearchParameters} from '../../../features/search-parameters/search-parameter-actions'; -import {initialSearchParameterSelector} from '../../../features/search-parameters/search-parameter-selectors'; -import {buildMockAutomaticFacetResponse} from '../../../test/mock-automatic-facet-response'; -import {buildMockAutomaticFacetSlice} from '../../../test/mock-automatic-facet-slice'; -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request'; -import {buildMockDateFacetRequest} from '../../../test/mock-date-facet-request'; -import {buildMockDateFacetSlice} from '../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../test/mock-date-facet-value'; +import {restoreSearchParameters} from '../../../features/search-parameters/search-parameter-actions.js'; +import {initialSearchParameterSelector} from '../../../features/search-parameters/search-parameter-selectors.js'; +import {buildMockAutomaticFacetResponse} from '../../../test/mock-automatic-facet-response.js'; +import {buildMockAutomaticFacetSlice} from '../../../test/mock-automatic-facet-slice.js'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request.js'; +import {buildMockDateFacetRequest} from '../../../test/mock-date-facet-request.js'; +import {buildMockDateFacetSlice} from '../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../test/mock-date-facet-value.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request'; -import {buildMockNumericFacetRequest} from '../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetSlice} from '../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../test/mock-numeric-facet-value'; -import {buildMockSearchParameters} from '../../../test/mock-search-parameters'; -import {createMockState} from '../../../test/mock-state'; -import {buildMockStaticFilterSlice} from '../../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../../test/mock-static-filter-value'; -import {buildMockTabSlice} from '../../../test/mock-tab-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {buildMockNumericFacetRequest} from '../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetSlice} from '../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../test/mock-numeric-facet-value.js'; +import {buildMockSearchParameters} from '../../../test/mock-search-parameters.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildMockStaticFilterSlice} from '../../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../../test/mock-static-filter-value.js'; +import {buildMockTabSlice} from '../../../test/mock-tab-state.js'; import { buildCoreSearchParameterManager, SearchParameterManager, SearchParameterManagerProps, validateParams, -} from './headless-core-search-parameter-manager'; +} from './headless-core-search-parameter-manager.js'; -jest.mock('../../../features/search-parameters/search-parameter-actions'); +vi.mock('../../../features/search-parameters/search-parameter-actions'); describe('search parameter manager', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.ts b/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.ts index 8957ab0634a..878bc3bec65 100644 --- a/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.ts +++ b/packages/headless/src/controllers/core/search-parameter-manager/headless-core-search-parameter-manager.ts @@ -1,31 +1,31 @@ import {RecordValue, Schema} from '@coveo/bueno'; -import {CoreEngine} from '../../../app/engine'; -import {AutomaticFacetResponse} from '../../../features/facets/automatic-facet-set/interfaces/response'; -import {findActiveValueAncestry} from '../../../features/facets/category-facet-set/category-facet-utils'; +import {CoreEngine} from '../../../app/engine.js'; +import {AutomaticFacetResponse} from '../../../features/facets/automatic-facet-set/interfaces/response.js'; +import {findActiveValueAncestry} from '../../../features/facets/category-facet-set/category-facet-utils.js'; import { BaseFacetValueRequest, CurrentValues, -} from '../../../features/facets/facet-api/request'; -import {FacetRequest} from '../../../features/facets/facet-set/interfaces/request'; +} from '../../../features/facets/facet-api/request.js'; +import {FacetRequest} from '../../../features/facets/facet-set/interfaces/request.js'; import { getQ, getSortCriteria, getFacets, -} from '../../../features/parameter-manager/parameter-manager-selectors'; -import {getQueryInitialState} from '../../../features/query/query-state'; +} from '../../../features/parameter-manager/parameter-manager-selectors.js'; +import {getQueryInitialState} from '../../../features/query/query-state.js'; import { restoreSearchParameters, SearchParameters, -} from '../../../features/search-parameters/search-parameter-actions'; -import {searchParametersDefinition} from '../../../features/search-parameters/search-parameter-schema'; -import {initialSearchParameterSelector} from '../../../features/search-parameters/search-parameter-selectors'; -import {getSortCriteriaInitialState} from '../../../features/sort-criteria/sort-criteria-state'; -import {SearchParametersState} from '../../../state/search-app-state'; -import {validateInitialState} from '../../../utils/validate-payload'; +} from '../../../features/search-parameters/search-parameter-actions.js'; +import {searchParametersDefinition} from '../../../features/search-parameters/search-parameter-schema.js'; +import {initialSearchParameterSelector} from '../../../features/search-parameters/search-parameter-selectors.js'; +import {getSortCriteriaInitialState} from '../../../features/sort-criteria/sort-criteria-state.js'; +import {SearchParametersState} from '../../../state/search-app-state.js'; +import {validateInitialState} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export type {SearchParameters}; diff --git a/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.test.ts b/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.test.ts index 50dbefc36df..dd8915abca4 100644 --- a/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.test.ts +++ b/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.test.ts @@ -1,27 +1,27 @@ import { collapseSmartSnippetRelatedQuestion, expandSmartSnippetRelatedQuestion, -} from '../../../features/question-answering/question-answering-actions'; -import {smartSnippetAnalyticsClient} from '../../../features/question-answering/question-answering-analytics-actions'; -import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice'; -import {getQuestionAnsweringInitialState} from '../../../features/question-answering/question-answering-state'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {emptyQuestionAnswer} from '../../../features/search/search-state'; +} from '../../../features/question-answering/question-answering-actions.js'; +import {smartSnippetAnalyticsClient} from '../../../features/question-answering/question-answering-analytics-actions.js'; +import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice.js'; +import {getQuestionAnsweringInitialState} from '../../../features/question-answering/question-answering-state.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {emptyQuestionAnswer} from '../../../features/search/search-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockRaw} from '../../../test/mock-raw'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildMockSearchState} from '../../../test/mock-search-state'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockRaw} from '../../../test/mock-raw.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {buildMockSearchState} from '../../../test/mock-search-state.js'; +import {createMockState} from '../../../test/mock-state.js'; import { CoreSmartSnippetQuestionsList, buildCoreSmartSnippetQuestionsList, -} from './headless-core-smart-snippet-questions-list'; +} from './headless-core-smart-snippet-questions-list.js'; -jest.mock('../../../features/question-answering/question-answering-actions'); -jest.mock( +vi.mock('../../../features/question-answering/question-answering-actions'); +vi.mock( '../../../features/question-answering/question-answering-analytics-actions' ); diff --git a/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.ts b/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.ts index cfe910e446c..6c9121fe926 100644 --- a/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.ts +++ b/packages/headless/src/controllers/core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.ts @@ -1,25 +1,25 @@ -import {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering'; -import {Result} from '../../../api/search/search/result'; -import {CoreEngine} from '../../../app/engine'; +import {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering.js'; +import {Result} from '../../../api/search/search/result.js'; +import {CoreEngine} from '../../../app/engine.js'; import { collapseSmartSnippetRelatedQuestion, expandSmartSnippetRelatedQuestion, -} from '../../../features/question-answering/question-answering-actions'; -import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice'; -import {getResultProperty} from '../../../features/result-templates/result-templates-helpers'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/question-answering/question-answering-actions.js'; +import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice.js'; +import {getResultProperty} from '../../../features/result-templates/result-templates-helpers.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { QuestionAnsweringSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; -import {SmartSnippetAnalyticsClient} from '../smart-snippet/headless-core-smart-snippet'; +} from '../../controller/headless-controller.js'; +import {SmartSnippetAnalyticsClient} from '../smart-snippet/headless-core-smart-snippet.js'; -export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering'; +export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering.js'; export interface SmartSnippetQuestionsListOptions { /** diff --git a/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.test.ts b/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.test.ts index a22c0ffd7cf..ae10c3d56b4 100644 --- a/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.test.ts +++ b/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.test.ts @@ -1,4 +1,4 @@ -import {QuestionsAnswers} from '../../../api/search/search/question-answering'; +import {QuestionsAnswers} from '../../../api/search/search/question-answering.js'; import { closeFeedbackModal, collapseSmartSnippet, @@ -6,30 +6,30 @@ import { expandSmartSnippet, likeSmartSnippet, openFeedbackModal, -} from '../../../features/question-answering/question-answering-actions'; +} from '../../../features/question-answering/question-answering-actions.js'; import { SmartSnippetFeedback, smartSnippetAnalyticsClient, -} from '../../../features/question-answering/question-answering-analytics-actions'; -import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {emptyQuestionAnswer} from '../../../features/search/search-state'; -import {SearchAppState} from '../../../state/search-app-state'; +} from '../../../features/question-answering/question-answering-analytics-actions.js'; +import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {emptyQuestionAnswer} from '../../../features/search/search-state.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockSearchResponse} from '../../../test/mock-search-response'; -import {buildMockSearchState} from '../../../test/mock-search-state'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockSearchResponse} from '../../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../../test/mock-search-state.js'; +import {createMockState} from '../../../test/mock-state.js'; import { SmartSnippetCore, SmartSnippetState, buildCoreSmartSnippet, -} from './headless-core-smart-snippet'; +} from './headless-core-smart-snippet.js'; -jest.mock('../../../features/question-answering/question-answering-actions'); -jest.mock( +vi.mock('../../../features/question-answering/question-answering-actions'); +vi.mock( '../../../features/question-answering/question-answering-analytics-actions' ); @@ -39,7 +39,7 @@ describe('SmartSnippet', () => { let smartSnippet: SmartSnippetCore; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initState(); initController(); }); diff --git a/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.ts b/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.ts index c8932cbaa41..ed65939e608 100644 --- a/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.ts +++ b/packages/headless/src/controllers/core/smart-snippet/headless-core-smart-snippet.ts @@ -1,10 +1,10 @@ -import {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering'; -import {Result} from '../../../api/search/search/result'; -import {CoreEngine} from '../../../app/engine'; +import {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering.js'; +import {Result} from '../../../api/search/search/result.js'; +import {CoreEngine} from '../../../app/engine.js'; import { ClickAction, CustomAction, -} from '../../../features/analytics/analytics-utils'; +} from '../../../features/analytics/analytics-utils.js'; import { closeFeedbackModal, collapseSmartSnippet, @@ -12,29 +12,29 @@ import { expandSmartSnippet, likeSmartSnippet, openFeedbackModal, -} from '../../../features/question-answering/question-answering-actions'; -import {SmartSnippetFeedback} from '../../../features/question-answering/question-answering-analytics-actions'; +} from '../../../features/question-answering/question-answering-actions.js'; +import {SmartSnippetFeedback} from '../../../features/question-answering/question-answering-analytics-actions.js'; import { QuestionAnsweringInlineLinkActionCreatorPayload, QuestionAnsweringUniqueIdentifierActionCreatorPayload, -} from '../../../features/question-answering/question-answering-document-id'; -import {answerSourceSelector} from '../../../features/question-answering/question-answering-selectors'; -import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice'; -import {pushRecentResult} from '../../../features/recent-results/recent-results-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/question-answering/question-answering-document-id.js'; +import {answerSourceSelector} from '../../../features/question-answering/question-answering-selectors.js'; +import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice.js'; +import {pushRecentResult} from '../../../features/recent-results/recent-results-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { QuestionAnsweringSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { Controller, buildController, -} from '../../controller/headless-controller'; -import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links'; -import {buildInteractiveResultCore} from '../interactive-result/headless-core-interactive-result'; +} from '../../controller/headless-controller.js'; +import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links.js'; +import {buildInteractiveResultCore} from '../interactive-result/headless-core-interactive-result.js'; -export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering'; +export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering.js'; export interface SmartSnippetOptions { /** diff --git a/packages/headless/src/controllers/core/sort/headless-core-sort.test.ts b/packages/headless/src/controllers/core/sort/headless-core-sort.test.ts index 9f7c84677ab..40360524086 100644 --- a/packages/headless/src/controllers/core/sort/headless-core-sort.test.ts +++ b/packages/headless/src/controllers/core/sort/headless-core-sort.test.ts @@ -1,5 +1,5 @@ -import {configuration} from '../../../app/common-reducers'; -import {updatePage} from '../../../features/pagination/pagination-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {updatePage} from '../../../features/pagination/pagination-actions.js'; import { buildRelevanceSortCriterion, buildDateSortCriterion, @@ -7,21 +7,21 @@ import { buildCriterionExpression, SortCriterion, buildFieldSortCriterion, -} from '../../../features/sort-criteria/criteria'; +} from '../../../features/sort-criteria/criteria.js'; import { registerSortCriterion, updateSortCriterion, -} from '../../../features/sort-criteria/sort-criteria-actions'; -import {sortCriteriaReducer as sortCriteria} from '../../../features/sort-criteria/sort-criteria-slice'; +} from '../../../features/sort-criteria/sort-criteria-actions.js'; +import {sortCriteriaReducer as sortCriteria} from '../../../features/sort-criteria/sort-criteria-slice.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; -import {Sort, SortProps, buildCoreSort} from './headless-core-sort'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {Sort, SortProps, buildCoreSort} from './headless-core-sort.js'; -jest.mock('../../../features/sort-criteria/sort-criteria-actions'); -jest.mock('../../../features/pagination/pagination-actions'); +vi.mock('../../../features/sort-criteria/sort-criteria-actions'); +vi.mock('../../../features/pagination/pagination-actions'); describe('Sort', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/sort/headless-core-sort.ts b/packages/headless/src/controllers/core/sort/headless-core-sort.ts index c980cbbd9e6..5c50f0ad0ca 100644 --- a/packages/headless/src/controllers/core/sort/headless-core-sort.ts +++ b/packages/headless/src/controllers/core/sort/headless-core-sort.ts @@ -1,24 +1,27 @@ import {ArrayValue, isArray, Schema} from '@coveo/bueno'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {updatePage} from '../../../features/pagination/pagination-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {updatePage} from '../../../features/pagination/pagination-actions.js'; import { buildCriterionExpression, SortCriterion, criterionDefinition, -} from '../../../features/sort-criteria/criteria'; +} from '../../../features/sort-criteria/criteria.js'; import { registerSortCriterion, updateSortCriterion, -} from '../../../features/sort-criteria/sort-criteria-actions'; -import {sortCriteriaReducer as sortCriteria} from '../../../features/sort-criteria/sort-criteria-slice'; -import {ConfigurationSection, SortSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {validateInitialState} from '../../../utils/validate-payload'; +} from '../../../features/sort-criteria/sort-criteria-actions.js'; +import {sortCriteriaReducer as sortCriteria} from '../../../features/sort-criteria/sort-criteria-slice.js'; +import { + ConfigurationSection, + SortSection, +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {validateInitialState} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface SortProps { /** diff --git a/packages/headless/src/controllers/core/status/headless-core-status.test.ts b/packages/headless/src/controllers/core/status/headless-core-status.test.ts index 6edc8a74f5b..cab3fa87b7f 100644 --- a/packages/headless/src/controllers/core/status/headless-core-status.test.ts +++ b/packages/headless/src/controllers/core/status/headless-core-status.test.ts @@ -1,11 +1,11 @@ -import {searchReducer as search} from '../../../features/search/search-slice'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockResult} from '../../../test/mock-result'; -import {createMockState} from '../../../test/mock-state'; -import {buildCoreStatus} from './headless-core-status'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildCoreStatus} from './headless-core-status.js'; describe('CoreStatus', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/status/headless-core-status.ts b/packages/headless/src/controllers/core/status/headless-core-status.ts index 72b525c0c6c..04c0096855f 100644 --- a/packages/headless/src/controllers/core/status/headless-core-status.ts +++ b/packages/headless/src/controllers/core/status/headless-core-status.ts @@ -1,12 +1,12 @@ -import {CoreEngine} from '../../../app/engine'; -import {firstSearchExecutedSelector} from '../../../features/search/search-selectors'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +import {CoreEngine} from '../../../app/engine.js'; +import {firstSearchExecutedSelector} from '../../../features/search/search-selectors.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface SearchStatus extends Controller { /** diff --git a/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.test.ts b/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.test.ts index 3e6501104c1..6356ebc83a9 100644 --- a/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.test.ts +++ b/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.test.ts @@ -1,12 +1,12 @@ -import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice'; +import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; -import {buildCoreTabManager} from './headless-core-tab-manager'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildCoreTabManager} from './headless-core-tab-manager.js'; -jest.mock('../../../features/tab-set/tab-set-actions'); +vi.mock('../../../features/tab-set/tab-set-actions'); describe('Core Tab Manager', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.ts b/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.ts index 7eb81acabe6..da3c325455d 100644 --- a/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.ts +++ b/packages/headless/src/controllers/core/tab-manager/headless-core-tab-manager.ts @@ -1,12 +1,12 @@ import {createSelector} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../../app/engine'; -import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice'; -import {TabSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +import {CoreEngine} from '../../../app/engine.js'; +import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice.js'; +import {TabSection} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface TabManager extends Controller { /** diff --git a/packages/headless/src/controllers/core/tab/headless-core-tab.test.ts b/packages/headless/src/controllers/core/tab/headless-core-tab.test.ts index 9cfbf096993..e9c05c64c5c 100644 --- a/packages/headless/src/controllers/core/tab/headless-core-tab.test.ts +++ b/packages/headless/src/controllers/core/tab/headless-core-tab.test.ts @@ -1,19 +1,19 @@ -import {configuration} from '../../../app/common-reducers'; -import {getConfigurationInitialState} from '../../../features/configuration/configuration-state'; +import {configuration} from '../../../app/common-reducers.js'; +import {getConfigurationInitialState} from '../../../features/configuration/configuration-state.js'; import { registerTab, updateActiveTab, -} from '../../../features/tab-set/tab-set-actions'; -import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice'; +} from '../../../features/tab-set/tab-set-actions.js'; +import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; -import {buildMockTabSlice} from '../../../test/mock-tab-state'; -import {buildCoreTab, Tab, TabProps} from './headless-core-tab'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildMockTabSlice} from '../../../test/mock-tab-state.js'; +import {buildCoreTab, Tab, TabProps} from './headless-core-tab.js'; -jest.mock('../../../features/tab-set/tab-set-actions'); +vi.mock('../../../features/tab-set/tab-set-actions'); describe('Core Tab', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/core/tab/headless-core-tab.ts b/packages/headless/src/controllers/core/tab/headless-core-tab.ts index 07598075682..849df5e99a2 100644 --- a/packages/headless/src/controllers/core/tab/headless-core-tab.ts +++ b/packages/headless/src/controllers/core/tab/headless-core-tab.ts @@ -1,25 +1,28 @@ import {BooleanValue, Schema} from '@coveo/bueno'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {getConfigurationInitialState} from '../../../features/configuration/configuration-state'; -import {prepareForSearchWithQuery} from '../../../features/search/search-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {getConfigurationInitialState} from '../../../features/configuration/configuration-state.js'; +import {prepareForSearchWithQuery} from '../../../features/search/search-actions.js'; import { registerTab, updateActiveTab, -} from '../../../features/tab-set/tab-set-actions'; -import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice'; -import {ConfigurationSection, TabSection} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../features/tab-set/tab-set-actions.js'; +import {tabSetReducer as tabSet} from '../../../features/tab-set/tab-set-slice.js'; +import { + ConfigurationSection, + TabSection, +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { requiredEmptyAllowedString, requiredNonEmptyString, validateInitialState, validateOptions, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface TabOptions { /** diff --git a/packages/headless/src/controllers/core/triggers/headless-core-notify-trigger.ts b/packages/headless/src/controllers/core/triggers/headless-core-notify-trigger.ts index cee5fb8aab8..1bb70131658 100644 --- a/packages/headless/src/controllers/core/triggers/headless-core-notify-trigger.ts +++ b/packages/headless/src/controllers/core/triggers/headless-core-notify-trigger.ts @@ -1,4 +1,4 @@ -import {Controller} from '../../controller/headless-controller'; +import {Controller} from '../../controller/headless-controller.js'; /** * The `NotifyTrigger` controller handles notify triggers. A [Notify trigger](https://docs.coveo.com/en/3413#notify) query pipeline rule lets you define a message to be displayed to the end user when a certain condition is met. diff --git a/packages/headless/src/controllers/core/triggers/headless-core-query-trigger.ts b/packages/headless/src/controllers/core/triggers/headless-core-query-trigger.ts index c23b96fd030..60ef0f6ec18 100644 --- a/packages/headless/src/controllers/core/triggers/headless-core-query-trigger.ts +++ b/packages/headless/src/controllers/core/triggers/headless-core-query-trigger.ts @@ -1,4 +1,4 @@ -import {Controller} from '../../controller/headless-controller'; +import {Controller} from '../../controller/headless-controller.js'; /** * The `QueryTrigger` controller handles [query trigger](https://docs.coveo.com/en/3413#query) query pipeline rules, which let you define a search query to execute when a certain condition is met. diff --git a/packages/headless/src/controllers/core/triggers/headless-core-redirection-trigger.ts b/packages/headless/src/controllers/core/triggers/headless-core-redirection-trigger.ts index 34604d7358a..442339376a5 100644 --- a/packages/headless/src/controllers/core/triggers/headless-core-redirection-trigger.ts +++ b/packages/headless/src/controllers/core/triggers/headless-core-redirection-trigger.ts @@ -1,4 +1,4 @@ -import {Controller} from '../../controller/headless-controller'; +import {Controller} from '../../controller/headless-controller.js'; /** * The `RedirectionTrigger` controller handles redirection triggers. A [Redirection trigger](https://docs.coveo.com/en/3413#redirect) query pipeline rule lets you define a URL to redirect the user's browser to when a certain condition is met. diff --git a/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ssr.ts b/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ssr.ts index 4125fbed2d7..3971b8a40a1 100644 --- a/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ssr.ts +++ b/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ssr.ts @@ -1,11 +1,11 @@ -import {CoreEngine} from '../../app/engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {CoreEngine} from '../../app/engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { DictionaryFieldContext, buildDictionaryFieldContext, -} from './headless-dictionary-field-context'; +} from './headless-dictionary-field-context.js'; -export * from './headless-dictionary-field-context'; +export * from './headless-dictionary-field-context.js'; export interface DictionaryFieldContextDefinition extends ControllerDefinitionWithoutProps< diff --git a/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.test.ts b/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.test.ts index 5cf4ab59f2d..5d18663d802 100644 --- a/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.test.ts +++ b/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.test.ts @@ -2,19 +2,19 @@ import { setContext, addContext, removeContext, -} from '../../features/dictionary-field-context/dictionary-field-context-actions'; -import {dictionaryFieldContextReducer as dictionaryFieldContext} from '../../features/dictionary-field-context/dictionary-field-context-slice'; +} from '../../features/dictionary-field-context/dictionary-field-context-actions.js'; +import {dictionaryFieldContextReducer as dictionaryFieldContext} from '../../features/dictionary-field-context/dictionary-field-context-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildDictionaryFieldContext, DictionaryFieldContext, -} from './headless-dictionary-field-context'; +} from './headless-dictionary-field-context.js'; -jest.mock( +vi.mock( '../../features/dictionary-field-context/dictionary-field-context-actions' ); diff --git a/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ts b/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ts index 00e35b27fd0..fe0cee93fd5 100644 --- a/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ts +++ b/packages/headless/src/controllers/dictionary-field-context/headless-dictionary-field-context.ts @@ -1,14 +1,17 @@ -import {CoreEngine} from '../../app/engine'; +import {CoreEngine} from '../../app/engine.js'; import { addContext, removeContext, setContext, -} from '../../features/dictionary-field-context/dictionary-field-context-actions'; -import {dictionaryFieldContextReducer as dictionaryFieldContext} from '../../features/dictionary-field-context/dictionary-field-context-slice'; -import {DictionaryFieldContextPayload} from '../../features/dictionary-field-context/dictionary-field-context-state'; -import {DictionaryFieldContextSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {Controller, buildController} from '../controller/headless-controller'; +} from '../../features/dictionary-field-context/dictionary-field-context-actions.js'; +import {dictionaryFieldContextReducer as dictionaryFieldContext} from '../../features/dictionary-field-context/dictionary-field-context-slice.js'; +import {DictionaryFieldContextPayload} from '../../features/dictionary-field-context/dictionary-field-context-state.js'; +import {DictionaryFieldContextSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import { + Controller, + buildController, +} from '../controller/headless-controller.js'; export type {DictionaryFieldContextPayload}; diff --git a/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ssr.ts b/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ssr.ts index 33bb8ea9493..5f3256d42e9 100644 --- a/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ssr.ts +++ b/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {DidYouMean, buildDidYouMean} from './headless-did-you-mean'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {DidYouMean, buildDidYouMean} from './headless-did-you-mean.js'; -export * from './headless-did-you-mean'; +export * from './headless-did-you-mean.js'; export interface DidYouMeanDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.test.ts b/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.test.ts index f8a7ca51257..88bd14b1c87 100644 --- a/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.test.ts +++ b/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.test.ts @@ -1,17 +1,17 @@ import { applyDidYouMeanCorrection, enableDidYouMean, -} from '../../features/did-you-mean/did-you-mean-actions'; -import {executeSearch} from '../../features/search/search-actions'; +} from '../../features/did-you-mean/did-you-mean-actions.js'; +import {executeSearch} from '../../features/search/search-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildDidYouMean, DidYouMean} from './headless-did-you-mean'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildDidYouMean, DidYouMean} from './headless-did-you-mean.js'; -jest.mock('../../features/did-you-mean/did-you-mean-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/did-you-mean/did-you-mean-actions'); +vi.mock('../../features/search/search-actions'); describe('did you mean', () => { let dym: DidYouMean; diff --git a/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ts b/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ts index d42baf0f47c..4dffc79b09e 100644 --- a/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ts +++ b/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ts @@ -1,20 +1,20 @@ import { QueryCorrection, WordCorrection, -} from '../../api/search/search/query-corrections'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +} from '../../api/search/search/query-corrections.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { didYouMeanClick, logDidYouMeanClick, -} from '../../features/did-you-mean/did-you-mean-analytics-actions'; -import {executeSearch} from '../../features/search/search-actions'; +} from '../../features/did-you-mean/did-you-mean-analytics-actions.js'; +import {executeSearch} from '../../features/search/search-actions.js'; import { buildCoreDidYouMean, DidYouMean, DidYouMeanProps, DidYouMeanState, DidYouMeanOptions, -} from '../core/did-you-mean/headless-core-did-you-mean'; +} from '../core/did-you-mean/headless-core-did-you-mean.js'; export type { QueryCorrection, diff --git a/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.test.ts b/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.test.ts index 4b2f2fd2d7a..361017196d2 100644 --- a/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.test.ts +++ b/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.test.ts @@ -1,23 +1,24 @@ -import {logDocumentSuggestionOpen} from '../../features/case-assist/case-assist-analytics-actions'; -import {buildMockCaseAssistState} from '../../test/mock-case-assist-state'; +import {Mock} from 'vitest'; +import {logDocumentSuggestionOpen} from '../../features/case-assist/case-assist-analytics-actions.js'; +import {buildMockCaseAssistState} from '../../test/mock-case-assist-state.js'; import { buildMockCaseAssistEngine, MockedCaseAssistEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {buildInteractiveResultCore} from '../core/interactive-result/headless-core-interactive-result'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildInteractiveResultCore} from '../core/interactive-result/headless-core-interactive-result.js'; import { buildCaseAssistInteractiveResult, CaseAssistInteractiveResultProps, -} from './case-assist-headless-interactive-result'; +} from './case-assist-headless-interactive-result.js'; -jest.mock('../core/interactive-result/headless-core-interactive-result'); -jest.mock('../../features/case-assist/case-assist-analytics-actions'); +vi.mock('../core/interactive-result/headless-core-interactive-result'); +vi.mock('../../features/case-assist/case-assist-analytics-actions'); describe('InteractiveResult', () => { let engine: MockedCaseAssistEngine; let interactiveResultProps: CaseAssistInteractiveResultProps; - let mockedBuildInteractiveResultCore: jest.Mock; + let mockedBuildInteractiveResultCore: Mock; const resultStringParams = { uniqueId: 'unique-id', }; @@ -39,8 +40,8 @@ describe('InteractiveResult', () => { } beforeEach(() => { - jest.resetAllMocks(); - mockedBuildInteractiveResultCore = jest.mocked(buildInteractiveResultCore); + vi.resetAllMocks(); + mockedBuildInteractiveResultCore = vi.mocked(buildInteractiveResultCore); initEngine(); initializeInteractiveResult(); }); @@ -54,7 +55,7 @@ describe('InteractiveResult', () => { }); it('dispatches #logDocumentSuggestionOpen when the action is triggered for the first time', () => { - const mockedLogDocumentSuggestionOpen = jest.mocked( + const mockedLogDocumentSuggestionOpen = vi.mocked( logDocumentSuggestionOpen ); @@ -66,7 +67,7 @@ describe('InteractiveResult', () => { }); it('does not dispatch logDocumentSuggestionOpen when the action is triggered for the second time', () => { - const mockedLogDocumentSuggestionOpen = jest.mocked( + const mockedLogDocumentSuggestionOpen = vi.mocked( logDocumentSuggestionOpen ); diff --git a/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.ts b/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.ts index 4ccc0997175..d195df6f6b5 100644 --- a/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.ts +++ b/packages/headless/src/controllers/document-suggestion-list/case-assist-headless-interactive-result.ts @@ -1,12 +1,12 @@ -import {Result} from '../../api/search/search/result'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {logDocumentSuggestionOpen} from '../../features/case-assist/case-assist-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {logDocumentSuggestionOpen} from '../../features/case-assist/case-assist-analytics-actions.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from '../core/interactive-result/headless-core-interactive-result'; +} from '../core/interactive-result/headless-core-interactive-result.js'; export type { InteractiveResultCore, diff --git a/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.test.ts b/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.test.ts index 1131dd836b2..43d2ace0e77 100644 --- a/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.test.ts +++ b/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.test.ts @@ -1,21 +1,21 @@ -import {configuration} from '../../app/common-reducers'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; -import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; -import {getDocumentSuggestionInitialState} from '../../features/document-suggestion/document-suggestion-state'; -import {buildMockCaseAssistState} from '../../test/mock-case-assist-state'; +import {configuration} from '../../app/common-reducers.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; +import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; +import {getDocumentSuggestionInitialState} from '../../features/document-suggestion/document-suggestion-state.js'; +import {buildMockCaseAssistState} from '../../test/mock-case-assist-state.js'; import { buildMockCaseAssistEngine, MockedCaseAssistEngine, -} from '../../test/mock-engine-v2'; +} from '../../test/mock-engine-v2.js'; import { DocumentSuggestionList, buildDocumentSuggestionList, -} from './headless-document-suggestion-list'; +} from './headless-document-suggestion-list.js'; -jest.mock('../../features/document-suggestion/document-suggestion-actions'); +vi.mock('../../features/document-suggestion/document-suggestion-actions'); describe('DocumentSuggestionList', () => { let engine: MockedCaseAssistEngine; @@ -30,7 +30,7 @@ describe('DocumentSuggestionList', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initEngine(); initDocumentSuggestion(); }); @@ -56,7 +56,7 @@ describe('DocumentSuggestionList', () => { describe('#fetch', () => { it('dispatches a #fetchDocumentSuggestions', () => { - const mockedFetchDocumentSuggestions = jest.mocked( + const mockedFetchDocumentSuggestions = vi.mocked( fetchDocumentSuggestions ); diff --git a/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.ts b/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.ts index 9e90f6efb21..e9b11437b33 100644 --- a/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.ts +++ b/packages/headless/src/controllers/document-suggestion-list/headless-document-suggestion-list.ts @@ -1,21 +1,24 @@ -import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client'; -import {DocumentSuggestionResponse} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {configuration} from '../../app/common-reducers'; -import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; -import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; +import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client.js'; +import {DocumentSuggestionResponse} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response.js'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {configuration} from '../../app/common-reducers.js'; +import {caseAssistConfigurationReducer as caseAssistConfiguration} from '../../features/case-assist-configuration/case-assist-configuration-slice.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; +import {fetchDocumentSuggestions} from '../../features/document-suggestion/document-suggestion-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; import { ConfigurationSection, CaseAssistConfigurationSection, CaseInputSection, DocumentSuggestionSection, CaseFieldSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; /** * The `DocumentSuggestion` controller is responsible for getting document suggestions using case information present in the state. diff --git a/packages/headless/src/controllers/facet-manager/headless-facet-manager.ssr.ts b/packages/headless/src/controllers/facet-manager/headless-facet-manager.ssr.ts index cf25a6f94df..3a2ac9b4a1e 100644 --- a/packages/headless/src/controllers/facet-manager/headless-facet-manager.ssr.ts +++ b/packages/headless/src/controllers/facet-manager/headless-facet-manager.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {FacetManager, buildFacetManager} from './headless-facet-manager'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {FacetManager, buildFacetManager} from './headless-facet-manager.js'; -export * from './headless-facet-manager'; +export * from './headless-facet-manager.js'; export interface FacetManagerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facet-manager/headless-facet-manager.ts b/packages/headless/src/controllers/facet-manager/headless-facet-manager.ts index 3f19827a34f..d8c65ab5a32 100644 --- a/packages/headless/src/controllers/facet-manager/headless-facet-manager.ts +++ b/packages/headless/src/controllers/facet-manager/headless-facet-manager.ts @@ -1,10 +1,10 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { buildCoreFacetManager, FacetManager, FacetManagerState, FacetManagerPayload, -} from '../core/facet-manager/headless-core-facet-manager'; +} from '../core/facet-manager/headless-core-facet-manager.js'; export type {FacetManagerState, FacetManagerPayload, FacetManager}; diff --git a/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.ts b/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.ts index a361e8b467a..b3b14ca42e0 100644 --- a/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.ts +++ b/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common.js'; import { AutomaticFacetGenerator, AutomaticFacetGeneratorProps, buildAutomaticFacetGenerator, -} from './headless-automatic-facet-generator'; +} from './headless-automatic-facet-generator.js'; -export * from './headless-automatic-facet-generator'; +export * from './headless-automatic-facet-generator.js'; export interface AutomaticFacetGeneratorDefinition extends ControllerDefinitionWithoutProps< diff --git a/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.test.ts b/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.test.ts index 01b20b3aa28..32cffb56599 100644 --- a/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.test.ts +++ b/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.test.ts @@ -1,21 +1,21 @@ -import {configuration} from '../../../app/common-reducers'; -import {setOptions} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions'; -import {NUMBER_OF_VALUE_DEFAULT} from '../../../features/facets/automatic-facet-set/automatic-facet-set-constants'; -import {automaticFacetSetReducer as automaticFacetSet} from '../../../features/facets/automatic-facet-set/automatic-facet-set-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; +import {configuration} from '../../../app/common-reducers.js'; +import {setOptions} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions.js'; +import {NUMBER_OF_VALUE_DEFAULT} from '../../../features/facets/automatic-facet-set/automatic-facet-set-constants.js'; +import {automaticFacetSetReducer as automaticFacetSet} from '../../../features/facets/automatic-facet-set/automatic-facet-set-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { AutomaticFacetGeneratorProps, AutomaticFacetGenerator, buildAutomaticFacetGenerator, AutomaticFacetGeneratorOptions, -} from './headless-automatic-facet-generator'; +} from './headless-automatic-facet-generator.js'; -jest.mock( +vi.mock( '../../../features/facets/automatic-facet-set/automatic-facet-set-actions' ); @@ -36,7 +36,7 @@ describe('automatic facets', () => { automaticFacets = buildAutomaticFacetGenerator(engine, props); } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); setup(); }); diff --git a/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ts b/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ts index 71ee43f124f..96c2d79f43b 100644 --- a/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ts +++ b/packages/headless/src/controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ts @@ -1,25 +1,25 @@ -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {setOptions} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions'; -import {automaticFacetSetReducer as automaticFacetSet} from '../../../features/facets/automatic-facet-set/automatic-facet-set-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {setOptions} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions.js'; +import {automaticFacetSetReducer as automaticFacetSet} from '../../../features/facets/automatic-facet-set/automatic-facet-set-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { AutomaticFacetSection, ConfigurationSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { Controller, buildController, -} from '../../controller/headless-controller'; -import {buildAutomaticFacet} from '../automatic-facet/headless-automatic-facet'; -import {FacetValue} from '../facet/headless-facet'; +} from '../../controller/headless-controller.js'; +import {buildAutomaticFacet} from '../automatic-facet/headless-automatic-facet.js'; +import {FacetValue} from '../facet/headless-facet.js'; import { AutomaticFacetGeneratorOptions, buildOptions, -} from './headless-automatic-facet-generator-options'; +} from './headless-automatic-facet-generator-options.js'; export type {AutomaticFacetGeneratorOptions}; diff --git a/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.test.ts b/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.test.ts index 3b281edcb53..23125464363 100644 --- a/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.test.ts +++ b/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.test.ts @@ -1,23 +1,23 @@ -import {buildAutomaticFacet} from '../../../controllers/facets/automatic-facet/headless-automatic-facet'; +import {buildAutomaticFacet} from '../../../controllers/facets/automatic-facet/headless-automatic-facet.js'; import { deselectAllAutomaticFacetValues, toggleSelectAutomaticFacetValue, -} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions'; -import {executeSearch} from '../../../features/search/search-actions'; -import {SearchAppState} from '../../../state/search-app-state'; -import {buildMockAutomaticFacetSlice} from '../../../test/mock-automatic-facet-slice'; +} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions.js'; +import {executeSearch} from '../../../features/search/search-actions.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {buildMockAutomaticFacetSlice} from '../../../test/mock-automatic-facet-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {createMockState} from '../../../test/mock-state'; -import {AutomaticFacet} from '../automatic-facet-generator/headless-automatic-facet-generator'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {AutomaticFacet} from '../automatic-facet-generator/headless-automatic-facet-generator.js'; -jest.mock( +vi.mock( '../../../features/facets/automatic-facet-set/automatic-facet-set-actions' ); -jest.mock('../../../features/search/search-actions'); +vi.mock('../../../features/search/search-actions'); describe('automatic facet', () => { const field = 'field'; diff --git a/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.ts b/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.ts index 4d49337132e..49b23b26ee7 100644 --- a/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.ts +++ b/packages/headless/src/controllers/facets/automatic-facet/headless-automatic-facet.ts @@ -1,20 +1,20 @@ -import {SearchEngine} from '../../../app/search-engine/search-engine'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; import { deselectAllAutomaticFacetValues, toggleSelectAutomaticFacetValue, -} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions'; +} from '../../../features/facets/automatic-facet-set/automatic-facet-set-actions.js'; import { facetClearAll, logFacetClearAll, -} from '../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { getLegacyAnalyticsActionForToggleFacetSelect, getAnalyticsActionForToggleFacetSelect, -} from '../../../features/facets/facet-set/facet-set-utils'; -import {FacetValue} from '../../../features/facets/facet-set/interfaces/response'; -import {executeSearch} from '../../../features/search/search-actions'; -import {buildController} from '../../controller/headless-controller'; -import {AutomaticFacet} from '../automatic-facet-generator/headless-automatic-facet-generator'; +} from '../../../features/facets/facet-set/facet-set-utils.js'; +import {FacetValue} from '../../../features/facets/facet-set/interfaces/response.js'; +import {executeSearch} from '../../../features/search/search-actions.js'; +import {buildController} from '../../controller/headless-controller.js'; +import {AutomaticFacet} from '../automatic-facet-generator/headless-automatic-facet-generator.js'; /** * @internal diff --git a/packages/headless/src/controllers/facets/category-facet/headless-category-facet-search.ts b/packages/headless/src/controllers/facets/category-facet/headless-category-facet-search.ts index 971e14961a1..1fcd62e9304 100644 --- a/packages/headless/src/controllers/facets/category-facet/headless-category-facet-search.ts +++ b/packages/headless/src/controllers/facets/category-facet/headless-category-facet-search.ts @@ -1,20 +1,20 @@ -import {CoreEngine} from '../../../app/engine'; -import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments'; -import {registerCategoryFacetSearch} from '../../../features/facets/facet-search-set/category/category-facet-search-actions'; -import {defaultFacetSearchOptions} from '../../../features/facets/facet-search-set/facet-search-reducer-helpers'; +import {CoreEngine} from '../../../app/engine.js'; +import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments.js'; +import {registerCategoryFacetSearch} from '../../../features/facets/facet-search-set/category/category-facet-search-actions.js'; +import {defaultFacetSearchOptions} from '../../../features/facets/facet-search-set/facet-search-reducer-helpers.js'; import { executeFacetSearch, executeFieldSuggest, -} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; +} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; import { CategoryFacetSearchSection, ConfigurationSection, -} from '../../../state/state-sections'; +} from '../../../state/state-sections.js'; import { buildCoreCategoryFacetSearch, CategoryFacetSearchProps, -} from '../../core/facets/facet-search/category/headless-category-facet-search'; -import {buildGenericFacetSearch} from '../../core/facets/facet-search/facet-search'; +} from '../../core/facets/facet-search/category/headless-category-facet-search.js'; +import {buildGenericFacetSearch} from '../../core/facets/facet-search/facet-search.js'; export function buildCategoryFacetSearch( engine: CoreEngine< diff --git a/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ssr.ts b/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ssr.ts index 56a73d8b496..428afa921f3 100644 --- a/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ssr.ts +++ b/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common.js'; import { CategoryFacet, CategoryFacetProps, buildCategoryFacet, -} from './headless-category-facet'; +} from './headless-category-facet.js'; -export * from './headless-category-facet'; +export * from './headless-category-facet.js'; export interface CategoryFacetDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facets/category-facet/headless-category-facet.test.ts b/packages/headless/src/controllers/facets/category-facet/headless-category-facet.test.ts index 6f9d272e279..bf9bd59e686 100644 --- a/packages/headless/src/controllers/facets/category-facet/headless-category-facet.test.ts +++ b/packages/headless/src/controllers/facets/category-facet/headless-category-facet.test.ts @@ -1,48 +1,48 @@ -import {configuration} from '../../../app/common-reducers'; -import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions.js'; import { registerCategoryFacet, toggleSelectCategoryFacetValue, deselectAllCategoryFacetValues, updateCategoryFacetNumberOfValues, updateCategoryFacetSortCriterion, -} from '../../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice'; -import {defaultCategoryFacetOptions} from '../../../features/facets/category-facet-set/category-facet-set-slice'; +} from '../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {defaultCategoryFacetOptions} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; import { CategoryFacetRequest, CategoryFacetSortCriterion, -} from '../../../features/facets/category-facet-set/interfaces/request'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; +} from '../../../features/facets/category-facet-set/interfaces/request.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; import { executeSearch, fetchFacetValues, -} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchAppState} from '../../../state/search-app-state'; -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response'; -import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search'; -import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value'; +} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search.js'; +import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; -import * as FacetIdDeterminor from '../../core/facets/_common/facet-id-determinor'; -import * as CategoryFacetSearch from '../../core/facets/facet-search/category/headless-category-facet-search'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../core/facets/_common/facet-id-determinor.js'; +import * as CategoryFacetSearch from '../../core/facets/facet-search/category/headless-category-facet-search.js'; import { buildCategoryFacet, CategoryFacet, CategoryFacetOptions, -} from './headless-category-facet'; +} from './headless-category-facet.js'; -jest.mock( +vi.mock( '../../../features/facets/category-facet-set/category-facet-set-actions' ); -jest.mock('../../../features/search/search-actions'); -jest.mock('../../../features/facet-options/facet-options-actions'); +vi.mock('../../../features/search/search-actions'); +vi.mock('../../../features/facet-options/facet-options-actions'); describe('category facet', () => { const facetId = '1'; @@ -83,7 +83,7 @@ describe('category facet', () => { }); it('it calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initCategoryFacet(); @@ -447,7 +447,7 @@ describe('category facet', () => { }); it('exposes a #facetSearch property', () => { - jest.spyOn(CategoryFacetSearch, 'buildCoreCategoryFacetSearch'); + vi.spyOn(CategoryFacetSearch, 'buildCoreCategoryFacetSearch'); initCategoryFacet(); expect(categoryFacet.facetSearch).toBeTruthy(); diff --git a/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ts b/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ts index 690b2324198..4820e248571 100644 --- a/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ts +++ b/packages/headless/src/controllers/facets/category-facet/headless-category-facet.ts @@ -1,14 +1,14 @@ -import {configuration} from '../../../app/common-reducers'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice'; -import {CategoryFacetSortCriterion} from '../../../features/facets/category-facet-set/interfaces/request'; -import {CategoryFacetValue} from '../../../features/facets/category-facet-set/interfaces/response'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; +import {configuration} from '../../../app/common-reducers.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {CategoryFacetSortCriterion} from '../../../features/facets/category-facet-set/interfaces/request.js'; +import {CategoryFacetValue} from '../../../features/facets/category-facet-set/interfaces/response.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; import { executeFacetSearch, executeFieldSuggest, -} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; +} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; import { logFacetUpdateSort, logFacetShowMore, @@ -20,20 +20,24 @@ import { facetClearAll, facetDeselect, facetSelect, -} from '../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { SearchAction, executeSearch, fetchFacetValues, -} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { CategoryFacetSearchSection, CategoryFacetSection, ConfigurationSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import { + CategoryFacetOptions, + CategoryFacetSearchOptions, +} from '../../core/facets/category-facet/headless-core-category-facet-options.js'; import { buildCoreCategoryFacet, CategoryFacet, @@ -44,12 +48,8 @@ import { CategoryFacetSearchResult, CoreCategoryFacet, CoreCategoryFacetState, -} from '../../core/facets/category-facet/headless-core-category-facet'; -import { - CategoryFacetOptions, - CategoryFacetSearchOptions, -} from '../../core/facets/category-facet/headless-core-category-facet-options'; -import {buildCategoryFacetSearch} from './headless-category-facet-search'; +} from '../../core/facets/category-facet/headless-core-category-facet.js'; +import {buildCategoryFacetSearch} from './headless-category-facet-search.js'; export type { CategoryFacetValue, diff --git a/packages/headless/src/controllers/facets/facet/headless-facet-options.ts b/packages/headless/src/controllers/facets/facet/headless-facet-options.ts index fd002ce9fbf..6c55f10d1a6 100644 --- a/packages/headless/src/controllers/facets/facet/headless-facet-options.ts +++ b/packages/headless/src/controllers/facets/facet/headless-facet-options.ts @@ -2,11 +2,11 @@ import {ArrayValue, RecordValue, Schema, StringValue} from '@coveo/bueno'; import { FacetResultsMustMatch, facetResultsMustMatch, -} from '../../../features/facets/facet-api/request'; +} from '../../../features/facets/facet-api/request.js'; import { facetSortCriteria, FacetSortCriterion, -} from '../../../features/facets/facet-set/interfaces/request'; +} from '../../../features/facets/facet-set/interfaces/request.js'; import { facetId, field, @@ -17,7 +17,7 @@ import { allowedValues, hasBreadcrumbs, customSort, -} from '../../core/facets/_common/facet-option-definitions'; +} from '../../core/facets/_common/facet-option-definitions.js'; export interface FacetOptions { /** diff --git a/packages/headless/src/controllers/facets/facet/headless-facet.ssr.ts b/packages/headless/src/controllers/facets/facet/headless-facet.ssr.ts index e0653a7cc61..03930038ccc 100644 --- a/packages/headless/src/controllers/facets/facet/headless-facet.ssr.ts +++ b/packages/headless/src/controllers/facets/facet/headless-facet.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common'; -import {Facet, FacetProps, buildFacet} from './headless-facet'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common.js'; +import {Facet, FacetProps, buildFacet} from './headless-facet.js'; -export * from './headless-facet'; +export * from './headless-facet.js'; export interface FacetDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facets/facet/headless-facet.test.ts b/packages/headless/src/controllers/facets/facet/headless-facet.test.ts index c589d6a1b0e..69ba528536c 100644 --- a/packages/headless/src/controllers/facets/facet/headless-facet.test.ts +++ b/packages/headless/src/controllers/facets/facet/headless-facet.test.ts @@ -1,44 +1,44 @@ -import {configuration} from '../../../app/common-reducers'; -import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; +import {configuration} from '../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; import { registerFacet, deselectAllFacetValues, updateFacetSortCriterion, updateFacetNumberOfValues, updateFacetIsFieldExpanded, -} from '../../../features/facets/facet-set/facet-set-actions'; +} from '../../../features/facets/facet-set/facet-set-actions.js'; import { executeToggleFacetExclude, executeToggleFacetSelect, -} from '../../../features/facets/facet-set/facet-set-controller-actions'; -import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice'; -import {FacetRequest} from '../../../features/facets/facet-set/interfaces/request'; -import {FacetValue} from '../../../features/facets/facet-set/interfaces/response'; +} from '../../../features/facets/facet-set/facet-set-controller-actions.js'; +import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice.js'; +import {FacetRequest} from '../../../features/facets/facet-set/interfaces/request.js'; +import {FacetValue} from '../../../features/facets/facet-set/interfaces/response.js'; import { executeSearch, fetchFacetValues, -} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {SearchAppState} from '../../../state/search-app-state'; +} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {buildMockFacetSearch} from '../../../test/mock-facet-search'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {createMockState} from '../../../test/mock-state'; -import * as FacetIdDeterminor from '../../core/facets/_common/facet-id-determinor'; -import * as FacetSearch from '../../core/facets/facet-search/specific/headless-facet-search'; -import {buildFacet, Facet, FacetOptions} from './headless-facet'; - -jest.mock('../../../features/facets/facet-set/facet-set-actions'); -jest.mock('../../../features/facet-options/facet-options-actions'); -jest.mock('../../../features/search/search-actions'); -jest.mock('../../../features/facets/facet-set/facet-set-controller-actions'); +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {buildMockFacetSearch} from '../../../test/mock-facet-search.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {createMockState} from '../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../core/facets/_common/facet-id-determinor.js'; +import * as FacetSearch from '../../core/facets/facet-search/specific/headless-facet-search.js'; +import {buildFacet, Facet, FacetOptions} from './headless-facet.js'; + +vi.mock('../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../features/facet-options/facet-options-actions'); +vi.mock('../../../features/search/search-actions'); +vi.mock('../../../features/facets/facet-set/facet-set-controller-actions'); describe('facet', () => { const facetId = '1'; @@ -93,7 +93,7 @@ describe('facet', () => { }); it('it calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initFacet(); @@ -575,7 +575,7 @@ describe('facet', () => { }); it('exposes a #facetSearch property', () => { - jest.spyOn(FacetSearch, 'buildFacetSearch'); + vi.spyOn(FacetSearch, 'buildFacetSearch'); initFacet(); expect(facet.facetSearch).toBeTruthy(); expect(FacetSearch.buildFacetSearch).toHaveBeenCalled(); diff --git a/packages/headless/src/controllers/facets/facet/headless-facet.ts b/packages/headless/src/controllers/facets/facet/headless-facet.ts index 0550e78a082..c9da4013941 100644 --- a/packages/headless/src/controllers/facets/facet/headless-facet.ts +++ b/packages/headless/src/controllers/facets/facet/headless-facet.ts @@ -1,14 +1,14 @@ -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments'; -import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions'; -import {FacetValueState} from '../../../features/facets/facet-api/value'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments.js'; +import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions.js'; +import {FacetValueState} from '../../../features/facets/facet-api/value.js'; import { executeFacetSearch, executeFieldSuggest, -} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; +} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; import { logFacetClearAll, logFacetUpdateSort, @@ -20,28 +20,28 @@ import { facetUpdateSort, facetClearAll, facetExclude, -} from '../../../features/facets/facet-set/facet-set-analytics-actions'; -import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice'; +} from '../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice.js'; import { getLegacyAnalyticsActionForToggleFacetExclude, getLegacyAnalyticsActionForToggleFacetSelect, getAnalyticsActionForToggleFacetExclude, getAnalyticsActionForToggleFacetSelect, -} from '../../../features/facets/facet-set/facet-set-utils'; -import {FacetSortCriterion} from '../../../features/facets/facet-set/interfaces/request'; +} from '../../../features/facets/facet-set/facet-set-utils.js'; +import {FacetSortCriterion} from '../../../features/facets/facet-set/interfaces/request.js'; import { executeSearch, fetchFacetValues, -} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { FacetSection, ConfigurationSection, FacetSearchSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {buildFacetSearch} from '../../core/facets/facet-search/specific/headless-facet-search'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {buildFacetSearch} from '../../core/facets/facet-search/specific/headless-facet-search.js'; import { buildCoreFacet, Facet, @@ -52,12 +52,12 @@ import { SpecificFacetSearchResult, CoreFacet, CoreFacetState, -} from '../../core/facets/facet/headless-core-facet'; +} from '../../core/facets/facet/headless-core-facet.js'; import { FacetOptions, FacetSearchOptions, facetOptionsSchema, -} from './headless-facet-options'; +} from './headless-facet-options.js'; export type { FacetOptions, diff --git a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ssr.ts b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ssr.ts index d41e9748ca6..a7958574655 100644 --- a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ssr.ts +++ b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ssr.ts @@ -1,10 +1,14 @@ -import {SearchEngine} from '../../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common'; -import {DateFacet, DateFacetProps, buildDateFacet} from './headless-date-facet'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common.js'; +import { + DateFacet, + DateFacetProps, + buildDateFacet, +} from './headless-date-facet.js'; -export * from './headless-date-facet'; +export * from './headless-date-facet.js'; -export {buildDateRange} from './headless-date-facet'; +export {buildDateRange} from './headless-date-facet.js'; export interface DateFacetDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.test.ts b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.test.ts index 466105ea538..09c6916eeb9 100644 --- a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.test.ts +++ b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.test.ts @@ -1,42 +1,40 @@ -import {configuration} from '../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; -import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice'; -import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions'; +import {configuration} from '../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; +import {facetOptionsReducer as facetOptions} from '../../../../features/facet-options/facet-options-slice.js'; +import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions.js'; import { registerDateFacet, validateManualDateRanges, -} from '../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockDateFacetResponse} from '../../../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; +} from '../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockDateFacetResponse} from '../../../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor'; +} from '../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor.js'; import { DateFacet, buildDateFacet, DateFacetOptions, buildDateRange, -} from './headless-date-facet'; +} from './headless-date-facet.js'; -jest.mock( +vi.mock( '../../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); -jest.mock('../../../../features/search/search-actions'); -jest.mock('../../../../features/facets/facet-set/facet-set-actions'); -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock( - '../../../../features/facets/range-facets/generic/range-facet-actions' -); +vi.mock('../../../../features/search/search-actions'); +vi.mock('../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facets/range-facets/generic/range-facet-actions'); describe('date facet', () => { const facetId = '1'; @@ -90,7 +88,7 @@ describe('date facet', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initDateFacet(); diff --git a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ts b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ts index 9a5d1b7120d..50776477d2d 100644 --- a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ts +++ b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-facet.ts @@ -1,19 +1,19 @@ -import {SearchEngine} from '../../../../app/search-engine/search-engine'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; import { facetClearAll, facetUpdateSort, logFacetClearAll, logFacetUpdateSort, -} from '../../../../features/facets/facet-set/facet-set-analytics-actions'; -import {DateRangeRequest} from '../../../../features/facets/range-facets/date-facet-set/interfaces/request'; -import {DateFacetValue} from '../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {RangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/interfaces/request'; +} from '../../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {DateRangeRequest} from '../../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; +import {DateFacetValue} from '../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {RangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/interfaces/request.js'; import { getLegacyAnalyticsActionForToggleRangeFacetExclude, getLegacyAnalyticsActionForToggleRangeFacetSelect, getAnalyticsActionForToggleFacetSelect, -} from '../../../../features/facets/range-facets/generic/range-facet-utils'; -import {executeSearch} from '../../../../features/search/search-actions'; +} from '../../../../features/facets/range-facets/generic/range-facet-utils.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; import { buildCoreDateFacet, buildDateRange, @@ -22,8 +22,8 @@ import { DateFacetState, DateRangeInput, DateRangeOptions, -} from '../../../core/facets/range-facet/date-facet/headless-core-date-facet'; -import {DateFacetOptions} from '../../../core/facets/range-facet/date-facet/headless-date-facet-options'; +} from '../../../core/facets/range-facet/date-facet/headless-core-date-facet.js'; +import {DateFacetOptions} from '../../../core/facets/range-facet/date-facet/headless-date-facet-options.js'; export type { DateFacetOptions, diff --git a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ssr.ts b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ssr.ts index cbf6c8ddd00..959a1c9965f 100644 --- a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ssr.ts +++ b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common.js'; import { DateFilter, DateFilterProps, buildDateFilter, -} from './headless-date-filter'; +} from './headless-date-filter.js'; -export * from './headless-date-filter'; +export * from './headless-date-filter.js'; export interface DateFilterDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.test.ts b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.test.ts index f3efd1700eb..3c3cd0eeabc 100644 --- a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.test.ts +++ b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.test.ts @@ -1,36 +1,37 @@ -import {configuration} from '../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; +import {Mock} from 'vitest'; +import {configuration} from '../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; import { registerDateFacet, updateDateFacetValues, validateManualDateRanges, -} from '../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockDateFacetResponse} from '../../../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; +} from '../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockDateFacetResponse} from '../../../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor'; -import {buildDateRange} from '../../../core/facets/range-facet/date-facet/date-range'; +} from '../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor.js'; +import {buildDateRange} from '../../../core/facets/range-facet/date-facet/date-range.js'; import { buildDateFilter, DateFilter, DateFilterInitialState, DateFilterOptions, -} from './headless-date-filter'; +} from './headless-date-filter.js'; -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock( +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock( '../../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); -jest.mock('../../../../features/search/search-actions'); +vi.mock('../../../../features/search/search-actions'); describe('date filter', () => { const facetId = '1'; @@ -47,7 +48,7 @@ describe('date filter', () => { beforeEach(() => { initialState = undefined; - (updateDateFacetValues as unknown as jest.Mock).mockReturnValue(() => {}); + (updateDateFacetValues as unknown as Mock).mockReturnValue(() => {}); options = { facetId, @@ -86,7 +87,7 @@ describe('date filter', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initDateFilter(); diff --git a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ts b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ts index 156be315935..679999140b9 100644 --- a/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ts +++ b/packages/headless/src/controllers/facets/range-facet/date-facet/headless-date-filter.ts @@ -1,20 +1,20 @@ -import {configuration} from '../../../../app/common-reducers'; -import {SearchEngine} from '../../../../app/search-engine/search-engine'; +import {configuration} from '../../../../app/common-reducers.js'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; import { facetClearAll, facetSelect, logFacetClearAll, logFacetSelect, -} from '../../../../features/facets/facet-set/facet-set-analytics-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; +} from '../../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; import { ConfigurationSection, DateFacetSection, SearchSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; import { buildCoreDateFilter, DateFilter, @@ -23,7 +23,7 @@ import { DateFilterProps, DateFilterRange, DateFilterState, -} from '../../../core/facets/range-facet/date-facet/headless-core-date-filter'; +} from '../../../core/facets/range-facet/date-facet/headless-core-date-filter.js'; export type { DateFilterOptions, diff --git a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.ts b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.ts index bf0362b48ee..2db4c010d3f 100644 --- a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.ts +++ b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.ts @@ -1,14 +1,14 @@ -import {SearchEngine} from '../../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common.js'; import { NumericFacet, NumericFacetProps, buildNumericFacet, -} from './headless-numeric-facet'; +} from './headless-numeric-facet.js'; -export * from './headless-numeric-facet'; +export * from './headless-numeric-facet.js'; -export {buildNumericRange} from './headless-numeric-facet'; +export {buildNumericRange} from './headless-numeric-facet.js'; export interface NumericFacetDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.test.ts b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.test.ts index 5e8fb9496ad..1bc126bc63b 100644 --- a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.test.ts +++ b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.test.ts @@ -1,45 +1,43 @@ -import {configuration} from '../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; -import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions'; -import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions'; -import {NumericFacetValue} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +import {configuration} from '../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; +import {deselectAllFacetValues} from '../../../../features/facets/facet-set/facet-set-actions.js'; +import {updateRangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/range-facet-actions.js'; +import {NumericFacetValue} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { deselectAllNumericFacetValues, registerNumericFacet, validateManualNumericRanges, -} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {executeToggleNumericFacetSelect} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../state/search-app-state'; +} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {executeToggleNumericFacetSelect} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor.js'; import { NumericFacet, buildNumericFacet, NumericFacetOptions, buildNumericRange, -} from './headless-numeric-facet'; +} from './headless-numeric-facet.js'; -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../features/facets/facet-set/facet-set-actions'); -jest.mock( +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facets/facet-set/facet-set-actions'); +vi.mock( '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); -jest.mock( - '../../../../features/facets/range-facets/generic/range-facet-actions' -); -jest.mock('../../../../features/search/search-actions'); +vi.mock('../../../../features/facets/range-facets/generic/range-facet-actions'); +vi.mock('../../../../features/search/search-actions'); -jest.mock( +vi.mock( '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions' ); @@ -95,7 +93,7 @@ describe('numeric facet', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initNumericFacet(); diff --git a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ts b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ts index d7dc953dce8..34141da5b55 100644 --- a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ts +++ b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ts @@ -1,27 +1,27 @@ -import {configuration} from '../../../../app/common-reducers'; -import {SearchEngine} from '../../../../app/search-engine/search-engine'; +import {configuration} from '../../../../app/common-reducers.js'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; import { facetClearAll, facetUpdateSort, logFacetClearAll, logFacetUpdateSort, -} from '../../../../features/facets/facet-set/facet-set-analytics-actions'; -import {RangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/interfaces/request'; +} from '../../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {RangeFacetSortCriterion} from '../../../../features/facets/range-facets/generic/interfaces/request.js'; import { getLegacyAnalyticsActionForToggleRangeFacetSelect, getAnalyticsActionForToggleFacetSelect, -} from '../../../../features/facets/range-facets/generic/range-facet-utils'; -import {NumericRangeRequest} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; -import {NumericFacetValue} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; +} from '../../../../features/facets/range-facets/generic/range-facet-utils.js'; +import {NumericRangeRequest} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {NumericFacetValue} from '../../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; import { ConfigurationSection, NumericFacetSection, SearchSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; import { buildCoreNumericFacet, buildNumericRange, @@ -30,7 +30,7 @@ import { NumericFacetProps, NumericFacetState, NumericRangeOptions, -} from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet'; +} from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet.js'; export type { NumericRangeOptions, diff --git a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.ts b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.ts index 6a3e5e46991..daef643f15c 100644 --- a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.ts +++ b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../../app/ssr-engine/types/common.js'; import { NumericFilter, NumericFilterProps, buildNumericFilter, -} from './headless-numeric-filter'; +} from './headless-numeric-filter.js'; -export * from './headless-numeric-filter'; +export * from './headless-numeric-filter.js'; export interface NumericFilterDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.test.ts b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.test.ts index 127f8b2ca11..428bc6b1a99 100644 --- a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.test.ts +++ b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.test.ts @@ -1,34 +1,35 @@ -import {configuration} from '../../../../app/common-reducers'; -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; +import {Mock} from 'vitest'; +import {configuration} from '../../../../app/common-reducers.js'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; import { registerNumericFacet, updateNumericFacetValues, validateManualNumericRanges, -} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; -import {SearchAppState} from '../../../../state/search-app-state'; +} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../test/mock-state'; -import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor'; -import {buildNumericRange} from '../../../core/facets/range-facet/numeric-facet/numeric-range'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import * as FacetIdDeterminor from '../../../core/facets/_common/facet-id-determinor.js'; +import {buildNumericRange} from '../../../core/facets/range-facet/numeric-facet/numeric-range.js'; import { buildNumericFilter, NumericFilter, NumericFilterInitialState, NumericFilterOptions, -} from './headless-numeric-filter'; +} from './headless-numeric-filter.js'; -jest.mock('../../../../features/search/search-actions'); -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock( +vi.mock('../../../../features/search/search-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock( '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); @@ -85,7 +86,7 @@ describe('numeric filter', () => { }); it('calls #determineFacetId with the correct params', () => { - jest.spyOn(FacetIdDeterminor, 'determineFacetId'); + vi.spyOn(FacetIdDeterminor, 'determineFacetId'); initNumericFilter(); @@ -117,9 +118,7 @@ describe('numeric filter', () => { describe('#setRange', () => { beforeEach(() => { - (updateNumericFacetValues as unknown as jest.Mock).mockReturnValueOnce( - {} - ); + (updateNumericFacetValues as unknown as Mock).mockReturnValueOnce({}); }); it('dispatches a updateNumericFacetValues with the passed value', () => { const value = buildMockNumericFacetValue({}); diff --git a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ts b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ts index 1ca1f30113a..80a5396274b 100644 --- a/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ts +++ b/packages/headless/src/controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ts @@ -1,20 +1,20 @@ -import {configuration} from '../../../../app/common-reducers'; -import {SearchEngine} from '../../../../app/search-engine/search-engine'; +import {configuration} from '../../../../app/common-reducers.js'; +import {SearchEngine} from '../../../../app/search-engine/search-engine.js'; import { facetClearAll, facetSelect, logFacetClearAll, logFacetSelect, -} from '../../../../features/facets/facet-set/facet-set-analytics-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {executeSearch} from '../../../../features/search/search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; +} from '../../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {executeSearch} from '../../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; import { ConfigurationSection, NumericFacetSection, SearchSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; import { NumericFilterOptions, NumericFilterInitialState, @@ -23,7 +23,7 @@ import { NumericFilterState, NumericFilter, buildCoreNumericFilter, -} from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-filter'; +} from '../../../core/facets/range-facet/numeric-facet/headless-core-numeric-filter.js'; export type { NumericFilterOptions, diff --git a/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.ts b/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.ts index 8eaa3f213c8..587b01a7110 100644 --- a/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.ts +++ b/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common.js'; import { CategoryFieldSuggestions, CategoryFieldSuggestionsProps, buildCategoryFieldSuggestions, -} from './headless-category-field-suggestions'; +} from './headless-category-field-suggestions.js'; -export * from './headless-category-field-suggestions'; +export * from './headless-category-field-suggestions.js'; export interface CategoryFieldSuggestionsDefinition extends ControllerDefinitionWithoutProps< diff --git a/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.test.ts b/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.test.ts index 0ead4bc816a..096e70c3733 100644 --- a/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.test.ts +++ b/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.test.ts @@ -1,25 +1,25 @@ -import {CategoryFacetRequest} from '../../../features/facets/category-facet-set/interfaces/request'; -import {executeFieldSuggest} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; -import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {SearchAppState} from '../../../state/search-app-state'; -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search'; -import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice'; +import {CategoryFacetRequest} from '../../../features/facets/category-facet-set/interfaces/request.js'; +import {executeFieldSuggest} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; +import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSearch} from '../../../test/mock-category-facet-search.js'; +import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildCategoryFieldSuggestions, CategoryFieldSuggestions, CategoryFieldSuggestionsOptions, -} from './headless-category-field-suggestions'; +} from './headless-category-field-suggestions.js'; -jest.mock( +vi.mock( '../../../features/facets/facet-search-set/specific/specific-facet-search-actions' ); -jest.mock( +vi.mock( '../../../features/facets/facet-search-set/generic/generic-facet-search-actions' ); diff --git a/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ts b/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ts index bef0b7b91ba..47bd3e539cb 100644 --- a/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ts +++ b/packages/headless/src/controllers/field-suggestions/category-facet/headless-category-field-suggestions.ts @@ -1,37 +1,37 @@ -import {CategoryFacetSearchResult} from '../../../api/search/facet-search/category-facet-search/category-facet-search-response'; -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments'; -import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions'; -import {registerCategoryFacet} from '../../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice'; -import {defaultCategoryFacetOptions} from '../../../features/facets/category-facet-set/category-facet-set-slice'; -import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice'; +import {CategoryFacetSearchResult} from '../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments.js'; +import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions.js'; +import {registerCategoryFacet} from '../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {defaultCategoryFacetOptions} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {categoryFacetSearchSetReducer as categoryFacetSearchSet} from '../../../features/facets/facet-search-set/category/category-facet-search-set-slice.js'; import { executeFacetSearch, executeFieldSuggest, -} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; +} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; import { facetSelect, logFacetSelect, -} from '../../../features/facets/facet-set/facet-set-analytics-actions'; -import {executeSearch} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {executeSearch} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { CategoryFacetSearchSection, CategoryFacetSection, ConfigurationSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Subscribable, -} from '../../controller/headless-controller'; -import {determineFacetId} from '../../core/facets/_common/facet-id-determinor'; -import {CategoryFacetOptions} from '../../facets/category-facet/headless-category-facet'; -import {buildCategoryFacetSearch} from '../../facets/category-facet/headless-category-facet-search'; +} from '../../controller/headless-controller.js'; +import {determineFacetId} from '../../core/facets/_common/facet-id-determinor.js'; +import {buildCategoryFacetSearch} from '../../facets/category-facet/headless-category-facet-search.js'; +import {CategoryFacetOptions} from '../../facets/category-facet/headless-category-facet.js'; export interface CategoryFieldSuggestionsValue { /** diff --git a/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ssr.ts b/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ssr.ts index 11fcdd8d7f8..d4d9c8c953c 100644 --- a/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ssr.ts +++ b/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../../app/ssr-engine/types/common.js'; import { FieldSuggestions, FieldSuggestionsProps, buildFieldSuggestions, -} from './headless-field-suggestions'; +} from './headless-field-suggestions.js'; -export * from './headless-field-suggestions'; +export * from './headless-field-suggestions.js'; export interface FieldSuggestionsDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.test.ts b/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.test.ts index 6208f01d16a..348c884c55a 100644 --- a/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.test.ts +++ b/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.test.ts @@ -1,28 +1,28 @@ -import {executeFieldSuggest} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; -import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions'; -import {registerFacet} from '../../../features/facets/facet-set/facet-set-actions'; -import {defaultFacetOptions} from '../../../features/facets/facet-set/facet-set-slice'; -import {FacetRequest} from '../../../features/facets/facet-set/interfaces/request'; -import {SearchAppState} from '../../../state/search-app-state'; +import {executeFieldSuggest} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; +import {updateFacetSearch} from '../../../features/facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {registerFacet} from '../../../features/facets/facet-set/facet-set-actions.js'; +import {defaultFacetOptions} from '../../../features/facets/facet-set/facet-set-slice.js'; +import {FacetRequest} from '../../../features/facets/facet-set/interfaces/request.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetSearch} from '../../../test/mock-facet-search'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetSearch} from '../../../test/mock-facet-search.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildFieldSuggestions, FieldSuggestions, FieldSuggestionsOptions, -} from './headless-field-suggestions'; +} from './headless-field-suggestions.js'; -jest.mock('../../../features/facets/facet-set/facet-set-actions'); -jest.mock( +vi.mock('../../../features/facets/facet-set/facet-set-actions'); +vi.mock( '../../../features/facets/facet-search-set/generic/generic-facet-search-actions' ); -jest.mock( +vi.mock( '../../../features/facets/facet-search-set/specific/specific-facet-search-actions' ); @@ -49,7 +49,7 @@ describe('fieldSuggestions', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { facet: { facetId, diff --git a/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ts b/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ts index fc7e638ed78..3a1ef3b5907 100644 --- a/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ts +++ b/packages/headless/src/controllers/field-suggestions/facet/headless-field-suggestions.ts @@ -1,38 +1,38 @@ -import {configuration} from '../../../app/common-reducers'; -import {CoreEngine} from '../../../app/engine'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments'; -import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {CoreEngine} from '../../../app/engine.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {SearchThunkExtraArguments} from '../../../app/search-thunk-extra-arguments.js'; +import {updateFacetOptions} from '../../../features/facet-options/facet-options-actions.js'; import { executeFacetSearch, executeFieldSuggest, -} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; -import {registerFacet} from '../../../features/facets/facet-set/facet-set-actions'; +} from '../../../features/facets/facet-search-set/generic/generic-facet-search-actions.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; +import {registerFacet} from '../../../features/facets/facet-set/facet-set-actions.js'; import { facetExclude, facetSelect, logFacetExclude, logFacetSelect, -} from '../../../features/facets/facet-set/facet-set-analytics-actions'; -import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice'; -import {defaultFacetOptions} from '../../../features/facets/facet-set/facet-set-slice'; -import {executeSearch} from '../../../features/search/search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice.js'; +import {defaultFacetOptions} from '../../../features/facets/facet-set/facet-set-slice.js'; +import {executeSearch} from '../../../features/search/search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { FacetSection, ConfigurationSection, FacetSearchSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Subscribable, -} from '../../controller/headless-controller'; -import {determineFacetId} from '../../core/facets/_common/facet-id-determinor'; -import {buildFacetSearch} from '../../core/facets/facet-search/specific/headless-facet-search'; -import {FacetOptions} from '../../facets/facet/headless-facet-options'; +} from '../../controller/headless-controller.js'; +import {determineFacetId} from '../../core/facets/_common/facet-id-determinor.js'; +import {buildFacetSearch} from '../../core/facets/facet-search/specific/headless-facet-search.js'; +import {FacetOptions} from '../../facets/facet/headless-facet-options.js'; export interface FieldSuggestionsValue { /** diff --git a/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ssr.ts b/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ssr.ts index 1194c360954..f0058b09934 100644 --- a/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ssr.ts +++ b/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { FoldedResultList, FoldedResultListProps, buildFoldedResultList, -} from './headless-folded-result-list'; +} from './headless-folded-result-list.js'; -export * from './headless-folded-result-list'; +export * from './headless-folded-result-list.js'; export interface FoldedResultListDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.test.ts b/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.test.ts index 77dbf07c135..23b4750f252 100644 --- a/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.test.ts +++ b/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.test.ts @@ -1,19 +1,19 @@ -import {loadCollection} from '../../features/folding/folding-actions'; -import {fetchMoreResults} from '../../features/search/search-actions'; -import {SearchAppState} from '../../state/search-app-state'; +import {loadCollection} from '../../features/folding/folding-actions.js'; +import {fetchMoreResults} from '../../features/search/search-actions.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; import { FoldedResultList, buildFoldedResultList, -} from './headless-folded-result-list'; +} from './headless-folded-result-list.js'; -jest.mock('../../features/folding/folding-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/folding/folding-actions'); +vi.mock('../../features/search/search-actions'); describe('folded result list', () => { let state: SearchAppState; diff --git a/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ts b/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ts index ef9bf2466d0..890ec52674e 100644 --- a/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ts +++ b/packages/headless/src/controllers/folded-result-list/headless-folded-result-list.ts @@ -1,7 +1,7 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {loadCollection} from '../../features/folding/folding-actions'; -import {foldedResultAnalyticsClient} from '../../features/folding/folding-analytics-actions'; -import {fetchMoreResults} from '../../features/search/search-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {loadCollection} from '../../features/folding/folding-actions.js'; +import {foldedResultAnalyticsClient} from '../../features/folding/folding-analytics-actions.js'; +import {fetchMoreResults} from '../../features/search/search-actions.js'; import { buildCoreFoldedResultList, FoldingOptions, @@ -10,7 +10,7 @@ import { FoldedResultListState, FoldedCollection, FoldedResult, -} from '../core/folded-result-list/headless-core-folded-result-list'; +} from '../core/folded-result-list/headless-core-folded-result-list.js'; export type { FoldedResultListOptions, diff --git a/packages/headless/src/controllers/generated-answer/headless-generated-answer.test.ts b/packages/headless/src/controllers/generated-answer/headless-generated-answer.test.ts index 22fa1d7176c..3d96b48a731 100644 --- a/packages/headless/src/controllers/generated-answer/headless-generated-answer.test.ts +++ b/packages/headless/src/controllers/generated-answer/headless-generated-answer.test.ts @@ -1,17 +1,17 @@ -import {updateResponseFormat} from '../../features/generated-answer/generated-answer-actions'; +import {updateResponseFormat} from '../../features/generated-answer/generated-answer-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildGeneratedAnswer, GeneratedAnswerProps, GeneratedResponseFormat, -} from './headless-generated-answer'; +} from './headless-generated-answer.js'; -jest.mock('../../features/generated-answer/generated-answer-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/generated-answer/generated-answer-actions'); +vi.mock('../../features/search/search-actions'); describe('generated answer', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/generated-answer/headless-generated-answer.ts b/packages/headless/src/controllers/generated-answer/headless-generated-answer.ts index f6aae68a7b3..256c3471825 100644 --- a/packages/headless/src/controllers/generated-answer/headless-generated-answer.ts +++ b/packages/headless/src/controllers/generated-answer/headless-generated-answer.ts @@ -1,15 +1,15 @@ -import {GeneratedAnswerCitation} from '../../api/generated-answer/generated-answer-event-payload'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {generatedAnswerAnalyticsClient} from '../../features/generated-answer/generated-answer-analytics-actions'; -import {GeneratedAnswerState} from '../../features/generated-answer/generated-answer-state'; -import {GeneratedResponseFormat} from '../../features/generated-answer/generated-response-format'; +import {GeneratedAnswerCitation} from '../../api/generated-answer/generated-answer-event-payload.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {generatedAnswerAnalyticsClient} from '../../features/generated-answer/generated-answer-analytics-actions.js'; +import {GeneratedAnswerState} from '../../features/generated-answer/generated-answer-state.js'; +import {GeneratedResponseFormat} from '../../features/generated-answer/generated-response-format.js'; import { GeneratedAnswer, GeneratedAnswerProps, GeneratedAnswerPropsInitialState, -} from '../core/generated-answer/headless-core-generated-answer'; -import {buildSearchAPIGeneratedAnswer} from '../core/generated-answer/headless-searchapi-generated-answer'; -import {buildAnswerApiGeneratedAnswer} from '../knowledge/generated-answer/headless-answerapi-generated-answer'; +} from '../core/generated-answer/headless-core-generated-answer.js'; +import {buildSearchAPIGeneratedAnswer} from '../core/generated-answer/headless-searchapi-generated-answer.js'; +import {buildAnswerApiGeneratedAnswer} from '../knowledge/generated-answer/headless-answerapi-generated-answer.js'; export type { GeneratedAnswerCitation, diff --git a/packages/headless/src/controllers/generated-answer/headless-interactive-citation.ts b/packages/headless/src/controllers/generated-answer/headless-interactive-citation.ts index 1abae393ed2..bccd6374e45 100644 --- a/packages/headless/src/controllers/generated-answer/headless-interactive-citation.ts +++ b/packages/headless/src/controllers/generated-answer/headless-interactive-citation.ts @@ -1,11 +1,11 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {generatedAnswerAnalyticsClient} from '../../features/generated-answer/generated-answer-analytics-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {generatedAnswerAnalyticsClient} from '../../features/generated-answer/generated-answer-analytics-actions.js'; import { InteractiveCitation, InteractiveCitationOptions, InteractiveCitationProps, buildInteractiveCitationCore, -} from '../core/generated-answer/headless-core-interactive-citation'; +} from '../core/generated-answer/headless-core-interactive-citation.js'; export type { InteractiveCitation, diff --git a/packages/headless/src/controllers/history-manager/headless-history-manager.ssr.ts b/packages/headless/src/controllers/history-manager/headless-history-manager.ssr.ts index 2c27174ac13..ef2fda1f0da 100644 --- a/packages/headless/src/controllers/history-manager/headless-history-manager.ssr.ts +++ b/packages/headless/src/controllers/history-manager/headless-history-manager.ssr.ts @@ -1,8 +1,11 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {HistoryManager, buildHistoryManager} from './headless-history-manager'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import { + HistoryManager, + buildHistoryManager, +} from './headless-history-manager.js'; -export * from './headless-history-manager'; +export * from './headless-history-manager.js'; export interface HistoryManagerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/history-manager/headless-history-manager.test.ts b/packages/headless/src/controllers/history-manager/headless-history-manager.test.ts index 41ee72ec15b..90ec18224d6 100644 --- a/packages/headless/src/controllers/history-manager/headless-history-manager.test.ts +++ b/packages/headless/src/controllers/history-manager/headless-history-manager.test.ts @@ -1,19 +1,22 @@ -import {configuration} from '../../app/common-reducers'; -import {facetOrderReducer as facetOrder} from '../../features/facets/facet-order/facet-order-slice'; -import {back, forward} from '../../features/history/history-actions'; -import {history} from '../../features/history/history-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {facetOrderReducer as facetOrder} from '../../features/facets/facet-order/facet-order-slice.js'; +import {back, forward} from '../../features/history/history-actions.js'; +import {history} from '../../features/history/history-slice.js'; import { extractHistory, getHistoryInitialState, -} from '../../features/history/history-state'; +} from '../../features/history/history-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildHistoryManager, HistoryManager} from './headless-history-manager'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import { + buildHistoryManager, + HistoryManager, +} from './headless-history-manager.js'; -jest.mock('../../features/history/history-actions'); +vi.mock('../../features/history/history-actions'); describe('History Manager', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/history-manager/headless-history-manager.ts b/packages/headless/src/controllers/history-manager/headless-history-manager.ts index e0185c902f9..e5dfb74f431 100644 --- a/packages/headless/src/controllers/history-manager/headless-history-manager.ts +++ b/packages/headless/src/controllers/history-manager/headless-history-manager.ts @@ -1,9 +1,9 @@ import {isNullOrUndefined} from '@coveo/bueno'; -import {configuration} from '../../app/common-reducers'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {StateWithHistory} from '../../app/undoable'; -import {facetOrderReducer as facetOrder} from '../../features/facets/facet-order/facet-order-slice'; -import {back, forward} from '../../features/history/history-actions'; +import {configuration} from '../../app/common-reducers.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {StateWithHistory} from '../../app/undoable.js'; +import {facetOrderReducer as facetOrder} from '../../features/facets/facet-order/facet-order-slice.js'; +import {back, forward} from '../../features/history/history-actions.js'; import { logNavigateBackward, logNavigateForward, @@ -11,13 +11,19 @@ import { historyBackward, historyForward, noResultsBack, -} from '../../features/history/history-analytics-actions'; -import {history} from '../../features/history/history-slice'; -import {HistoryState} from '../../features/history/history-state'; -import {executeSearch} from '../../features/search/search-actions'; -import {ConfigurationSection, HistorySection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../features/history/history-analytics-actions.js'; +import {history} from '../../features/history/history-slice.js'; +import {HistoryState} from '../../features/history/history-state.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import { + ConfigurationSection, + HistorySection, +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; /** * The `HistoryManager` controller is in charge of allowing navigating back and forward in the search interface history. diff --git a/packages/headless/src/controllers/insight-interface/insight-interface.test.ts b/packages/headless/src/controllers/insight-interface/insight-interface.test.ts index 4233f50fbf4..e5b2c888059 100644 --- a/packages/headless/src/controllers/insight-interface/insight-interface.test.ts +++ b/packages/headless/src/controllers/insight-interface/insight-interface.test.ts @@ -1,16 +1,16 @@ -import {configuration} from '../../app/common-reducers'; -import {insightConfigurationReducer as insightConfiguration} from '../../features/insight-configuration/insight-configuration-slice'; -import {fetchInterface} from '../../features/insight-interface/insight-interface-actions'; -import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {insightConfigurationReducer as insightConfiguration} from '../../features/insight-configuration/insight-configuration-slice.js'; +import {fetchInterface} from '../../features/insight-interface/insight-interface-actions.js'; +import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildInsightInterface, InsightInterface} from './insight-interface'; +} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildInsightInterface, InsightInterface} from './insight-interface.js'; -jest.mock('../../features/insight-interface/insight-interface-actions'); +vi.mock('../../features/insight-interface/insight-interface-actions'); describe('Insight Interface', () => { let engine: MockedInsightEngine; diff --git a/packages/headless/src/controllers/insight-interface/insight-interface.ts b/packages/headless/src/controllers/insight-interface/insight-interface.ts index 5fcfc64faf1..44c15be374c 100644 --- a/packages/headless/src/controllers/insight-interface/insight-interface.ts +++ b/packages/headless/src/controllers/insight-interface/insight-interface.ts @@ -1,18 +1,21 @@ -import {configuration} from '../../app/common-reducers'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {insightConfigurationReducer as insightConfiguration} from '../../features/insight-configuration/insight-configuration-slice'; -import {fetchInterface} from '../../features/insight-interface/insight-interface-actions'; -import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice'; -import {InsightInterfaceState} from '../../features/insight-interface/insight-interface-state'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {insightConfigurationReducer as insightConfiguration} from '../../features/insight-configuration/insight-configuration-slice.js'; +import {fetchInterface} from '../../features/insight-interface/insight-interface-actions.js'; +import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice.js'; +import {InsightInterfaceState} from '../../features/insight-interface/insight-interface-state.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; import { ConfigurationSection, InsightConfigurationSection, InsightInterfaceSection, SearchHubSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; /** * The `InsightInterface` controller is responsible for retrieving the Insight interface configuration. diff --git a/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.test.ts b/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.test.ts index 811eb88544d..889bb4e0241 100644 --- a/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.test.ts +++ b/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.test.ts @@ -1,37 +1,37 @@ -import {configuration} from '../../../app/common-reducers'; +import {configuration} from '../../../app/common-reducers.js'; import { attachResult, detachResult, -} from '../../../features/attached-results/attached-results-actions'; +} from '../../../features/attached-results/attached-results-actions.js'; import { logCaseAttach, logCaseDetach, -} from '../../../features/attached-results/attached-results-analytics-actions'; -import {attachedResultsReducer as attachedResults} from '../../../features/attached-results/attached-results-slice'; -import {buildAttachedResultFromSearchResult} from '../../../features/attached-results/attached-results-utils'; -import {InsightAppState} from '../../../state/insight-app-state'; -import {createMockAttachedResult} from '../../../test/mock-attached-results'; +} from '../../../features/attached-results/attached-results-analytics-actions.js'; +import {attachedResultsReducer as attachedResults} from '../../../features/attached-results/attached-results-slice.js'; +import {buildAttachedResultFromSearchResult} from '../../../features/attached-results/attached-results-utils.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; +import {createMockAttachedResult} from '../../../test/mock-attached-results.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockResult} from '../../../test/mock-result'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; import { AttachToCase, AttachToCaseOptions, buildAttachToCase, -} from './headless-attach-to-case'; +} from './headless-attach-to-case.js'; -jest.mock( +vi.mock( '../../../features/attached-results/attached-results-analytics-actions', () => ({ - logCaseAttach: jest.fn(() => () => {}), - logCaseDetach: jest.fn(() => () => {}), + logCaseAttach: vi.fn(() => () => {}), + logCaseDetach: vi.fn(() => () => {}), }) ); -jest.mock('../../../features/attached-results/attached-results-actions'); +vi.mock('../../../features/attached-results/attached-results-actions'); describe('insight attach to case', () => { let engine: MockedInsightEngine; @@ -55,7 +55,7 @@ describe('insight attach to case', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('initializes', () => { diff --git a/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.ts b/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.ts index 6a412d839f7..fbbfe2b9815 100644 --- a/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.ts +++ b/packages/headless/src/controllers/insight/attach-to-case/headless-attach-to-case.ts @@ -1,26 +1,26 @@ import {isNullOrUndefined} from '@coveo/bueno'; -import {Result} from '../../../api/search/search/result'; -import {configuration} from '../../../app/common-reducers'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {Result} from '../../../api/search/search/result.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { attachResult, detachResult, -} from '../../../features/attached-results/attached-results-actions'; +} from '../../../features/attached-results/attached-results-actions.js'; import { logCaseAttach, logCaseDetach, -} from '../../../features/attached-results/attached-results-analytics-actions'; -import {attachedResultsReducer as attachedResults} from '../../../features/attached-results/attached-results-slice'; -import {buildAttachedResultFromSearchResult} from '../../../features/attached-results/attached-results-utils'; +} from '../../../features/attached-results/attached-results-analytics-actions.js'; +import {attachedResultsReducer as attachedResults} from '../../../features/attached-results/attached-results-slice.js'; +import {buildAttachedResultFromSearchResult} from '../../../features/attached-results/attached-results-utils.js'; import { AttachedResultsSection, ConfigurationSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export interface AttachToCaseProps { /** diff --git a/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.test.ts b/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.test.ts index 993c61d9bca..09787686589 100644 --- a/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.test.ts +++ b/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.test.ts @@ -1,57 +1,57 @@ -import {configuration} from '../../../app/common-reducers'; -import {deselectAllBreadcrumbs} from '../../../features/breadcrumb/breadcrumb-actions'; -import {deselectAllCategoryFacetValues} from '../../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice'; -import {CategoryFacetValue} from '../../../features/facets/category-facet-set/interfaces/response'; +import {configuration} from '../../../app/common-reducers.js'; +import {deselectAllBreadcrumbs} from '../../../features/breadcrumb/breadcrumb-actions.js'; +import {deselectAllCategoryFacetValues} from '../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {CategoryFacetValue} from '../../../features/facets/category-facet-set/interfaces/response.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, updateFreezeCurrentValues, -} from '../../../features/facets/facet-set/facet-set-actions'; -import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice'; -import {FacetValue} from '../../../features/facets/facet-set/interfaces/response'; +} from '../../../features/facets/facet-set/facet-set-actions.js'; +import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice.js'; +import {FacetValue} from '../../../features/facets/facet-set/interfaces/response.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {NumericFacetValue} from '../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; +} from '../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {NumericFacetValue} from '../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericFacetSetReducer as numericFacetSet} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; -import {getSearchInitialState} from '../../../features/search/search-state'; +} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; +import {getSearchInitialState} from '../../../features/search/search-state.js'; import { toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from '../../../features/static-filter-set/static-filter-set-actions'; -import {InsightAppState} from '../../../state/insight-app-state'; -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response'; -import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value'; -import {buildMockDateFacetRequest} from '../../../test/mock-date-facet-request'; -import {buildMockDateFacetResponse} from '../../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../test/mock-date-facet-value'; +} from '../../../features/static-filter-set/static-filter-set-actions.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value.js'; +import {buildMockDateFacetRequest} from '../../../test/mock-date-facet-request.js'; +import {buildMockDateFacetResponse} from '../../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../test/mock-date-facet-value.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockNumericFacetRequest} from '../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetResponse} from '../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../test/mock-numeric-facet-value'; -import {buildMockStaticFilterSlice} from '../../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../../test/mock-static-filter-value'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockNumericFacetRequest} from '../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetResponse} from '../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../test/mock-numeric-facet-value.js'; +import {buildMockStaticFilterSlice} from '../../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../../test/mock-static-filter-value.js'; import { BreadcrumbManager, CategoryFacetBreadcrumb, @@ -59,21 +59,21 @@ import { FacetBreadcrumb, NumericFacetBreadcrumb, buildBreadcrumbManager, -} from './headless-insight-breadcrumb-manager'; +} from './headless-insight-breadcrumb-manager.js'; -jest.mock('../../../features/breadcrumb/breadcrumb-actions'); -jest.mock( +vi.mock('../../../features/breadcrumb/breadcrumb-actions'); +vi.mock( '../../../features/facets/category-facet-set/category-facet-set-actions' ); -jest.mock('../../../features/facets/facet-set/facet-set-actions'); -jest.mock( +vi.mock('../../../features/facets/facet-set/facet-set-actions'); +vi.mock( '../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); -jest.mock( +vi.mock( '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); -jest.mock('../../../features/insight-search/insight-search-actions'); -jest.mock('../../../features/static-filter-set/static-filter-set-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/static-filter-set/static-filter-set-actions'); describe('insight breadcrumb manager', () => { const facetId = 'abc123'; diff --git a/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.ts b/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.ts index 38c8f4c4773..43d8a824944 100644 --- a/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.ts +++ b/packages/headless/src/controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.ts @@ -1,51 +1,51 @@ -import {configuration} from '../../../app/common-reducers'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {deselectAllCategoryFacetValues} from '../../../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryBreadcrumbFacet} from '../../../features/facets/category-facet-set/category-facet-set-analytics-actions'; -import {logCategoryFacetBreadcrumb} from '../../../features/facets/category-facet-set/category-facet-set-insight-analytics-actions'; -import {categoryFacetResponseSelectedValuesSelector} from '../../../features/facets/category-facet-set/category-facet-set-selectors'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice'; +import {configuration} from '../../../app/common-reducers.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {deselectAllCategoryFacetValues} from '../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryBreadcrumbFacet} from '../../../features/facets/category-facet-set/category-facet-set-analytics-actions.js'; +import {logCategoryFacetBreadcrumb} from '../../../features/facets/category-facet-set/category-facet-set-insight-analytics-actions.js'; +import {categoryFacetResponseSelectedValuesSelector} from '../../../features/facets/category-facet-set/category-facet-set-selectors.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, updateFreezeCurrentValues, -} from '../../../features/facets/facet-set/facet-set-actions'; -import {breadcrumbFacet} from '../../../features/facets/facet-set/facet-set-analytics-actions'; -import {logFacetBreadcrumb} from '../../../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {facetResponseActiveValuesSelector} from '../../../features/facets/facet-set/facet-set-selectors'; -import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice'; -import {FacetSlice} from '../../../features/facets/facet-set/facet-set-state'; -import {logClearBreadcrumbs} from '../../../features/facets/generic/facet-generic-insight-analytics-actions'; +} from '../../../features/facets/facet-set/facet-set-actions.js'; +import {breadcrumbFacet} from '../../../features/facets/facet-set/facet-set-analytics-actions.js'; +import {logFacetBreadcrumb} from '../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {facetResponseActiveValuesSelector} from '../../../features/facets/facet-set/facet-set-selectors.js'; +import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice.js'; +import {FacetSlice} from '../../../features/facets/facet-set/facet-set-state.js'; +import {logClearBreadcrumbs} from '../../../features/facets/generic/facet-generic-insight-analytics-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateBreadcrumbFacet} from '../../../features/facets/range-facets/date-facet-set/date-facet-analytics-actions'; -import {logDateFacetBreadcrumb} from '../../../features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions'; -import {dateFacetActiveValuesSelector} from '../../../features/facets/range-facets/date-facet-set/date-facet-selectors'; -import {dateFacetSetReducer as dateFacetSet} from '../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetSlice} from '../../../features/facets/range-facets/date-facet-set/date-facet-set-state'; +} from '../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateBreadcrumbFacet} from '../../../features/facets/range-facets/date-facet-set/date-facet-analytics-actions.js'; +import {logDateFacetBreadcrumb} from '../../../features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.js'; +import {dateFacetActiveValuesSelector} from '../../../features/facets/range-facets/date-facet-set/date-facet-selectors.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetSlice} from '../../../features/facets/range-facets/date-facet-set/date-facet-set-state.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericBreadcrumbFacet} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions'; -import {logNumericFacetBreadcrumb} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions'; -import {numericFacetActiveValuesSelector} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-selectors'; -import {numericFacetSetReducer as numericFacetSet} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {NumericFacetSlice} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-state'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericBreadcrumbFacet} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.js'; +import {logNumericFacetBreadcrumb} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.js'; +import {numericFacetActiveValuesSelector} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {NumericFacetSlice} from '../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { staticFilterDeselect, toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from '../../../features/static-filter-set/static-filter-set-actions'; -import {logInsightStaticFilterDeselect} from '../../../features/static-filter-set/static-filter-set-insight-analytics-actions'; +} from '../../../features/static-filter-set/static-filter-set-actions.js'; +import {logInsightStaticFilterDeselect} from '../../../features/static-filter-set/static-filter-set-insight-analytics-actions.js'; import { StaticFilterSlice, StaticFilterValue, -} from '../../../features/static-filter-set/static-filter-set-state'; +} from '../../../features/static-filter-set/static-filter-set-state.js'; import { CategoryFacetSection, ConfigurationSection, @@ -53,8 +53,8 @@ import { FacetSection, NumericFacetSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { Breadcrumb, BreadcrumbManager, @@ -69,7 +69,7 @@ import { GetBreadcrumbsConfiguration, NumericFacetBreadcrumb, StaticFilterBreadcrumb, -} from '../../core/breadcrumb-manager/headless-core-breadcrumb-manager'; +} from '../../core/breadcrumb-manager/headless-core-breadcrumb-manager.js'; export type { NumericFacetBreadcrumb, diff --git a/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.test.ts b/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.test.ts index 1a5cb30758c..b60b56fea34 100644 --- a/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.test.ts +++ b/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.test.ts @@ -1,17 +1,17 @@ import { applyDidYouMeanCorrection, enableDidYouMean, -} from '../../../features/did-you-mean/did-you-mean-actions'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +} from '../../../features/did-you-mean/did-you-mean-actions.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildDidYouMean, DidYouMean} from './headless-insight-did-you-mean'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildDidYouMean, DidYouMean} from './headless-insight-did-you-mean.js'; -jest.mock('../../../features/insight-search/insight-search-actions'); -jest.mock('../../../features/did-you-mean/did-you-mean-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/did-you-mean/did-you-mean-actions'); describe('did you mean', () => { let dym: DidYouMean; diff --git a/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.ts b/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.ts index 557dbc508b1..6f18581df29 100644 --- a/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.ts +++ b/packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.ts @@ -1,16 +1,16 @@ import { QueryCorrection, WordCorrection, -} from '../../../api/search/search/query-corrections'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {didYouMeanClick} from '../../../features/did-you-mean/did-you-mean-analytics-actions'; -import {logDidYouMeanClick} from '../../../features/did-you-mean/did-you-mean-insight-analytics-actions'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +} from '../../../api/search/search/query-corrections.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {didYouMeanClick} from '../../../features/did-you-mean/did-you-mean-analytics-actions.js'; +import {logDidYouMeanClick} from '../../../features/did-you-mean/did-you-mean-insight-analytics-actions.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { buildCoreDidYouMean, DidYouMean, DidYouMeanState, -} from '../../core/did-you-mean/headless-core-did-you-mean'; +} from '../../core/did-you-mean/headless-core-did-you-mean.js'; export type {QueryCorrection, WordCorrection, DidYouMean, DidYouMeanState}; diff --git a/packages/headless/src/controllers/insight/facet-conditions-manager/headless-facet-conditions-manager.ts b/packages/headless/src/controllers/insight/facet-conditions-manager/headless-facet-conditions-manager.ts index 1321517a086..319dc1378c0 100644 --- a/packages/headless/src/controllers/insight/facet-conditions-manager/headless-facet-conditions-manager.ts +++ b/packages/headless/src/controllers/insight/facet-conditions-manager/headless-facet-conditions-manager.ts @@ -1,10 +1,10 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { FacetConditionsManager, AnyFacetValuesCondition, FacetConditionsManagerProps, buildCoreFacetConditionsManager, -} from '../../core/facets/facet-conditions-manager/headless-facet-conditions-manager'; +} from '../../core/facets/facet-conditions-manager/headless-facet-conditions-manager.js'; export type { FacetConditionsManager, diff --git a/packages/headless/src/controllers/insight/facet-manager/headless-insight-facet-manager.ts b/packages/headless/src/controllers/insight/facet-manager/headless-insight-facet-manager.ts index e46a9a2c0ac..a34343293e1 100644 --- a/packages/headless/src/controllers/insight/facet-manager/headless-insight-facet-manager.ts +++ b/packages/headless/src/controllers/insight/facet-manager/headless-insight-facet-manager.ts @@ -1,10 +1,10 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { buildCoreFacetManager, FacetManagerState, FacetManagerPayload, FacetManager, -} from '../../core/facet-manager/headless-core-facet-manager'; +} from '../../core/facet-manager/headless-core-facet-manager.js'; export type {FacetManagerState, FacetManagerPayload, FacetManager}; diff --git a/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.test.ts b/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.test.ts index 5ea87f3d91e..d950f32d61c 100644 --- a/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.test.ts +++ b/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.test.ts @@ -1,40 +1,40 @@ -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; import { deselectAllCategoryFacetValues, toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, updateCategoryFacetSortCriterion, -} from '../../../../features/facets/category-facet-set/category-facet-set-actions'; -import {defaultCategoryFacetOptions} from '../../../../features/facets/category-facet-set/category-facet-set-slice'; +} from '../../../../features/facets/category-facet-set/category-facet-set-actions.js'; +import {defaultCategoryFacetOptions} from '../../../../features/facets/category-facet-set/category-facet-set-slice.js'; import { CategoryFacetRequest, CategoryFacetSortCriterion, -} from '../../../../features/facets/category-facet-set/interfaces/request'; +} from '../../../../features/facets/category-facet-set/interfaces/request.js'; import { executeSearch, fetchFacetValues, -} from '../../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../../state/insight-app-state'; -import {buildMockCategoryFacetRequest} from '../../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../../test/mock-category-facet-response'; -import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../../test/mock-category-facet-value'; +} from '../../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../../state/insight-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValue} from '../../../../test/mock-category-facet-value.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../test/mock-insight-state'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../test/mock-insight-state.js'; import { CategoryFacet, CategoryFacetOptions, buildCategoryFacet, -} from './headless-insight-category-facet'; +} from './headless-insight-category-facet.js'; -jest.mock( +vi.mock( '../../../../features/facets/category-facet-set/category-facet-set-actions' ); -jest.mock('../../../../features/insight-search/insight-search-actions'); -jest.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/insight-search/insight-search-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); describe('insight category facet', () => { const facetId = '1'; diff --git a/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.ts b/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.ts index 7c8682f1f7d..f84c6f20246 100644 --- a/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.ts +++ b/packages/headless/src/controllers/insight/facets/category-facet/headless-insight-category-facet.ts @@ -1,11 +1,11 @@ -import {InsightEngine} from '../../../../app/insight-engine/insight-engine'; -import {CategoryFacetSortCriterion} from '../../../../features/facets/category-facet-set/interfaces/request'; +import {InsightEngine} from '../../../../app/insight-engine/insight-engine.js'; +import {CategoryFacetSortCriterion} from '../../../../features/facets/category-facet-set/interfaces/request.js'; import { facetClearAll, facetDeselect, facetSelect, facetUpdateSort, -} from '../../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetDeselect, @@ -13,12 +13,12 @@ import { logFacetShowLess, logFacetShowMore, logFacetUpdateSort, -} from '../../../../features/facets/facet-set/facet-set-insight-analytics-actions'; +} from '../../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; import { executeSearch, fetchFacetValues, -} from '../../../../features/insight-search/insight-search-actions'; -import {SearchAction} from '../../../../features/search/search-actions'; +} from '../../../../features/insight-search/insight-search-actions.js'; +import {SearchAction} from '../../../../features/search/search-actions.js'; import { buildCoreCategoryFacet, CategoryFacet, @@ -33,7 +33,7 @@ import { CategoryFacetValueCommon, CoreCategoryFacet, CoreCategoryFacetState, -} from '../../../core/facets/category-facet/headless-core-category-facet'; +} from '../../../core/facets/category-facet/headless-core-category-facet.js'; export type { CategoryFacetValueCommon, diff --git a/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet-options.ts b/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet-options.ts index 03c5d397bea..e70cbbf6295 100644 --- a/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet-options.ts +++ b/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet-options.ts @@ -1,6 +1,6 @@ import {ArrayValue, RecordValue, Schema, StringValue} from '@coveo/bueno'; -import {facetResultsMustMatch} from '../../../../features/facets/facet-api/request'; -import {facetSortCriteria} from '../../../../features/facets/facet-set/interfaces/request'; +import {facetResultsMustMatch} from '../../../../features/facets/facet-api/request.js'; +import {facetSortCriteria} from '../../../../features/facets/facet-set/interfaces/request.js'; import { facetId, field, @@ -10,11 +10,11 @@ import { facetSearch, allowedValues, customSort, -} from '../../../core/facets/_common/facet-option-definitions'; +} from '../../../core/facets/_common/facet-option-definitions.js'; import { FacetOptions as CoreFacetOptions, FacetSearchOptions, -} from '../../../core/facets/facet/headless-core-facet-options'; +} from '../../../core/facets/facet/headless-core-facet-options.js'; export type {FacetSearchOptions, CoreFacetOptions}; diff --git a/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.test.ts b/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.test.ts index b099ce21f8f..54870765cd1 100644 --- a/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.test.ts +++ b/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.test.ts @@ -1,32 +1,32 @@ -import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions'; +import {updateFacetOptions} from '../../../../features/facet-options/facet-options-actions.js'; import { deselectAllFacetValues, updateFacetSortCriterion, updateFacetNumberOfValues, -} from '../../../../features/facets/facet-set/facet-set-actions'; -import {executeToggleFacetSelect} from '../../../../features/facets/facet-set/facet-set-controller-actions'; -import {FacetRequest} from '../../../../features/facets/facet-set/interfaces/request'; -import {FacetValue} from '../../../../features/facets/facet-set/interfaces/response'; +} from '../../../../features/facets/facet-set/facet-set-actions.js'; +import {executeToggleFacetSelect} from '../../../../features/facets/facet-set/facet-set-controller-actions.js'; +import {FacetRequest} from '../../../../features/facets/facet-set/interfaces/request.js'; +import {FacetValue} from '../../../../features/facets/facet-set/interfaces/response.js'; import { executeSearch, fetchFacetValues, -} from '../../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../../state/insight-app-state'; +} from '../../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../../state/insight-app-state.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../../test/mock-facet-request'; -import {buildMockFacetSearch} from '../../../../test/mock-facet-search'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../../test/mock-facet-value'; -import {buildMockInsightState} from '../../../../test/mock-insight-state'; -import {buildFacet, Facet, FacetOptions} from './headless-insight-facet'; - -jest.mock('../../../../features/facets/facet-set/facet-set-actions'); -jest.mock('../../../../features/insight-search/insight-search-actions'); -jest.mock('../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../features/facets/facet-set/facet-set-controller-actions'); +} from '../../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../../test/mock-facet-request.js'; +import {buildMockFacetSearch} from '../../../../test/mock-facet-search.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../../../test/mock-facet-value.js'; +import {buildMockInsightState} from '../../../../test/mock-insight-state.js'; +import {buildFacet, Facet, FacetOptions} from './headless-insight-facet.js'; + +vi.mock('../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../features/insight-search/insight-search-actions'); +vi.mock('../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../features/facets/facet-set/facet-set-controller-actions'); describe('InsightFacet', () => { const facetId = '1'; diff --git a/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.ts b/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.ts index f3de9f12989..b2a5a1c85e1 100644 --- a/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.ts +++ b/packages/headless/src/controllers/insight/facets/facet/headless-insight-facet.ts @@ -1,33 +1,33 @@ -import {configuration} from '../../../../app/common-reducers'; -import {InsightEngine} from '../../../../app/insight-engine/insight-engine'; -import {FacetValueState} from '../../../../features/facets/facet-api/value'; -import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice'; +import {configuration} from '../../../../app/common-reducers.js'; +import {InsightEngine} from '../../../../app/insight-engine/insight-engine.js'; +import {FacetValueState} from '../../../../features/facets/facet-api/value.js'; +import {specificFacetSearchSetReducer as facetSearchSet} from '../../../../features/facets/facet-search-set/specific/specific-facet-search-set-slice.js'; import { facetClearAll, facetUpdateSort, -} from '../../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetShowLess, logFacetShowMore, logFacetUpdateSort, -} from '../../../../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {getInsightAnalyticsActionForToggleFacetSelect} from '../../../../features/facets/facet-set/facet-set-insight-utils'; -import {facetSetReducer as facetSet} from '../../../../features/facets/facet-set/facet-set-slice'; -import {getAnalyticsActionForToggleFacetSelect} from '../../../../features/facets/facet-set/facet-set-utils'; -import {FacetSortCriterion} from '../../../../features/facets/facet-set/interfaces/request'; +} from '../../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {getInsightAnalyticsActionForToggleFacetSelect} from '../../../../features/facets/facet-set/facet-set-insight-utils.js'; +import {facetSetReducer as facetSet} from '../../../../features/facets/facet-set/facet-set-slice.js'; +import {getAnalyticsActionForToggleFacetSelect} from '../../../../features/facets/facet-set/facet-set-utils.js'; +import {FacetSortCriterion} from '../../../../features/facets/facet-set/interfaces/request.js'; import { executeSearch, fetchFacetValues, -} from '../../../../features/insight-search/insight-search-actions'; -import {searchReducer as search} from '../../../../features/search/search-slice'; +} from '../../../../features/insight-search/insight-search-actions.js'; +import {searchReducer as search} from '../../../../features/search/search-slice.js'; import { FacetSection, ConfigurationSection, FacetSearchSection, SearchSection, -} from '../../../../state/state-sections'; -import {loadReducerError} from '../../../../utils/errors'; +} from '../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../utils/errors.js'; import { buildCoreFacet, CoreFacet, @@ -38,13 +38,13 @@ import { FacetState, FacetValue, SpecificFacetSearchResult, -} from '../../../core/facets/facet/headless-core-facet'; +} from '../../../core/facets/facet/headless-core-facet.js'; import { FacetOptions, FacetSearchOptions, facetOptionsSchema, CoreFacetOptions, -} from './headless-insight-facet-options'; +} from './headless-insight-facet-options.js'; export type { FacetOptions, diff --git a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.test.ts b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.test.ts index 18a452b9180..404743ce312 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.test.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.test.ts @@ -1,34 +1,34 @@ -import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions'; -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; -import {deselectAllDateFacetValues} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {executeToggleDateFacetSelect} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions'; -import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {updateRangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/range-facet-actions'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../../../state/insight-app-state'; -import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value'; +import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions.js'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; +import {deselectAllDateFacetValues} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {executeToggleDateFacetSelect} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions.js'; +import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {updateRangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/range-facet-actions.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../../../state/insight-app-state.js'; +import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../../test/mock-insight-state'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../../test/mock-insight-state.js'; import { DateFacet, DateFacetOptions, buildDateFacet, -} from './headless-insight-date-facet'; +} from './headless-insight-date-facet.js'; -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); -jest.mock('../../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../../features/insight-search/insight-search-actions'); -jest.mock( +vi.mock('../../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../../features/insight-search/insight-search-actions'); +vi.mock( '../../../../../features/facets/range-facets/date-facet-set/date-facet-controller-actions' ); -jest.mock('../../../../../features/facets/facet-set/facet-set-actions'); -jest.mock( +vi.mock('../../../../../features/facets/facet-set/facet-set-actions'); +vi.mock( '../../../../../features/facets/range-facets/generic/range-facet-actions' ); diff --git a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.ts b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.ts index 139ecc2e5ae..84478c51257 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.ts @@ -1,18 +1,18 @@ -import {InsightEngine} from '../../../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../../../app/insight-engine/insight-engine.js'; import { facetClearAll, facetUpdateSort, -} from '../../../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetUpdateSort, -} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request'; -import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response'; -import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request'; -import {getInsightAnalyticsActionForToggleRangeFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-insight-utils'; -import {getAnalyticsActionForToggleFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-utils'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; +} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {DateRangeRequest} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/request.js'; +import {DateFacetValue} from '../../../../../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request.js'; +import {getInsightAnalyticsActionForToggleRangeFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-insight-utils.js'; +import {getAnalyticsActionForToggleFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-utils.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; import { buildCoreDateFacet, buildDateRange, @@ -21,8 +21,8 @@ import { DateFacetState, DateRangeInput, DateRangeOptions, -} from '../../../../core/facets/range-facet/date-facet/headless-core-date-facet'; -import {DateFacetOptions} from '../../../../core/facets/range-facet/date-facet/headless-date-facet-options'; +} from '../../../../core/facets/range-facet/date-facet/headless-core-date-facet.js'; +import {DateFacetOptions} from '../../../../core/facets/range-facet/date-facet/headless-date-facet-options.js'; export type { DateFacetOptions, diff --git a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.test.ts b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.test.ts index 6e8afe7e05b..aaa9e75d34b 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.test.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.test.ts @@ -1,26 +1,27 @@ -import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions'; -import {updateDateFacetValues} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../../../state/insight-app-state'; -import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value'; +import {Mock} from 'vitest'; +import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions.js'; +import {updateDateFacetValues} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../../../state/insight-app-state.js'; +import {buildMockDateFacetSlice} from '../../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../../test/mock-date-facet-value.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../../test/mock-insight-state'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../../test/mock-insight-state.js'; import { buildDateFilter, DateFilter, DateFilterInitialState, DateFilterOptions, -} from './headless-insight-date-filter'; +} from './headless-insight-date-filter.js'; -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/date-facet-set/date-facet-actions' ); -jest.mock('../../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../../features/insight-search/insight-search-actions'); +vi.mock('../../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../../features/insight-search/insight-search-actions'); describe('insight date filter', () => { const facetId = '1'; @@ -36,7 +37,7 @@ describe('insight date filter', () => { } beforeEach(() => { - (updateDateFacetValues as unknown as jest.Mock).mockReturnValue(() => {}); + (updateDateFacetValues as unknown as Mock).mockReturnValue(() => {}); initialState = undefined; options = { diff --git a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.ts b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.ts index 82d0ee9ae2e..b15347bb80a 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.ts @@ -1,22 +1,22 @@ -import {configuration} from '../../../../../app/common-reducers'; -import {InsightEngine} from '../../../../../app/insight-engine/insight-engine'; +import {configuration} from '../../../../../app/common-reducers.js'; +import {InsightEngine} from '../../../../../app/insight-engine/insight-engine.js'; import { facetClearAll, facetSelect, -} from '../../../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetSelect, -} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; -import {searchReducer as search} from '../../../../../features/search/search-slice'; +} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; +import {searchReducer as search} from '../../../../../features/search/search-slice.js'; import { ConfigurationSection, DateFacetSection, SearchSection, -} from '../../../../../state/state-sections'; -import {loadReducerError} from '../../../../../utils/errors'; +} from '../../../../../state/state-sections.js'; +import {loadReducerError} from '../../../../../utils/errors.js'; import { buildCoreDateFilter, DateFilter, @@ -25,7 +25,7 @@ import { DateFilterProps, DateFilterRange, DateFilterState, -} from '../../../../core/facets/range-facet/date-facet/headless-core-date-filter'; +} from '../../../../core/facets/range-facet/date-facet/headless-core-date-filter.js'; export type { DateFilterOptions, diff --git a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.test.ts b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.test.ts index 7732565814f..5f599f060f6 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.test.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.test.ts @@ -1,21 +1,21 @@ -import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../../../state/insight-app-state'; +import {deselectAllFacetValues} from '../../../../../features/facets/facet-set/facet-set-actions.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../../../state/insight-app-state.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../../test/mock-insight-state'; -import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../../test/mock-insight-state.js'; +import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value.js'; import { NumericFacet, buildNumericFacet, NumericFacetOptions, -} from './headless-insight-numeric-facet'; +} from './headless-insight-numeric-facet.js'; -jest.mock('../../../../../features/insight-search/insight-search-actions'); -jest.mock('../../../../../features/facets/facet-set/facet-set-actions'); +vi.mock('../../../../../features/insight-search/insight-search-actions'); +vi.mock('../../../../../features/facets/facet-set/facet-set-actions'); describe('insight numeric facet', () => { const facetId = '1'; diff --git a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.ts b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.ts index 2ba9026940b..131d7bfdbdd 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.ts @@ -1,18 +1,18 @@ -import {InsightEngine} from '../../../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../../../app/insight-engine/insight-engine.js'; import { facetClearAll, facetUpdateSort, -} from '../../../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetUpdateSort, -} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request'; -import {getInsightAnalyticsActionForToggleRangeFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-insight-utils'; -import {getAnalyticsActionForToggleFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-utils'; -import {NumericRangeRequest} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request'; -import {NumericFacetValue} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; +} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {RangeFacetSortCriterion} from '../../../../../features/facets/range-facets/generic/interfaces/request.js'; +import {getInsightAnalyticsActionForToggleRangeFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-insight-utils.js'; +import {getAnalyticsActionForToggleFacetSelect} from '../../../../../features/facets/range-facets/generic/range-facet-utils.js'; +import {NumericRangeRequest} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {NumericFacetValue} from '../../../../../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; import { buildCoreNumericFacet, buildNumericRange, @@ -21,7 +21,7 @@ import { NumericFacetProps, NumericFacetState, NumericRangeOptions, -} from '../../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet'; +} from '../../../../core/facets/range-facet/numeric-facet/headless-core-numeric-facet.js'; export type { NumericRangeOptions, diff --git a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.test.ts b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.test.ts index ee2ca09e037..9699ec071c0 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.test.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.test.ts @@ -1,26 +1,27 @@ -import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions'; -import {updateNumericFacetValues} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../../../state/insight-app-state'; +import {describe, it, expect, vi, Mock, beforeEach} from 'vitest'; +import {updateFacetOptions} from '../../../../../features/facet-options/facet-options-actions.js'; +import {updateNumericFacetValues} from '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../../../state/insight-app-state.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../../test/mock-insight-state'; -import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value'; +} from '../../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../../test/mock-insight-state.js'; +import {buildMockNumericFacetSlice} from '../../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../../test/mock-numeric-facet-value.js'; import { buildNumericFilter, NumericFilter, NumericFilterInitialState, NumericFilterOptions, -} from './headless-insight-numeric-filter'; +} from './headless-insight-numeric-filter.js'; -jest.mock( +vi.mock( '../../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-actions' ); -jest.mock('../../../../../features/facet-options/facet-options-actions'); -jest.mock('../../../../../features/insight-search/insight-search-actions'); +vi.mock('../../../../../features/facet-options/facet-options-actions'); +vi.mock('../../../../../features/insight-search/insight-search-actions'); describe('insight numeric filter', () => { const facetId = '1'; @@ -36,7 +37,7 @@ describe('insight numeric filter', () => { } beforeEach(() => { - (updateNumericFacetValues as unknown as jest.Mock).mockReturnValue({}); + (updateNumericFacetValues as unknown as Mock).mockReturnValue({}); initialState = undefined; options = { diff --git a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.ts b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.ts index 90a40a3b0d2..da4ad987d50 100644 --- a/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.ts +++ b/packages/headless/src/controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.ts @@ -1,13 +1,13 @@ -import {InsightEngine} from '../../../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../../../app/insight-engine/insight-engine.js'; import { facetClearAll, facetSelect, -} from '../../../../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../../../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetSelect, -} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {executeSearch} from '../../../../../features/insight-search/insight-search-actions'; +} from '../../../../../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {executeSearch} from '../../../../../features/insight-search/insight-search-actions.js'; import { NumericFilterOptions, NumericFilterInitialState, @@ -16,7 +16,7 @@ import { NumericFilterState, NumericFilter, buildCoreNumericFilter, -} from '../../../../core/facets/range-facet/numeric-facet/headless-core-numeric-filter'; +} from '../../../../core/facets/range-facet/numeric-facet/headless-core-numeric-filter.js'; export type { NumericFilterOptions, diff --git a/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.test.ts b/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.test.ts index f7f89821cc7..2c5ed40b8f6 100644 --- a/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.test.ts +++ b/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.test.ts @@ -1,19 +1,19 @@ -import {loadCollection} from '../../../features/folding/insight-folding-actions'; -import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../state/insight-app-state'; +import {loadCollection} from '../../../features/folding/insight-folding-actions.js'; +import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockResult} from '../../../test/mock-result'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; import { FoldedResultList, buildFoldedResultList, -} from './headless-insight-folded-result-list'; +} from './headless-insight-folded-result-list.js'; -jest.mock('../../../features/folding/insight-folding-actions'); -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/folding/insight-folding-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('insight folded result list', () => { let state: InsightAppState; diff --git a/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.ts b/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.ts index 24c7f0a1107..d327805f77c 100644 --- a/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.ts +++ b/packages/headless/src/controllers/insight/folded-result-list/headless-insight-folded-result-list.ts @@ -1,7 +1,7 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {insightFoldedResultAnalyticsClient} from '../../../features/folding/folding-insight-analytics-actions'; -import {loadCollection} from '../../../features/folding/insight-folding-actions'; -import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {insightFoldedResultAnalyticsClient} from '../../../features/folding/folding-insight-analytics-actions.js'; +import {loadCollection} from '../../../features/folding/insight-folding-actions.js'; +import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions.js'; import { buildCoreFoldedResultList, FoldingOptions, @@ -10,7 +10,7 @@ import { FoldedResultList, FoldedResultListOptions, FoldedResultListState, -} from '../../core/folded-result-list/headless-core-folded-result-list'; +} from '../../core/folded-result-list/headless-core-folded-result-list.js'; export type { FoldedResultListOptions, diff --git a/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.test.ts b/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.test.ts index 20b4a8da971..5ab2453e4e0 100644 --- a/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.test.ts +++ b/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.test.ts @@ -1,17 +1,17 @@ -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; import { buildGeneratedAnswer, GeneratedAnswer, GeneratedAnswerProps, -} from './headless-insight-generated-answer'; +} from './headless-insight-generated-answer.js'; -jest.mock('../../../features/generated-answer/generated-answer-actions'); -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/generated-answer/generated-answer-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('insight generated answer', () => { let generatedAnswer: GeneratedAnswer; diff --git a/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.ts b/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.ts index b0e7beda63a..d99c2f3cee2 100644 --- a/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.ts +++ b/packages/headless/src/controllers/insight/generated-answer/headless-insight-generated-answer.ts @@ -1,15 +1,16 @@ -import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {retryGeneratedAnswer} from '../../../features/generated-answer/generated-answer-analytics-actions'; -import {generatedAnswerInsightAnalyticsClient} from '../../../features/generated-answer/generated-answer-insight-analytics-actions'; -import {GeneratedAnswerState} from '../../../features/generated-answer/generated-answer-state'; -import {GeneratedResponseFormat} from '../../../features/generated-answer/generated-response-format'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +import {GeneratedAnswerCitation} from '../../../api/generated-answer/generated-answer-event-payload.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {retryGeneratedAnswer} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; +import {generatedAnswerInsightAnalyticsClient} from '../../../features/generated-answer/generated-answer-insight-analytics-actions.js'; +import {GeneratedAnswerState} from '../../../features/generated-answer/generated-answer-state.js'; +import {GeneratedResponseFormat} from '../../../features/generated-answer/generated-response-format.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { GeneratedAnswer, GeneratedAnswerProps, -} from '../../core/generated-answer/headless-core-generated-answer'; -import {buildSearchAPIGeneratedAnswer} from '../../core/generated-answer/headless-searchapi-generated-answer'; +} from '../../core/generated-answer/headless-core-generated-answer.js'; +import {buildSearchAPIGeneratedAnswer} from '../../core/generated-answer/headless-searchapi-generated-answer.js'; +import {buildAnswerApiGeneratedAnswer} from '../../knowledge/generated-answer/headless-answerapi-generated-answer.js'; export type { GeneratedAnswerCitation, @@ -31,11 +32,17 @@ export function buildGeneratedAnswer( props: GeneratedAnswerProps = {} ): GeneratedAnswer { const {dispatch} = engine; - const controller = buildSearchAPIGeneratedAnswer( - engine, - generatedAnswerInsightAnalyticsClient, - props - ); + const controller = props.answerConfigurationId + ? buildAnswerApiGeneratedAnswer( + engine, + generatedAnswerInsightAnalyticsClient, + props + ) + : buildSearchAPIGeneratedAnswer( + engine, + generatedAnswerInsightAnalyticsClient, + props + ); return { ...controller, diff --git a/packages/headless/src/controllers/insight/generated-answer/headless-insight-interactive-citation.ts b/packages/headless/src/controllers/insight/generated-answer/headless-insight-interactive-citation.ts index b9d1140cb09..1207953f700 100644 --- a/packages/headless/src/controllers/insight/generated-answer/headless-insight-interactive-citation.ts +++ b/packages/headless/src/controllers/insight/generated-answer/headless-insight-interactive-citation.ts @@ -1,11 +1,11 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {logOpenGeneratedAnswerSource} from '../../../features/generated-answer/generated-answer-insight-analytics-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {logOpenGeneratedAnswerSource} from '../../../features/generated-answer/generated-answer-insight-analytics-actions.js'; import { InteractiveCitation, InteractiveCitationOptions, InteractiveCitationProps, buildInteractiveCitationCore, -} from '../../core/generated-answer/headless-core-interactive-citation'; +} from '../../core/generated-answer/headless-core-interactive-citation.js'; export type { InteractiveCitation, diff --git a/packages/headless/src/controllers/insight/pager/headless-insight-pager.test.ts b/packages/headless/src/controllers/insight/pager/headless-insight-pager.test.ts index 945686137ce..45d1731b079 100644 --- a/packages/headless/src/controllers/insight/pager/headless-insight-pager.test.ts +++ b/packages/headless/src/controllers/insight/pager/headless-insight-pager.test.ts @@ -1,17 +1,17 @@ -import {fetchPage} from '../../../features/insight-search/insight-search-actions'; +import {fetchPage} from '../../../features/insight-search/insight-search-actions.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; import { Pager, PagerOptions, PagerInitialState, buildPager, -} from './headless-insight-pager'; +} from './headless-insight-pager.js'; -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('Pager', () => { let engine: MockedInsightEngine; diff --git a/packages/headless/src/controllers/insight/pager/headless-insight-pager.ts b/packages/headless/src/controllers/insight/pager/headless-insight-pager.ts index b5d4a83e9ad..c9a19afd23c 100644 --- a/packages/headless/src/controllers/insight/pager/headless-insight-pager.ts +++ b/packages/headless/src/controllers/insight/pager/headless-insight-pager.ts @@ -1,11 +1,11 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {fetchPage} from '../../../features/insight-search/insight-search-actions'; -import {browseResults} from '../../../features/pagination/pagination-analytics-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {fetchPage} from '../../../features/insight-search/insight-search-actions.js'; +import {browseResults} from '../../../features/pagination/pagination-analytics-actions.js'; import { logPageNumber, logPageNext, logPagePrevious, -} from '../../../features/pagination/pagination-insight-analytics-actions'; +} from '../../../features/pagination/pagination-insight-analytics-actions.js'; import { buildCorePager, PagerInitialState, @@ -13,7 +13,7 @@ import { PagerProps, Pager, PagerState, -} from '../../core/pager/headless-core-pager'; +} from '../../core/pager/headless-core-pager.js'; export type {PagerInitialState, PagerOptions, PagerProps, Pager, PagerState}; diff --git a/packages/headless/src/controllers/insight/query-error/headless-insight-query-error.ts b/packages/headless/src/controllers/insight/query-error/headless-insight-query-error.ts index ad64d2d19d5..2d1d7224a0a 100644 --- a/packages/headless/src/controllers/insight/query-error/headless-insight-query-error.ts +++ b/packages/headless/src/controllers/insight/query-error/headless-insight-query-error.ts @@ -1,9 +1,9 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { buildCoreQueryError, QueryError, QueryErrorState, -} from '../../core/query-error/headless-core-query-error'; +} from '../../core/query-error/headless-core-query-error.js'; export type {QueryError, QueryErrorState}; /** diff --git a/packages/headless/src/controllers/insight/query-summary/headless-insight-query-summary.ts b/packages/headless/src/controllers/insight/query-summary/headless-insight-query-summary.ts index 2abe3b84c61..138ebbd815a 100644 --- a/packages/headless/src/controllers/insight/query-summary/headless-insight-query-summary.ts +++ b/packages/headless/src/controllers/insight/query-summary/headless-insight-query-summary.ts @@ -1,9 +1,9 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { buildCoreQuerySummary, QuerySummary, QuerySummaryState, -} from '../../core/query-summary/headless-core-query-summary'; +} from '../../core/query-summary/headless-core-query-summary.js'; export type {QuerySummary, QuerySummaryState}; /** diff --git a/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.test.ts b/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.test.ts index 38c373d54fd..6da7c8eb342 100644 --- a/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.test.ts +++ b/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.test.ts @@ -1,28 +1,28 @@ -import {HtmlRequestOptions} from '../../../api/search/html/html-request'; -import {configuration} from '../../../app/common-reducers'; -import {insightInterfaceReducer as insightInterface} from '../../../features/insight-interface/insight-interface-slice'; -import {buildInsightResultPreviewRequest} from '../../../features/insight-search/insight-result-preview-request-builder'; -import {logDocumentQuickview} from '../../../features/result-preview/result-preview-insight-analytics-actions'; -import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice'; -import {InsightAppState} from '../../../state/insight-app-state'; +import {HtmlRequestOptions} from '../../../api/search/html/html-request.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {insightInterfaceReducer as insightInterface} from '../../../features/insight-interface/insight-interface-slice.js'; +import {buildInsightResultPreviewRequest} from '../../../features/insight-search/insight-result-preview-request-builder.js'; +import {logDocumentQuickview} from '../../../features/result-preview/result-preview-insight-analytics-actions.js'; +import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildCoreQuickview} from '../../core/quickview/headless-core-quickview'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {buildCoreQuickview} from '../../core/quickview/headless-core-quickview.js'; import { buildQuickview, QuickviewOptions, Quickview, -} from './headless-insight-quickview'; +} from './headless-insight-quickview.js'; -jest.mock('../../core/quickview/headless-core-quickview'); -jest.mock( +vi.mock('../../core/quickview/headless-core-quickview'); +vi.mock( '../../../features/result-preview/result-preview-insight-analytics-actions' ); -jest.mock( +vi.mock( '../../../features/insight-search/insight-result-preview-request-builder' ); @@ -31,7 +31,7 @@ describe('Insight Quickview', () => { let state: InsightAppState; let options: QuickviewOptions; let quickview: Quickview; - const mockedBuildCoreQuickview = jest.mocked(buildCoreQuickview); + const mockedBuildCoreQuickview = vi.mocked(buildCoreQuickview); function initEngine(preloadedState = buildMockInsightState()) { state = preloadedState; engine = buildMockInsightEngine(preloadedState); @@ -42,7 +42,7 @@ describe('Insight Quickview', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); options = { result: buildMockResult(), maximumPreviewSize: 0, @@ -71,7 +71,7 @@ describe('Insight Quickview', () => { }); it('#buildResultPreviewRequest calls #buildInsightResultPreviewRequest and returns its results', () => { - const mockedBuildInsightResultPreviewRequest = jest.mocked( + const mockedBuildInsightResultPreviewRequest = vi.mocked( buildInsightResultPreviewRequest ); @@ -92,7 +92,7 @@ describe('Insight Quickview', () => { }); it('#fetchResultContentCallback logs a document quickview', () => { - const mockedLogDocumentQuickview = jest.mocked(logDocumentQuickview); + const mockedLogDocumentQuickview = vi.mocked(logDocumentQuickview); const coreQuickviewParamsFetchResultContentCallback = mockedBuildCoreQuickview.mock.calls[0][4]; diff --git a/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.ts b/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.ts index 4b8b1c77181..afb772cd9d1 100644 --- a/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.ts +++ b/packages/headless/src/controllers/insight/quickview/headless-insight-quickview.ts @@ -1,16 +1,16 @@ -import {Result} from '../../../api/search/search/result'; -import {configuration} from '../../../app/common-reducers'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {insightInterfaceReducer as insightInterface} from '../../../features/insight-interface/insight-interface-slice'; +import {Result} from '../../../api/search/search/result.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {insightInterfaceReducer as insightInterface} from '../../../features/insight-interface/insight-interface-slice.js'; import { buildInsightResultPreviewRequest, StateNeededByInsightHtmlEndpoint, -} from '../../../features/insight-search/insight-result-preview-request-builder'; -import {logDocumentQuickview} from '../../../features/result-preview/result-preview-insight-analytics-actions'; -import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice'; -import {loadReducerError} from '../../../utils/errors'; -import {Controller} from '../../controller/headless-controller'; -import {buildCoreQuickview} from '../../core/quickview/headless-core-quickview'; +} from '../../../features/insight-search/insight-result-preview-request-builder.js'; +import {logDocumentQuickview} from '../../../features/result-preview/result-preview-insight-analytics-actions.js'; +import {resultPreviewReducer as resultPreview} from '../../../features/result-preview/result-preview-slice.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {Controller} from '../../controller/headless-controller.js'; +import {buildCoreQuickview} from '../../core/quickview/headless-core-quickview.js'; export interface QuickviewProps { /** diff --git a/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.test.ts b/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.test.ts index a5bba92dfc7..a63dc7af151 100644 --- a/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.test.ts +++ b/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.test.ts @@ -1,20 +1,20 @@ -import {Result} from '../../../api/search/search/result'; -import {configuration} from '../../../app/common-reducers'; -import {pushRecentResult} from '../../../features/recent-results/recent-results-actions'; -import {logDocumentOpen} from '../../../features/result/result-insight-analytics-actions'; +import {Result} from '../../../api/search/search/result.js'; +import {configuration} from '../../../app/common-reducers.js'; +import {pushRecentResult} from '../../../features/recent-results/recent-results-actions.js'; +import {logDocumentOpen} from '../../../features/result/result-insight-analytics-actions.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockResult} from '../../../test/mock-result'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; import { buildInteractiveResult, InteractiveResult, -} from './headless-insight-interactive-result'; +} from './headless-insight-interactive-result.js'; -jest.mock('../../../features/result/result-insight-analytics-actions'); -jest.mock('../../../features/recent-results/recent-results-actions'); +vi.mock('../../../features/result/result-insight-analytics-actions'); +vi.mock('../../../features/recent-results/recent-results-actions'); describe('InsightInteractiveResult', () => { let engine: MockedInsightEngine; @@ -46,11 +46,11 @@ describe('InsightInteractiveResult', () => { beforeEach(() => { engine = buildMockInsightEngine(buildMockInsightState()); initializeInteractiveResult(); - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('it adds the correct reducers to engine', () => { @@ -59,7 +59,7 @@ describe('InsightInteractiveResult', () => { it('when calling select() should add the result to recent results list', () => { interactiveResult.select(); - jest.runAllTimers(); + vi.runAllTimers(); expect(pushRecentResult).toHaveBeenCalled(); }); diff --git a/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.ts b/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.ts index fb516d6a33e..c78c0f7fdaa 100644 --- a/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.ts +++ b/packages/headless/src/controllers/insight/result-list/headless-insight-interactive-result.ts @@ -1,13 +1,13 @@ -import {Result} from '../../../api/search/search/result'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {pushRecentResult} from '../../../features/recent-results/recent-results-actions'; -import {logDocumentOpen} from '../../../features/result/result-insight-analytics-actions'; +import {Result} from '../../../api/search/search/result.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {pushRecentResult} from '../../../features/recent-results/recent-results-actions.js'; +import {logDocumentOpen} from '../../../features/result/result-insight-analytics-actions.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from '../../core/interactive-result/headless-core-interactive-result'; +} from '../../core/interactive-result/headless-core-interactive-result.js'; export type { InteractiveResultCoreOptions, diff --git a/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.test.ts b/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.test.ts index 87f04b7272a..31443b15feb 100644 --- a/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.test.ts +++ b/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.test.ts @@ -1,13 +1,13 @@ -import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions'; +import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildResultList} from './headless-insight-result-list'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {buildResultList} from './headless-insight-result-list.js'; -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('InsightResultList', () => { let engine: MockedInsightEngine; @@ -17,11 +17,11 @@ describe('InsightResultList', () => { const results = new Array(10).fill(buildMockResult()); engine.state.search.results = results; engine.state.search.response.totalCountFiltered = 1000; - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('fetchMoreResults should dispatch a fetchMoreResults action', () => { diff --git a/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.ts b/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.ts index bc20677a40b..1fc2bbe3aff 100644 --- a/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.ts +++ b/packages/headless/src/controllers/insight/result-list/headless-insight-result-list.ts @@ -1,12 +1,12 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {fetchMoreResults} from '../../../features/insight-search/insight-search-actions.js'; import { buildCoreResultList, ResultList, ResultListOptions, ResultListProps, ResultListState, -} from '../../core/result-list/headless-core-result-list'; +} from '../../core/result-list/headless-core-result-list.js'; export type {ResultListOptions, ResultListProps, ResultListState, ResultList}; diff --git a/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.test.ts b/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.test.ts index c046fab31ec..ae0941a1673 100644 --- a/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.test.ts +++ b/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.test.ts @@ -1,18 +1,18 @@ -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {updateNumberOfResults} from '../../../features/pagination/pagination-actions'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {updateNumberOfResults} from '../../../features/pagination/pagination-actions.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; import { ResultsPerPage, ResultsPerPageProps, buildResultsPerPage, -} from './headless-insight-results-per-page'; +} from './headless-insight-results-per-page.js'; -jest.mock('../../../features/pagination/pagination-actions'); -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/pagination/pagination-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('InsightResultsPerPage', () => { let engine: MockedInsightEngine; diff --git a/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.ts b/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.ts index 0b971170232..9a08aab9685 100644 --- a/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.ts +++ b/packages/headless/src/controllers/insight/results-per-page/headless-insight-results-per-page.ts @@ -1,16 +1,16 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { logPagerResize, browseResults, -} from '../../../features/pagination/pagination-analytics-actions'; +} from '../../../features/pagination/pagination-analytics-actions.js'; import { ResultsPerPage, ResultsPerPageProps, ResultsPerPageInitialState, ResultsPerPageState, buildCoreResultsPerPage, -} from '../../core/results-per-page/headless-core-results-per-page'; +} from '../../core/results-per-page/headless-core-results-per-page.js'; export type { ResultsPerPage, diff --git a/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.test.ts b/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.test.ts index 0567a34fc61..091c0980296 100644 --- a/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.test.ts +++ b/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.test.ts @@ -1,26 +1,26 @@ import { executeSearch, fetchQuerySuggestions, -} from '../../../features/insight-search/insight-search-actions'; -import {InsightAppState} from '../../../state/insight-app-state'; +} from '../../../features/insight-search/insight-search-actions.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {buildMockQuerySuggest} from '../../../test/mock-query-suggest'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {buildMockQuerySuggest} from '../../../test/mock-query-suggest.js'; import { SearchBox, SearchBoxProps, SearchBoxOptions, buildSearchBox, -} from './headless-insight-search-box'; +} from './headless-insight-search-box.js'; -jest.mock('../../../features/query/query-insight-analytics-actions', () => ({ - logSearchboxSubmit: jest.fn(() => () => {}), +vi.mock('../../../features/query/query-insight-analytics-actions', () => ({ + logSearchboxSubmit: vi.fn(() => () => {}), })); -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('headless searchBox', () => { const id = 'search-box-123'; @@ -31,7 +31,7 @@ describe('headless searchBox', () => { let props: SearchBoxProps; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); const options: SearchBoxOptions = { id, numberOfSuggestions: 10, diff --git a/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.ts b/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.ts index 07f3a705ab7..4e704f09bcf 100644 --- a/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.ts +++ b/packages/headless/src/controllers/insight/search-box/headless-insight-search-box.ts @@ -1,19 +1,19 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { executeSearch, fetchQuerySuggestions, -} from '../../../features/insight-search/insight-search-actions'; -import {searchboxSubmit} from '../../../features/query/query-analytics-actions'; -import {logSearchboxSubmit} from '../../../features/query/query-insight-analytics-actions'; -import {Controller} from '../../controller/headless-controller'; +} from '../../../features/insight-search/insight-search-actions.js'; +import {searchboxSubmit} from '../../../features/query/query-analytics-actions.js'; +import {logSearchboxSubmit} from '../../../features/query/query-insight-analytics-actions.js'; +import {Controller} from '../../controller/headless-controller.js'; +import {SearchBoxOptions} from '../../core/search-box/headless-core-search-box-options.js'; import { buildCoreSearchBox, Delimiters, SearchBoxState, Suggestion, SuggestionHighlightingOptions, -} from '../../core/search-box/headless-core-search-box'; -import {SearchBoxOptions} from '../../core/search-box/headless-core-search-box-options'; +} from '../../core/search-box/headless-core-search-box.js'; export type { SearchBoxOptions, diff --git a/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.test.ts b/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.test.ts index 4a732b76df5..f1ac6fde163 100644 --- a/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.test.ts +++ b/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.test.ts @@ -1,22 +1,22 @@ -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {restoreSearchParameters} from '../../../features/search-parameters/search-parameter-actions'; -import {initialSearchParameterSelector} from '../../../features/search-parameters/search-parameter-selectors'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {restoreSearchParameters} from '../../../features/search-parameters/search-parameter-actions.js'; +import {initialSearchParameterSelector} from '../../../features/search-parameters/search-parameter-selectors.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; import { buildSearchParameterManager, SearchParameterManager, SearchParameterManagerProps, -} from './headless-insight-search-parameter-manager'; +} from './headless-insight-search-parameter-manager.js'; -jest.mock('../../../features/search-parameters/search-parameter-actions'); -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/search-parameters/search-parameter-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('insight search parameter manager', () => { let engine: MockedInsightEngine; @@ -28,7 +28,7 @@ describe('insight search parameter manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockInsightEngine(buildMockInsightState()); props = { initialState: { diff --git a/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.ts b/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.ts index 9ad33c7afe1..f652c3e5d5f 100644 --- a/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.ts +++ b/packages/headless/src/controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.ts @@ -1,9 +1,9 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {SearchParameters} from '../../../features/search-parameters/search-parameter-actions'; -import {parametersChange} from '../../../features/search-parameters/search-parameter-analytics-actions'; -import {logParametersChange} from '../../../features/search-parameters/search-parameter-insight-analytics-actions'; -import {deepEqualAnyOrder} from '../../../utils/compare-utils'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {SearchParameters} from '../../../features/search-parameters/search-parameter-actions.js'; +import {parametersChange} from '../../../features/search-parameters/search-parameter-analytics-actions.js'; +import {logParametersChange} from '../../../features/search-parameters/search-parameter-insight-analytics-actions.js'; +import {deepEqualAnyOrder} from '../../../utils/compare-utils.js'; import { buildCoreSearchParameterManager, enrichParameters, @@ -12,7 +12,7 @@ import { SearchParameterManagerInitialState, SearchParameterManagerProps, SearchParameterManagerState, -} from '../../core/search-parameter-manager/headless-core-search-parameter-manager'; +} from '../../core/search-parameter-manager/headless-core-search-parameter-manager.js'; export type { SearchParameters, diff --git a/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-interactive-questions.ts b/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-interactive-questions.ts index 12c924c5efb..4bddfa691ee 100644 --- a/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-interactive-questions.ts +++ b/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-interactive-questions.ts @@ -1,22 +1,22 @@ -import {Result} from '../../../api/search/search/result'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {logOpenSmartSnippetSuggestionSource} from '../../../features/question-answering/question-answering-insight-analytics-actions'; +import {Result} from '../../../api/search/search/result.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {logOpenSmartSnippetSuggestionSource} from '../../../features/question-answering/question-answering-insight-analytics-actions.js'; import { answerSourceSelector, relatedQuestionSelector, -} from '../../../features/question-answering/question-answering-selectors'; -import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice'; -import {pushRecentResult} from '../../../features/recent-results/recent-results-actions'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/question-answering/question-answering-selectors.js'; +import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice.js'; +import {pushRecentResult} from '../../../features/recent-results/recent-results-actions.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { QuestionAnsweringSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildInteractiveResultCore, InteractiveResultCore, -} from '../../core/interactive-result/headless-core-interactive-result'; +} from '../../core/interactive-result/headless-core-interactive-result.js'; /** * @internal diff --git a/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list.ts b/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list.ts index 8c750ab1307..1b7dffa7fa3 100644 --- a/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list.ts +++ b/packages/headless/src/controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list.ts @@ -1,23 +1,23 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {insightSmartSnippetAnalyticsClient} from '../../../features/question-answering/question-answering-insight-analytics-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {insightSmartSnippetAnalyticsClient} from '../../../features/question-answering/question-answering-insight-analytics-actions.js'; import { buildCoreSmartSnippetQuestionsList, CoreSmartSnippetQuestionsList, SmartSnippetQuestionsListProps, CoreSmartSnippetQuestionsListState, -} from '../../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list'; -import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links'; -import {buildSmartSnippetInteractiveInlineLinks} from '../smart-snippet/headless-insight-smart-snippet-interactive-inline-links'; -import {buildInsightSmartSnippetInteractiveQuestions} from './headless-insight-smart-snippet-interactive-questions'; +} from '../../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.js'; +import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links.js'; +import {buildSmartSnippetInteractiveInlineLinks} from '../smart-snippet/headless-insight-smart-snippet-interactive-inline-links.js'; +import {buildInsightSmartSnippetInteractiveQuestions} from './headless-insight-smart-snippet-interactive-questions.js'; -export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering'; +export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering.js'; export type { SmartSnippetQuestionsListOptions, SmartSnippetQuestionsListProps, CoreSmartSnippetQuestionsListState, SmartSnippetRelatedQuestion, CoreSmartSnippetQuestionsList, -} from '../../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list'; +} from '../../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.js'; /** * A scoped and simplified part of the headless state that is relevant to the `SmartSnippetQuestionsList` controller. diff --git a/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet-interactive-inline-links.ts b/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet-interactive-inline-links.ts index 05e08ac9e89..e23d26f938f 100644 --- a/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet-interactive-inline-links.ts +++ b/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet-interactive-inline-links.ts @@ -1,21 +1,21 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { logOpenSmartSnippetInlineLink, logOpenSmartSnippetSuggestionInlineLink, -} from '../../../features/question-answering/question-answering-insight-analytics-actions'; -import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice'; -import {searchReducer as search} from '../../../features/search/search-slice'; +} from '../../../features/question-answering/question-answering-insight-analytics-actions.js'; +import {questionAnsweringReducer as questionAnswering} from '../../../features/question-answering/question-answering-slice.js'; +import {searchReducer as search} from '../../../features/search/search-slice.js'; import { QuestionAnsweringSection, SearchSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; -import {getObjectHash} from '../../../utils/utils'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; +import {getObjectHash} from '../../../utils/utils.js'; import { buildInteractiveResultCore, InteractiveResultCore, -} from '../../core/interactive-result/headless-core-interactive-result'; -import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links'; +} from '../../core/interactive-result/headless-core-interactive-result.js'; +import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links.js'; export interface SmartSnippetInteractiveInlineLinksOptions { /** diff --git a/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet.ts b/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet.ts index e5b3b04d6c4..d0c5427726b 100644 --- a/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet.ts +++ b/packages/headless/src/controllers/insight/smart-snippet/headless-insight-smart-snippet.ts @@ -1,21 +1,21 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {insightSmartSnippetAnalyticsClient} from '../../../features/question-answering/question-answering-insight-analytics-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {insightSmartSnippetAnalyticsClient} from '../../../features/question-answering/question-answering-insight-analytics-actions.js'; import { SmartSnippet, SmartSnippetProps, buildCoreSmartSnippet, -} from '../../core/smart-snippet/headless-core-smart-snippet'; -import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links'; -import {buildSmartSnippetInteractiveInlineLinks} from './headless-insight-smart-snippet-interactive-inline-links'; +} from '../../core/smart-snippet/headless-core-smart-snippet.js'; +import {InlineLink} from '../../smart-snippet/headless-smart-snippet-interactive-inline-links.js'; +import {buildSmartSnippetInteractiveInlineLinks} from './headless-insight-smart-snippet-interactive-inline-links.js'; -export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering'; +export type {QuestionAnswerDocumentIdentifier} from '../../../api/search/search/question-answering.js'; export type { SmartSnippetOptions, SmartSnippetProps, SmartSnippetState, SmartSnippet, SmartSnippetCore, -} from '../../core/smart-snippet/headless-core-smart-snippet'; +} from '../../core/smart-snippet/headless-core-smart-snippet.js'; export type {InlineLink}; /** diff --git a/packages/headless/src/controllers/insight/sort/headless-insight-sort.test.ts b/packages/headless/src/controllers/insight/sort/headless-insight-sort.test.ts index b195f219327..fa92bff86a3 100644 --- a/packages/headless/src/controllers/insight/sort/headless-insight-sort.test.ts +++ b/packages/headless/src/controllers/insight/sort/headless-insight-sort.test.ts @@ -1,18 +1,18 @@ -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { buildDateSortCriterion, SortOrder, -} from '../../../features/sort-criteria/criteria'; -import {updateSortCriterion} from '../../../features/sort-criteria/sort-criteria-actions'; +} from '../../../features/sort-criteria/criteria.js'; +import {updateSortCriterion} from '../../../features/sort-criteria/sort-criteria-actions.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {Sort, SortProps, buildSort} from './headless-insight-sort'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {Sort, SortProps, buildSort} from './headless-insight-sort.js'; -jest.mock('../../../features/sort-criteria/sort-criteria-actions'); -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/sort-criteria/sort-criteria-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('InsightSort', () => { let engine: MockedInsightEngine; diff --git a/packages/headless/src/controllers/insight/sort/headless-insight-sort.ts b/packages/headless/src/controllers/insight/sort/headless-insight-sort.ts index 0165007fe52..59b50878c7c 100644 --- a/packages/headless/src/controllers/insight/sort/headless-insight-sort.ts +++ b/packages/headless/src/controllers/insight/sort/headless-insight-sort.ts @@ -1,15 +1,15 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {SortCriterion} from '../../../features/sort-criteria/criteria'; -import {resultsSort} from '../../../features/sort-criteria/sort-criteria-analytics-actions'; -import {logResultsSort} from '../../../features/sort-criteria/sort-criteria-insight-analytics-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {SortCriterion} from '../../../features/sort-criteria/criteria.js'; +import {resultsSort} from '../../../features/sort-criteria/sort-criteria-analytics-actions.js'; +import {logResultsSort} from '../../../features/sort-criteria/sort-criteria-insight-analytics-actions.js'; import { buildCoreSort, Sort, SortProps, SortState, SortInitialState, -} from '../../core/sort/headless-core-sort'; +} from '../../core/sort/headless-core-sort.js'; export type {Sort, SortProps, SortState, SortInitialState}; diff --git a/packages/headless/src/controllers/insight/status/headless-insight-status.ts b/packages/headless/src/controllers/insight/status/headless-insight-status.ts index 03e72d59071..8995669f4ef 100644 --- a/packages/headless/src/controllers/insight/status/headless-insight-status.ts +++ b/packages/headless/src/controllers/insight/status/headless-insight-status.ts @@ -1,9 +1,9 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; import { SearchStatusState, buildCoreStatus, SearchStatus, -} from '../../core/status/headless-core-status'; +} from '../../core/status/headless-core-status.js'; export type {SearchStatus, SearchStatusState}; diff --git a/packages/headless/src/controllers/insight/tab/headless-insight-tab.test.ts b/packages/headless/src/controllers/insight/tab/headless-insight-tab.test.ts index 34c6b8ac5d9..1a3a63ea05e 100644 --- a/packages/headless/src/controllers/insight/tab/headless-insight-tab.test.ts +++ b/packages/headless/src/controllers/insight/tab/headless-insight-tab.test.ts @@ -1,17 +1,17 @@ -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; import { buildTab, Tab, TabInitialState, TabOptions, -} from './headless-insight-tab'; +} from './headless-insight-tab.js'; -jest.mock('../../../features/insight-search/insight-search-actions'); +vi.mock('../../../features/insight-search/insight-search-actions'); describe('insight Tab', () => { let engine: MockedInsightEngine; diff --git a/packages/headless/src/controllers/insight/tab/headless-insight-tab.ts b/packages/headless/src/controllers/insight/tab/headless-insight-tab.ts index 7a9349e7ff9..53d8d85a7f5 100644 --- a/packages/headless/src/controllers/insight/tab/headless-insight-tab.ts +++ b/packages/headless/src/controllers/insight/tab/headless-insight-tab.ts @@ -1,7 +1,7 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {interfaceChange} from '../../../features/analytics/analytics-actions'; -import {executeSearch} from '../../../features/insight-search/insight-search-actions'; -import {logInsightInterfaceChange} from '../../../features/insight-search/insight-search-analytics-actions'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {interfaceChange} from '../../../features/analytics/analytics-actions.js'; +import {executeSearch} from '../../../features/insight-search/insight-search-actions.js'; +import {logInsightInterfaceChange} from '../../../features/insight-search/insight-search-analytics-actions.js'; import { buildCoreTab, Tab, @@ -9,7 +9,7 @@ import { TabState, TabInitialState, TabOptions, -} from '../../core/tab/headless-core-tab'; +} from '../../core/tab/headless-core-tab.js'; export type {Tab, TabProps, TabState, TabInitialState, TabOptions}; diff --git a/packages/headless/src/controllers/insight/user-actions/headless-user-actions.test.ts b/packages/headless/src/controllers/insight/user-actions/headless-user-actions.test.ts index 6ad8cdcce66..02d36a17aa8 100644 --- a/packages/headless/src/controllers/insight/user-actions/headless-user-actions.test.ts +++ b/packages/headless/src/controllers/insight/user-actions/headless-user-actions.test.ts @@ -1,26 +1,24 @@ -import {configuration} from '../../../app/common-reducers'; -import {logOpenUserActions} from '../../../features/insight-search/insight-analytics-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {logOpenUserActions} from '../../../features/insight-search/insight-analytics-actions.js'; import { fetchUserActions, registerUserActions, -} from '../../../features/insight-user-actions/insight-user-actions-actions'; -import {insightUserActionsReducer} from '../../../features/insight-user-actions/insight-user-actions-slice'; +} from '../../../features/insight-user-actions/insight-user-actions-actions.js'; +import {insightUserActionsReducer} from '../../../features/insight-user-actions/insight-user-actions-slice.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; import { UserActions, UserActionsOptions, buildUserActions, -} from './headless-user-actions'; +} from './headless-user-actions.js'; -jest.mock( - '../../../features/insight-user-actions/insight-user-actions-actions' -); +vi.mock('../../../features/insight-user-actions/insight-user-actions-actions'); -jest.mock('../../../features/insight-search/insight-analytics-actions'); +vi.mock('../../../features/insight-search/insight-analytics-actions'); describe('UserActions', () => { let engine: MockedInsightEngine; diff --git a/packages/headless/src/controllers/insight/user-actions/headless-user-actions.ts b/packages/headless/src/controllers/insight/user-actions/headless-user-actions.ts index 244a890ceed..c49baaaa93a 100644 --- a/packages/headless/src/controllers/insight/user-actions/headless-user-actions.ts +++ b/packages/headless/src/controllers/insight/user-actions/headless-user-actions.ts @@ -1,27 +1,27 @@ -import {configuration} from '../../../app/common-reducers'; -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {logOpenUserActions} from '../../../features/insight-search/insight-analytics-actions'; +import {configuration} from '../../../app/common-reducers.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {logOpenUserActions} from '../../../features/insight-search/insight-analytics-actions.js'; import { fetchUserActions, registerUserActions, -} from '../../../features/insight-user-actions/insight-user-actions-actions'; -import {insightUserActionsReducer} from '../../../features/insight-user-actions/insight-user-actions-slice'; -import {UserActionsState} from '../../../features/insight-user-actions/insight-user-actions-state'; +} from '../../../features/insight-user-actions/insight-user-actions-actions.js'; +import {insightUserActionsReducer} from '../../../features/insight-user-actions/insight-user-actions-slice.js'; +import {UserActionsState} from '../../../features/insight-user-actions/insight-user-actions-state.js'; import { ConfigurationSection, InsightUserActionsSection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildController, Controller, -} from '../../controller/headless-controller'; +} from '../../controller/headless-controller.js'; export type { UserActionsState, UserAction, UserSession, -} from '../../../features/insight-user-actions/insight-user-actions-state'; +} from '../../../features/insight-user-actions/insight-user-actions-state.js'; export interface UserActionsProps { /** diff --git a/packages/headless/src/controllers/instant-results/headless-interactive-instant-result.ts b/packages/headless/src/controllers/instant-results/headless-interactive-instant-result.ts index 468f5a05140..9e1c95e9acc 100644 --- a/packages/headless/src/controllers/instant-results/headless-interactive-instant-result.ts +++ b/packages/headless/src/controllers/instant-results/headless-interactive-instant-result.ts @@ -1,14 +1,14 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logInstantResultOpen} from '../../features/instant-results/instant-result-analytics-actions'; -import {pushRecentResult} from '../../features/recent-results/recent-results-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logInstantResultOpen} from '../../features/instant-results/instant-result-analytics-actions.js'; +import {pushRecentResult} from '../../features/recent-results/recent-results-actions.js'; import { buildInteractiveResultCore, InteractiveResultCoreProps, -} from '../core/interactive-result/headless-core-interactive-result'; +} from '../core/interactive-result/headless-core-interactive-result.js'; import { InteractiveResult, InteractiveResultOptions, -} from '../result-list/headless-interactive-result'; +} from '../result-list/headless-interactive-result.js'; export interface InteractiveInstantResultOptions extends InteractiveResultOptions {} diff --git a/packages/headless/src/controllers/instant-results/instant-results-options.ts b/packages/headless/src/controllers/instant-results/instant-results-options.ts index c88880aaa93..3b8c51c5f47 100644 --- a/packages/headless/src/controllers/instant-results/instant-results-options.ts +++ b/packages/headless/src/controllers/instant-results/instant-results-options.ts @@ -1,5 +1,5 @@ import {NumberValue, Schema} from '@coveo/bueno'; -import {nonEmptyString} from '../../utils/validate-payload'; +import {nonEmptyString} from '../../utils/validate-payload.js'; export interface InstantResultOptions { /** diff --git a/packages/headless/src/controllers/instant-results/instant-results.ssr.ts b/packages/headless/src/controllers/instant-results/instant-results.ssr.ts index 93aa2539cab..814137a8882 100644 --- a/packages/headless/src/controllers/instant-results/instant-results.ssr.ts +++ b/packages/headless/src/controllers/instant-results/instant-results.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { InstantResultProps, InstantResults, buildInstantResults, -} from './instant-results'; +} from './instant-results.js'; -export * from './instant-results'; +export * from './instant-results.js'; export interface InstantResultsDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/instant-results/instant-results.test.ts b/packages/headless/src/controllers/instant-results/instant-results.test.ts index 9f113f4b6f0..ee6b7086c91 100644 --- a/packages/headless/src/controllers/instant-results/instant-results.test.ts +++ b/packages/headless/src/controllers/instant-results/instant-results.test.ts @@ -1,21 +1,21 @@ -import {registerInstantResults} from '../../features/instant-results/instant-results-actions'; -import {instantResultsReducer as instantResults} from '../../features/instant-results/instant-results-slice'; -import {SearchAppState} from '../../state/search-app-state'; +import {registerInstantResults} from '../../features/instant-results/instant-results-actions.js'; +import {instantResultsReducer as instantResults} from '../../features/instant-results/instant-results-slice.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildInstantResults} from './instant-results'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildInstantResults} from './instant-results.js'; -jest.mock('../../features/instant-results/instant-results-actions'); +vi.mock('../../features/instant-results/instant-results-actions'); describe('instant results', () => { let engine: MockedSearchEngine; let state: SearchAppState; beforeEach(() => { - jest.useFakeTimers(); + vi.useFakeTimers(); state = createMockState(); engine = buildMockSearchEngine(state); }); diff --git a/packages/headless/src/controllers/instant-results/instant-results.ts b/packages/headless/src/controllers/instant-results/instant-results.ts index 416faa9c600..95b17268b7b 100644 --- a/packages/headless/src/controllers/instant-results/instant-results.ts +++ b/packages/headless/src/controllers/instant-results/instant-results.ts @@ -1,26 +1,29 @@ import {SerializedError} from '@reduxjs/toolkit'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {hasExpired} from '../../features/instant-items/instant-items-state'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {hasExpired} from '../../features/instant-items/instant-items-state.js'; import { clearExpiredResults, registerInstantResults, updateInstantResultsQuery, -} from '../../features/instant-results/instant-results-actions'; -import {instantResultsReducer as instantResults} from '../../features/instant-results/instant-results-slice'; -import {fetchInstantResults} from '../../features/search/search-actions'; -import {InstantResultSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {randomID} from '../../utils/utils'; -import {validateOptions} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../features/instant-results/instant-results-actions.js'; +import {instantResultsReducer as instantResults} from '../../features/instant-results/instant-results-slice.js'; +import {fetchInstantResults} from '../../features/search/search-actions.js'; +import {InstantResultSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {randomID} from '../../utils/utils.js'; +import {validateOptions} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; import { InstantResultOptions, instantResultsOptionsSchema, -} from './instant-results-options'; +} from './instant-results-options.js'; -export type {InstantResultOptions} from './instant-results-options'; +export type {InstantResultOptions} from './instant-results-options.js'; export interface InstantResultProps { options: InstantResultOptions; diff --git a/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.test.ts b/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.test.ts index 05531dbe010..fb7a584a334 100644 --- a/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.test.ts +++ b/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.test.ts @@ -1,53 +1,53 @@ -import {answerEvaluation} from '../../../api/knowledge/post-answer-evaluation'; +import {answerEvaluation} from '../../../api/knowledge/post-answer-evaluation.js'; import { answerApi, fetchAnswer, StateNeededByAnswerAPI, -} from '../../../api/knowledge/stream-answer-api'; +} from '../../../api/knowledge/stream-answer-api.js'; import { resetAnswer, updateAnswerConfigurationId, updateResponseFormat, -} from '../../../features/generated-answer/generated-answer-actions'; +} from '../../../features/generated-answer/generated-answer-actions.js'; import { generatedAnswerAnalyticsClient, GeneratedAnswerFeedback, -} from '../../../features/generated-answer/generated-answer-analytics-actions'; -import {getGeneratedAnswerInitialState} from '../../../features/generated-answer/generated-answer-state'; -import {queryReducer} from '../../../features/query/query-slice'; +} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; +import {getGeneratedAnswerInitialState} from '../../../features/generated-answer/generated-answer-state.js'; +import {queryReducer} from '../../../features/query/query-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; import { GeneratedAnswerProps, GeneratedResponseFormat, -} from '../../generated-answer/headless-generated-answer'; -import {buildAnswerApiGeneratedAnswer} from './headless-answerapi-generated-answer'; +} from '../../generated-answer/headless-generated-answer.js'; +import {buildAnswerApiGeneratedAnswer} from './headless-answerapi-generated-answer.js'; -jest.mock('../../../features/generated-answer/generated-answer-actions'); -jest.mock( +vi.mock('../../../features/generated-answer/generated-answer-actions'); +vi.mock( '../../../features/generated-answer/generated-answer-analytics-actions' ); -jest.mock('../../../features/search/search-actions'); -jest.mock('../../../api/knowledge/stream-answer-api', () => { - const originalStreamAnswerApi = jest.requireActual( +vi.mock('../../../features/search/search-actions'); +vi.mock('../../../api/knowledge/stream-answer-api', async () => { + const originalStreamAnswerApi = await vi.importActual( '../../../api/knowledge/stream-answer-api' ); return { ...originalStreamAnswerApi, - fetchAnswer: jest.fn(), + fetchAnswer: vi.fn(), selectAnswer: () => ({ data: {answer: 'This est une answer', answerId: '12345_6'}, }), }; }); -jest.mock('../../../api/knowledge/post-answer-evaluation', () => ({ +vi.mock('../../../api/knowledge/post-answer-evaluation', () => ({ answerEvaluation: { endpoints: { post: { - initiate: jest.fn(), + initiate: vi.fn(), }, }, }, @@ -80,7 +80,7 @@ describe('knowledge-generated-answer', () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); engine = buildEngineWithGeneratedAnswer(); }); diff --git a/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.ts b/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.ts index cf39eed3ff5..54bae540828 100644 --- a/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.ts +++ b/packages/headless/src/controllers/knowledge/generated-answer/headless-answerapi-generated-answer.ts @@ -1,7 +1,7 @@ import { answerEvaluation, AnswerEvaluationPOSTParams, -} from '../../../api/knowledge/post-answer-evaluation'; +} from '../../../api/knowledge/post-answer-evaluation.js'; import { answerApi, fetchAnswer, @@ -9,26 +9,27 @@ import { selectAnswer, selectAnswerTriggerParams, StateNeededByAnswerAPI, -} from '../../../api/knowledge/stream-answer-api'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; +} from '../../../api/knowledge/stream-answer-api.js'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; import { resetAnswer, sendGeneratedAnswerFeedback, updateAnswerConfigurationId, -} from '../../../features/generated-answer/generated-answer-actions'; -import {GeneratedAnswerFeedback} from '../../../features/generated-answer/generated-answer-analytics-actions'; -import {queryReducer as query} from '../../../features/query/query-slice'; +} from '../../../features/generated-answer/generated-answer-actions.js'; +import {GeneratedAnswerFeedback} from '../../../features/generated-answer/generated-answer-analytics-actions.js'; +import {queryReducer as query} from '../../../features/query/query-slice.js'; import { GeneratedAnswerSection, QuerySection, -} from '../../../state/state-sections'; -import {loadReducerError} from '../../../utils/errors'; +} from '../../../state/state-sections.js'; +import {loadReducerError} from '../../../utils/errors.js'; import { buildCoreGeneratedAnswer, GeneratedAnswer, GeneratedAnswerAnalyticsClient, GeneratedAnswerProps, -} from '../../core/generated-answer/headless-core-generated-answer'; +} from '../../core/generated-answer/headless-core-generated-answer.js'; export interface AnswerApiGeneratedAnswer extends Omit { @@ -119,7 +120,7 @@ const subscribeToSearchRequest = ( * @returns A `AnswerApiGeneratedAnswer` controller instance. */ export function buildAnswerApiGeneratedAnswer( - engine: SearchEngine, + engine: SearchEngine | InsightEngine, analyticsClient: SearchAPIGeneratedAnswerAnalyticsClient, props: AnswerApiGeneratedAnswerProps = {} ): AnswerApiGeneratedAnswer { @@ -175,7 +176,7 @@ export function buildAnswerApiGeneratedAnswer( } function loadAnswerApiReducers( - engine: SearchEngine + engine: SearchEngine | InsightEngine ): engine is SearchEngine< GeneratedAnswerSection & QuerySection & {answer: ReturnType} diff --git a/packages/headless/src/controllers/pager/headless-pager.ssr.ts b/packages/headless/src/controllers/pager/headless-pager.ssr.ts index 8b56236bc3d..541d426d464 100644 --- a/packages/headless/src/controllers/pager/headless-pager.ssr.ts +++ b/packages/headless/src/controllers/pager/headless-pager.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {Pager, PagerProps, buildPager} from './headless-pager'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {Pager, PagerProps, buildPager} from './headless-pager.js'; -export * from './headless-pager'; +export * from './headless-pager.js'; export interface PagerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/pager/headless-pager.test.ts b/packages/headless/src/controllers/pager/headless-pager.test.ts index 13f42aee9f7..987aa9afb50 100644 --- a/packages/headless/src/controllers/pager/headless-pager.test.ts +++ b/packages/headless/src/controllers/pager/headless-pager.test.ts @@ -1,18 +1,18 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import {fetchPage} from '../../features/search/search-actions'; +import {fetchPage} from '../../features/search/search-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; import { Pager, PagerOptions, PagerInitialState, buildPager, -} from './headless-pager'; +} from './headless-pager.js'; -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/search/search-actions'); describe('Pager', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/pager/headless-pager.ts b/packages/headless/src/controllers/pager/headless-pager.ts index cb2f7015076..46eba73e368 100644 --- a/packages/headless/src/controllers/pager/headless-pager.ts +++ b/packages/headless/src/controllers/pager/headless-pager.ts @@ -1,11 +1,11 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { logPageNumber, logPageNext, logPagePrevious, browseResults, -} from '../../features/pagination/pagination-analytics-actions'; -import {fetchPage} from '../../features/search/search-actions'; +} from '../../features/pagination/pagination-analytics-actions.js'; +import {fetchPage} from '../../features/search/search-actions.js'; import { buildCorePager, PagerInitialState, @@ -13,7 +13,7 @@ import { PagerProps, Pager, PagerState, -} from '../core/pager/headless-core-pager'; +} from '../core/pager/headless-core-pager.js'; export type {PagerInitialState, PagerOptions, PagerProps, Pager, PagerState}; diff --git a/packages/headless/src/controllers/query-error/headless-query-error.ssr.ts b/packages/headless/src/controllers/query-error/headless-query-error.ssr.ts index 401d88a028c..a071ae6eda6 100644 --- a/packages/headless/src/controllers/query-error/headless-query-error.ssr.ts +++ b/packages/headless/src/controllers/query-error/headless-query-error.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {QueryError, buildQueryError} from './headless-query-error'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {QueryError, buildQueryError} from './headless-query-error.js'; -export * from './headless-query-error'; +export * from './headless-query-error.js'; export interface QueryErrorDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/query-error/headless-query-error.test.ts b/packages/headless/src/controllers/query-error/headless-query-error.test.ts index a5238760cf9..b2bbf16227f 100644 --- a/packages/headless/src/controllers/query-error/headless-query-error.test.ts +++ b/packages/headless/src/controllers/query-error/headless-query-error.test.ts @@ -1,7 +1,7 @@ -import {searchReducer as search} from '../../features/search/search-slice'; -import {buildMockSearchEngine} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildQueryError} from './headless-query-error'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {buildMockSearchEngine} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildQueryError} from './headless-query-error.js'; describe('query error', () => { it('it adds the correct reducers to engine', () => { diff --git a/packages/headless/src/controllers/query-error/headless-query-error.ts b/packages/headless/src/controllers/query-error/headless-query-error.ts index 4c2a5c867e1..73a2b4bf3d9 100644 --- a/packages/headless/src/controllers/query-error/headless-query-error.ts +++ b/packages/headless/src/controllers/query-error/headless-query-error.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { buildCoreQueryError, QueryError, QueryErrorState, -} from '../core/query-error/headless-core-query-error'; +} from '../core/query-error/headless-core-query-error.js'; export type {QueryError, QueryErrorState}; diff --git a/packages/headless/src/controllers/query-summary/headless-query-summary.ssr.ts b/packages/headless/src/controllers/query-summary/headless-query-summary.ssr.ts index 0d0237e5780..bd2369b2edb 100644 --- a/packages/headless/src/controllers/query-summary/headless-query-summary.ssr.ts +++ b/packages/headless/src/controllers/query-summary/headless-query-summary.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {QuerySummary, buildQuerySummary} from './headless-query-summary'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {QuerySummary, buildQuerySummary} from './headless-query-summary.js'; -export * from './headless-query-summary'; +export * from './headless-query-summary.js'; export interface QuerySummaryDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/query-summary/headless-query-summary.ts b/packages/headless/src/controllers/query-summary/headless-query-summary.ts index 6624283bd57..6acc211abac 100644 --- a/packages/headless/src/controllers/query-summary/headless-query-summary.ts +++ b/packages/headless/src/controllers/query-summary/headless-query-summary.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { buildCoreQuerySummary, QuerySummary, QuerySummaryState, -} from '../core/query-summary/headless-core-query-summary'; +} from '../core/query-summary/headless-core-query-summary.js'; export type {QuerySummary, QuerySummaryState}; /** diff --git a/packages/headless/src/controllers/quickview/case-assist-headless-quickview.test.ts b/packages/headless/src/controllers/quickview/case-assist-headless-quickview.test.ts index 1ba7ffe2a5a..6da68d4777c 100644 --- a/packages/headless/src/controllers/quickview/case-assist-headless-quickview.test.ts +++ b/packages/headless/src/controllers/quickview/case-assist-headless-quickview.test.ts @@ -1,33 +1,34 @@ -import {logQuickviewDocumentSuggestionClick} from '../../features/case-assist/case-assist-analytics-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; -import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions'; -import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder'; -import {CaseAssistAppState} from '../../state/case-assist-app-state'; -import {buildMockDocumentSuggestion} from '../../test/mock-case-assist-document-suggestion'; -import {buildMockCaseAssistState} from '../../test/mock-case-assist-state'; +import {Mock} from 'vitest'; +import {logQuickviewDocumentSuggestionClick} from '../../features/case-assist/case-assist-analytics-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; +import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions.js'; +import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder.js'; +import {CaseAssistAppState} from '../../state/case-assist-app-state.js'; +import {buildMockDocumentSuggestion} from '../../test/mock-case-assist-document-suggestion.js'; +import {buildMockCaseAssistState} from '../../test/mock-case-assist-state.js'; import { buildMockCaseAssistEngine, MockedCaseAssistEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {buildCoreQuickview} from '../core/quickview/headless-core-quickview'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildCoreQuickview} from '../core/quickview/headless-core-quickview.js'; import { buildCaseAssistQuickview, CaseAssistQuickviewOptions, CaseAssistQuickview, -} from './case-assist-headless-quickview'; -import {CoreQuickviewState} from './headless-quickview'; +} from './case-assist-headless-quickview.js'; +import {CoreQuickviewState} from './headless-quickview.js'; -jest.mock('../core/quickview/headless-core-quickview'); -jest.mock('../../features/result-preview/result-preview-actions'); -jest.mock('../../features/case-assist/case-assist-analytics-actions'); +vi.mock('../core/quickview/headless-core-quickview'); +vi.mock('../../features/result-preview/result-preview-actions'); +vi.mock('../../features/case-assist/case-assist-analytics-actions'); describe('CaseAssistQuickview', () => { let engine: MockedCaseAssistEngine; let options: CaseAssistQuickviewOptions; let quickview: CaseAssistQuickview; let engineState: CaseAssistAppState; - let mockedBuildCoreQuickview: jest.Mock; + let mockedBuildCoreQuickview: Mock; let coreQuickviewState: Partial; const testUniqueId = 'testUniqueId'; @@ -43,8 +44,8 @@ describe('CaseAssistQuickview', () => { beforeEach(() => { coreQuickviewState = {}; - jest.resetAllMocks(); - mockedBuildCoreQuickview = jest.mocked(buildCoreQuickview); + vi.resetAllMocks(); + mockedBuildCoreQuickview = vi.mocked(buildCoreQuickview); mockedBuildCoreQuickview.mockImplementation(() => ({ state: coreQuickviewState, })); @@ -73,9 +74,7 @@ describe('CaseAssistQuickview', () => { }); it('dispatches a #preparePreviewPagination on initialization', () => { - const mockedPreparePreviewPagination = jest.mocked( - preparePreviewPagination - ); + const mockedPreparePreviewPagination = vi.mocked(preparePreviewPagination); expect(mockedPreparePreviewPagination).toHaveBeenCalledWith({ results: engineState.documentSuggestion.documents, @@ -117,7 +116,7 @@ describe('CaseAssistQuickview', () => { }); it('#fetchResultContentCallback dispatches a #logQuickviewDocumentSuggestionClick with the proper uniqueId', () => { - const mockedLogQuickviewDocumentSuggestionClick = jest.mocked( + const mockedLogQuickviewDocumentSuggestionClick = vi.mocked( logQuickviewDocumentSuggestionClick ); diff --git a/packages/headless/src/controllers/quickview/case-assist-headless-quickview.ts b/packages/headless/src/controllers/quickview/case-assist-headless-quickview.ts index 5f810b73792..333b062cb39 100644 --- a/packages/headless/src/controllers/quickview/case-assist-headless-quickview.ts +++ b/packages/headless/src/controllers/quickview/case-assist-headless-quickview.ts @@ -1,20 +1,20 @@ -import {CaseAssistAPIClient} from '../../api/service/case-assist/case-assist-api-client'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {CoreEngine} from '../../app/engine'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {logQuickviewDocumentSuggestionClick} from '../../features/case-assist/case-assist-analytics-actions'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; -import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions'; -import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder'; -import {DocumentSuggestionSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +import {CaseAssistAPIClient} from '../../api/service/case-assist/case-assist-api-client.js'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {CoreEngine} from '../../app/engine.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {logQuickviewDocumentSuggestionClick} from '../../features/case-assist/case-assist-analytics-actions.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; +import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions.js'; +import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder.js'; +import {DocumentSuggestionSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { buildCoreQuickview, QuickviewOptions, QuickviewState, QuickviewProps, Quickview, -} from '../core/quickview/headless-core-quickview'; +} from '../core/quickview/headless-core-quickview.js'; export interface CaseAssistQuickviewProps extends QuickviewProps {} diff --git a/packages/headless/src/controllers/quickview/headless-quickview.ssr.ts b/packages/headless/src/controllers/quickview/headless-quickview.ssr.ts index cec28d16934..d7d32606fb2 100644 --- a/packages/headless/src/controllers/quickview/headless-quickview.ssr.ts +++ b/packages/headless/src/controllers/quickview/headless-quickview.ssr.ts @@ -1,8 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {Quickview, QuickviewProps, buildQuickview} from './headless-quickview'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import { + Quickview, + QuickviewProps, + buildQuickview, +} from './headless-quickview.js'; -export * from './headless-quickview'; +export * from './headless-quickview.js'; export interface QuickviewDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/quickview/headless-quickview.test.ts b/packages/headless/src/controllers/quickview/headless-quickview.test.ts index c725853dc23..231f699052d 100644 --- a/packages/headless/src/controllers/quickview/headless-quickview.test.ts +++ b/packages/headless/src/controllers/quickview/headless-quickview.test.ts @@ -1,27 +1,27 @@ -import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions'; -import {logDocumentQuickview} from '../../features/result-preview/result-preview-analytics-actions'; -import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder'; -import {searchReducer} from '../../features/search/search-slice'; -import {SearchAppState} from '../../state/search-app-state'; +import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions.js'; +import {logDocumentQuickview} from '../../features/result-preview/result-preview-analytics-actions.js'; +import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder.js'; +import {searchReducer} from '../../features/search/search-slice.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; -import {buildCoreQuickview} from '../core/quickview/headless-core-quickview'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildCoreQuickview} from '../core/quickview/headless-core-quickview.js'; import { buildQuickview, QuickviewOptions, Quickview, -} from './headless-quickview'; +} from './headless-quickview.js'; -jest.mock('../core/quickview/headless-core-quickview'); -jest.mock('../../features/result-preview/result-preview-actions'); -jest.mock('../../features/result-preview/result-preview-analytics-actions'); +vi.mock('../core/quickview/headless-core-quickview'); +vi.mock('../../features/result-preview/result-preview-actions'); +vi.mock('../../features/result-preview/result-preview-analytics-actions'); describe('Quickview', () => { - const mockedBuildCoreQuickview = jest.mocked(buildCoreQuickview); + const mockedBuildCoreQuickview = vi.mocked(buildCoreQuickview); let engine: MockedSearchEngine; let state: SearchAppState; let options: QuickviewOptions; @@ -37,7 +37,7 @@ describe('Quickview', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initEngine(); options = { result: buildMockResult(), @@ -64,9 +64,7 @@ describe('Quickview', () => { }); it('dispatches #preparePreviewPagination', () => { - const mockedPreparePreviewPagination = jest.mocked( - preparePreviewPagination - ); + const mockedPreparePreviewPagination = vi.mocked(preparePreviewPagination); expect(preparePreviewPagination).toHaveBeenCalledWith({ results: state.search.results, @@ -78,7 +76,7 @@ describe('Quickview', () => { }); it('#fetchResultContentCallback logs a document quickview', () => { - const mockedLogDocumentQuickview = jest.mocked(logDocumentQuickview); + const mockedLogDocumentQuickview = vi.mocked(logDocumentQuickview); const coreQuickviewParamsFetchResultContentCallback = mockedBuildCoreQuickview.mock.calls[0][4]; diff --git a/packages/headless/src/controllers/quickview/headless-quickview.ts b/packages/headless/src/controllers/quickview/headless-quickview.ts index 985fe6851d5..6b061fb08f1 100644 --- a/packages/headless/src/controllers/quickview/headless-quickview.ts +++ b/packages/headless/src/controllers/quickview/headless-quickview.ts @@ -1,20 +1,20 @@ -import {HtmlApiClient} from '../../api/search/html/html-api-client'; -import {CoreEngine} from '../../app/engine'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions'; -import {logDocumentQuickview} from '../../features/result-preview/result-preview-analytics-actions'; -import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {SearchSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +import {HtmlApiClient} from '../../api/search/html/html-api-client.js'; +import {CoreEngine} from '../../app/engine.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {preparePreviewPagination} from '../../features/result-preview/result-preview-actions.js'; +import {logDocumentQuickview} from '../../features/result-preview/result-preview-analytics-actions.js'; +import {buildResultPreviewRequest} from '../../features/result-preview/result-preview-request-builder.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {SearchSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { buildCoreQuickview, QuickviewOptions, QuickviewState as CoreQuickviewState, QuickviewProps, Quickview as CoreQuickview, -} from '../core/quickview/headless-core-quickview'; +} from '../core/quickview/headless-core-quickview.js'; export type { QuickviewOptions, diff --git a/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ssr.ts b/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ssr.ts index a1d58c29567..d07888841bd 100644 --- a/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ssr.ts +++ b/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { RecentQueriesList, RecentQueriesListProps, buildRecentQueriesList, -} from './headless-recent-queries-list'; +} from './headless-recent-queries-list.js'; -export * from './headless-recent-queries-list'; +export * from './headless-recent-queries-list.js'; export interface RecentQueriesListDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.test.ts b/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.test.ts index 557073c86fa..3bb5936a7b1 100644 --- a/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.test.ts +++ b/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.test.ts @@ -1,28 +1,28 @@ import {NumberValue} from '@coveo/bueno'; -import {deselectAllBreadcrumbs} from '../../features/breadcrumb/breadcrumb-actions'; +import {deselectAllBreadcrumbs} from '../../features/breadcrumb/breadcrumb-actions.js'; import { clearRecentQueries, registerRecentQueries, -} from '../../features/recent-queries/recent-queries-actions'; -import {logClearRecentQueries} from '../../features/recent-queries/recent-queries-analytics-actions'; -import {recentQueriesReducer as recentQueries} from '../../features/recent-queries/recent-queries-slice'; -import {prepareForSearchWithQuery} from '../../features/search/search-actions'; -import {searchReducer as search} from '../../features/search/search-slice'; +} from '../../features/recent-queries/recent-queries-actions.js'; +import {logClearRecentQueries} from '../../features/recent-queries/recent-queries-analytics-actions.js'; +import {recentQueriesReducer as recentQueries} from '../../features/recent-queries/recent-queries-slice.js'; +import {prepareForSearchWithQuery} from '../../features/search/search-actions.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockQueryState} from '../../test/mock-query-state'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockQueryState} from '../../test/mock-query-state.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildRecentQueriesList, RecentQueriesList, -} from './headless-recent-queries-list'; +} from './headless-recent-queries-list.js'; -jest.mock('../../features/recent-queries/recent-queries-actions'); -jest.mock('../../features/breadcrumb/breadcrumb-actions'); -jest.mock('../../features/search/search-actions'); -jest.mock('../../features/recent-queries/recent-queries-analytics-actions'); +vi.mock('../../features/recent-queries/recent-queries-actions'); +vi.mock('../../features/breadcrumb/breadcrumb-actions'); +vi.mock('../../features/search/search-actions'); +vi.mock('../../features/recent-queries/recent-queries-analytics-actions'); describe('recent queries list', () => { let engine: MockedSearchEngine; @@ -71,7 +71,7 @@ describe('recent queries list', () => { initialState: testInitialState, options: testOptions, }; - const mockedPrepareForSearchWithQuery = jest.mocked( + const mockedPrepareForSearchWithQuery = vi.mocked( prepareForSearchWithQuery ); @@ -99,7 +99,7 @@ describe('recent queries list', () => { }); it('#executeRecentQuery should validate the given index parameter', () => { - const validationSpy = jest.spyOn(NumberValue.prototype, 'validate'); + const validationSpy = vi.spyOn(NumberValue.prototype, 'validate'); engine.state.recentQueries = {...testInitialState, ...testOptions}; expect(() => recentQueriesList.executeRecentQuery(100)).toThrow(); diff --git a/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ts b/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ts index 1f01e1c5beb..4a1d4246175 100644 --- a/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ts +++ b/packages/headless/src/controllers/recent-queries-list/headless-recent-queries-list.ts @@ -5,30 +5,33 @@ import { Schema, isBoolean, } from '@coveo/bueno'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { clearRecentQueries, registerRecentQueries, -} from '../../features/recent-queries/recent-queries-actions'; +} from '../../features/recent-queries/recent-queries-actions.js'; import { logClearRecentQueries, logRecentQueryClick, -} from '../../features/recent-queries/recent-queries-analytics-actions'; -import {recentQueriesReducer as recentQueries} from '../../features/recent-queries/recent-queries-slice'; +} from '../../features/recent-queries/recent-queries-analytics-actions.js'; +import {recentQueriesReducer as recentQueries} from '../../features/recent-queries/recent-queries-slice.js'; import { PrepareForSearchWithQueryOptions, executeSearch, prepareForSearchWithQuery, -} from '../../features/search/search-actions'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {UpdateQueryActionCreatorPayload} from '../../ssr.index'; -import {RecentQueriesSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../features/search/search-actions.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {UpdateQueryActionCreatorPayload} from '../../ssr.index.js'; +import {RecentQueriesSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { validateInitialState, validateOptions, -} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; export interface RecentQueriesListProps { /** diff --git a/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.test.ts b/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.test.ts index 2e6c76b4409..8d070b629d7 100644 --- a/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.test.ts +++ b/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.test.ts @@ -1,18 +1,18 @@ -import {Result} from '../../api/search/search/result'; -import {configuration} from '../../app/common-reducers'; -import {logRecentResultClick} from '../../features/recent-results/recent-results-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {configuration} from '../../app/common-reducers.js'; +import {logRecentResultClick} from '../../features/recent-results/recent-results-analytics-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildInteractiveRecentResult, InteractiveRecentResult, -} from './headless-interactive-recent-result'; +} from './headless-interactive-recent-result.js'; -jest.mock('../../features/recent-results/recent-results-analytics-actions'); +vi.mock('../../features/recent-results/recent-results-analytics-actions'); describe('InteractiveRecentResult', () => { let engine: MockedSearchEngine; @@ -40,11 +40,11 @@ describe('InteractiveRecentResult', () => { beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initializeInteractiveRecentResult(); - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('it adds the correct reducers to engine', () => { @@ -53,7 +53,7 @@ describe('InteractiveRecentResult', () => { it('when calling select(), logs recentResultClick', () => { interactiveRecentResult.select(); - jest.runAllTimers(); + vi.runAllTimers(); expect(logRecentResultClick).toHaveBeenCalledWith(mockResult); }); diff --git a/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.ts b/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.ts index aa20bb75950..2e6a22add39 100644 --- a/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.ts +++ b/packages/headless/src/controllers/recent-results-list/headless-interactive-recent-result.ts @@ -1,12 +1,12 @@ -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logRecentResultClick} from '../../features/recent-results/recent-results-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logRecentResultClick} from '../../features/recent-results/recent-results-analytics-actions.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from '../core/interactive-result/headless-core-interactive-result'; +} from '../core/interactive-result/headless-core-interactive-result.js'; export interface InteractiveRecentResultOptions extends InteractiveResultCoreOptions { diff --git a/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ssr.ts b/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ssr.ts index 6b928244ecc..5cca4ec94e6 100644 --- a/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ssr.ts +++ b/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { RecentResultsList, RecentResultsListProps, buildRecentResultsList, -} from './headless-recent-results-list'; +} from './headless-recent-results-list.js'; -export * from './headless-recent-results-list'; +export * from './headless-recent-results-list.js'; export interface RecentResultsListDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.test.ts b/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.test.ts index 783ef3f6249..58b20ee1f4e 100644 --- a/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.test.ts +++ b/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.test.ts @@ -1,22 +1,22 @@ import { clearRecentResults, registerRecentResults, -} from '../../features/recent-results/recent-results-actions'; -import {logClearRecentResults} from '../../features/recent-results/recent-results-analytics-actions'; -import {recentResultsReducer as recentResults} from '../../features/recent-results/recent-results-slice'; +} from '../../features/recent-results/recent-results-actions.js'; +import {logClearRecentResults} from '../../features/recent-results/recent-results-analytics-actions.js'; +import {recentResultsReducer as recentResults} from '../../features/recent-results/recent-results-slice.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildRecentResultsList, RecentResultsList, -} from './headless-recent-results-list'; +} from './headless-recent-results-list.js'; -jest.mock('../../features/recent-results/recent-results-analytics-actions'); -jest.mock('../../features/recent-results/recent-results-actions'); +vi.mock('../../features/recent-results/recent-results-analytics-actions'); +vi.mock('../../features/recent-results/recent-results-actions'); describe('recent results list', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ts b/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ts index 73d26bc00a6..797500e4e7d 100644 --- a/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ts +++ b/packages/headless/src/controllers/recent-results-list/headless-recent-results-list.ts @@ -1,19 +1,22 @@ import {ArrayValue, NumberValue, Schema} from '@coveo/bueno'; -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { clearRecentResults, registerRecentResults, -} from '../../features/recent-results/recent-results-actions'; -import {logClearRecentResults} from '../../features/recent-results/recent-results-analytics-actions'; -import {recentResultsReducer as recentResults} from '../../features/recent-results/recent-results-slice'; -import {RecentResultsSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../features/recent-results/recent-results-actions.js'; +import {logClearRecentResults} from '../../features/recent-results/recent-results-analytics-actions.js'; +import {recentResultsReducer as recentResults} from '../../features/recent-results/recent-results-slice.js'; +import {RecentResultsSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { validateInitialState, validateOptions, -} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; export interface RecentResultsListProps { /** diff --git a/packages/headless/src/controllers/recommendation/headless-recommendation.test.ts b/packages/headless/src/controllers/recommendation/headless-recommendation.test.ts index 6684e4cbc5a..7ac11dda507 100644 --- a/packages/headless/src/controllers/recommendation/headless-recommendation.test.ts +++ b/packages/headless/src/controllers/recommendation/headless-recommendation.test.ts @@ -1,22 +1,22 @@ -import {configuration} from '../../app/common-reducers'; -import {updateNumberOfResults} from '../../features/pagination/pagination-actions'; +import {configuration} from '../../app/common-reducers.js'; +import {updateNumberOfResults} from '../../features/pagination/pagination-actions.js'; import { getRecommendations, setRecommendationId, -} from '../../features/recommendation/recommendation-actions'; -import {recommendationReducer} from '../../features/recommendation/recommendation-slice'; +} from '../../features/recommendation/recommendation-actions.js'; +import {recommendationReducer} from '../../features/recommendation/recommendation-slice.js'; import { buildMockRecommendationEngine, MockedRecommendationEngine, -} from '../../test/mock-engine-v2'; -import {createMockRecommendationState} from '../../test/mock-recommendation-state'; +} from '../../test/mock-engine-v2.js'; +import {createMockRecommendationState} from '../../test/mock-recommendation-state.js'; import { buildRecommendationList, RecommendationList, -} from './headless-recommendation'; +} from './headless-recommendation.js'; -jest.mock('../../features/recommendation/recommendation-actions'); -jest.mock('../../features/pagination/pagination-actions'); +vi.mock('../../features/recommendation/recommendation-actions'); +vi.mock('../../features/pagination/pagination-actions'); describe('Recommendation', () => { let recommendation: RecommendationList; @@ -27,7 +27,7 @@ describe('Recommendation', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initEngine(); recommendation = buildRecommendationList(engine); }); @@ -40,7 +40,7 @@ describe('Recommendation', () => { }); it('when #options.id is set to a non empty value, it dispatches #setRecommendationId', () => { - const mockedSetRecommendationId = jest.mocked(setRecommendationId); + const mockedSetRecommendationId = vi.mocked(setRecommendationId); recommendation = buildRecommendationList(engine, {options: {id: 'foo'}}); @@ -51,7 +51,7 @@ describe('Recommendation', () => { }); it('when #options.id is set to an empty value, it does not dispatches #setRecommendationId', () => { - const mockedSetRecommendationId = jest.mocked(setRecommendationId); + const mockedSetRecommendationId = vi.mocked(setRecommendationId); recommendation = buildRecommendationList(engine, {options: {id: ''}}); @@ -59,7 +59,7 @@ describe('Recommendation', () => { }); it('when #options.numberOfRecommendations is set, it dispatches #updateNumberOfResults', () => { - const mockedUpdateNumberOfResults = jest.mocked(updateNumberOfResults); + const mockedUpdateNumberOfResults = vi.mocked(updateNumberOfResults); recommendation = buildRecommendationList(engine, { options: {numberOfRecommendations: 20}, @@ -72,7 +72,7 @@ describe('Recommendation', () => { }); it('when #options.numberOfRecommendations is not set, it does not dispatches #updateNumberOfResults', () => { - const mockedUpdateNumberOfResults = jest.mocked(updateNumberOfResults); + const mockedUpdateNumberOfResults = vi.mocked(updateNumberOfResults); recommendation = buildRecommendationList(engine); @@ -86,7 +86,7 @@ describe('Recommendation', () => { }); it('#refresh dispatches #getRecommendations', () => { - const mockedGetRecommendations = jest.mocked(getRecommendations); + const mockedGetRecommendations = vi.mocked(getRecommendations); recommendation.refresh(); diff --git a/packages/headless/src/controllers/recommendation/headless-recommendation.ts b/packages/headless/src/controllers/recommendation/headless-recommendation.ts index 38a42d26783..a4eeae3f7e8 100644 --- a/packages/headless/src/controllers/recommendation/headless-recommendation.ts +++ b/packages/headless/src/controllers/recommendation/headless-recommendation.ts @@ -1,17 +1,20 @@ import {NumberValue, Schema, StringValue} from '@coveo/bueno'; -import {Result} from '../../api/search/search/result'; -import {configuration} from '../../app/common-reducers'; -import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine'; -import {loadPaginationActions} from '../../features/pagination/pagination-actions-loader'; +import {Result} from '../../api/search/search/result.js'; +import {configuration} from '../../app/common-reducers.js'; +import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine.js'; +import {loadPaginationActions} from '../../features/pagination/pagination-actions-loader.js'; import { getRecommendations, setRecommendationId, -} from '../../features/recommendation/recommendation-actions'; -import {recommendationReducer as recommendation} from '../../features/recommendation/recommendation-slice'; -import {loadReducerError} from '../../utils/errors'; -import {validateOptions} from '../../utils/validate-payload'; -import {ErrorPayload} from '../controller/error-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../features/recommendation/recommendation-actions.js'; +import {recommendationReducer as recommendation} from '../../features/recommendation/recommendation-slice.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {validateOptions} from '../../utils/validate-payload.js'; +import {ErrorPayload} from '../controller/error-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; const optionsSchema = new Schema({ id: new StringValue({ diff --git a/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.test.ts b/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.test.ts index 845fa57d21f..20fa9314830 100644 --- a/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.test.ts +++ b/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.test.ts @@ -1,23 +1,24 @@ -import {logRecommendationOpen} from '../../../features/recommendation/recommendation-analytics-actions'; +import {Mock} from 'vitest'; +import {logRecommendationOpen} from '../../../features/recommendation/recommendation-analytics-actions.js'; import { buildMockRecommendationEngine, MockedRecommendationEngine, -} from '../../../test/mock-engine-v2'; -import {createMockRecommendationState} from '../../../test/mock-recommendation-state'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildInteractiveResultCore} from '../../core/interactive-result/headless-core-interactive-result'; +} from '../../../test/mock-engine-v2.js'; +import {createMockRecommendationState} from '../../../test/mock-recommendation-state.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {buildInteractiveResultCore} from '../../core/interactive-result/headless-core-interactive-result.js'; import { buildInteractiveResult, RecommendationInteractiveResultProps, -} from './headless-recommendation-interactive-result'; +} from './headless-recommendation-interactive-result.js'; -jest.mock('../../core/interactive-result/headless-core-interactive-result'); -jest.mock('../../../features/recommendation/recommendation-analytics-actions'); +vi.mock('../../core/interactive-result/headless-core-interactive-result'); +vi.mock('../../../features/recommendation/recommendation-analytics-actions'); describe('RecommendationInteractiveResult', () => { let engine: MockedRecommendationEngine; let interactiveResultProps: RecommendationInteractiveResultProps; - let mockedBuildInteractiveResultCore: jest.Mock; + let mockedBuildInteractiveResultCore: Mock; const resultStringParams = { uniqueId: 'unique-id', }; @@ -39,8 +40,8 @@ describe('RecommendationInteractiveResult', () => { } beforeEach(() => { - jest.resetAllMocks(); - mockedBuildInteractiveResultCore = jest.mocked(buildInteractiveResultCore); + vi.resetAllMocks(); + mockedBuildInteractiveResultCore = vi.mocked(buildInteractiveResultCore); initEngine(); initializeInteractiveResult(); }); @@ -54,7 +55,7 @@ describe('RecommendationInteractiveResult', () => { }); it('calls logRecommendationOpen when the action is triggered for the first time', () => { - const mockedLogDocumentSuggestionOpen = jest.mocked(logRecommendationOpen); + const mockedLogDocumentSuggestionOpen = vi.mocked(logRecommendationOpen); mockedSelect(); expect(mockedLogDocumentSuggestionOpen).toHaveBeenCalledTimes(1); @@ -64,7 +65,7 @@ describe('RecommendationInteractiveResult', () => { }); it('does not call #logRecommendationOpen when the action is triggered for the second time', () => { - const mockedLogDocumentSuggestionOpen = jest.mocked(logRecommendationOpen); + const mockedLogDocumentSuggestionOpen = vi.mocked(logRecommendationOpen); mockedSelect(); mockedSelect(); diff --git a/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.ts b/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.ts index a0df1425ee7..3a404593027 100644 --- a/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.ts +++ b/packages/headless/src/controllers/recommendation/result-list/headless-recommendation-interactive-result.ts @@ -1,12 +1,12 @@ -import {Result} from '../../../api/search/search/result'; -import {RecommendationEngine} from '../../../app/recommendation-engine/recommendation-engine'; -import {logRecommendationOpen} from '../../../features/recommendation/recommendation-analytics-actions'; +import {Result} from '../../../api/search/search/result.js'; +import {RecommendationEngine} from '../../../app/recommendation-engine/recommendation-engine.js'; +import {logRecommendationOpen} from '../../../features/recommendation/recommendation-analytics-actions.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from '../../core/interactive-result/headless-core-interactive-result'; +} from '../../core/interactive-result/headless-core-interactive-result.js'; export type { InteractiveResultCoreOptions, diff --git a/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ssr.ts b/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ssr.ts index 395523da5f1..079841a8cb4 100644 --- a/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ssr.ts +++ b/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { RelevanceInspector, RelevanceInspectorProps, buildRelevanceInspector, -} from './headless-relevance-inspector'; +} from './headless-relevance-inspector.js'; -export * from './headless-relevance-inspector'; +export * from './headless-relevance-inspector.js'; export interface RelevanceInspectorDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.test.ts b/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.test.ts index 942d3d6ccc6..373c97b92c4 100644 --- a/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.test.ts +++ b/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.test.ts @@ -1,29 +1,29 @@ -import {configuration} from '../../app/common-reducers'; -import {disableDebug, enableDebug} from '../../features/debug/debug-actions'; -import {rankingInformationSelector} from '../../features/debug/debug-selectors'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {disableDebug, enableDebug} from '../../features/debug/debug-actions.js'; +import {rankingInformationSelector} from '../../features/debug/debug-selectors.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; import { disableFetchAllFields, enableFetchAllFields, fetchFieldsDescription, -} from '../../features/fields/fields-actions'; -import {fieldsReducer as fields} from '../../features/fields/fields-slice'; -import {searchReducer as search} from '../../features/search/search-slice'; +} from '../../features/fields/fields-actions.js'; +import {fieldsReducer as fields} from '../../features/fields/fields-slice.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockFieldDescription} from '../../test/mock-field-description'; -import {buildMockSearchResponseWithDebugInfo} from '../../test/mock-search-response'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockFieldDescription} from '../../test/mock-field-description.js'; +import {buildMockSearchResponseWithDebugInfo} from '../../test/mock-search-response.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildRelevanceInspector, RelevanceInspector, RelevanceInspectorProps, -} from './headless-relevance-inspector'; +} from './headless-relevance-inspector.js'; -jest.mock('../../features/debug/debug-actions'); -jest.mock('../../features/fields/fields-actions'); +vi.mock('../../features/debug/debug-actions'); +vi.mock('../../features/fields/fields-actions'); describe('RelevanceInspector', () => { let engine: MockedSearchEngine; @@ -52,14 +52,14 @@ describe('RelevanceInspector', () => { }); it('when enabling debug, should call the listener', () => { - const listenerSpy = jest.fn(); + const listenerSpy = vi.fn(); relevanceInspector.subscribe(listenerSpy); relevanceInspector.enable(); expect(listenerSpy).toHaveBeenCalledTimes(1); }); it('when enabling debug twice, should call the listener once', () => { - const listenerSpy = jest.fn(); + const listenerSpy = vi.fn(); relevanceInspector.subscribe(listenerSpy); relevanceInspector.enable(); relevanceInspector.enable(); @@ -67,7 +67,7 @@ describe('RelevanceInspector', () => { }); it('when disabling, should call the listener', () => { - const listenerSpy = jest.fn(); + const listenerSpy = vi.fn(); relevanceInspector.enable(); relevanceInspector.subscribe(listenerSpy); relevanceInspector.disable(); @@ -75,7 +75,7 @@ describe('RelevanceInspector', () => { }); it('when disabling twice, should call the listener once', () => { - const listenerSpy = jest.fn(); + const listenerSpy = vi.fn(); relevanceInspector.enable(); relevanceInspector.subscribe(listenerSpy); relevanceInspector.disable(); diff --git a/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ts b/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ts index e48c6dbc3c6..7aacee466e0 100644 --- a/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ts +++ b/packages/headless/src/controllers/relevance-inspector/headless-relevance-inspector.ts @@ -1,40 +1,43 @@ import {BooleanValue, Schema} from '@coveo/bueno'; -import {FieldDescription} from '../../api/search/fields/fields-response'; +import {FieldDescription} from '../../api/search/fields/fields-response.js'; import { ExecutionReport, ExecutionStep, -} from '../../api/search/search/execution-report'; -import {QueryRankingExpression} from '../../api/search/search/query-ranking-expression'; -import {Result} from '../../api/search/search/result'; -import {SearchResponseSuccessWithDebugInfo} from '../../api/search/search/search-response'; -import {SecurityIdentity} from '../../api/search/search/security-identity'; -import {configuration} from '../../app/common-reducers'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {enableDebug, disableDebug} from '../../features/debug/debug-actions'; -import {rankingInformationSelector} from '../../features/debug/debug-selectors'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; +} from '../../api/search/search/execution-report.js'; +import {QueryRankingExpression} from '../../api/search/search/query-ranking-expression.js'; +import {Result} from '../../api/search/search/result.js'; +import {SearchResponseSuccessWithDebugInfo} from '../../api/search/search/search-response.js'; +import {SecurityIdentity} from '../../api/search/search/security-identity.js'; +import {configuration} from '../../app/common-reducers.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {enableDebug, disableDebug} from '../../features/debug/debug-actions.js'; +import {rankingInformationSelector} from '../../features/debug/debug-selectors.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; import { QueryRankingExpressionWeights, DocumentWeights, RankingInformation, TermWeightReport, -} from '../../features/debug/ranking-info-parser'; +} from '../../features/debug/ranking-info-parser.js'; import { disableFetchAllFields, enableFetchAllFields, fetchFieldsDescription, -} from '../../features/fields/fields-actions'; -import {fieldsReducer as fields} from '../../features/fields/fields-slice'; -import {searchReducer as search} from '../../features/search/search-slice'; +} from '../../features/fields/fields-actions.js'; +import {fieldsReducer as fields} from '../../features/fields/fields-slice.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; import { ConfigurationSection, DebugSection, FieldsSection, SearchSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {validateInitialState} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {validateInitialState} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; export type { RankingInformation, diff --git a/packages/headless/src/controllers/result-list/headless-interactive-result.test.ts b/packages/headless/src/controllers/result-list/headless-interactive-result.test.ts index cca8be2f512..8657151ceb2 100644 --- a/packages/headless/src/controllers/result-list/headless-interactive-result.test.ts +++ b/packages/headless/src/controllers/result-list/headless-interactive-result.test.ts @@ -1,20 +1,20 @@ -import {Result} from '../../api/search/search/result'; -import {configuration} from '../../app/common-reducers'; -import {pushRecentResult} from '../../features/recent-results/recent-results-actions'; -import {logDocumentOpen} from '../../features/result/result-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {configuration} from '../../app/common-reducers.js'; +import {pushRecentResult} from '../../features/recent-results/recent-results-actions.js'; +import {logDocumentOpen} from '../../features/result/result-analytics-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildInteractiveResult, InteractiveResult, -} from './headless-interactive-result'; +} from './headless-interactive-result.js'; -jest.mock('../../features/recent-results/recent-results-actions'); -jest.mock('../../features/result/result-analytics-actions'); +vi.mock('../../features/recent-results/recent-results-actions'); +vi.mock('../../features/result/result-analytics-actions'); describe('InteractiveResult', () => { let engine: MockedSearchEngine; @@ -42,11 +42,11 @@ describe('InteractiveResult', () => { beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initializeInteractiveResult(); - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('it adds the correct reducers to engine', () => { @@ -55,7 +55,7 @@ describe('InteractiveResult', () => { it('when calling select() should add the result to recent results list', () => { interactiveResult.select(); - jest.runAllTimers(); + vi.runAllTimers(); expect(pushRecentResult).toHaveBeenCalled(); }); diff --git a/packages/headless/src/controllers/result-list/headless-interactive-result.ts b/packages/headless/src/controllers/result-list/headless-interactive-result.ts index ac03ed355c5..59481042ec8 100644 --- a/packages/headless/src/controllers/result-list/headless-interactive-result.ts +++ b/packages/headless/src/controllers/result-list/headless-interactive-result.ts @@ -1,13 +1,13 @@ -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {pushRecentResult} from '../../features/recent-results/recent-results-actions'; -import {logDocumentOpen} from '../../features/result/result-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {pushRecentResult} from '../../features/recent-results/recent-results-actions.js'; +import {logDocumentOpen} from '../../features/result/result-analytics-actions.js'; import { buildInteractiveResultCore, InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from '../core/interactive-result/headless-core-interactive-result'; +} from '../core/interactive-result/headless-core-interactive-result.js'; export interface InteractiveResultOptions extends InteractiveResultCoreOptions { /** diff --git a/packages/headless/src/controllers/result-list/headless-result-list.ssr.ts b/packages/headless/src/controllers/result-list/headless-result-list.ssr.ts index b96093806b0..8a0c6d1a0ff 100644 --- a/packages/headless/src/controllers/result-list/headless-result-list.ssr.ts +++ b/packages/headless/src/controllers/result-list/headless-result-list.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { ResultList, ResultListProps, buildResultList, -} from './headless-result-list'; +} from './headless-result-list.js'; -export * from './headless-result-list'; +export * from './headless-result-list.js'; export interface ResultListDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/result-list/headless-result-list.test.ts b/packages/headless/src/controllers/result-list/headless-result-list.test.ts index e415a608c75..e6484849819 100644 --- a/packages/headless/src/controllers/result-list/headless-result-list.test.ts +++ b/packages/headless/src/controllers/result-list/headless-result-list.test.ts @@ -1,13 +1,13 @@ -import {fetchMoreResults} from '../../features/search/search-actions'; +import {fetchMoreResults} from '../../features/search/search-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; -import {buildResultList} from './headless-result-list'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildResultList} from './headless-result-list.js'; -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/search/search-actions'); describe('ResultList', () => { let engine: MockedSearchEngine; @@ -17,11 +17,11 @@ describe('ResultList', () => { const results = new Array(10).fill(buildMockResult()); engine.state.search.results = results; engine.state.search.response.totalCountFiltered = 1000; - jest.useFakeTimers(); + vi.useFakeTimers(); }); afterEach(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('fetchMoreResults should dispatch a fetchMoreResults action', () => { diff --git a/packages/headless/src/controllers/result-list/headless-result-list.ts b/packages/headless/src/controllers/result-list/headless-result-list.ts index e7469c307d6..53ae67c306f 100644 --- a/packages/headless/src/controllers/result-list/headless-result-list.ts +++ b/packages/headless/src/controllers/result-list/headless-result-list.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {fetchMoreResults} from '../../features/search/search-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {fetchMoreResults} from '../../features/search/search-actions.js'; import { buildCoreResultList, ResultList, ResultListOptions, ResultListProps, ResultListState, -} from '../core/result-list/headless-core-result-list'; +} from '../core/result-list/headless-core-result-list.js'; export type {ResultListOptions, ResultListProps, ResultListState, ResultList}; diff --git a/packages/headless/src/controllers/results-per-page/__snapshots__/headless-results-per-page.test.ts.snap b/packages/headless/src/controllers/results-per-page/__snapshots__/headless-results-per-page.test.ts.snap index ca56302b2ec..db29e3bfec4 100644 --- a/packages/headless/src/controllers/results-per-page/__snapshots__/headless-results-per-page.test.ts.snap +++ b/packages/headless/src/controllers/results-per-page/__snapshots__/headless-results-per-page.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`ResultsPerPage calling #set executes a fetchPage with the proper analytics payload 1`] = ` +exports[`ResultsPerPage > calling #set executes a fetchPage with the proper analytics payload 1`] = ` [ { "legacy": [Function], diff --git a/packages/headless/src/controllers/results-per-page/headless-results-per-page.ssr.ts b/packages/headless/src/controllers/results-per-page/headless-results-per-page.ssr.ts index c450af9c0a7..10dd0bfa6bb 100644 --- a/packages/headless/src/controllers/results-per-page/headless-results-per-page.ssr.ts +++ b/packages/headless/src/controllers/results-per-page/headless-results-per-page.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { ResultsPerPage, ResultsPerPageProps, buildResultsPerPage, -} from './headless-results-per-page'; +} from './headless-results-per-page.js'; -export * from './headless-results-per-page'; +export * from './headless-results-per-page.js'; export interface ResultsPerPageDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/results-per-page/headless-results-per-page.test.ts b/packages/headless/src/controllers/results-per-page/headless-results-per-page.test.ts index 4b163d9a3b0..17d7e205592 100644 --- a/packages/headless/src/controllers/results-per-page/headless-results-per-page.test.ts +++ b/packages/headless/src/controllers/results-per-page/headless-results-per-page.test.ts @@ -1,35 +1,35 @@ import {AsyncThunk, UnknownAction} from '@reduxjs/toolkit'; import {ThunkDispatch} from 'redux-thunk'; -import {GeneratedAnswerAPIClient} from '../../api/generated-answer/generated-answer-client'; -import {SearchAPIClient} from '../../api/search/search-api-client'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {configuration} from '../../app/common-reducers'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {GeneratedAnswerAPIClient} from '../../api/generated-answer/generated-answer-client.js'; +import {SearchAPIClient} from '../../api/search/search-api-client.js'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {configuration} from '../../app/common-reducers.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { registerNumberOfResults, updateNumberOfResults, -} from '../../features/pagination/pagination-actions'; -import {paginationReducer as pagination} from '../../features/pagination/pagination-slice'; +} from '../../features/pagination/pagination-actions.js'; +import {paginationReducer as pagination} from '../../features/pagination/pagination-slice.js'; +import {StateNeededByExecuteSearch} from '../../features/search/search-actions-thunk-processor.js'; import { ExecuteSearchThunkReturn, fetchPage, TransitiveSearchAction, -} from '../../features/search/search-actions'; -import {StateNeededByExecuteSearch} from '../../features/search/search-actions-thunk-processor'; +} from '../../features/search/search-actions.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockPagination} from '../../test/mock-pagination'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockPagination} from '../../test/mock-pagination.js'; +import {createMockState} from '../../test/mock-state.js'; import { ResultsPerPage, ResultsPerPageProps, buildResultsPerPage, -} from './headless-results-per-page'; +} from './headless-results-per-page.js'; -jest.mock('../../features/pagination/pagination-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/pagination/pagination-actions'); +vi.mock('../../features/search/search-actions'); describe('ResultsPerPage', () => { let engine: MockedSearchEngine; @@ -59,12 +59,12 @@ describe('ResultsPerPage', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); props = { initialState: {}, }; - mockedFetchPage = jest.mocked(fetchPage); + mockedFetchPage = vi.mocked(fetchPage); initResultsPerPage(); }); diff --git a/packages/headless/src/controllers/results-per-page/headless-results-per-page.ts b/packages/headless/src/controllers/results-per-page/headless-results-per-page.ts index 5576357162f..0914cddb2d5 100644 --- a/packages/headless/src/controllers/results-per-page/headless-results-per-page.ts +++ b/packages/headless/src/controllers/results-per-page/headless-results-per-page.ts @@ -1,23 +1,23 @@ -import {configuration} from '../../app/common-reducers'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {configuration} from '../../app/common-reducers.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { browseResults, logPagerResize, -} from '../../features/pagination/pagination-analytics-actions'; -import {paginationReducer as pagination} from '../../features/pagination/pagination-slice'; -import {fetchPage} from '../../features/search/search-actions'; +} from '../../features/pagination/pagination-analytics-actions.js'; +import {paginationReducer as pagination} from '../../features/pagination/pagination-slice.js'; +import {fetchPage} from '../../features/search/search-actions.js'; import { ConfigurationSection, PaginationSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { buildCoreResultsPerPage, ResultsPerPage, ResultsPerPageInitialState, ResultsPerPageProps, ResultsPerPageState, -} from '../core/results-per-page/headless-core-results-per-page'; +} from '../core/results-per-page/headless-core-results-per-page.js'; export type { ResultsPerPage, diff --git a/packages/headless/src/controllers/search-box/headless-search-box.ssr.ts b/packages/headless/src/controllers/search-box/headless-search-box.ssr.ts index 3d6528f57a2..226705986bd 100644 --- a/packages/headless/src/controllers/search-box/headless-search-box.ssr.ts +++ b/packages/headless/src/controllers/search-box/headless-search-box.ssr.ts @@ -1,8 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {SearchBox, SearchBoxProps, buildSearchBox} from './headless-search-box'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import { + SearchBox, + SearchBoxProps, + buildSearchBox, +} from './headless-search-box.js'; -export * from './headless-search-box'; +export * from './headless-search-box.js'; export interface SearchBoxDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/search-box/headless-search-box.test.ts b/packages/headless/src/controllers/search-box/headless-search-box.test.ts index 4aff2c6e6be..ff003637058 100644 --- a/packages/headless/src/controllers/search-box/headless-search-box.test.ts +++ b/packages/headless/src/controllers/search-box/headless-search-box.test.ts @@ -1,27 +1,27 @@ -import {fetchQuerySuggestions} from '../../features/query-suggest/query-suggest-actions'; -import {logSearchboxSubmit} from '../../features/query/query-analytics-actions'; -import {executeSearch} from '../../features/search/search-actions'; -import {SearchAppState} from '../../state/search-app-state'; +import {fetchQuerySuggestions} from '../../features/query-suggest/query-suggest-actions.js'; +import {logSearchboxSubmit} from '../../features/query/query-analytics-actions.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockQuerySuggest} from '../../test/mock-query-suggest'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockQuerySuggest} from '../../test/mock-query-suggest.js'; +import {createMockState} from '../../test/mock-state.js'; import { SearchBox, SearchBoxProps, SearchBoxOptions, buildSearchBox, -} from './headless-search-box'; +} from './headless-search-box.js'; -jest.mock('../../features/query/query-analytics-actions', () => ({ - logSearchboxSubmit: jest.fn(() => () => {}), - searchboxSubmit: jest.fn(() => () => {}), +vi.mock('../../features/query/query-analytics-actions', () => ({ + logSearchboxSubmit: vi.fn(() => () => {}), + searchboxSubmit: vi.fn(() => () => {}), })); -jest.mock('../../features/search/search-actions'); -jest.mock('../../features/query-suggest/query-suggest-actions'); +vi.mock('../../features/search/search-actions'); +vi.mock('../../features/query-suggest/query-suggest-actions'); describe('headless searchBox', () => { const id = 'search-box-123'; @@ -54,7 +54,7 @@ describe('headless searchBox', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); function initState() { diff --git a/packages/headless/src/controllers/search-box/headless-search-box.ts b/packages/headless/src/controllers/search-box/headless-search-box.ts index a3afb422199..bd9821e1455 100644 --- a/packages/headless/src/controllers/search-box/headless-search-box.ts +++ b/packages/headless/src/controllers/search-box/headless-search-box.ts @@ -1,18 +1,21 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {fetchQuerySuggestions} from '../../features/query-suggest/query-suggest-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {fetchQuerySuggestions} from '../../features/query-suggest/query-suggest-actions.js'; import { logSearchboxSubmit, searchboxSubmit, -} from '../../features/query/query-analytics-actions'; -import {executeSearch} from '../../features/search/search-actions'; -import {SuggestionHighlightingOptions, Delimiters} from '../../utils/highlight'; -import {Controller} from '../controller/headless-controller'; +} from '../../features/query/query-analytics-actions.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import { + SuggestionHighlightingOptions, + Delimiters, +} from '../../utils/highlight.js'; +import {Controller} from '../controller/headless-controller.js'; +import {SearchBoxOptions} from '../core/search-box/headless-core-search-box-options.js'; import { buildCoreSearchBox, SearchBoxState, Suggestion, -} from '../core/search-box/headless-core-search-box'; -import {SearchBoxOptions} from '../core/search-box/headless-core-search-box-options'; +} from '../core/search-box/headless-core-search-box.js'; export type { SearchBoxOptions, diff --git a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.test.ts b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.test.ts index d3ab2e91a29..e789b4a5005 100644 --- a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.test.ts +++ b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.test.ts @@ -1,34 +1,32 @@ -import {SSRSearchEngine} from '../../app/search-engine/search-engine.ssr'; -import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common'; -import {configurationReducer} from '../../features/configuration/configuration-slice'; -import {debugReducer} from '../../features/debug/debug-slice'; -import {facetOptionsReducer} from '../../features/facet-options/facet-options-slice'; -import {automaticFacetSetReducer} from '../../features/facets/automatic-facet-set/automatic-facet-set-slice'; -import {categoryFacetSetReducer} from '../../features/facets/category-facet-set/category-facet-set-slice'; -import {facetSetReducer} from '../../features/facets/facet-set/facet-set-slice'; -import {dateFacetSetReducer} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {numericFacetSetReducer} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {paginationReducer} from '../../features/pagination/pagination-slice'; -import {queryReducer} from '../../features/query/query-slice'; -import {sortCriteriaReducer} from '../../features/sort-criteria/sort-criteria-slice'; -import {staticFilterSetReducer} from '../../features/static-filter-set/static-filter-set-slice'; -import {tabSetReducer} from '../../features/tab-set/tab-set-slice'; -import {buildMockSSRSearchEngine} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {advancedSearchQueriesReducer} from './../../features/advanced-search-queries/advanced-search-queries-slice'; +import {SSRSearchEngine} from '../../app/search-engine/search-engine.ssr.js'; +import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common.js'; +import {configurationReducer} from '../../features/configuration/configuration-slice.js'; +import {debugReducer} from '../../features/debug/debug-slice.js'; +import {facetOptionsReducer} from '../../features/facet-options/facet-options-slice.js'; +import {automaticFacetSetReducer} from '../../features/facets/automatic-facet-set/automatic-facet-set-slice.js'; +import {categoryFacetSetReducer} from '../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {facetSetReducer} from '../../features/facets/facet-set/facet-set-slice.js'; +import {dateFacetSetReducer} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {numericFacetSetReducer} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {paginationReducer} from '../../features/pagination/pagination-slice.js'; +import {queryReducer} from '../../features/query/query-slice.js'; +import {sortCriteriaReducer} from '../../features/sort-criteria/sort-criteria-slice.js'; +import {staticFilterSetReducer} from '../../features/static-filter-set/static-filter-set-slice.js'; +import {tabSetReducer} from '../../features/tab-set/tab-set-slice.js'; +import {buildMockSSRSearchEngine} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {advancedSearchQueriesReducer} from './../../features/advanced-search-queries/advanced-search-queries-slice.js'; import { SearchParameterManager, buildSearchParameterManager, -} from './headless-search-parameter-manager'; +} from './headless-search-parameter-manager.js'; import { SearchParameterManagerBuildProps, defineSearchParameterManager, -} from './headless-search-parameter-manager.ssr'; +} from './headless-search-parameter-manager.ssr.js'; -jest.mock('./headless-search-parameter-manager'); -const buildSearchParameterManagerMock = jest.mocked( - buildSearchParameterManager -); +vi.mock('./headless-search-parameter-manager'); +const buildSearchParameterManagerMock = vi.mocked(buildSearchParameterManager); type SearchParameterManagerDefinitionType = ControllerDefinitionWithProps< SSRSearchEngine, diff --git a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.ts b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.ts index 86d43e5dac5..ff66df7179c 100644 --- a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.ts +++ b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ssr.ts @@ -1,28 +1,28 @@ -import {CoreEngine} from '../../app/engine'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common'; -import {configurationReducer as configuration} from '../../features/configuration/configuration-slice'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; -import {facetOptionsReducer as facetOptions} from '../../features/facet-options/facet-options-slice'; -import {automaticFacetSetReducer as automaticFacetSet} from '../../features/facets/automatic-facet-set/automatic-facet-set-slice'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../features/facets/category-facet-set/category-facet-set-slice'; -import {facetSetReducer as facetSet} from '../../features/facets/facet-set/facet-set-slice'; -import {dateFacetSetReducer as dateFacetSet} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {numericFacetSetReducer as numericFacetSet} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {paginationReducer as pagination} from '../../features/pagination/pagination-slice'; -import {queryReducer as query} from '../../features/query/query-slice'; -import {sortCriteriaReducer as sortCriteria} from '../../features/sort-criteria/sort-criteria-slice'; -import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice'; -import {tabSetReducer as tabSet} from '../../features/tab-set/tab-set-slice'; -import {loadReducerError} from '../../utils/errors'; -import {advancedSearchQueriesReducer as advancedSearchQueries} from './../../features/advanced-search-queries/advanced-search-queries-slice'; +import {CoreEngine} from '../../app/engine.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common.js'; +import {configurationReducer as configuration} from '../../features/configuration/configuration-slice.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; +import {facetOptionsReducer as facetOptions} from '../../features/facet-options/facet-options-slice.js'; +import {automaticFacetSetReducer as automaticFacetSet} from '../../features/facets/automatic-facet-set/automatic-facet-set-slice.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../features/facets/category-facet-set/category-facet-set-slice.js'; +import {facetSetReducer as facetSet} from '../../features/facets/facet-set/facet-set-slice.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {paginationReducer as pagination} from '../../features/pagination/pagination-slice.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; +import {sortCriteriaReducer as sortCriteria} from '../../features/sort-criteria/sort-criteria-slice.js'; +import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice.js'; +import {tabSetReducer as tabSet} from '../../features/tab-set/tab-set-slice.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {advancedSearchQueriesReducer as advancedSearchQueries} from './../../features/advanced-search-queries/advanced-search-queries-slice.js'; import { SearchParameterManager, SearchParameterManagerInitialState, buildSearchParameterManager, -} from './headless-search-parameter-manager'; +} from './headless-search-parameter-manager.js'; -export * from './headless-search-parameter-manager'; +export * from './headless-search-parameter-manager.js'; export interface SearchParameterManagerBuildProps { initialState: SearchParameterManagerInitialState; diff --git a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.test.ts b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.test.ts index 5b2bf9a03a7..d8593c7802f 100644 --- a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.test.ts +++ b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.test.ts @@ -1,38 +1,38 @@ -import {restoreSearchParameters} from '../../features/search-parameters/search-parameter-actions'; -import {initialSearchParameterSelector} from '../../features/search-parameters/search-parameter-selectors'; -import {executeSearch} from '../../features/search/search-actions'; -import {buildMockAutomaticFacetResponse} from '../../test/mock-automatic-facet-response'; -import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice'; -import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValueRequest} from '../../test/mock-category-facet-value-request'; -import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request'; -import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../test/mock-date-facet-value'; +import {restoreSearchParameters} from '../../features/search-parameters/search-parameter-actions.js'; +import {initialSearchParameterSelector} from '../../features/search-parameters/search-parameter-selectors.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {buildMockAutomaticFacetResponse} from '../../test/mock-automatic-facet-response.js'; +import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice.js'; +import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../test/mock-category-facet-value-request.js'; +import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request.js'; +import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../test/mock-facet-value'; -import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request'; -import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../test/mock-numeric-facet-value'; -import {buildMockSearchParameters} from '../../test/mock-search-parameters'; -import {createMockState} from '../../test/mock-state'; -import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value'; -import {buildMockTabSlice} from '../../test/mock-tab-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../test/mock-facet-value-request.js'; +import {buildMockFacetValue} from '../../test/mock-facet-value.js'; +import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../test/mock-numeric-facet-value.js'; +import {buildMockSearchParameters} from '../../test/mock-search-parameters.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value.js'; +import {buildMockTabSlice} from '../../test/mock-tab-state.js'; import { buildSearchParameterManager, SearchParameterManager, SearchParameterManagerProps, -} from './headless-search-parameter-manager'; +} from './headless-search-parameter-manager.js'; -jest.mock('../../features/search-parameters/search-parameter-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/search-parameters/search-parameter-actions'); +vi.mock('../../features/search/search-actions'); describe('search parameter manager', () => { let engine: MockedSearchEngine; @@ -44,7 +44,7 @@ describe('search parameter manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); props = { initialState: { diff --git a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ts b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ts index 53e67beff30..aa43a19d195 100644 --- a/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ts +++ b/packages/headless/src/controllers/search-parameter-manager/headless-search-parameter-manager.ts @@ -1,16 +1,16 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {getDebugInitialState} from '../../features/debug/debug-state'; -import {getPaginationInitialState} from '../../features/pagination/pagination-state'; -import {getQueryInitialState} from '../../features/query/query-state'; -import {SearchParameters} from '../../features/search-parameters/search-parameter-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {getDebugInitialState} from '../../features/debug/debug-state.js'; +import {getPaginationInitialState} from '../../features/pagination/pagination-state.js'; +import {getQueryInitialState} from '../../features/query/query-state.js'; +import {SearchParameters} from '../../features/search-parameters/search-parameter-actions.js'; import { legacyLogParametersChange, parametersChange, -} from '../../features/search-parameters/search-parameter-analytics-actions'; -import {executeSearch} from '../../features/search/search-actions'; -import {StaticFilterValue} from '../../features/static-filter-set/static-filter-set-state'; -import {SearchParametersState} from '../../state/search-app-state'; -import {deepEqualAnyOrder} from '../../utils/compare-utils'; +} from '../../features/search-parameters/search-parameter-analytics-actions.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {StaticFilterValue} from '../../features/static-filter-set/static-filter-set-state.js'; +import {SearchParametersState} from '../../state/search-app-state.js'; +import {deepEqualAnyOrder} from '../../utils/compare-utils.js'; import { buildCoreSearchParameterManager, enrichParameters, @@ -20,7 +20,7 @@ import { SearchParameterManagerProps, SearchParameterManagerState, validateParams, -} from '../core/search-parameter-manager/headless-core-search-parameter-manager'; +} from '../core/search-parameter-manager/headless-core-search-parameter-manager.js'; export type { SearchParameters, diff --git a/packages/headless/src/controllers/search-status/headless-search-status.ssr.ts b/packages/headless/src/controllers/search-status/headless-search-status.ssr.ts index 95b57834f6d..cc991d4688f 100644 --- a/packages/headless/src/controllers/search-status/headless-search-status.ssr.ts +++ b/packages/headless/src/controllers/search-status/headless-search-status.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {SearchStatus, buildSearchStatus} from './headless-search-status'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {SearchStatus, buildSearchStatus} from './headless-search-status.js'; -export * from './headless-search-status'; +export * from './headless-search-status.js'; export interface SearchStatusDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/search-status/headless-search-status.ts b/packages/headless/src/controllers/search-status/headless-search-status.ts index df46031adbb..796b047c924 100644 --- a/packages/headless/src/controllers/search-status/headless-search-status.ts +++ b/packages/headless/src/controllers/search-status/headless-search-status.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { buildCoreStatus, SearchStatusState, SearchStatus, -} from '../core/status/headless-core-status'; +} from '../core/status/headless-core-status.js'; export type {SearchStatusState, SearchStatus}; diff --git a/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-interactive-questions.ts b/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-interactive-questions.ts index 458a4a1fbc9..168867d40fd 100644 --- a/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-interactive-questions.ts +++ b/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-interactive-questions.ts @@ -1,19 +1,19 @@ -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logOpenSmartSnippetSuggestionSource} from '../../features/question-answering/question-answering-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logOpenSmartSnippetSuggestionSource} from '../../features/question-answering/question-answering-analytics-actions.js'; import { answerSourceSelector, relatedQuestionSelector, -} from '../../features/question-answering/question-answering-selectors'; -import {questionAnsweringReducer as questionAnswering} from '../../features/question-answering/question-answering-slice'; -import {pushRecentResult} from '../../features/recent-results/recent-results-actions'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {QuestionAnsweringSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; +} from '../../features/question-answering/question-answering-selectors.js'; +import {questionAnsweringReducer as questionAnswering} from '../../features/question-answering/question-answering-slice.js'; +import {pushRecentResult} from '../../features/recent-results/recent-results-actions.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {QuestionAnsweringSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; import { buildInteractiveResultCore, InteractiveResultCore, -} from '../core/interactive-result/headless-core-interactive-result'; +} from '../core/interactive-result/headless-core-interactive-result.js'; /** * @internal diff --git a/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.ts b/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.ts index d7830477e02..f17fddc0851 100644 --- a/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.ts +++ b/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {SmartSnippetQuestionsListProps} from '../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {SmartSnippetQuestionsListProps} from '../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.js'; import { SmartSnippetQuestionsList, buildSmartSnippetQuestionsList, -} from './headless-smart-snippet-questions-list'; +} from './headless-smart-snippet-questions-list.js'; -export * from './headless-smart-snippet-questions-list'; +export * from './headless-smart-snippet-questions-list.js'; export interface SmartSnippetQuestionsListDefinition extends ControllerDefinitionWithoutProps< diff --git a/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ts b/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ts index bc10faebef2..1b020177e09 100644 --- a/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ts +++ b/packages/headless/src/controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ts @@ -1,25 +1,25 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {smartSnippetAnalyticsClient} from '../../features/question-answering/question-answering-analytics-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {smartSnippetAnalyticsClient} from '../../features/question-answering/question-answering-analytics-actions.js'; import { buildCoreSmartSnippetQuestionsList, CoreSmartSnippetQuestionsListState, CoreSmartSnippetQuestionsList, SmartSnippetQuestionsListProps, -} from '../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list'; +} from '../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.js'; import { buildSmartSnippetInteractiveInlineLinks, InlineLink, -} from '../smart-snippet/headless-smart-snippet-interactive-inline-links'; -import {buildSmartSnippetInteractiveQuestions} from './headless-smart-snippet-interactive-questions'; +} from '../smart-snippet/headless-smart-snippet-interactive-inline-links.js'; +import {buildSmartSnippetInteractiveQuestions} from './headless-smart-snippet-interactive-questions.js'; -export type {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering'; +export type {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering.js'; export type { SmartSnippetQuestionsListOptions, SmartSnippetQuestionsListProps, SmartSnippetRelatedQuestion, CoreSmartSnippetQuestionsList, CoreSmartSnippetQuestionsListState, -} from '../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list'; +} from '../core/smart-snippet-questions-list/headless-core-smart-snippet-questions-list.js'; /** * A scoped and simplified part of the headless state that is relevant to the `SmartSnippetQuestionsList` controller. diff --git a/packages/headless/src/controllers/smart-snippet/headless-smart-snippet-interactive-inline-links.ts b/packages/headless/src/controllers/smart-snippet/headless-smart-snippet-interactive-inline-links.ts index 524ac8f5e01..748f643df93 100644 --- a/packages/headless/src/controllers/smart-snippet/headless-smart-snippet-interactive-inline-links.ts +++ b/packages/headless/src/controllers/smart-snippet/headless-smart-snippet-interactive-inline-links.ts @@ -1,17 +1,17 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { logOpenSmartSnippetInlineLink, logOpenSmartSnippetSuggestionInlineLink, -} from '../../features/question-answering/question-answering-analytics-actions'; -import {questionAnsweringReducer as questionAnswering} from '../../features/question-answering/question-answering-slice'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {QuestionAnsweringSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {getObjectHash} from '../../utils/utils'; +} from '../../features/question-answering/question-answering-analytics-actions.js'; +import {questionAnsweringReducer as questionAnswering} from '../../features/question-answering/question-answering-slice.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {QuestionAnsweringSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {getObjectHash} from '../../utils/utils.js'; import { buildInteractiveResultCore, InteractiveResultCore, -} from '../core/interactive-result/headless-core-interactive-result'; +} from '../core/interactive-result/headless-core-interactive-result.js'; export interface InlineLink { /** diff --git a/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ssr.ts b/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ssr.ts index 9976f687eac..73eda35d3fe 100644 --- a/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ssr.ts +++ b/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { SmartSnippet, SmartSnippetProps, buildSmartSnippet, -} from './headless-smart-snippet'; +} from './headless-smart-snippet.js'; -export * from './headless-smart-snippet'; +export * from './headless-smart-snippet.js'; export interface SmartSnippetDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ts b/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ts index 6bd3a54514c..9e1a095b8f6 100644 --- a/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ts +++ b/packages/headless/src/controllers/smart-snippet/headless-smart-snippet.ts @@ -1,5 +1,5 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {smartSnippetAnalyticsClient} from '../../features/question-answering/question-answering-analytics-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {smartSnippetAnalyticsClient} from '../../features/question-answering/question-answering-analytics-actions.js'; import { SmartSnippet, SmartSnippetCore, @@ -7,10 +7,10 @@ import { SmartSnippetProps, SmartSnippetState, buildCoreSmartSnippet, -} from '../core/smart-snippet/headless-core-smart-snippet'; -import {buildSmartSnippetInteractiveInlineLinks} from './headless-smart-snippet-interactive-inline-links'; +} from '../core/smart-snippet/headless-core-smart-snippet.js'; +import {buildSmartSnippetInteractiveInlineLinks} from './headless-smart-snippet-interactive-inline-links.js'; -export type {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering'; +export type {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering.js'; export type { SmartSnippet, SmartSnippetOptions, diff --git a/packages/headless/src/controllers/sort/headless-sort.ssr.ts b/packages/headless/src/controllers/sort/headless-sort.ssr.ts index fb4fedbb12d..c890447c1b6 100644 --- a/packages/headless/src/controllers/sort/headless-sort.ssr.ts +++ b/packages/headless/src/controllers/sort/headless-sort.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {Sort, SortProps, buildSort} from './headless-sort'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {Sort, SortProps, buildSort} from './headless-sort.js'; -export * from './headless-sort'; +export * from './headless-sort.js'; export interface SortDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/sort/headless-sort.test.ts b/packages/headless/src/controllers/sort/headless-sort.test.ts index f5dfe021775..2ff87b93625 100644 --- a/packages/headless/src/controllers/sort/headless-sort.test.ts +++ b/packages/headless/src/controllers/sort/headless-sort.test.ts @@ -1,18 +1,18 @@ -import {executeSearch} from '../../features/search/search-actions'; +import {executeSearch} from '../../features/search/search-actions.js'; import { buildDateSortCriterion, SortOrder, -} from '../../features/sort-criteria/criteria'; -import {updateSortCriterion} from '../../features/sort-criteria/sort-criteria-actions'; +} from '../../features/sort-criteria/criteria.js'; +import {updateSortCriterion} from '../../features/sort-criteria/sort-criteria-actions.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {Sort, SortProps, buildSort} from './headless-sort'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {Sort, SortProps, buildSort} from './headless-sort.js'; -jest.mock('../../features/sort-criteria/sort-criteria-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/sort-criteria/sort-criteria-actions'); +vi.mock('../../features/search/search-actions'); describe('Sort', () => { let engine: MockedSearchEngine; @@ -24,7 +24,7 @@ describe('Sort', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); props = { initialState: {}, diff --git a/packages/headless/src/controllers/sort/headless-sort.ts b/packages/headless/src/controllers/sort/headless-sort.ts index f164bde1430..903cb7a1eab 100644 --- a/packages/headless/src/controllers/sort/headless-sort.ts +++ b/packages/headless/src/controllers/sort/headless-sort.ts @@ -1,17 +1,17 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {executeSearch} from '../../features/search/search-actions'; -import {SortCriterion} from '../../features/sort-criteria/criteria'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {SortCriterion} from '../../features/sort-criteria/criteria.js'; import { logResultsSort, resultsSort, -} from '../../features/sort-criteria/sort-criteria-analytics-actions'; +} from '../../features/sort-criteria/sort-criteria-analytics-actions.js'; import { buildCoreSort, Sort, SortProps, SortState, SortInitialState, -} from '../core/sort/headless-core-sort'; +} from '../core/sort/headless-core-sort.js'; export type {Sort, SortProps, SortState, SortInitialState}; diff --git a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box-options.ts b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box-options.ts index 4f1bd602a76..f995e280c1a 100644 --- a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box-options.ts +++ b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box-options.ts @@ -2,7 +2,7 @@ import {BooleanValue, Schema, StringValue} from '@coveo/bueno'; import { searchBoxOptionDefinitions, SearchBoxOptions, -} from '../core/search-box/headless-core-search-box-options'; +} from '../core/search-box/headless-core-search-box-options.js'; export interface StandaloneSearchBoxOptions extends SearchBoxOptions { /** diff --git a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ssr.ts b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ssr.ts index b293fb2ccf4..5363faa7d6c 100644 --- a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ssr.ts +++ b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { StandaloneSearchBox, StandaloneSearchBoxProps, buildStandaloneSearchBox, -} from './headless-standalone-search-box'; +} from './headless-standalone-search-box.js'; -export * from './headless-standalone-search-box'; +export * from './headless-standalone-search-box.js'; export interface StandaloneSearchBoxDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.test.ts b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.test.ts index e436dace5d1..c9ddb524dce 100644 --- a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.test.ts +++ b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.test.ts @@ -1,40 +1,40 @@ -import {configuration} from '../../app/common-reducers'; +import {configuration} from '../../app/common-reducers.js'; import { registerQuerySetQuery, updateQuerySetQuery, -} from '../../features/query-set/query-set-actions'; -import {selectQuerySuggestion} from '../../features/query-suggest/query-suggest-actions'; -import {querySuggestReducer as querySuggest} from '../../features/query-suggest/query-suggest-slice'; -import {updateQuery} from '../../features/query/query-actions'; -import {queryReducer as query} from '../../features/query/query-slice'; +} from '../../features/query-set/query-set-actions.js'; +import {selectQuerySuggestion} from '../../features/query-suggest/query-suggest-actions.js'; +import {querySuggestReducer as querySuggest} from '../../features/query-suggest/query-suggest-slice.js'; +import {updateQuery} from '../../features/query/query-actions.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; import { fetchRedirectUrl, registerStandaloneSearchBox, resetStandaloneSearchBox, updateAnalyticsToOmniboxFromLink, updateAnalyticsToSearchFromLink, -} from '../../features/standalone-search-box-set/standalone-search-box-set-actions'; -import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../features/standalone-search-box-set/standalone-search-box-set-slice'; -import {StandaloneSearchBoxAnalytics} from '../../features/standalone-search-box-set/standalone-search-box-set-state'; -import {SearchAppState} from '../../state/search-app-state'; +} from '../../features/standalone-search-box-set/standalone-search-box-set-actions.js'; +import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../features/standalone-search-box-set/standalone-search-box-set-slice.js'; +import {StandaloneSearchBoxAnalytics} from '../../features/standalone-search-box-set/standalone-search-box-set-state.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockOmniboxSuggestionMetadata} from '../../test/mock-omnibox-suggestion-metadata'; -import {buildMockQuerySuggest} from '../../test/mock-query-suggest'; -import {buildMockStandaloneSearchBoxEntry} from '../../test/mock-standalone-search-box-entry'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockOmniboxSuggestionMetadata} from '../../test/mock-omnibox-suggestion-metadata.js'; +import {buildMockQuerySuggest} from '../../test/mock-query-suggest.js'; +import {buildMockStandaloneSearchBoxEntry} from '../../test/mock-standalone-search-box-entry.js'; +import {createMockState} from '../../test/mock-state.js'; import { buildStandaloneSearchBox, StandaloneSearchBox, StandaloneSearchBoxOptions, -} from './headless-standalone-search-box'; +} from './headless-standalone-search-box.js'; -jest.mock('../../features/query-set/query-set-actions'); -jest.mock('../../features/query-suggest/query-suggest-actions'); -jest.mock('../../features/query/query-actions'); -jest.mock( +vi.mock('../../features/query-set/query-set-actions'); +vi.mock('../../features/query-suggest/query-suggest-actions'); +vi.mock('../../features/query/query-actions'); +vi.mock( '../../features/standalone-search-box-set/standalone-search-box-set-actions' ); @@ -110,6 +110,7 @@ describe('headless standalone searchBox', () => { it('should return the right state', () => { expect(searchBox.state).toEqual({ + searchBoxId: id, value: state.querySet[id], suggestions: state.querySuggest[id]!.completions.map((completion) => ({ value: completion.expression, @@ -183,7 +184,7 @@ describe('headless standalone searchBox', () => { }); it('calls #submit', () => { - jest.spyOn(searchBox, 'submit'); + vi.spyOn(searchBox, 'submit'); searchBox.selectSuggestion('a'); expect(searchBox.submit).toHaveBeenCalledTimes(1); diff --git a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ts b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ts index db60fddcf56..20fdf2eda96 100644 --- a/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ts +++ b/packages/headless/src/controllers/standalone-search-box/headless-standalone-search-box.ts @@ -1,10 +1,10 @@ -import {configuration} from '../../app/common-reducers'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {selectQuerySuggestion} from '../../features/query-suggest/query-suggest-actions'; -import {buildOmniboxSuggestionMetadata} from '../../features/query-suggest/query-suggest-analytics-actions'; -import {querySuggestReducer as querySuggest} from '../../features/query-suggest/query-suggest-slice'; -import {updateQuery} from '../../features/query/query-actions'; -import {queryReducer as query} from '../../features/query/query-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {selectQuerySuggestion} from '../../features/query-suggest/query-suggest-actions.js'; +import {buildOmniboxSuggestionMetadata} from '../../features/query-suggest/query-suggest-analytics-actions.js'; +import {querySuggestReducer as querySuggest} from '../../features/query-suggest/query-suggest-slice.js'; +import {updateQuery} from '../../features/query/query-actions.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; import { fetchRedirectUrl, registerStandaloneSearchBox, @@ -12,28 +12,28 @@ import { updateAnalyticsToSearchFromLink, resetStandaloneSearchBox, updateStandaloneSearchBoxRedirectionUrl, -} from '../../features/standalone-search-box-set/standalone-search-box-set-actions'; -import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../features/standalone-search-box-set/standalone-search-box-set-slice'; -import {StandaloneSearchBoxAnalytics} from '../../features/standalone-search-box-set/standalone-search-box-set-state'; +} from '../../features/standalone-search-box-set/standalone-search-box-set-actions.js'; +import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../features/standalone-search-box-set/standalone-search-box-set-slice.js'; +import {StandaloneSearchBoxAnalytics} from '../../features/standalone-search-box-set/standalone-search-box-set-state.js'; import { ConfigurationSection, QuerySection, QuerySuggestionSection, StandaloneSearchBoxSection, -} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {randomID} from '../../utils/utils'; -import {validateOptions} from '../../utils/validate-payload'; -import {defaultSearchBoxOptions} from '../core/search-box/headless-core-search-box-options'; +} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {randomID} from '../../utils/utils.js'; +import {validateOptions} from '../../utils/validate-payload.js'; +import {defaultSearchBoxOptions} from '../core/search-box/headless-core-search-box-options.js'; import { buildSearchBox, SearchBox, SearchBoxState, -} from '../search-box/headless-search-box'; +} from '../search-box/headless-search-box.js'; import { StandaloneSearchBoxOptions, standaloneSearchBoxSchema, -} from './headless-standalone-search-box-options'; +} from './headless-standalone-search-box-options.js'; export type {StandaloneSearchBoxOptions, StandaloneSearchBoxAnalytics}; diff --git a/packages/headless/src/controllers/static-filter/headless-static-filter.ssr.ts b/packages/headless/src/controllers/static-filter/headless-static-filter.ssr.ts index 3c532fd0b86..86910aad997 100644 --- a/packages/headless/src/controllers/static-filter/headless-static-filter.ssr.ts +++ b/packages/headless/src/controllers/static-filter/headless-static-filter.ssr.ts @@ -1,14 +1,14 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; import { StaticFilter, StaticFilterProps, buildStaticFilter, -} from './headless-static-filter'; +} from './headless-static-filter.js'; -export * from './headless-static-filter'; +export * from './headless-static-filter.js'; -export {buildStaticFilterValue} from './headless-static-filter'; +export {buildStaticFilterValue} from './headless-static-filter.js'; export interface StaticFilterDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/static-filter/headless-static-filter.test.ts b/packages/headless/src/controllers/static-filter/headless-static-filter.test.ts index 3469967028a..1ac8e623574 100644 --- a/packages/headless/src/controllers/static-filter/headless-static-filter.test.ts +++ b/packages/headless/src/controllers/static-filter/headless-static-filter.test.ts @@ -1,26 +1,26 @@ -import {executeSearch} from '../../features/search/search-actions'; +import {executeSearch} from '../../features/search/search-actions.js'; import { deselectAllStaticFilterValues, registerStaticFilter, toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from '../../features/static-filter-set/static-filter-set-actions'; -import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice'; +} from '../../features/static-filter-set/static-filter-set-actions.js'; +import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value.js'; import { buildStaticFilter, StaticFilter, StaticFilterOptions, -} from './headless-static-filter'; +} from './headless-static-filter.js'; -jest.mock('../../features/search/search-actions'); -jest.mock('../../features/static-filter-set/static-filter-set-actions'); +vi.mock('../../features/search/search-actions'); +vi.mock('../../features/static-filter-set/static-filter-set-actions'); describe('Static Filter', () => { let engine: MockedSearchEngine; @@ -32,7 +32,7 @@ describe('Static Filter', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); options = { id: 'a', diff --git a/packages/headless/src/controllers/static-filter/headless-static-filter.ts b/packages/headless/src/controllers/static-filter/headless-static-filter.ts index c329c094c4f..4fefb1e1d8c 100644 --- a/packages/headless/src/controllers/static-filter/headless-static-filter.ts +++ b/packages/headless/src/controllers/static-filter/headless-static-filter.ts @@ -1,9 +1,9 @@ import {Schema} from '@coveo/bueno'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { SearchAction, executeSearch, -} from '../../features/search/search-actions'; +} from '../../features/search/search-actions.js'; import { deselectAllStaticFilterValues, logStaticFilterClearAll, @@ -15,24 +15,27 @@ import { staticFilterSelect, toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from '../../features/static-filter-set/static-filter-set-actions'; +} from '../../features/static-filter-set/static-filter-set-actions.js'; import { staticFilterIdSchema, staticFilterValuesSchema, -} from '../../features/static-filter-set/static-filter-set-schema'; -import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice'; +} from '../../features/static-filter-set/static-filter-set-schema.js'; +import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice.js'; import { StaticFilterValue, StaticFilterValueState, -} from '../../features/static-filter-set/static-filter-set-state'; -import {StaticFilterSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {validateOptions} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; +} from '../../features/static-filter-set/static-filter-set-state.js'; +import {StaticFilterSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {validateOptions} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; import { buildStaticFilterValue, StaticFilterValueOptions, -} from './static-filter-value'; +} from './static-filter-value.js'; export type { StaticFilterValue, diff --git a/packages/headless/src/controllers/static-filter/static-filter-value.test.ts b/packages/headless/src/controllers/static-filter/static-filter-value.test.ts index 70961228d3b..2da198722bd 100644 --- a/packages/headless/src/controllers/static-filter/static-filter-value.test.ts +++ b/packages/headless/src/controllers/static-filter/static-filter-value.test.ts @@ -1,4 +1,4 @@ -import {buildStaticFilterValue} from './static-filter-value'; +import {buildStaticFilterValue} from './static-filter-value.js'; describe('#buildStaticFilterValue', () => { it('when #state is not specified, it defaults to idle', () => { diff --git a/packages/headless/src/controllers/static-filter/static-filter-value.ts b/packages/headless/src/controllers/static-filter/static-filter-value.ts index a13a13a9697..18ab0cc2bff 100644 --- a/packages/headless/src/controllers/static-filter/static-filter-value.ts +++ b/packages/headless/src/controllers/static-filter/static-filter-value.ts @@ -1,7 +1,7 @@ import { StaticFilterValue, StaticFilterValueState, -} from '../../features/static-filter-set/static-filter-set-state'; +} from '../../features/static-filter-set/static-filter-set-state.js'; export interface StaticFilterValueOptions { /** diff --git a/packages/headless/src/controllers/tab-manager/headless-tab-manager.ssr.ts b/packages/headless/src/controllers/tab-manager/headless-tab-manager.ssr.ts index 318b49d2ebe..1f62c6872d9 100644 --- a/packages/headless/src/controllers/tab-manager/headless-tab-manager.ssr.ts +++ b/packages/headless/src/controllers/tab-manager/headless-tab-manager.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {TabManager, buildTabManager} from './headless-tab-manager'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {TabManager, buildTabManager} from './headless-tab-manager.js'; -export * from './headless-tab-manager'; +export * from './headless-tab-manager.js'; export interface TabManagerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/tab-manager/headless-tab-manager.test.ts b/packages/headless/src/controllers/tab-manager/headless-tab-manager.test.ts index f5fab3131b3..32ddb5e4fb1 100644 --- a/packages/headless/src/controllers/tab-manager/headless-tab-manager.test.ts +++ b/packages/headless/src/controllers/tab-manager/headless-tab-manager.test.ts @@ -1,11 +1,11 @@ import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildTabManager, TabManager} from './headless-tab-manager'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildTabManager, TabManager} from './headless-tab-manager.js'; -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/search/search-actions'); describe('Tab', () => { let engine: MockedSearchEngine; diff --git a/packages/headless/src/controllers/tab-manager/headless-tab-manager.ts b/packages/headless/src/controllers/tab-manager/headless-tab-manager.ts index 24869e576fa..bb599190755 100644 --- a/packages/headless/src/controllers/tab-manager/headless-tab-manager.ts +++ b/packages/headless/src/controllers/tab-manager/headless-tab-manager.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { TabManager, TabManagerState, buildCoreTabManager, -} from '../core/tab-manager/headless-core-tab-manager'; +} from '../core/tab-manager/headless-core-tab-manager.js'; export type {TabManager, TabManagerState}; diff --git a/packages/headless/src/controllers/tab/headless-tab.ssr.ts b/packages/headless/src/controllers/tab/headless-tab.ssr.ts index 89060559be2..8817fcbf23e 100644 --- a/packages/headless/src/controllers/tab/headless-tab.ssr.ts +++ b/packages/headless/src/controllers/tab/headless-tab.ssr.ts @@ -1,8 +1,8 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {Tab, TabProps, buildTab} from './headless-tab'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {Tab, TabProps, buildTab} from './headless-tab.js'; -export * from './headless-tab'; +export * from './headless-tab.js'; export interface TabDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/tab/headless-tab.test.ts b/packages/headless/src/controllers/tab/headless-tab.test.ts index 356ad886af3..36c5a4edac6 100644 --- a/packages/headless/src/controllers/tab/headless-tab.test.ts +++ b/packages/headless/src/controllers/tab/headless-tab.test.ts @@ -1,12 +1,12 @@ -import {executeSearch} from '../../features/search/search-actions'; +import {executeSearch} from '../../features/search/search-actions.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {buildTab, Tab, TabProps} from './headless-tab'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildTab, Tab, TabProps} from './headless-tab.js'; -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/search/search-actions'); describe('Tab', () => { const expression = 'abc123'; diff --git a/packages/headless/src/controllers/tab/headless-tab.ts b/packages/headless/src/controllers/tab/headless-tab.ts index b5fcae6de5c..e397865b881 100644 --- a/packages/headless/src/controllers/tab/headless-tab.ts +++ b/packages/headless/src/controllers/tab/headless-tab.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { interfaceChange, logInterfaceChange, -} from '../../features/analytics/analytics-actions'; -import {executeSearch} from '../../features/search/search-actions'; +} from '../../features/analytics/analytics-actions.js'; +import {executeSearch} from '../../features/search/search-actions.js'; import { buildCoreTab, Tab, @@ -11,7 +11,7 @@ import { TabState, TabInitialState, TabOptions, -} from '../core/tab/headless-core-tab'; +} from '../core/tab/headless-core-tab.js'; export type {Tab, TabProps, TabState, TabInitialState, TabOptions}; diff --git a/packages/headless/src/controllers/triggers/headless-execute-trigger.ssr.ts b/packages/headless/src/controllers/triggers/headless-execute-trigger.ssr.ts index 92c21aa74d9..d6fd5b9fb89 100644 --- a/packages/headless/src/controllers/triggers/headless-execute-trigger.ssr.ts +++ b/packages/headless/src/controllers/triggers/headless-execute-trigger.ssr.ts @@ -1,8 +1,11 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {ExecuteTrigger, buildExecuteTrigger} from './headless-execute-trigger'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import { + ExecuteTrigger, + buildExecuteTrigger, +} from './headless-execute-trigger.js'; -export * from './headless-execute-trigger'; +export * from './headless-execute-trigger.js'; export interface ExecuteTriggerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/triggers/headless-execute-trigger.test.ts b/packages/headless/src/controllers/triggers/headless-execute-trigger.test.ts index b1d9c61ea0c..f9d53b6733d 100644 --- a/packages/headless/src/controllers/triggers/headless-execute-trigger.test.ts +++ b/packages/headless/src/controllers/triggers/headless-execute-trigger.test.ts @@ -1,14 +1,18 @@ -import {logTriggerExecute} from '../../features/triggers/trigger-analytics-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; -import {FunctionExecutionTrigger} from '../../features/triggers/triggers-state'; +import {Mock} from 'vitest'; +import {logTriggerExecute} from '../../features/triggers/trigger-analytics-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; +import {FunctionExecutionTrigger} from '../../features/triggers/triggers-state.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {ExecuteTrigger, buildExecuteTrigger} from './headless-execute-trigger'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import { + ExecuteTrigger, + buildExecuteTrigger, +} from './headless-execute-trigger.js'; -jest.mock('../../features/triggers/trigger-analytics-actions'); +vi.mock('../../features/triggers/trigger-analytics-actions'); describe('ExecuteTrigger', () => { let engine: MockedSearchEngine; @@ -23,11 +27,11 @@ describe('ExecuteTrigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); initExecuteTrigger(); }); @@ -47,7 +51,7 @@ describe('ExecuteTrigger', () => { }); describe('when the #engine.state.triggers.executions is not updated', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initExecuteTrigger(); @@ -67,7 +71,7 @@ describe('ExecuteTrigger', () => { }); describe('when the #engine.state.triggers.executions is updated', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initExecuteTrigger(); @@ -99,7 +103,7 @@ describe('ExecuteTrigger', () => { }); describe('when the #engine.state.triggers.executions is updated with an empty array', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initExecuteTrigger(); @@ -120,7 +124,7 @@ describe('ExecuteTrigger', () => { }); describe('when a non-empty #engine.state.triggers.executions is updated with an empty array', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); setEngineTriggersState([ @@ -145,7 +149,7 @@ describe('ExecuteTrigger', () => { }); describe('when a non-empty #engine.state.triggers.executions is updated with the same array', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); setEngineTriggersState([ diff --git a/packages/headless/src/controllers/triggers/headless-execute-trigger.ts b/packages/headless/src/controllers/triggers/headless-execute-trigger.ts index 81435314a8d..16deeb4875e 100644 --- a/packages/headless/src/controllers/triggers/headless-execute-trigger.ts +++ b/packages/headless/src/controllers/triggers/headless-execute-trigger.ts @@ -1,11 +1,14 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logTriggerExecute} from '../../features/triggers/trigger-analytics-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; -import {FunctionExecutionTrigger} from '../../features/triggers/triggers-state'; -import {TriggerSection} from '../../state/state-sections'; -import {arrayEqual} from '../../utils/compare-utils'; -import {loadReducerError} from '../../utils/errors'; -import {buildController, Controller} from '../controller/headless-controller'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logTriggerExecute} from '../../features/triggers/trigger-analytics-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; +import {FunctionExecutionTrigger} from '../../features/triggers/triggers-state.js'; +import {TriggerSection} from '../../state/state-sections.js'; +import {arrayEqual} from '../../utils/compare-utils.js'; +import {loadReducerError} from '../../utils/errors.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; /** * The `ExecuteTrigger` controller handles Execute triggers from the query response. An [Execute trigger](https://docs.coveo.com/en/3413#execute) query pipeline rule lets you define a custom JavaScript function to be executed in the frontend when a certain condition is met. diff --git a/packages/headless/src/controllers/triggers/headless-notify-trigger.ssr.ts b/packages/headless/src/controllers/triggers/headless-notify-trigger.ssr.ts index d18ab57ac26..8e82de2383b 100644 --- a/packages/headless/src/controllers/triggers/headless-notify-trigger.ssr.ts +++ b/packages/headless/src/controllers/triggers/headless-notify-trigger.ssr.ts @@ -1,13 +1,13 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {NotifyTrigger} from '../core/triggers/headless-core-notify-trigger'; -import {buildNotifyTrigger} from './headless-notify-trigger'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {NotifyTrigger} from '../core/triggers/headless-core-notify-trigger.js'; +import {buildNotifyTrigger} from './headless-notify-trigger.js'; -export {buildNotifyTrigger} from './headless-notify-trigger'; +export {buildNotifyTrigger} from './headless-notify-trigger.js'; export type { NotifyTrigger, NotifyTriggerState, -} from '../core/triggers/headless-core-notify-trigger'; +} from '../core/triggers/headless-core-notify-trigger.js'; export interface NotifyTriggerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/triggers/headless-notify-trigger.test.ts b/packages/headless/src/controllers/triggers/headless-notify-trigger.test.ts index efcaefecb30..83cb8e7b0b2 100644 --- a/packages/headless/src/controllers/triggers/headless-notify-trigger.test.ts +++ b/packages/headless/src/controllers/triggers/headless-notify-trigger.test.ts @@ -1,14 +1,15 @@ -import {logNotifyTrigger} from '../../features/triggers/trigger-analytics-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; +import {Mock} from 'vitest'; +import {logNotifyTrigger} from '../../features/triggers/trigger-analytics-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {NotifyTrigger} from '../core/triggers/headless-core-notify-trigger'; -import {buildNotifyTrigger} from './headless-notify-trigger'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {NotifyTrigger} from '../core/triggers/headless-core-notify-trigger.js'; +import {buildNotifyTrigger} from './headless-notify-trigger.js'; -jest.mock('../../features/triggers/trigger-analytics-actions'); +vi.mock('../../features/triggers/trigger-analytics-actions'); describe('NotifyTrigger', () => { let engine: MockedSearchEngine; @@ -23,11 +24,11 @@ describe('NotifyTrigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); initNotifyTrigger(); }); @@ -47,7 +48,7 @@ describe('NotifyTrigger', () => { }); describe('when the #engine.state.triggers.notifications is not updated', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initNotifyTrigger(); @@ -66,7 +67,7 @@ describe('NotifyTrigger', () => { }); describe('when the #engine.state.triggers.notifications is updated', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initNotifyTrigger(); @@ -86,7 +87,7 @@ describe('NotifyTrigger', () => { }); describe('when the #engine.state.triggers.notifications is updated with an empty array', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initNotifyTrigger(); @@ -106,7 +107,7 @@ describe('NotifyTrigger', () => { }); describe('when a non-empty #engine.state.triggers.notifications is updated with an empty array', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); setEngineTriggersState(['hello', 'world']); @@ -127,7 +128,7 @@ describe('NotifyTrigger', () => { }); describe('when a non-empty #engine.state.triggers.notifications is updated with the same array', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); setEngineTriggersState(['hello', 'world']); diff --git a/packages/headless/src/controllers/triggers/headless-notify-trigger.ts b/packages/headless/src/controllers/triggers/headless-notify-trigger.ts index 85ee21dae22..ee503661edf 100644 --- a/packages/headless/src/controllers/triggers/headless-notify-trigger.ts +++ b/packages/headless/src/controllers/triggers/headless-notify-trigger.ts @@ -1,11 +1,11 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logNotifyTrigger} from '../../features/triggers/trigger-analytics-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; -import {TriggerSection} from '../../state/state-sections'; -import {arrayEqual} from '../../utils/compare-utils'; -import {loadReducerError} from '../../utils/errors'; -import {buildController} from '../controller/headless-controller'; -import {NotifyTrigger} from '../core/triggers/headless-core-notify-trigger'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logNotifyTrigger} from '../../features/triggers/trigger-analytics-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; +import {TriggerSection} from '../../state/state-sections.js'; +import {arrayEqual} from '../../utils/compare-utils.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {buildController} from '../controller/headless-controller.js'; +import {NotifyTrigger} from '../core/triggers/headless-core-notify-trigger.js'; /** * Creates a `NotifyTrigger` controller instance. diff --git a/packages/headless/src/controllers/triggers/headless-query-trigger.ssr.ts b/packages/headless/src/controllers/triggers/headless-query-trigger.ssr.ts index 6a4d8ddd9b0..1fd83e9f66e 100644 --- a/packages/headless/src/controllers/triggers/headless-query-trigger.ssr.ts +++ b/packages/headless/src/controllers/triggers/headless-query-trigger.ssr.ts @@ -1,14 +1,14 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {QueryTrigger} from '../core/triggers/headless-core-query-trigger'; -import {buildQueryTrigger} from './headless-query-trigger'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {QueryTrigger} from '../core/triggers/headless-core-query-trigger.js'; +import {buildQueryTrigger} from './headless-query-trigger.js'; export type { QueryTrigger, QueryTriggerState, -} from '../core/triggers/headless-core-query-trigger'; +} from '../core/triggers/headless-core-query-trigger.js'; -export * from './headless-query-trigger'; +export * from './headless-query-trigger.js'; export interface QueryTriggerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/triggers/headless-query-trigger.test.ts b/packages/headless/src/controllers/triggers/headless-query-trigger.test.ts index 40ae424a5de..4e5065a9c34 100644 --- a/packages/headless/src/controllers/triggers/headless-query-trigger.test.ts +++ b/packages/headless/src/controllers/triggers/headless-query-trigger.test.ts @@ -1,17 +1,18 @@ -import {updateQuery} from '../../features/query/query-actions'; -import {queryReducer as query} from '../../features/query/query-slice'; -import {executeSearch} from '../../features/search/search-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; +import {Mock} from 'vitest'; +import {updateQuery} from '../../features/query/query-actions.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; +import {executeSearch} from '../../features/search/search-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {QueryTrigger} from '../core/triggers/headless-core-query-trigger'; -import {buildQueryTrigger} from './headless-query-trigger'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {QueryTrigger} from '../core/triggers/headless-core-query-trigger.js'; +import {buildQueryTrigger} from './headless-query-trigger.js'; -jest.mock('../../features/query/query-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/query/query-actions'); +vi.mock('../../features/search/search-actions'); describe('QueryTrigger', () => { let engine: MockedSearchEngine; @@ -22,7 +23,7 @@ describe('QueryTrigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { @@ -46,7 +47,7 @@ describe('QueryTrigger', () => { }); describe('when a search without a trigger is performed', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { engine = buildMockSearchEngine(createMockState()); initQueryTrigger(); diff --git a/packages/headless/src/controllers/triggers/headless-query-trigger.ts b/packages/headless/src/controllers/triggers/headless-query-trigger.ts index 31ce092598c..84547d9047b 100644 --- a/packages/headless/src/controllers/triggers/headless-query-trigger.ts +++ b/packages/headless/src/controllers/triggers/headless-query-trigger.ts @@ -1,17 +1,17 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {updateQuery} from '../../features/query/query-actions'; -import {queryReducer as query} from '../../features/query/query-slice'; -import {executeSearch} from '../../features/search/search-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {updateQuery} from '../../features/query/query-actions.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; +import {executeSearch} from '../../features/search/search-actions.js'; import { logUndoTriggerQuery, undoTriggerQuery, -} from '../../features/triggers/trigger-analytics-actions'; -import {updateIgnoreQueryTrigger} from '../../features/triggers/triggers-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; -import {TriggerSection, QuerySection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {buildController} from '../controller/headless-controller'; -import {QueryTrigger} from '../core/triggers/headless-core-query-trigger'; +} from '../../features/triggers/trigger-analytics-actions.js'; +import {updateIgnoreQueryTrigger} from '../../features/triggers/triggers-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; +import {TriggerSection, QuerySection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {buildController} from '../controller/headless-controller.js'; +import {QueryTrigger} from '../core/triggers/headless-core-query-trigger.js'; /** * Creates a `QueryTrigger` controller instance. diff --git a/packages/headless/src/controllers/triggers/headless-redirection-trigger.ssr.ts b/packages/headless/src/controllers/triggers/headless-redirection-trigger.ssr.ts index 614f3435236..b878c1ef0db 100644 --- a/packages/headless/src/controllers/triggers/headless-redirection-trigger.ssr.ts +++ b/packages/headless/src/controllers/triggers/headless-redirection-trigger.ssr.ts @@ -1,13 +1,13 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common'; -import {RedirectionTrigger} from '../core/triggers/headless-core-redirection-trigger'; -import {buildRedirectionTrigger} from './headless-redirection-trigger'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithoutProps} from '../../app/ssr-engine/types/common.js'; +import {RedirectionTrigger} from '../core/triggers/headless-core-redirection-trigger.js'; +import {buildRedirectionTrigger} from './headless-redirection-trigger.js'; -export {buildRedirectionTrigger} from './headless-redirection-trigger'; +export {buildRedirectionTrigger} from './headless-redirection-trigger.js'; export type { RedirectionTrigger, RedirectionTriggerState, -} from '../core/triggers/headless-core-redirection-trigger'; +} from '../core/triggers/headless-core-redirection-trigger.js'; export interface RedirectionTriggerDefinition extends ControllerDefinitionWithoutProps {} diff --git a/packages/headless/src/controllers/triggers/headless-redirection-trigger.test.ts b/packages/headless/src/controllers/triggers/headless-redirection-trigger.test.ts index c3a56eb7565..38bd4fb1d50 100644 --- a/packages/headless/src/controllers/triggers/headless-redirection-trigger.test.ts +++ b/packages/headless/src/controllers/triggers/headless-redirection-trigger.test.ts @@ -1,14 +1,15 @@ -import {logTriggerRedirect} from '../../features/triggers/trigger-analytics-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; +import {Mock} from 'vitest'; +import {logTriggerRedirect} from '../../features/triggers/trigger-analytics-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {RedirectionTrigger} from '../core/triggers/headless-core-redirection-trigger'; -import {buildRedirectionTrigger} from './headless-redirection-trigger'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {RedirectionTrigger} from '../core/triggers/headless-core-redirection-trigger.js'; +import {buildRedirectionTrigger} from './headless-redirection-trigger.js'; -jest.mock('../../features/triggers/trigger-analytics-actions'); +vi.mock('../../features/triggers/trigger-analytics-actions'); describe('RedirectionTrigger', () => { let engine: MockedSearchEngine; @@ -19,7 +20,7 @@ describe('RedirectionTrigger', () => { } function registeredListeners() { - return (engine.subscribe as jest.Mock).mock.calls.map((args) => args[0]); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0]); } beforeEach(() => { @@ -42,7 +43,7 @@ describe('RedirectionTrigger', () => { }); describe('when the #engine.state.triggers.redirectTo is already initialized', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { const state = createMockState(); state.triggers.redirectTo = 'https://www.google.com'; @@ -61,7 +62,7 @@ describe('RedirectionTrigger', () => { }); describe('when the #engine.state.triggers.redirectTo is not updated', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { redirectionTrigger.subscribe(listener); const [firstListener] = registeredListeners(); @@ -78,7 +79,7 @@ describe('RedirectionTrigger', () => { }); describe('when the #engine.state.triggers.redirectTo is updated to the empty string', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { redirectionTrigger.subscribe(listener); engine.state.triggers!.redirectTo = ''; @@ -96,7 +97,7 @@ describe('RedirectionTrigger', () => { }); describe('when the #engine.state.triggers.redirectTo is updated', () => { - const listener = jest.fn(); + const listener = vi.fn(); beforeEach(() => { redirectionTrigger.subscribe(listener); engine.state.triggers!.redirectTo = 'https://www.coveo.com'; diff --git a/packages/headless/src/controllers/triggers/headless-redirection-trigger.ts b/packages/headless/src/controllers/triggers/headless-redirection-trigger.ts index 06da02e8797..d7a30299b87 100644 --- a/packages/headless/src/controllers/triggers/headless-redirection-trigger.ts +++ b/packages/headless/src/controllers/triggers/headless-redirection-trigger.ts @@ -1,10 +1,10 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logTriggerRedirect} from '../../features/triggers/trigger-analytics-actions'; -import {triggerReducer as triggers} from '../../features/triggers/triggers-slice'; -import {TriggerSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {buildController} from '../controller/headless-controller'; -import {RedirectionTrigger} from '../core/triggers/headless-core-redirection-trigger'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logTriggerRedirect} from '../../features/triggers/trigger-analytics-actions.js'; +import {triggerReducer as triggers} from '../../features/triggers/triggers-slice.js'; +import {TriggerSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {buildController} from '../controller/headless-controller.js'; +import {RedirectionTrigger} from '../core/triggers/headless-core-redirection-trigger.js'; /** * Creates a `RedirectionTrigger` controller instance. diff --git a/packages/headless/src/controllers/url-manager/headless-url-manager.ssr.ts b/packages/headless/src/controllers/url-manager/headless-url-manager.ssr.ts index faf39eb5eb5..b173d66b267 100644 --- a/packages/headless/src/controllers/url-manager/headless-url-manager.ssr.ts +++ b/packages/headless/src/controllers/url-manager/headless-url-manager.ssr.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ControllerDefinitionWithProps} from '../../app/ssr-engine/types/common.js'; import { UrlManager, UrlManagerInitialState, buildUrlManager, -} from './headless-url-manager'; +} from './headless-url-manager.js'; -export * from './headless-url-manager'; +export * from './headless-url-manager.js'; /** * @internal diff --git a/packages/headless/src/controllers/url-manager/headless-url-manager.test.ts b/packages/headless/src/controllers/url-manager/headless-url-manager.test.ts index c4529fb87f1..40bb75f9b96 100644 --- a/packages/headless/src/controllers/url-manager/headless-url-manager.test.ts +++ b/packages/headless/src/controllers/url-manager/headless-url-manager.test.ts @@ -1,16 +1,17 @@ -import {configuration} from '../../app/common-reducers'; -import {restoreSearchParameters} from '../../features/search-parameters/search-parameter-actions'; -import {initialSearchParameterSelector} from '../../features/search-parameters/search-parameter-selectors'; -import {executeSearch} from '../../features/search/search-actions'; +import {Mock} from 'vitest'; +import {configuration} from '../../app/common-reducers.js'; +import {restoreSearchParameters} from '../../features/search-parameters/search-parameter-actions.js'; +import {initialSearchParameterSelector} from '../../features/search-parameters/search-parameter-selectors.js'; +import {executeSearch} from '../../features/search/search-actions.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockState} from '../../test/mock-state'; -import {UrlManager, buildUrlManager} from './headless-url-manager'; +} from '../../test/mock-engine-v2.js'; +import {createMockState} from '../../test/mock-state.js'; +import {UrlManager, buildUrlManager} from './headless-url-manager.js'; -jest.mock('../../features/search-parameters/search-parameter-actions'); -jest.mock('../../features/search/search-actions'); +vi.mock('../../features/search-parameters/search-parameter-actions'); +vi.mock('../../features/search/search-actions'); describe('url manager', () => { let engine: MockedSearchEngine; @@ -25,7 +26,7 @@ describe('url manager', () => { } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); engine = buildMockSearchEngine(createMockState()); initUrlManager(); }); @@ -103,20 +104,18 @@ describe('url manager', () => { describe('#subscribe', () => { function callListener() { - return (engine.subscribe as jest.Mock).mock.calls.map( - (args) => args[0] - )[0](); + return (engine.subscribe as Mock).mock.calls.map((args) => args[0])[0](); } it('should not call listener when initially subscribing', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); expect(listener).not.toHaveBeenCalled(); }); it('should not call listener when only the requestId changes', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); engine.state.search.requestId = 'abcde'; @@ -126,7 +125,7 @@ describe('url manager', () => { }); it('should not call listener when only a fragment value modified', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); engine.state.query!.q = 'albums'; @@ -136,7 +135,7 @@ describe('url manager', () => { }); it('should call listener when a fragment value is added and the requestId has changed', () => { - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); engine.state.search.requestId = 'abcde'; @@ -149,7 +148,7 @@ describe('url manager', () => { it('should call listener when a fragment value is removed and the requestId has changed', () => { initUrlManager('q=movies'); - const listener = jest.fn(); + const listener = vi.fn(); manager.subscribe(listener); engine.state.search.requestId = 'abcde'; diff --git a/packages/headless/src/controllers/url-manager/headless-url-manager.ts b/packages/headless/src/controllers/url-manager/headless-url-manager.ts index 6e34e58e4f2..0fae242e427 100644 --- a/packages/headless/src/controllers/url-manager/headless-url-manager.ts +++ b/packages/headless/src/controllers/url-manager/headless-url-manager.ts @@ -1,14 +1,17 @@ import {Schema, StringValue} from '@coveo/bueno'; -import {configuration} from '../../app/common-reducers'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {buildSearchParameterSerializer} from '../../features/search-parameters/search-parameter-serializer'; -import {SearchParametersState} from '../../state/search-app-state'; -import {ConfigurationSection} from '../../state/state-sections'; -import {deepEqualAnyOrder} from '../../utils/compare-utils'; -import {loadReducerError} from '../../utils/errors'; -import {validateInitialState} from '../../utils/validate-payload'; -import {buildController, Controller} from '../controller/headless-controller'; -import {buildSearchParameterManager} from '../search-parameter-manager/headless-search-parameter-manager'; +import {configuration} from '../../app/common-reducers.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {buildSearchParameterSerializer} from '../../features/search-parameters/search-parameter-serializer.js'; +import {SearchParametersState} from '../../state/search-app-state.js'; +import {ConfigurationSection} from '../../state/state-sections.js'; +import {deepEqualAnyOrder} from '../../utils/compare-utils.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {validateInitialState} from '../../utils/validate-payload.js'; +import { + buildController, + Controller, +} from '../controller/headless-controller.js'; +import {buildSearchParameterManager} from '../search-parameter-manager/headless-search-parameter-manager.js'; export interface UrlManagerProps { /** diff --git a/packages/headless/src/features/actions-history/ipx-actions-history-actions-loader.ts b/packages/headless/src/features/actions-history/ipx-actions-history-actions-loader.ts index faee000659a..a40895e3fba 100644 --- a/packages/headless/src/features/actions-history/ipx-actions-history-actions-loader.ts +++ b/packages/headless/src/features/actions-history/ipx-actions-history-actions-loader.ts @@ -1,6 +1,6 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {addPageViewEntryInActionsHistory} from './ipx-actions-history-actions'; +import {CoreEngine} from '../../app/engine.js'; +import {addPageViewEntryInActionsHistory} from './ipx-actions-history-actions.js'; /** * Internal and experimental actions loader for the IPX. diff --git a/packages/headless/src/features/actions-history/ipx-actions-history-actions.ts b/packages/headless/src/features/actions-history/ipx-actions-history-actions.ts index 47c6c1b805a..8af4c1323d2 100644 --- a/packages/headless/src/features/actions-history/ipx-actions-history-actions.ts +++ b/packages/headless/src/features/actions-history/ipx-actions-history-actions.ts @@ -1,6 +1,6 @@ import {createAsyncThunk} from '@reduxjs/toolkit'; -import {historyStore} from '../../api/analytics/coveo-analytics-utils'; -import {SearchAppState} from '../../state/search-app-state'; +import {historyStore} from '../../api/analytics/coveo-analytics-utils.js'; +import {SearchAppState} from '../../state/search-app-state.js'; export const addPageViewEntryInActionsHistory = createAsyncThunk( 'analytics/addPageViewEntry', diff --git a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions-loader.ts b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions-loader.ts index db87060f269..d5574dcdc98 100644 --- a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions-loader.ts +++ b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions-loader.ts @@ -1,11 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {advancedSearchQueriesReducer as advancedSearchQueries} from '../../features/advanced-search-queries/advanced-search-queries-slice'; +import {CoreEngine} from '../../app/engine.js'; +import {advancedSearchQueriesReducer as advancedSearchQueries} from '../../features/advanced-search-queries/advanced-search-queries-slice.js'; import { updateAdvancedSearchQueries, registerAdvancedSearchQueries, AdvancedSearchQueryActionCreatorPayload, -} from './advanced-search-queries-actions'; +} from './advanced-search-queries-actions.js'; export type {AdvancedSearchQueryActionCreatorPayload}; diff --git a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions.ts b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions.ts index 4d6d82d5bc7..1258c7cd81b 100644 --- a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions.ts +++ b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-actions.ts @@ -1,6 +1,6 @@ import {StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; const optionalAndPossiblyEmpty = () => new StringValue({required: false, emptyAllowed: true}); diff --git a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.test.ts b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.test.ts index 2bbde86528f..57db94d5564 100644 --- a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.test.ts +++ b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.test.ts @@ -1,16 +1,16 @@ -import {buildMockAdvancedSearchQueriesState} from '../../test/mock-advanced-search-queries-state'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; +import {buildMockAdvancedSearchQueriesState} from '../../test/mock-advanced-search-queries-state.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; import { registerAdvancedSearchQueries, updateAdvancedSearchQueries, -} from './advanced-search-queries-actions'; -import {advancedSearchQueriesReducer} from './advanced-search-queries-slice'; +} from './advanced-search-queries-actions.js'; +import {advancedSearchQueriesReducer} from './advanced-search-queries-slice.js'; import { AdvancedSearchQueriesState, getAdvancedSearchQueriesInitialState, -} from './advanced-search-queries-state'; +} from './advanced-search-queries-state.js'; describe('advanced search parameters', () => { const defaultCq = 'mock-default-cq'; diff --git a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.ts b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.ts index 2fb4e39a095..932e71861a6 100644 --- a/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.ts +++ b/packages/headless/src/features/advanced-search-queries/advanced-search-queries-slice.ts @@ -1,12 +1,12 @@ import {isUndefined} from '@coveo/bueno'; import {createReducer} from '@reduxjs/toolkit'; -import {change} from '../history/history-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; +import {change} from '../history/history-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; import { registerAdvancedSearchQueries, updateAdvancedSearchQueries, -} from './advanced-search-queries-actions'; -import {getAdvancedSearchQueriesInitialState} from './advanced-search-queries-state'; +} from './advanced-search-queries-actions.js'; +import {getAdvancedSearchQueriesInitialState} from './advanced-search-queries-state.js'; export const advancedSearchQueriesReducer = createReducer( getAdvancedSearchQueriesInitialState(), diff --git a/packages/headless/src/features/analytics/analytics-actions.ts b/packages/headless/src/features/analytics/analytics-actions.ts index acca43679dc..084fc6da31d 100644 --- a/packages/headless/src/features/analytics/analytics-actions.ts +++ b/packages/headless/src/features/analytics/analytics-actions.ts @@ -1,12 +1,12 @@ -import {SearchPageEvents as LegacySearchPageEvents} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; -import {Result} from '../../api/search/search/result'; +import {SearchPageEvents as LegacySearchPageEvents} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; +import {Result} from '../../api/search/search/result.js'; import { validatePayload, requiredNonEmptyString, nonEmptyString, -} from '../../utils/validate-payload'; -import {OmniboxSuggestionMetadata} from '../query-suggest/query-suggest-analytics-actions'; -import {SearchAction} from '../search/search-actions'; +} from '../../utils/validate-payload.js'; +import {OmniboxSuggestionMetadata} from '../query-suggest/query-suggest-analytics-actions.js'; +import {SearchAction} from '../search/search-actions.js'; import { ClickAction, CustomAction, @@ -15,8 +15,8 @@ import { partialDocumentInformation, LegacySearchAction, validateResultPayload, -} from './analytics-utils'; -import {SearchPageEvents} from './search-action-cause'; +} from './analytics-utils.js'; +import {SearchPageEvents} from './search-action-cause.js'; export interface SearchEventPayload { /** The identifier of the search action (e.g., `interfaceLoad`). */ diff --git a/packages/headless/src/features/analytics/analytics-utils.test.ts b/packages/headless/src/features/analytics/analytics-utils.test.ts index 00d8c19fcec..12895e8331b 100644 --- a/packages/headless/src/features/analytics/analytics-utils.test.ts +++ b/packages/headless/src/features/analytics/analytics-utils.test.ts @@ -1,23 +1,24 @@ import {createRelay} from '@coveo/relay'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockAnalyticsState} from '../../test/mock-analytics-state'; +import {MockInstance} from 'vitest'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockAnalyticsState} from '../../test/mock-analytics-state.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {createMockRecommendationState} from '../../test/mock-recommendation-state'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockResultWithFolding} from '../../test/mock-result-with-folding'; -import {createMockState} from '../../test/mock-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +} from '../../test/mock-engine-v2.js'; +import {createMockRecommendationState} from '../../test/mock-recommendation-state.js'; +import {buildMockResultWithFolding} from '../../test/mock-result-with-folding.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { documentIdentifier, makeAnalyticsAction, partialDocumentInformation, partialRecommendationInformation, -} from './analytics-utils'; +} from './analytics-utils.js'; -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); /* cSpell:ignore CAJS */ @@ -172,9 +173,7 @@ describe('analytics-utils', () => { }); it('should log an error permanentid is not available on a result', () => { - const spyConsole = jest - .spyOn(console, 'warn') - .mockImplementation(() => {}); + const spyConsole = vi.spyOn(console, 'warn').mockImplementation(() => {}); const result = buildMockResult(); delete result.raw.permanentid; @@ -189,9 +188,9 @@ describe('analytics-utils', () => { describe('#makeAnalytics', () => { let engine: MockedSearchEngine; let analyticsMode: 'legacy' | 'next'; - let relayEmitSpy: jest.SpyInstance; - const fakeCAJSLog = jest.fn(); - const createRelayMocked = jest.mocked(createRelay); + let relayEmitSpy: MockInstance; + const fakeCAJSLog = vi.fn(); + const createRelayMocked = vi.mocked(createRelay); const baseMakeAnalyticParams = { prefix: 'analytics/noop', __legacy__getBuilder: () => @@ -205,19 +204,19 @@ describe('analytics-utils', () => { analyticsType: '🥖', }; function buildMockRelay() { - relayEmitSpy = jest.fn(); + relayEmitSpy = vi.fn(); createRelayMocked.mockReturnValue({ emit: relayEmitSpy as unknown as ReturnType['emit'], - on: jest.fn(), - off: jest.fn(), - getMeta: jest.fn(), - updateConfig: jest.fn(), + on: vi.fn(), + off: vi.fn(), + getMeta: vi.fn(), + updateConfig: vi.fn(), version: 'test', }); } beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); buildMockRelay(); engine = buildMockSearchEngine( createMockState({ diff --git a/packages/headless/src/features/analytics/analytics-utils.ts b/packages/headless/src/features/analytics/analytics-utils.ts index 9246e078d5c..9c76912696e 100644 --- a/packages/headless/src/features/analytics/analytics-utils.ts +++ b/packages/headless/src/features/analytics/analytics-utils.ts @@ -20,44 +20,44 @@ import type { EventDescription, AnalyticsClientSendEventHook, } from 'coveo.analytics'; -import {AnalyticsClient} from 'coveo.analytics/dist/definitions/client/analytics'; -import {SearchEventResponse} from 'coveo.analytics/dist/definitions/events'; +import {AnalyticsClient} from 'coveo.analytics/dist/definitions/client/analytics.js'; +import {SearchEventResponse} from 'coveo.analytics/dist/definitions/events.js'; import { PartialDocumentInformation, DocumentIdentifier, -} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; +} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; import {Logger} from 'pino'; -import {getRelayInstanceFromState} from '../../api/analytics/analytics-relay-client'; +import {getRelayInstanceFromState} from '../../api/analytics/analytics-relay-client.js'; import { CaseAssistAnalyticsProvider, configureCaseAssistAnalytics, StateNeededByCaseAssistAnalytics, -} from '../../api/analytics/case-assist-analytics'; +} from '../../api/analytics/case-assist-analytics.js'; import { configureInsightAnalytics, InsightAnalyticsProvider, StateNeededByInsightAnalyticsProvider, -} from '../../api/analytics/insight-analytics'; -import {StateNeededByInstantResultsAnalyticsProvider} from '../../api/analytics/instant-result-analytics'; +} from '../../api/analytics/insight-analytics.js'; +import {StateNeededByInstantResultsAnalyticsProvider} from '../../api/analytics/instant-result-analytics.js'; import { configureLegacyAnalytics, SearchAnalyticsProvider, StateNeededBySearchAnalyticsProvider, -} from '../../api/analytics/search-analytics'; -import {PreprocessRequest} from '../../api/preprocess-request'; -import {Raw} from '../../api/search/search/raw'; -import {Result} from '../../api/search/search/result'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {RecommendationAppState} from '../../state/recommendation-app-state'; -import {SearchAppState} from '../../state/search-app-state'; +} from '../../api/analytics/search-analytics.js'; +import {PreprocessRequest} from '../../api/preprocess-request.js'; +import {Raw} from '../../api/search/search/raw.js'; +import {Result} from '../../api/search/search/result.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {RecommendationAppState} from '../../state/recommendation-app-state.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { ConfigurationSection, PipelineSection, -} from '../../state/state-sections'; -import {requiredNonEmptyString} from '../../utils/validate-payload'; -import {ResultWithFolding} from '../folding/folding-slice'; -import {getAllIncludedResultsFrom} from '../folding/folding-utils'; -import {getPipelineInitialState} from '../pipeline/pipeline-state'; +} from '../../state/state-sections.js'; +import {requiredNonEmptyString} from '../../utils/validate-payload.js'; +import {ResultWithFolding} from '../folding/folding-slice.js'; +import {getAllIncludedResultsFrom} from '../folding/folding-utils.js'; +import {getPipelineInitialState} from '../pipeline/pipeline-state.js'; export interface PreparableAnalyticsActionOptions< StateNeeded extends ConfigurationSection, diff --git a/packages/headless/src/features/analytics/click-analytics-actions-loader.ts b/packages/headless/src/features/analytics/click-analytics-actions-loader.ts index 5d3c76b143a..3345455ce02 100644 --- a/packages/headless/src/features/analytics/click-analytics-actions-loader.ts +++ b/packages/headless/src/features/analytics/click-analytics-actions-loader.ts @@ -1,17 +1,17 @@ -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { logOpenSmartSnippetInlineLink, logOpenSmartSnippetSource, logOpenSmartSnippetSuggestionInlineLink, logOpenSmartSnippetSuggestionSource, -} from '../question-answering/question-answering-analytics-actions'; +} from '../question-answering/question-answering-analytics-actions.js'; import { QuestionAnsweringInlineLinkActionCreatorPayload, QuestionAnsweringUniqueIdentifierActionCreatorPayload, -} from '../question-answering/question-answering-document-id'; -import {logDocumentOpen} from '../result/result-analytics-actions'; -import {ClickAction} from './analytics-utils'; +} from '../question-answering/question-answering-document-id.js'; +import {logDocumentOpen} from '../result/result-analytics-actions.js'; +import {ClickAction} from './analytics-utils.js'; /** * The click analytics action creators. diff --git a/packages/headless/src/features/analytics/generic-analytics-actions-loader.ts b/packages/headless/src/features/analytics/generic-analytics-actions-loader.ts index 4631709cb37..97077577271 100644 --- a/packages/headless/src/features/analytics/generic-analytics-actions-loader.ts +++ b/packages/headless/src/features/analytics/generic-analytics-actions-loader.ts @@ -1,4 +1,4 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { logSearchEvent, LogSearchEventActionCreatorPayload, @@ -6,8 +6,12 @@ import { LogClickEventActionCreatorPayload, logCustomEvent, LogCustomEventActionCreatorPayload, -} from './analytics-actions'; -import {ClickAction, CustomAction, LegacySearchAction} from './analytics-utils'; +} from './analytics-actions.js'; +import { + ClickAction, + CustomAction, + LegacySearchAction, +} from './analytics-utils.js'; export type { LogSearchEventActionCreatorPayload, diff --git a/packages/headless/src/features/analytics/insight-analytics-actions-loader.ts b/packages/headless/src/features/analytics/insight-analytics-actions-loader.ts index fff278f92a8..a4b6dc7ca54 100644 --- a/packages/headless/src/features/analytics/insight-analytics-actions-loader.ts +++ b/packages/headless/src/features/analytics/insight-analytics-actions-loader.ts @@ -1,14 +1,14 @@ -import {Result} from '../../api/search/search/result'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {LogCategoryFacetBreadcrumbActionCreatorPayload} from '../facets/category-facet-set/category-facet-set-analytics-actions'; -import {logCategoryFacetBreadcrumb} from '../facets/category-facet-set/category-facet-set-insight-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {LogCategoryFacetBreadcrumbActionCreatorPayload} from '../facets/category-facet-set/category-facet-set-analytics-actions.js'; +import {logCategoryFacetBreadcrumb} from '../facets/category-facet-set/category-facet-set-insight-analytics-actions.js'; import { LogFacetBreadcrumbActionCreatorPayload, LogFacetDeselectActionCreatorPayload, LogFacetExcludeActionCreatorPayload, LogFacetUnexcludeActionCreatorPayload, LogFacetSelectActionCreatorPayload, -} from '../facets/facet-set/facet-set-analytics-actions'; +} from '../facets/facet-set/facet-set-analytics-actions.js'; import { logFacetBreadcrumb, logFacetClearAll, @@ -18,39 +18,39 @@ import { logFacetShowMore, logFacetUpdateSort, LogFacetUpdateSortActionCreatorPayload, -} from '../facets/facet-set/facet-set-insight-analytics-actions'; -import {logClearBreadcrumbs} from '../facets/generic/facet-generic-insight-analytics-actions'; -import {LogDateFacetBreadcrumbActionCreatorPayload} from '../facets/range-facets/date-facet-set/date-facet-analytics-actions'; -import {logDateFacetBreadcrumb} from '../facets/range-facets/date-facet-set/date-facet-insight-analytics-actions'; -import {LogNumericFacetBreadcrumbActionCreatorPayload} from '../facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions'; -import {logNumericFacetBreadcrumb} from '../facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions'; +} from '../facets/facet-set/facet-set-insight-analytics-actions.js'; +import {logClearBreadcrumbs} from '../facets/generic/facet-generic-insight-analytics-actions.js'; +import {LogDateFacetBreadcrumbActionCreatorPayload} from '../facets/range-facets/date-facet-set/date-facet-analytics-actions.js'; +import {logDateFacetBreadcrumb} from '../facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.js'; +import {LogNumericFacetBreadcrumbActionCreatorPayload} from '../facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.js'; +import {logNumericFacetBreadcrumb} from '../facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.js'; import { logInsightCreateArticle, CreateArticleMetadata, logOpenUserActions, -} from '../insight-search/insight-analytics-actions'; +} from '../insight-search/insight-analytics-actions.js'; import { logInsightInterfaceChange, logInsightInterfaceLoad, -} from '../insight-search/insight-search-analytics-actions'; +} from '../insight-search/insight-search-analytics-actions.js'; import { logPageNext, logPageNumber, logPagePrevious, -} from '../pagination/pagination-insight-analytics-actions'; -import {SmartSnippetFeedback} from '../question-answering/question-answering-analytics-actions'; +} from '../pagination/pagination-insight-analytics-actions.js'; +import {SmartSnippetFeedback} from '../question-answering/question-answering-analytics-actions.js'; import { logCopyToClipboard, logCaseSendEmail, logFeedItemTextPost, -} from '../result-actions/result-actions-insight-analytics-actions'; -import {logResultsSort} from '../sort-criteria/sort-criteria-insight-analytics-actions'; +} from '../result-actions/result-actions-insight-analytics-actions.js'; +import {logResultsSort} from '../sort-criteria/sort-criteria-insight-analytics-actions.js'; import { LogStaticFilterToggleValueActionCreatorPayload, StaticFilterValueMetadata, -} from '../static-filter-set/static-filter-set-actions'; -import {logInsightStaticFilterDeselect} from '../static-filter-set/static-filter-set-insight-analytics-actions'; -import {InsightAction} from './analytics-utils'; +} from '../static-filter-set/static-filter-set-actions.js'; +import {logInsightStaticFilterDeselect} from '../static-filter-set/static-filter-set-insight-analytics-actions.js'; +import {InsightAction} from './analytics-utils.js'; export type { LogStaticFilterToggleValueActionCreatorPayload, diff --git a/packages/headless/src/features/analytics/insight-analytics-utils.ts b/packages/headless/src/features/analytics/insight-analytics-utils.ts index 7f769d0f81c..3746b8df1a6 100644 --- a/packages/headless/src/features/analytics/insight-analytics-utils.ts +++ b/packages/headless/src/features/analytics/insight-analytics-utils.ts @@ -1,6 +1,6 @@ import {InsightPanel} from '@coveo/relay-event-types'; -import {InsightAppState} from '../../state/insight-app-state'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +import {InsightAppState} from '../../state/insight-app-state.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; // TODO SFINT-5420: Update from where we are grabbing the case context. export const analyticsEventCaseContext = ( diff --git a/packages/headless/src/features/analytics/search-analytics-actions-loader.ts b/packages/headless/src/features/analytics/search-analytics-actions-loader.ts index 1a10b8dd147..791f94eccd9 100644 --- a/packages/headless/src/features/analytics/search-analytics-actions-loader.ts +++ b/packages/headless/src/features/analytics/search-analytics-actions-loader.ts @@ -1,9 +1,9 @@ -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {logDidYouMeanClick} from '../did-you-mean/did-you-mean-analytics-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {logDidYouMeanClick} from '../did-you-mean/did-you-mean-analytics-actions.js'; import { logCategoryFacetBreadcrumb, LogCategoryFacetBreadcrumbActionCreatorPayload, -} from '../facets/category-facet-set/category-facet-set-analytics-actions'; +} from '../facets/category-facet-set/category-facet-set-analytics-actions.js'; import { logFacetBreadcrumb, logFacetClearAll, @@ -20,33 +20,33 @@ import { LogFacetUnexcludeActionCreatorPayload, LogFacetSelectActionCreatorPayload, LogFacetUpdateSortActionCreatorPayload, -} from '../facets/facet-set/facet-set-analytics-actions'; -import {logClearBreadcrumbs} from '../facets/generic/facet-generic-analytics-actions'; +} from '../facets/facet-set/facet-set-analytics-actions.js'; +import {logClearBreadcrumbs} from '../facets/generic/facet-generic-analytics-actions.js'; import { logDateFacetBreadcrumb, LogDateFacetBreadcrumbActionCreatorPayload, -} from '../facets/range-facets/date-facet-set/date-facet-analytics-actions'; +} from '../facets/range-facets/date-facet-set/date-facet-analytics-actions.js'; import { logNumericFacetBreadcrumb, LogNumericFacetBreadcrumbActionCreatorPayload, -} from '../facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions'; +} from '../facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.js'; import { logNavigateBackward, logNavigateForward, logNoResultsBack, -} from '../history/history-analytics-actions'; +} from '../history/history-analytics-actions.js'; import { logPageNext, logPageNumber, logPagePrevious, logPagerResize, -} from '../pagination/pagination-analytics-actions'; +} from '../pagination/pagination-analytics-actions.js'; import { logQuerySuggestionClick, LogQuerySuggestionClickActionCreatorPayload, OmniboxSuggestionMetadata, -} from '../query-suggest/query-suggest-analytics-actions'; -import {logSearchboxSubmit} from '../query/query-analytics-actions'; +} from '../query-suggest/query-suggest-analytics-actions.js'; +import {logSearchboxSubmit} from '../query/query-analytics-actions.js'; import { logCollapseSmartSnippet, logExpandSmartSnippet, @@ -59,12 +59,12 @@ import { logCollapseSmartSnippetSuggestion, logExpandSmartSnippetSuggestion, SmartSnippetFeedback, -} from '../question-answering/question-answering-analytics-actions'; +} from '../question-answering/question-answering-analytics-actions.js'; import { QuestionAnsweringInlineLinkActionCreatorPayload, QuestionAnsweringUniqueIdentifierActionCreatorPayload, -} from '../question-answering/question-answering-document-id'; -import {logResultsSort} from '../sort-criteria/sort-criteria-analytics-actions'; +} from '../question-answering/question-answering-document-id.js'; +import {logResultsSort} from '../sort-criteria/sort-criteria-analytics-actions.js'; import { logStaticFilterSelect, logStaticFilterDeselect, @@ -72,7 +72,7 @@ import { LogStaticFilterToggleValueActionCreatorPayload, LogStaticFilterClearAllActionCreatorPayload, StaticFilterValueMetadata, -} from '../static-filter-set/static-filter-set-actions'; +} from '../static-filter-set/static-filter-set-actions.js'; import { logNotifyTrigger, logTriggerExecute, @@ -80,14 +80,14 @@ import { logTriggerRedirect, logUndoTriggerQuery, LogUndoTriggerQueryActionCreatorPayload, -} from '../triggers/trigger-analytics-actions'; +} from '../triggers/trigger-analytics-actions.js'; import { logInterfaceChange, logInterfaceLoad, logSearchFromLink, logOmniboxFromLink, -} from './analytics-actions'; -import {CustomAction, LegacySearchAction} from './analytics-utils'; +} from './analytics-actions.js'; +import {CustomAction, LegacySearchAction} from './analytics-utils.js'; export type { LogCategoryFacetBreadcrumbActionCreatorPayload, diff --git a/packages/headless/src/features/attached-results/__snapshots__/attached-results-analytics-actions.test.ts.snap b/packages/headless/src/features/attached-results/__snapshots__/attached-results-analytics-actions.test.ts.snap index ec626338d8f..65b09248cdd 100644 --- a/packages/headless/src/features/attached-results/__snapshots__/attached-results-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/attached-results/__snapshots__/attached-results-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`attached results analytics actions when analyticsMode is \`next\` logCaseAttach should call relay.emit properly 1`] = ` +exports[`attached results analytics actions > when analyticsMode is \`next\` > logCaseAttach > should call relay.emit properly 1`] = ` [ "InsightPanel.ItemAction", { @@ -23,7 +23,7 @@ exports[`attached results analytics actions when analyticsMode is \`next\` logCa ] `; -exports[`attached results analytics actions when analyticsMode is \`next\` logCaseDetach should call relay.emit properly 1`] = ` +exports[`attached results analytics actions > when analyticsMode is \`next\` > logCaseDetach > should call relay.emit properly 1`] = ` [ "InsightPanel.DetachItem", { diff --git a/packages/headless/src/features/attached-results/attached-results-actions-loader.ts b/packages/headless/src/features/attached-results/attached-results-actions-loader.ts index 735b7c9f158..3c191391606 100644 --- a/packages/headless/src/features/attached-results/attached-results-actions-loader.ts +++ b/packages/headless/src/features/attached-results/attached-results-actions-loader.ts @@ -1,11 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {attachedResultsReducer as attachedResults} from '../../features/attached-results/attached-results-slice'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {attachedResultsReducer as attachedResults} from '../../features/attached-results/attached-results-slice.js'; import { setAttachedResults, SetAttachedResultsActionCreatorPayload, -} from './attached-results-actions'; -import {AttachedResult} from './attached-results-state'; +} from './attached-results-actions.js'; +import {AttachedResult} from './attached-results-state.js'; export type {SetAttachedResultsActionCreatorPayload, AttachedResult}; export interface AttachedResultsActionCreators { diff --git a/packages/headless/src/features/attached-results/attached-results-actions.ts b/packages/headless/src/features/attached-results/attached-results-actions.ts index 09997d36973..d806aaa92c8 100644 --- a/packages/headless/src/features/attached-results/attached-results-actions.ts +++ b/packages/headless/src/features/attached-results/attached-results-actions.ts @@ -11,8 +11,8 @@ import { requiredNonEmptyString, nonEmptyString, serializeSchemaValidationError, -} from '../../utils/validate-payload'; -import {AttachedResult} from './attached-results-state'; +} from '../../utils/validate-payload.js'; +import {AttachedResult} from './attached-results-state.js'; export interface SetAttachedResultsActionCreatorPayload { /** diff --git a/packages/headless/src/features/attached-results/attached-results-analytics-actions.test.ts b/packages/headless/src/features/attached-results/attached-results-analytics-actions.test.ts index ab868cd7947..8c9296a6ba8 100644 --- a/packages/headless/src/features/attached-results/attached-results-analytics-actions.test.ts +++ b/packages/headless/src/features/attached-results/attached-results-analytics-actions.test.ts @@ -1,27 +1,27 @@ import {createRelay} from '@coveo/relay'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logCaseAttach, logCaseDetach, -} from './attached-results-analytics-actions'; +} from './attached-results-analytics-actions.js'; -const mockLogCaseAttach = jest.fn(); -const mockLogCaseDetach = jest.fn(); -const emit = jest.fn(); +const mockLogCaseAttach = vi.fn(); +const mockLogCaseDetach = vi.fn(); +const emit = vi.fn(); -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logCaseAttach: mockLogCaseAttach, logCaseDetach: mockLogCaseDetach, @@ -29,16 +29,16 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); @@ -113,7 +113,7 @@ describe('attached results analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/attached-results/attached-results-analytics-actions.ts b/packages/headless/src/features/attached-results/attached-results-analytics-actions.ts index e5f93575cdb..985e58b3af0 100644 --- a/packages/headless/src/features/attached-results/attached-results-analytics-actions.ts +++ b/packages/headless/src/features/attached-results/attached-results-analytics-actions.ts @@ -1,15 +1,15 @@ import {InsightPanel} from '@coveo/relay-event-types'; -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { analyticsEventItemMetadata, documentIdentifier, makeInsightAnalyticsActionFactory, partialDocumentInformation, validateResultPayload, -} from '../analytics/analytics-utils'; -import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export const logCaseAttach = (result: Result) => makeInsightAnalyticsActionFactory(SearchPageEvents.caseAttach)({ diff --git a/packages/headless/src/features/attached-results/attached-results-slice.test.ts b/packages/headless/src/features/attached-results/attached-results-slice.test.ts index 4785555976e..0268798b1ed 100644 --- a/packages/headless/src/features/attached-results/attached-results-slice.test.ts +++ b/packages/headless/src/features/attached-results/attached-results-slice.test.ts @@ -1,14 +1,14 @@ -import {createMockAttachedResult} from '../../test/mock-attached-results'; +import {createMockAttachedResult} from '../../test/mock-attached-results.js'; import { attachResult, detachResult, setAttachedResults, -} from './attached-results-actions'; -import {attachedResultsReducer} from './attached-results-slice'; +} from './attached-results-actions.js'; +import {attachedResultsReducer} from './attached-results-slice.js'; import { AttachedResultsState, getAttachedResultsInitialState, -} from './attached-results-state'; +} from './attached-results-state.js'; describe('attached results slice', () => { let state: AttachedResultsState; diff --git a/packages/headless/src/features/attached-results/attached-results-slice.ts b/packages/headless/src/features/attached-results/attached-results-slice.ts index 9b51381dce4..aa4c8625632 100644 --- a/packages/headless/src/features/attached-results/attached-results-slice.ts +++ b/packages/headless/src/features/attached-results/attached-results-slice.ts @@ -4,11 +4,11 @@ import { setAttachedResults, attachResult, detachResult, -} from './attached-results-actions'; +} from './attached-results-actions.js'; import { AttachedResult, getAttachedResultsInitialState, -} from './attached-results-state'; +} from './attached-results-state.js'; export const attachedResultsReducer = createReducer( getAttachedResultsInitialState(), diff --git a/packages/headless/src/features/attached-results/attached-results-utils.ts b/packages/headless/src/features/attached-results/attached-results-utils.ts index ecb465635ef..510404c794b 100644 --- a/packages/headless/src/features/attached-results/attached-results-utils.ts +++ b/packages/headless/src/features/attached-results/attached-results-utils.ts @@ -1,6 +1,6 @@ import {isString} from '@coveo/bueno'; -import {Result} from '../../api/search/search/result'; -import {AttachedResult} from './attached-results-state'; +import {Result} from '../../api/search/search/result.js'; +import {AttachedResult} from './attached-results-state.js'; const ensureStringOrUndefined = ( result: Result, diff --git a/packages/headless/src/features/breadcrumb/breadcrumb-actions-loader.ts b/packages/headless/src/features/breadcrumb/breadcrumb-actions-loader.ts index adaad83b91a..ef9376a11ee 100644 --- a/packages/headless/src/features/breadcrumb/breadcrumb-actions-loader.ts +++ b/packages/headless/src/features/breadcrumb/breadcrumb-actions-loader.ts @@ -1,9 +1,9 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; import { deselectAllBreadcrumbs, deselectAllNonBreadcrumbs, -} from './breadcrumb-actions'; +} from './breadcrumb-actions.js'; /** * The breadcrumb action creators. diff --git a/packages/headless/src/features/case-assist-configuration/case-assist-configuration-actions.ts b/packages/headless/src/features/case-assist-configuration/case-assist-configuration-actions.ts index 159a33aac45..5dc403df0f9 100644 --- a/packages/headless/src/features/case-assist-configuration/case-assist-configuration-actions.ts +++ b/packages/headless/src/features/case-assist-configuration/case-assist-configuration-actions.ts @@ -4,7 +4,7 @@ import { validatePayload, requiredNonEmptyString, nonEmptyString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export interface SetCaseAssistConfigurationActionCreatorPayload { /** diff --git a/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.test.ts b/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.test.ts index 12e37d763e4..466d5d99339 100644 --- a/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.test.ts +++ b/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.test.ts @@ -1,9 +1,9 @@ -import {setCaseAssistConfiguration} from './case-assist-configuration-actions'; -import {caseAssistConfigurationReducer} from './case-assist-configuration-slice'; +import {setCaseAssistConfiguration} from './case-assist-configuration-actions.js'; +import {caseAssistConfigurationReducer} from './case-assist-configuration-slice.js'; import { getCaseAssistConfigurationInitialState, CaseAssistConfigurationState, -} from './case-assist-configuration-state'; +} from './case-assist-configuration-state.js'; describe('case assist slice', () => { let state: CaseAssistConfigurationState; diff --git a/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.ts b/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.ts index 6daa2585430..10d3b8b7b8e 100644 --- a/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.ts +++ b/packages/headless/src/features/case-assist-configuration/case-assist-configuration-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setCaseAssistConfiguration} from './case-assist-configuration-actions'; -import {getCaseAssistConfigurationInitialState} from './case-assist-configuration-state'; +import {setCaseAssistConfiguration} from './case-assist-configuration-actions.js'; +import {getCaseAssistConfigurationInitialState} from './case-assist-configuration-state.js'; export const caseAssistConfigurationReducer = createReducer( getCaseAssistConfigurationInitialState(), diff --git a/packages/headless/src/features/case-assist/__snapshots__/case-assist-analytics-actions.test.ts.snap b/packages/headless/src/features/case-assist/__snapshots__/case-assist-analytics-actions.test.ts.snap index 14581a783d7..8d473b6a4b1 100644 --- a/packages/headless/src/features/case-assist/__snapshots__/case-assist-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/case-assist/__snapshots__/case-assist-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logAbandonCase with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logAbandonCase with the right payload 1`] = ` [ "caseAssist.cancel", { @@ -9,7 +9,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logAutoSelectCaseField with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logAutoSelectCaseField with the right payload 1`] = ` [ "caseAssist.selectFieldClassification", { @@ -22,14 +22,14 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logCaseStart with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logCaseStart with the right payload 1`] = ` [ "caseAssist.start", {}, ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logClassificationClick with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logClassificationClick with the right payload 1`] = ` [ "caseAssist.selectFieldClassification", { @@ -42,7 +42,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logCreateCase with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logCreateCase with the right payload 1`] = ` [ "caseAssist.createTicket", { @@ -57,7 +57,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logDocumentSuggestionClick with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logDocumentSuggestionClick with the right payload 1`] = ` [ "caseAssist.documentSuggestionClick", { @@ -69,7 +69,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logDocumentSuggestionOpen with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logDocumentSuggestionOpen with the right payload 1`] = ` [ "itemClick", { @@ -86,7 +86,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logDocumentSuggestionRating with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logDocumentSuggestionRating with the right payload 1`] = ` [ "caseAssist.documentSuggestionFeedback", { @@ -99,7 +99,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logQuickviewDocumentSuggestionClick with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logQuickviewDocumentSuggestionClick with the right payload 1`] = ` [ "itemClick", { @@ -116,7 +116,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logSolveCase with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logSolveCase with the right payload 1`] = ` [ "caseAssist.cancel", { @@ -125,7 +125,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logUpdateCaseField with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logUpdateCaseField with the right payload 1`] = ` [ "caseAssist.updateField", { diff --git a/packages/headless/src/features/case-assist/case-assist-analytics-actions-loader.ts b/packages/headless/src/features/case-assist/case-assist-analytics-actions-loader.ts index 8ab71f96367..1d444944135 100644 --- a/packages/headless/src/features/case-assist/case-assist-analytics-actions-loader.ts +++ b/packages/headless/src/features/case-assist/case-assist-analytics-actions-loader.ts @@ -1,5 +1,5 @@ -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {CaseAssistAction} from '../analytics/analytics-utils'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {CaseAssistAction} from '../analytics/analytics-utils.js'; import { logAbandonCase, logCaseNextStage, @@ -11,7 +11,7 @@ import { logSolveCase, logUpdateCaseField, logQuickviewDocumentSuggestionClick, -} from './case-assist-analytics-actions'; +} from './case-assist-analytics-actions.js'; export interface NextStageOptions { stageName?: string; diff --git a/packages/headless/src/features/case-assist/case-assist-analytics-actions.test.ts b/packages/headless/src/features/case-assist/case-assist-analytics-actions.test.ts index 0ca30d10ea4..d52d06a5fce 100644 --- a/packages/headless/src/features/case-assist/case-assist-analytics-actions.test.ts +++ b/packages/headless/src/features/case-assist/case-assist-analytics-actions.test.ts @@ -1,13 +1,13 @@ import {createRelay} from '@coveo/relay'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockCaseAssistState} from '../../test/mock-case-assist-state'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockCaseAssistState} from '../../test/mock-case-assist-state.js'; import { buildMockCaseAssistEngine, MockedCaseAssistEngine, -} from '../../test/mock-engine-v2'; -import {getCaseFieldInitialState} from '../case-field/case-field-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {getDocumentSuggestionInitialState} from '../document-suggestion/document-suggestion-state'; +} from '../../test/mock-engine-v2.js'; +import {getCaseFieldInitialState} from '../case-field/case-field-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {getDocumentSuggestionInitialState} from '../document-suggestion/document-suggestion-state.js'; import { logCaseStart, logCaseNextStage, @@ -21,34 +21,34 @@ import { logQuickviewDocumentSuggestionClick, logDocumentSuggestionOpen, logDocumentSuggestionRating, -} from './case-assist-analytics-actions'; +} from './case-assist-analytics-actions.js'; -const mockLogEnterInterface = jest.fn(); -const mockLogMoveToNextCaseStep = jest.fn(); -const mockLogCaseCreated = jest.fn(); -const mockLogCaseSolved = jest.fn(); -const mockLogCaseCancelled = jest.fn(); -const mockLogUpdateCaseField = jest.fn(); -const mockLogSelectFieldSuggestion = jest.fn(); -const mockLogSelectDocumentSuggestion = jest.fn(); -const mockLogRateDocumentSuggestion = jest.fn(); +const mockLogEnterInterface = vi.fn(); +const mockLogMoveToNextCaseStep = vi.fn(); +const mockLogCaseCreated = vi.fn(); +const mockLogCaseSolved = vi.fn(); +const mockLogCaseCancelled = vi.fn(); +const mockLogUpdateCaseField = vi.fn(); +const mockLogSelectFieldSuggestion = vi.fn(); +const mockLogSelectDocumentSuggestion = vi.fn(); +const mockLogRateDocumentSuggestion = vi.fn(); -const emit = jest.fn(); +const emit = vi.fn(); -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); -jest.mock('coveo.analytics', () => { - const mockCaseAssistClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCaseAssistClient = vi.fn(() => ({ + disable: vi.fn(), logEnterInterface: mockLogEnterInterface, logMoveToNextCaseStep: mockLogMoveToNextCaseStep, logCaseCreated: mockLogCaseCreated, @@ -62,7 +62,7 @@ jest.mock('coveo.analytics', () => { return { CaseAssistClient: mockCaseAssistClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -136,7 +136,7 @@ describe('generated answer insight analytics actions', () => { let engine: MockedCaseAssistEngine; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/case-assist/case-assist-analytics-actions.ts b/packages/headless/src/features/case-assist/case-assist-analytics-actions.ts index 2e3e7b7750c..aac353cb1dc 100644 --- a/packages/headless/src/features/case-assist/case-assist-analytics-actions.ts +++ b/packages/headless/src/features/case-assist/case-assist-analytics-actions.ts @@ -2,13 +2,13 @@ import {CaseAssist, ItemClick} from '@coveo/relay-event-types'; import { CaseAssistAction, makeCaseAssistAnalyticsAction, -} from '../analytics/analytics-utils'; -import {NextStageOptions} from './case-assist-analytics-actions-loader'; +} from '../analytics/analytics-utils.js'; +import {NextStageOptions} from './case-assist-analytics-actions-loader.js'; import { caseAssistCaseSelector, caseAssistCaseClassificationSelector, caseAssistDocumentSuggestionSelector, -} from './case-assist-analytics-selectors'; +} from './case-assist-analytics-selectors.js'; export const logCaseStart = (): CaseAssistAction => makeCaseAssistAnalyticsAction({ diff --git a/packages/headless/src/features/case-assist/case-assist-analytics-selectors.test.ts b/packages/headless/src/features/case-assist/case-assist-analytics-selectors.test.ts index 83c5b746dea..48bbb6a552c 100644 --- a/packages/headless/src/features/case-assist/case-assist-analytics-selectors.test.ts +++ b/packages/headless/src/features/case-assist/case-assist-analytics-selectors.test.ts @@ -1,4 +1,4 @@ -import {CaseAssistAppState} from '../../state/case-assist-app-state'; +import {CaseAssistAppState} from '../../state/case-assist-app-state.js'; import { KnownCaseFields, caseAssistCaseSelector, @@ -8,7 +8,7 @@ import { caseAssistCustomCaseFieldValuesSelector, caseAssistCustomCaseInputValuesSelector, caseAssistDocumentSuggestionSelector, -} from './case-assist-analytics-selectors'; +} from './case-assist-analytics-selectors.js'; describe('case assist analytics selectors', () => { const buildStateWithCaseInput = (): Partial => ({ diff --git a/packages/headless/src/features/case-assist/case-assist-analytics-selectors.ts b/packages/headless/src/features/case-assist/case-assist-analytics-selectors.ts index 3f6ef4abcba..4c5fd1d6ab6 100644 --- a/packages/headless/src/features/case-assist/case-assist-analytics-selectors.ts +++ b/packages/headless/src/features/case-assist/case-assist-analytics-selectors.ts @@ -1,4 +1,4 @@ -import {CaseAssistAppState} from '../../state/case-assist-app-state'; +import {CaseAssistAppState} from '../../state/case-assist-app-state.js'; export enum KnownCaseFields { id = 'id', diff --git a/packages/headless/src/features/case-context/case-context-actions-loader.ts b/packages/headless/src/features/case-context/case-context-actions-loader.ts index ba49740b302..fbdcea7466e 100644 --- a/packages/headless/src/features/case-context/case-context-actions-loader.ts +++ b/packages/headless/src/features/case-context/case-context-actions-loader.ts @@ -1,7 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {caseContextReducer as insightCaseContext} from '../../features/case-context/case-context-slice'; -import {setCaseContext, setCaseId, setCaseNumber} from './case-context-actions'; +import {CoreEngine} from '../../app/engine.js'; +import {caseContextReducer as insightCaseContext} from '../../features/case-context/case-context-slice.js'; +import { + setCaseContext, + setCaseId, + setCaseNumber, +} from './case-context-actions.js'; /** * The case context action creators. diff --git a/packages/headless/src/features/case-context/case-context-actions.ts b/packages/headless/src/features/case-context/case-context-actions.ts index 53021864787..b65b25457fc 100644 --- a/packages/headless/src/features/case-context/case-context-actions.ts +++ b/packages/headless/src/features/case-context/case-context-actions.ts @@ -3,7 +3,7 @@ import {createAction} from '@reduxjs/toolkit'; import { requiredEmptyAllowedString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; /** * Set case context action diff --git a/packages/headless/src/features/case-context/case-context-slice.spec.ts b/packages/headless/src/features/case-context/case-context-slice.spec.ts index 6ccaf430265..106de28ce6a 100644 --- a/packages/headless/src/features/case-context/case-context-slice.spec.ts +++ b/packages/headless/src/features/case-context/case-context-slice.spec.ts @@ -1,5 +1,9 @@ -import {setCaseContext, setCaseId, setCaseNumber} from './case-context-actions'; -import {caseContextReducer} from './case-context-slice'; +import { + setCaseContext, + setCaseId, + setCaseNumber, +} from './case-context-actions.js'; +import {caseContextReducer} from './case-context-slice.js'; describe('case context slice', () => { it('initializes state correctly', () => { diff --git a/packages/headless/src/features/case-context/case-context-slice.ts b/packages/headless/src/features/case-context/case-context-slice.ts index 3dc620ae0cc..8faabab8353 100644 --- a/packages/headless/src/features/case-context/case-context-slice.ts +++ b/packages/headless/src/features/case-context/case-context-slice.ts @@ -1,6 +1,10 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setCaseContext, setCaseId, setCaseNumber} from './case-context-actions'; -import {getCaseContextInitialState} from './case-context-state'; +import { + setCaseContext, + setCaseId, + setCaseNumber, +} from './case-context-actions.js'; +import {getCaseContextInitialState} from './case-context-state.js'; export const caseContextReducer = createReducer( getCaseContextInitialState(), diff --git a/packages/headless/src/features/case-field/case-field-actions-loader.ts b/packages/headless/src/features/case-field/case-field-actions-loader.ts index 452230c3a6e..44dd4e72a04 100644 --- a/packages/headless/src/features/case-field/case-field-actions-loader.ts +++ b/packages/headless/src/features/case-field/case-field-actions-loader.ts @@ -1,7 +1,7 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice'; +import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client.js'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {caseFieldReducer as caseField} from '../../features/case-field/case-field-slice.js'; import { fetchCaseClassifications, FetchClassificationsThunkReturn, @@ -9,7 +9,7 @@ import { SetCaseFieldActionCreatorPayload, StateNeededByFetchClassifications, registerCaseField, -} from './case-field-actions'; +} from './case-field-actions.js'; export type {SetCaseFieldActionCreatorPayload}; diff --git a/packages/headless/src/features/case-field/case-field-actions.ts b/packages/headless/src/features/case-field/case-field-actions.ts index 2fa9c12142c..977a05e0340 100644 --- a/packages/headless/src/features/case-field/case-field-actions.ts +++ b/packages/headless/src/features/case-field/case-field-actions.ts @@ -1,23 +1,23 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {getVisitorID} from '../../api/analytics/coveo-analytics-utils'; -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {isErrorResponse} from '../../api/search/search-api-client'; -import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client'; -import {prepareContextFromFields} from '../../api/service/case-assist/case-assist-params'; -import {GetCaseClassificationsRequest} from '../../api/service/case-assist/get-case-classifications/get-case-classifications-request'; -import {GetCaseClassificationsResponse} from '../../api/service/case-assist/get-case-classifications/get-case-classifications-response'; +import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {isErrorResponse} from '../../api/search/search-api-client.js'; +import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client.js'; +import {prepareContextFromFields} from '../../api/service/case-assist/case-assist-params.js'; +import {GetCaseClassificationsRequest} from '../../api/service/case-assist/get-case-classifications/get-case-classifications-request.js'; +import {GetCaseClassificationsResponse} from '../../api/service/case-assist/get-case-classifications/get-case-classifications-response.js'; import { CaseAssistConfigurationSection, CaseFieldSection, CaseInputSection, ConfigurationSection, DebugSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; import { validatePayload, requiredNonEmptyString, requiredEmptyAllowedString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export interface SetCaseFieldActionCreatorPayload { /** diff --git a/packages/headless/src/features/case-field/case-field-slice.test.ts b/packages/headless/src/features/case-field/case-field-slice.test.ts index a925a24a776..c90cc794409 100644 --- a/packages/headless/src/features/case-field/case-field-slice.test.ts +++ b/packages/headless/src/features/case-field/case-field-slice.test.ts @@ -1,11 +1,11 @@ -import {GetCaseClassificationsResponse} from '../../api/service/case-assist/get-case-classifications/get-case-classifications-response'; +import {GetCaseClassificationsResponse} from '../../api/service/case-assist/get-case-classifications/get-case-classifications-response.js'; import { updateCaseField, fetchCaseClassifications, registerCaseField, -} from './case-field-actions'; -import {caseFieldReducer} from './case-field-slice'; -import {getCaseFieldInitialState, CaseFieldState} from './case-field-state'; +} from './case-field-actions.js'; +import {caseFieldReducer} from './case-field-slice.js'; +import {getCaseFieldInitialState, CaseFieldState} from './case-field-state.js'; describe('case field slice', () => { let state: CaseFieldState; diff --git a/packages/headless/src/features/case-field/case-field-slice.ts b/packages/headless/src/features/case-field/case-field-slice.ts index 1b892e6de48..498c530965f 100644 --- a/packages/headless/src/features/case-field/case-field-slice.ts +++ b/packages/headless/src/features/case-field/case-field-slice.ts @@ -3,8 +3,8 @@ import { fetchCaseClassifications, registerCaseField, updateCaseField, -} from './case-field-actions'; -import {getCaseFieldInitialState} from './case-field-state'; +} from './case-field-actions.js'; +import {getCaseFieldInitialState} from './case-field-state.js'; export const caseFieldReducer = createReducer( getCaseFieldInitialState(), diff --git a/packages/headless/src/features/case-field/case-field-state.ts b/packages/headless/src/features/case-field/case-field-state.ts index feef73af6ae..b705924992e 100644 --- a/packages/headless/src/features/case-field/case-field-state.ts +++ b/packages/headless/src/features/case-field/case-field-state.ts @@ -1,4 +1,4 @@ -import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client'; +import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client.js'; export const getCaseFieldInitialState = (): CaseFieldState => ({ status: { diff --git a/packages/headless/src/features/case-input/case-input-actions-loader.ts b/packages/headless/src/features/case-input/case-input-actions-loader.ts index bfef815128e..76989dfbbd9 100644 --- a/packages/headless/src/features/case-input/case-input-actions-loader.ts +++ b/packages/headless/src/features/case-input/case-input-actions-loader.ts @@ -1,10 +1,10 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {caseInputReducer as caseInput} from '../../features/case-input/case-input-slice.js'; import { updateCaseInput, SetCaseInputActionCreatorPayload, -} from './case-input-actions'; +} from './case-input-actions.js'; export type {SetCaseInputActionCreatorPayload}; diff --git a/packages/headless/src/features/case-input/case-input-actions.ts b/packages/headless/src/features/case-input/case-input-actions.ts index fec53a4b850..291aeb63504 100644 --- a/packages/headless/src/features/case-input/case-input-actions.ts +++ b/packages/headless/src/features/case-input/case-input-actions.ts @@ -3,7 +3,7 @@ import { validatePayload, requiredNonEmptyString, requiredEmptyAllowedString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export interface SetCaseInputActionCreatorPayload { /** diff --git a/packages/headless/src/features/case-input/case-input-slice.test.ts b/packages/headless/src/features/case-input/case-input-slice.test.ts index 1f42ade2207..ebe16a60fff 100644 --- a/packages/headless/src/features/case-input/case-input-slice.test.ts +++ b/packages/headless/src/features/case-input/case-input-slice.test.ts @@ -1,6 +1,6 @@ -import {updateCaseInput} from './case-input-actions'; -import {caseInputReducer} from './case-input-slice'; -import {getCaseInputInitialState, CaseInputState} from './case-input-state'; +import {updateCaseInput} from './case-input-actions.js'; +import {caseInputReducer} from './case-input-slice.js'; +import {getCaseInputInitialState, CaseInputState} from './case-input-state.js'; describe('case input slice', () => { const testMapping = {fieldName: 'foo', fieldValue: 'fooValue'}; diff --git a/packages/headless/src/features/case-input/case-input-slice.ts b/packages/headless/src/features/case-input/case-input-slice.ts index 8606437a05f..dd677adc500 100644 --- a/packages/headless/src/features/case-input/case-input-slice.ts +++ b/packages/headless/src/features/case-input/case-input-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {updateCaseInput} from './case-input-actions'; -import {getCaseInputInitialState} from './case-input-state'; +import {updateCaseInput} from './case-input-actions.js'; +import {getCaseInputInitialState} from './case-input-state.js'; export const caseInputReducer = createReducer( getCaseInputInitialState(), diff --git a/packages/headless/src/features/commerce/common/actions.test.ts b/packages/headless/src/features/commerce/common/actions.test.ts index 42414b4e1f4..f1b5012186d 100644 --- a/packages/headless/src/features/commerce/common/actions.test.ts +++ b/packages/headless/src/features/commerce/common/actions.test.ts @@ -1,25 +1,26 @@ import {CurrencyCodeISO4217} from '@coveo/relay-event-types'; -import {getCommerceApiBaseUrl} from '../../../api/commerce/commerce-api-client'; +import {MockInstance} from 'vitest'; +import {getCommerceApiBaseUrl} from '../../../api/commerce/commerce-api-client.js'; import { BaseCommerceAPIRequest, CommerceAPIRequest, -} from '../../../api/commerce/common/request'; -import {NavigatorContext} from '../../../app/navigatorContextProvider'; -import {buildMockCommerceFacetRequest} from '../../../test/mock-commerce-facet-request'; -import {buildMockCommerceFacetSlice} from '../../../test/mock-commerce-facet-slice'; -import {buildMockCommerceRegularFacetValue} from '../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; -import {buildMockNavigatorContextProvider} from '../../../test/mock-navigator-context-provider'; -import {VERSION} from '../../../utils/version'; -import {CommerceFacetSlice} from '../facets/facet-set/facet-set-state'; -import {ManualNumericFacetSetSlice} from '../facets/numeric-facet/manual-numeric-facet-state'; +} from '../../../api/commerce/common/request.js'; +import {NavigatorContext} from '../../../app/navigatorContextProvider.js'; +import {buildMockCommerceFacetRequest} from '../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceFacetSlice} from '../../../test/mock-commerce-facet-slice.js'; +import {buildMockCommerceRegularFacetValue} from '../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; +import {buildMockNavigatorContextProvider} from '../../../test/mock-navigator-context-provider.js'; +import {VERSION} from '../../../utils/version.js'; +import {CommerceFacetSlice} from '../facets/facet-set/facet-set-state.js'; +import {ManualNumericFacetSetSlice} from '../facets/numeric-facet/manual-numeric-facet-state.js'; import { getCommercePaginationInitialSlice, getCommercePaginationInitialState, -} from '../pagination/pagination-state'; -import {SortBy, SortCriterion, SortDirection} from '../sort/sort'; -import {getCommerceSortInitialState} from '../sort/sort-state'; -import * as Actions from './actions'; +} from '../pagination/pagination-state.js'; +import {getCommerceSortInitialState} from '../sort/sort-state.js'; +import {SortBy, SortCriterion, SortDirection} from '../sort/sort.js'; +import * as Actions from './actions.js'; describe('commerce common actions', () => { let navigatorContext: NavigatorContext; @@ -158,13 +159,13 @@ describe('commerce common actions', () => { describe('#buildCommerceAPIRequest', () => { let state: Actions.ListingAndSearchStateNeededByQueryCommerceAPI; - let mockedBuildBaseCommerceAPIRequest: jest.SpyInstance; + let mockedBuildBaseCommerceAPIRequest: MockInstance; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); state = buildMockCommerceState(); - mockedBuildBaseCommerceAPIRequest = jest.spyOn( + mockedBuildBaseCommerceAPIRequest = vi.spyOn( Actions, - 'buildBaseCommerceAPIRequest' + 'buildCommerceAPIRequest' ); }); diff --git a/packages/headless/src/features/commerce/common/actions.ts b/packages/headless/src/features/commerce/common/actions.ts index e173ace56e6..c0cb7025290 100644 --- a/packages/headless/src/features/commerce/common/actions.ts +++ b/packages/headless/src/features/commerce/common/actions.ts @@ -1,12 +1,12 @@ -import {getAnalyticsSource} from '../../../api/analytics/analytics-selectors'; -import {getCommerceApiBaseUrl} from '../../../api/commerce/commerce-api-client'; -import {SortParam} from '../../../api/commerce/commerce-api-params'; +import {getAnalyticsSource} from '../../../api/analytics/analytics-selectors.js'; +import {getCommerceApiBaseUrl} from '../../../api/commerce/commerce-api-client.js'; +import {SortParam} from '../../../api/commerce/commerce-api-params.js'; import { BaseCommerceAPIRequest, CommerceAPIRequest, -} from '../../../api/commerce/common/request'; -import {CommerceSuccessResponse} from '../../../api/commerce/common/response'; -import {NavigatorContext} from '../../../app/navigatorContextProvider'; +} from '../../../api/commerce/common/request.js'; +import {CommerceSuccessResponse} from '../../../api/commerce/common/response.js'; +import {NavigatorContext} from '../../../app/navigatorContextProvider.js'; import { CartSection, CommerceContextSection, @@ -17,10 +17,10 @@ import { FacetOrderSection, ManualRangeSection, VersionSection, -} from '../../../state/state-sections'; -import {getProductsFromCartState} from '../context/cart/cart-state'; -import {AnyFacetRequest} from '../facets/facet-set/interfaces/request'; -import {SortBy, SortCriterion} from '../sort/sort'; +} from '../../../state/state-sections.js'; +import {getProductsFromCartState} from '../context/cart/cart-state.js'; +import {AnyFacetRequest} from '../facets/facet-set/interfaces/request.js'; +import {SortBy, SortCriterion} from '../sort/sort.js'; export type StateNeededByQueryCommerceAPI = CommerceConfigurationSection & CommerceContextSection & diff --git a/packages/headless/src/features/commerce/configuration/configuration-actions-loader.ts b/packages/headless/src/features/commerce/configuration/configuration-actions-loader.ts index 7edc68cc325..44ca7f8abe6 100644 --- a/packages/headless/src/features/commerce/configuration/configuration-actions-loader.ts +++ b/packages/headless/src/features/commerce/configuration/configuration-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {configurationReducer as configuration} from '../../configuration/configuration-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {configurationReducer as configuration} from '../../configuration/configuration-slice.js'; import { UpdateAnalyticsConfigurationPayload, UpdateBasicConfigurationPayload, @@ -10,7 +10,7 @@ import { updateAnalyticsConfiguration, updateBasicConfiguration, updateProxyBaseUrl, -} from './configuration-actions'; +} from './configuration-actions.js'; export type { UpdateAnalyticsConfigurationPayload, diff --git a/packages/headless/src/features/commerce/configuration/configuration-actions.ts b/packages/headless/src/features/commerce/configuration/configuration-actions.ts index 94d4d44fc07..e4d1ee35e83 100644 --- a/packages/headless/src/features/commerce/configuration/configuration-actions.ts +++ b/packages/headless/src/features/commerce/configuration/configuration-actions.ts @@ -1,12 +1,15 @@ import {StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {PlatformEnvironment} from '../../../utils/url-utils'; -import {nonEmptyString, validatePayload} from '../../../utils/validate-payload'; +import {PlatformEnvironment} from '../../../utils/url-utils.js'; +import { + nonEmptyString, + validatePayload, +} from '../../../utils/validate-payload.js'; import { UpdateAnalyticsConfigurationActionCreatorPayload, UpdateBasicConfigurationActionCreatorPayload, analyticsConfigurationSchema, -} from '../../configuration/configuration-actions'; +} from '../../configuration/configuration-actions.js'; export type UpdateBasicConfigurationPayload = UpdateBasicConfigurationActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/configuration/configuration-slice.test.ts b/packages/headless/src/features/commerce/configuration/configuration-slice.test.ts index fcc0106e30d..648563ed22f 100644 --- a/packages/headless/src/features/commerce/configuration/configuration-slice.test.ts +++ b/packages/headless/src/features/commerce/configuration/configuration-slice.test.ts @@ -4,12 +4,12 @@ import { updateAnalyticsConfiguration, updateBasicConfiguration, updateProxyBaseUrl, -} from './configuration-actions'; -import {configurationReducer} from './configuration-slice'; +} from './configuration-actions.js'; +import {configurationReducer} from './configuration-slice.js'; import { ConfigurationState, getConfigurationInitialState, -} from './configuration-state'; +} from './configuration-state.js'; describe('commerce configuration slice', () => { const initialState = getConfigurationInitialState(); diff --git a/packages/headless/src/features/commerce/configuration/configuration-slice.ts b/packages/headless/src/features/commerce/configuration/configuration-slice.ts index 7593f9cf2b7..259adf58597 100644 --- a/packages/headless/src/features/commerce/configuration/configuration-slice.ts +++ b/packages/headless/src/features/commerce/configuration/configuration-slice.ts @@ -9,11 +9,11 @@ import { UpdateBasicConfigurationPayload, updateProxyBaseUrl, UpdateProxyBaseUrlPayload, -} from './configuration-actions'; +} from './configuration-actions.js'; import { ConfigurationState, getConfigurationInitialState, -} from './configuration-state'; +} from './configuration-state.js'; export const configurationReducer = createReducer( getConfigurationInitialState(), diff --git a/packages/headless/src/features/commerce/configuration/configuration-state.ts b/packages/headless/src/features/commerce/configuration/configuration-state.ts index 1f924657e3c..ee7da9392b7 100644 --- a/packages/headless/src/features/commerce/configuration/configuration-state.ts +++ b/packages/headless/src/features/commerce/configuration/configuration-state.ts @@ -1,4 +1,4 @@ -import {CoreConfigurationState} from '../../configuration/configuration-state'; +import {CoreConfigurationState} from '../../configuration/configuration-state.js'; export interface ConfigurationState extends CoreConfigurationState { /** diff --git a/packages/headless/src/features/commerce/context/cart/cart-actions-loader.ts b/packages/headless/src/features/commerce/context/cart/cart-actions-loader.ts index e696912b56d..88a58e8fa07 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-actions-loader.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-actions-loader.ts @@ -1,9 +1,9 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../../api/commerce/commerce-api-client'; +import {AsyncThunkCommerceOptions} from '../../../../api/commerce/commerce-api-client.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../../app/commerce-engine/commerce-engine'; +} from '../../../../app/commerce-engine/commerce-engine.js'; import { CartActionPayload, PurchasePayload, @@ -14,8 +14,8 @@ import { purchase, setItems, updateItemQuantity, -} from './cart-actions'; -import {cartReducer as cart} from './cart-slice'; +} from './cart-actions.js'; +import {cartReducer as cart} from './cart-slice.js'; export type { CartActionPayload, diff --git a/packages/headless/src/features/commerce/context/cart/cart-actions.ts b/packages/headless/src/features/commerce/context/cart/cart-actions.ts index c4510e62bc0..a43057bb1cf 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-actions.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-actions.ts @@ -1,18 +1,18 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../../api/commerce/commerce-api-client'; -import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine'; -import {validatePayload} from '../../../../utils/validate-payload'; +import {AsyncThunkCommerceOptions} from '../../../../api/commerce/commerce-api-client.js'; +import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine.js'; +import {validatePayload} from '../../../../utils/validate-payload.js'; import { CartActionDetails, Transaction, getECCartActionPayload, getECPurchasePayload, -} from './cart-selector'; -import {CartItemWithMetadata} from './cart-state'; +} from './cart-selector.js'; +import {CartItemWithMetadata} from './cart-state.js'; import { setItemsPayloadDefinition, itemPayloadDefinition, -} from './cart-validation'; +} from './cart-validation.js'; export type SetItemsPayload = CartItemWithMetadata[]; diff --git a/packages/headless/src/features/commerce/context/cart/cart-selector.ts b/packages/headless/src/features/commerce/context/cart/cart-selector.ts index 6d13f811fa8..1f0a8380b1c 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-selector.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-selector.ts @@ -1,9 +1,9 @@ import {Ec} from '@coveo/relay-event-types'; import {createSelector} from '@reduxjs/toolkit'; -import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine'; -import {CartKey} from '../../../../controllers/commerce/context/cart/headless-cart'; -import {getCurrency} from '../context-selector'; -import {CartState} from './cart-state'; +import {CommerceEngineState} from '../../../../app/commerce-engine/commerce-engine.js'; +import {CartKey} from '../../../../controllers/commerce/context/cart/headless-cart.js'; +import {getCurrency} from '../context-selector.js'; +import {CartState} from './cart-state.js'; /** * The purchase transaction. diff --git a/packages/headless/src/features/commerce/context/cart/cart-slice.test.ts b/packages/headless/src/features/commerce/context/cart/cart-slice.test.ts index 3f2ac5b128d..d10231755fc 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-slice.test.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-slice.test.ts @@ -1,12 +1,12 @@ import {createAction} from '@reduxjs/toolkit'; -import {createCartKey} from '../../../../controllers/commerce/context/cart/headless-cart'; -import {purchase, setItems, updateItemQuantity} from './cart-actions'; -import {cartReducer} from './cart-slice'; +import {createCartKey} from '../../../../controllers/commerce/context/cart/headless-cart.js'; +import {purchase, setItems, updateItemQuantity} from './cart-actions.js'; +import {cartReducer} from './cart-slice.js'; import { CartItemWithMetadata, CartState, getCartInitialState, -} from './cart-state'; +} from './cart-state.js'; describe('cart-slice', () => { const someItem: CartItemWithMetadata = { diff --git a/packages/headless/src/features/commerce/context/cart/cart-slice.ts b/packages/headless/src/features/commerce/context/cart/cart-slice.ts index 0b238ac4101..8a51b233ab5 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-slice.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-slice.ts @@ -1,11 +1,11 @@ import {createReducer} from '@reduxjs/toolkit'; -import {createCartKey} from '../../../../controllers/commerce/context/cart/headless-cart'; -import {purchase, setItems, updateItemQuantity} from './cart-actions'; +import {createCartKey} from '../../../../controllers/commerce/context/cart/headless-cart.js'; +import {purchase, setItems, updateItemQuantity} from './cart-actions.js'; import { CartItemWithMetadata, CartState, getCartInitialState, -} from './cart-state'; +} from './cart-state.js'; export const cartReducer = createReducer( getCartInitialState(), diff --git a/packages/headless/src/features/commerce/context/cart/cart-state.test.ts b/packages/headless/src/features/commerce/context/cart/cart-state.test.ts index 9bb0684c929..64079187e92 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-state.test.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-state.test.ts @@ -1,4 +1,4 @@ -import {getProductsFromCartState} from './cart-state'; +import {getProductsFromCartState} from './cart-state.js'; describe('cart-state', () => { it('should aggregate products with a different price', () => { diff --git a/packages/headless/src/features/commerce/context/cart/cart-state.ts b/packages/headless/src/features/commerce/context/cart/cart-state.ts index 1839100497a..865ddc41df9 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-state.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-state.ts @@ -1,4 +1,4 @@ -import {CartItemParam} from '../../../../api/commerce/commerce-api-params'; +import {CartItemParam} from '../../../../api/commerce/commerce-api-params.js'; export interface CartItemWithMetadata extends CartItemParam { /** diff --git a/packages/headless/src/features/commerce/context/cart/cart-validation.ts b/packages/headless/src/features/commerce/context/cart/cart-validation.ts index 123f145af2a..9f06a3a26b4 100644 --- a/packages/headless/src/features/commerce/context/cart/cart-validation.ts +++ b/packages/headless/src/features/commerce/context/cart/cart-validation.ts @@ -5,8 +5,8 @@ import { Schema, StringValue, } from '@coveo/bueno'; -import {CartInitialState} from '../../../../controllers/commerce/context/cart/headless-cart'; -import {requiredNonEmptyString} from '../../../../utils/validate-payload'; +import {CartInitialState} from '../../../../controllers/commerce/context/cart/headless-cart.js'; +import {requiredNonEmptyString} from '../../../../utils/validate-payload.js'; export const itemPayloadDefinition = { productId: requiredNonEmptyString, diff --git a/packages/headless/src/features/commerce/context/context-actions-loader.ts b/packages/headless/src/features/commerce/context/context-actions-loader.ts index cebd32dfd01..0cfdf54d905 100644 --- a/packages/headless/src/features/commerce/context/context-actions-loader.ts +++ b/packages/headless/src/features/commerce/context/context-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; import { SetContextPayload, SetViewPayload, setContext, setView, -} from './context-actions'; -import {contextReducer as commerceContext} from './context-slice'; +} from './context-actions.js'; +import {contextReducer as commerceContext} from './context-slice.js'; export type {SetContextPayload, SetViewPayload}; diff --git a/packages/headless/src/features/commerce/context/context-actions.ts b/packages/headless/src/features/commerce/context/context-actions.ts index b51e37a28d8..43cddaae078 100644 --- a/packages/headless/src/features/commerce/context/context-actions.ts +++ b/packages/headless/src/features/commerce/context/context-actions.ts @@ -1,8 +1,8 @@ import {CurrencyCodeISO4217} from '@coveo/relay-event-types'; import {createAction} from '@reduxjs/toolkit'; -import {ViewParams} from '../../../api/commerce/commerce-api-params'; -import {validatePayload} from '../../../utils/validate-payload'; -import {contextDefinition, viewDefinition} from './context-validation'; +import {ViewParams} from '../../../api/commerce/commerce-api-params.js'; +import {validatePayload} from '../../../utils/validate-payload.js'; +import {contextDefinition, viewDefinition} from './context-validation.js'; export interface SetContextPayload { language: string; diff --git a/packages/headless/src/features/commerce/context/context-selector.ts b/packages/headless/src/features/commerce/context/context-selector.ts index f7e07acfbc8..54ba9ec906f 100644 --- a/packages/headless/src/features/commerce/context/context-selector.ts +++ b/packages/headless/src/features/commerce/context/context-selector.ts @@ -1,5 +1,5 @@ import {CurrencyCodeISO4217} from '@coveo/relay-event-types'; -import {CommerceContextState} from './context-state'; +import {CommerceContextState} from './context-state.js'; export function getCurrency(state: CommerceContextState): CurrencyCodeISO4217 { return state.currency; diff --git a/packages/headless/src/features/commerce/context/context-slice.test.ts b/packages/headless/src/features/commerce/context/context-slice.test.ts index 2134afd1449..dad406a0ae8 100644 --- a/packages/headless/src/features/commerce/context/context-slice.test.ts +++ b/packages/headless/src/features/commerce/context/context-slice.test.ts @@ -1,6 +1,6 @@ -import {setContext, setView} from './context-actions'; -import {contextReducer} from './context-slice'; -import {CommerceContextState, getContextInitialState} from './context-state'; +import {setContext, setView} from './context-actions.js'; +import {contextReducer} from './context-slice.js'; +import {CommerceContextState, getContextInitialState} from './context-state.js'; describe('context-slice', () => { let state: CommerceContextState; diff --git a/packages/headless/src/features/commerce/context/context-slice.ts b/packages/headless/src/features/commerce/context/context-slice.ts index 72ee1557112..e4212ef276b 100644 --- a/packages/headless/src/features/commerce/context/context-slice.ts +++ b/packages/headless/src/features/commerce/context/context-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setContext, setView} from './context-actions'; -import {getContextInitialState} from './context-state'; +import {setContext, setView} from './context-actions.js'; +import {getContextInitialState} from './context-state.js'; export const contextReducer = createReducer( getContextInitialState(), diff --git a/packages/headless/src/features/commerce/context/context-state.ts b/packages/headless/src/features/commerce/context/context-state.ts index 2ad8998ee56..2d867b3f46a 100644 --- a/packages/headless/src/features/commerce/context/context-state.ts +++ b/packages/headless/src/features/commerce/context/context-state.ts @@ -1,5 +1,5 @@ import {CurrencyCodeISO4217} from '@coveo/relay-event-types'; -import {ViewParams} from '../../../api/commerce/commerce-api-params'; +import {ViewParams} from '../../../api/commerce/commerce-api-params.js'; export interface CommerceContextState { language: string; diff --git a/packages/headless/src/features/commerce/context/context-validation.ts b/packages/headless/src/features/commerce/context/context-validation.ts index 5942d6a7563..36e425900ae 100644 --- a/packages/headless/src/features/commerce/context/context-validation.ts +++ b/packages/headless/src/features/commerce/context/context-validation.ts @@ -1,6 +1,6 @@ import {RecordValue, Schema, StringValue} from '@coveo/bueno'; import {CurrencyCodeISO4217} from '@coveo/relay-event-types'; -import {requiredNonEmptyString} from '../../../utils/validate-payload'; +import {requiredNonEmptyString} from '../../../utils/validate-payload.js'; const currencies = Intl.supportedValuesOf('currency') as CurrencyCodeISO4217[]; diff --git a/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.test.ts b/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.test.ts index 0879b6769c9..d378f39168b 100644 --- a/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.test.ts +++ b/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.test.ts @@ -1,7 +1,10 @@ -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {executeSearch} from '../search/search-actions'; -import {didYouMeanReducer} from './did-you-mean-slice'; -import {getDidYouMeanInitialState, DidYouMeanState} from './did-you-mean-state'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {executeSearch} from '../search/search-actions.js'; +import {didYouMeanReducer} from './did-you-mean-slice.js'; +import { + getDidYouMeanInitialState, + DidYouMeanState, +} from './did-you-mean-state.js'; describe('did you mean slice', () => { let state: DidYouMeanState; diff --git a/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.ts b/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.ts index 50758d8aa75..5673a4ffa90 100644 --- a/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.ts +++ b/packages/headless/src/features/commerce/did-you-mean/did-you-mean-slice.ts @@ -1,8 +1,8 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setToNonEmptyQueryCorrection} from '../../did-you-mean/did-you-mean-slice-functions'; -import {emptyNextCorrection} from '../../did-you-mean/did-you-mean-state'; -import {executeSearch} from '../search/search-actions'; -import {getDidYouMeanInitialState} from './did-you-mean-state'; +import {setToNonEmptyQueryCorrection} from '../../did-you-mean/did-you-mean-slice-functions.js'; +import {emptyNextCorrection} from '../../did-you-mean/did-you-mean-state.js'; +import {executeSearch} from '../search/search-actions.js'; +import {getDidYouMeanInitialState} from './did-you-mean-state.js'; export const didYouMeanReducer = createReducer( getDidYouMeanInitialState(), diff --git a/packages/headless/src/features/commerce/did-you-mean/did-you-mean-state.ts b/packages/headless/src/features/commerce/did-you-mean/did-you-mean-state.ts index 062e30bd0d5..8a40c1e18e6 100644 --- a/packages/headless/src/features/commerce/did-you-mean/did-you-mean-state.ts +++ b/packages/headless/src/features/commerce/did-you-mean/did-you-mean-state.ts @@ -1,5 +1,5 @@ -import {QueryCorrection} from '../../../api/search/search/query-corrections'; -import {emptyNextCorrection} from '../../did-you-mean/did-you-mean-state'; +import {QueryCorrection} from '../../../api/search/search/query-corrections.js'; +import {emptyNextCorrection} from '../../did-you-mean/did-you-mean-state.js'; export interface DidYouMeanState { /** diff --git a/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions-loader.ts b/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions-loader.ts index 0708e2a2fe0..aec623b6ec7 100644 --- a/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions-loader.ts +++ b/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice.js'; import { ToggleSelectCategoryFacetValuePayload, UpdateCategoryFacetNumberOfValuesPayload, toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, -} from './category-facet-actions'; +} from './category-facet-actions.js'; export type { ToggleSelectCategoryFacetValuePayload, diff --git a/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions.ts b/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions.ts index f01baa01e0c..eddbbc45ed5 100644 --- a/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions.ts +++ b/packages/headless/src/features/commerce/facets/category-facet/category-facet-actions.ts @@ -5,12 +5,12 @@ import { serializeSchemaValidationError, validatePayload, validatePayloadAndThrow, -} from '../../../../utils/validate-payload'; +} from '../../../../utils/validate-payload.js'; import { ToggleSelectCategoryFacetValueActionCreatorPayload, UpdateCategoryFacetNumberOfValuesActionCreatorPayload, -} from '../../../facets/category-facet-set/category-facet-set-actions'; -import {validateCategoryFacetValue} from '../../../facets/category-facet-set/category-facet-validate-payload'; +} from '../../../facets/category-facet-set/category-facet-set-actions.js'; +import {validateCategoryFacetValue} from '../../../facets/category-facet-set/category-facet-validate-payload.js'; export type UpdateCategoryFacetNumberOfValuesPayload = UpdateCategoryFacetNumberOfValuesActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions-loader.ts b/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions-loader.ts index 44d3f18bde3..83011ccebc2 100644 --- a/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions-loader.ts +++ b/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice.js'; import { DeselectAllValuesInCoreFacetPayload, UpdateCoreFacetFreezeCurrentValuesPayload, @@ -13,7 +13,7 @@ import { updateCoreFacetNumberOfValues, updateAutoSelectionForAllCoreFacets, clearAllCoreFacets, -} from './core-facet-actions'; +} from './core-facet-actions.js'; export type { DeselectAllValuesInCoreFacetPayload, diff --git a/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions.ts b/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions.ts index 784ed364d16..6c2b2f7f2bf 100644 --- a/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions.ts +++ b/packages/headless/src/features/commerce/facets/core-facet/core-facet-actions.ts @@ -3,13 +3,13 @@ import {createAction} from '@reduxjs/toolkit'; import { requiredNonEmptyString, validatePayload, -} from '../../../../utils/validate-payload'; +} from '../../../../utils/validate-payload.js'; import { UpdateFacetIsFieldExpandedActionCreatorPayload, UpdateFacetNumberOfValuesActionCreatorPayload, UpdateFreezeCurrentValuesActionCreatorPayload, -} from '../../../facets/facet-set/facet-set-actions'; -import {UpdateFacetAutoSelectionActionCreatorPayload} from '../../../facets/generic/facet-actions'; +} from '../../../facets/facet-set/facet-set-actions.js'; +import {UpdateFacetAutoSelectionActionCreatorPayload} from '../../../facets/generic/facet-actions.js'; export type UpdateCoreFacetNumberOfValuesPayload = UpdateFacetNumberOfValuesActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions-loader.ts b/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions-loader.ts index afa1b3543e5..0d5269a9c67 100644 --- a/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions-loader.ts +++ b/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice.js'; import { ToggleExcludeDateFacetValuePayload, ToggleSelectDateFacetValuePayload, @@ -8,7 +8,7 @@ import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from './date-facet-actions'; +} from './date-facet-actions.js'; /** * The date facet action creators. diff --git a/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions.ts b/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions.ts index 97d27b02c54..7b73b198e54 100644 --- a/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions.ts +++ b/packages/headless/src/features/commerce/facets/date-facet/date-facet-actions.ts @@ -5,13 +5,13 @@ import { serializeSchemaValidationError, validatePayload, validatePayloadAndThrow, -} from '../../../../utils/validate-payload'; +} from '../../../../utils/validate-payload.js'; import { ToggleSelectDateFacetValueActionCreatorPayload, UpdateDateFacetValuesActionCreatorPayload, validateManualDateRanges, -} from '../../../facets/range-facets/date-facet-set/date-facet-actions'; -import {dateFacetValueDefinition} from '../../../facets/range-facets/generic/range-facet-validate-payload'; +} from '../../../facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateFacetValueDefinition} from '../../../facets/range-facets/generic/range-facet-validate-payload.js'; export type ToggleSelectDateFacetValuePayload = ToggleSelectDateFacetValueActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.test.ts b/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.test.ts index 58d2a0f17ac..4bc6acc37da 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.test.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.test.ts @@ -1,29 +1,30 @@ -import {NavigatorContext} from '../../../../../app/navigatorContextProvider'; -import * as Actions from '../../../../../features/commerce/common/actions'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search'; -import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request'; -import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../../../test/mock-commerce-facet-value'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; -import {buildMockFacetSearchRequestOptions} from '../../../../../test/mock-facet-search-request-options'; -import {buildMockNavigatorContextProvider} from '../../../../../test/mock-navigator-context-provider'; -import {CategoryFacetValueRequest} from '../../facet-set/interfaces/request'; +import {MockInstance} from 'vitest'; +import {NavigatorContext} from '../../../../../app/navigatorContextProvider.js'; +import * as Actions from '../../../../../features/commerce/common/actions.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCategoryFacetSearch} from '../../../../../test/mock-category-facet-search.js'; +import {buildMockCommerceFacetRequest} from '../../../../../test/mock-commerce-facet-request.js'; +import {buildMockCommerceFacetSlice} from '../../../../../test/mock-commerce-facet-slice.js'; +import {buildMockCategoryFacetValue} from '../../../../../test/mock-commerce-facet-value.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; +import {buildMockFacetSearchRequestOptions} from '../../../../../test/mock-facet-search-request-options.js'; +import {buildMockNavigatorContextProvider} from '../../../../../test/mock-navigator-context-provider.js'; +import {CategoryFacetValueRequest} from '../../facet-set/interfaces/request.js'; import { getFacetIdWithCommerceFieldSuggestionNamespace, getFacetIdWithoutCommerceFieldSuggestionNamespace, -} from '../commerce-facet-search-actions'; -import {buildCategoryFacetSearchRequest} from './commerce-category-facet-search-request-builder'; +} from '../commerce-facet-search-actions.js'; +import {buildCategoryFacetSearchRequest} from './commerce-category-facet-search-request-builder.js'; describe('#buildCategoryFacetSearchRequest', () => { let state: CommerceAppState; let navigatorContext: NavigatorContext; const facetId = '1'; let query: string; - let buildCommerceAPIRequestMock: jest.SpyInstance; + let buildCommerceAPIRequestMock: MockInstance; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); query = 'test'; state = buildMockCommerceState(); @@ -36,10 +37,7 @@ describe('#buildCategoryFacetSearchRequest', () => { request: buildMockCommerceFacetRequest({type: 'hierarchical'}), }); - buildCommerceAPIRequestMock = jest.spyOn( - Actions, - 'buildCommerceAPIRequest' - ); + buildCommerceAPIRequestMock = vi.spyOn(Actions, 'buildCommerceAPIRequest'); navigatorContext = buildMockNavigatorContextProvider()(); }); @@ -171,7 +169,7 @@ describe('#buildCategoryFacetSearchRequest', () => { }); it('when not building a field suggestion request, returned request includes all properties returned by #buildCommerceAPIRequest, plus the #query property', () => { - const buildCommerceAPIRequestMock = jest.spyOn( + const buildCommerceAPIRequestMock = vi.spyOn( Actions, 'buildCommerceAPIRequest' ); diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.ts b/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.ts index fd8c124a4d7..bd1ffa5b923 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-request-builder.ts @@ -1,12 +1,12 @@ -import {CategoryFacetSearchRequest} from '../../../../../api/commerce/facet-search/facet-search-request'; -import {NavigatorContext} from '../../../../../app/navigatorContextProvider'; -import {buildCommerceAPIRequest} from '../../../common/actions'; +import {CategoryFacetSearchRequest} from '../../../../../api/commerce/facet-search/facet-search-request.js'; +import {NavigatorContext} from '../../../../../app/navigatorContextProvider.js'; +import {buildCommerceAPIRequest} from '../../../common/actions.js'; import { AnyFacetRequest, CategoryFacetRequest, -} from '../../facet-set/interfaces/request'; -import {getFacetIdWithoutCommerceFieldSuggestionNamespace} from '../commerce-facet-search-actions'; -import {StateNeededForCategoryFacetSearch} from './commerce-category-facet-search-state'; +} from '../../facet-set/interfaces/request.js'; +import {getFacetIdWithoutCommerceFieldSuggestionNamespace} from '../commerce-facet-search-actions.js'; +import {StateNeededForCategoryFacetSearch} from './commerce-category-facet-search-state.js'; export const buildCategoryFacetSearchRequest = ( facetId: string, diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-state.ts b/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-state.ts index c50938f32a0..f8850a7c1f0 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-state.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/category/commerce-category-facet-search-state.ts @@ -1,5 +1,5 @@ -import {CategoryFacetSearchSection} from '../../../../../state/state-sections'; -import {CoreStateNeededForFacetSearch} from '../commerce-facet-search-state'; +import {CategoryFacetSearchSection} from '../../../../../state/state-sections.js'; +import {CoreStateNeededForFacetSearch} from '../commerce-facet-search-state.js'; export type StateNeededForCategoryFacetSearch = CoreStateNeededForFacetSearch & CategoryFacetSearchSection; diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-actions.ts b/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-actions.ts index e5adce226b2..30133b56c92 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-actions.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-actions.ts @@ -2,18 +2,18 @@ import {AsyncThunkPayloadCreator, createAsyncThunk} from '@reduxjs/toolkit'; import { CommerceAPIResponse, CommerceFacetSearchAPIClient, -} from '../../../../api/commerce/commerce-api-client'; -import {FacetSearchType} from '../../../../api/commerce/facet-search/facet-search-request'; -import {CategoryFacetSearchResponse} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; -import {SpecificFacetSearchResponse} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; -import {AsyncThunkOptions} from '../../../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../../../app/thunk-extra-arguments'; -import {requiredNonEmptyString} from '../../../../utils/validate-payload'; -import {FieldSuggestionsOrderState} from '../field-suggestions-order/field-suggestions-order-state'; -import {buildCategoryFacetSearchRequest} from './category/commerce-category-facet-search-request-builder'; -import {StateNeededForAnyFacetSearch} from './commerce-facet-search-state'; -import {buildFacetSearchRequest} from './regular/commerce-regular-facet-search-request-builder'; -import {StateNeededForRegularFacetSearch} from './regular/commerce-regular-facet-search-state'; +} from '../../../../api/commerce/commerce-api-client.js'; +import {FacetSearchType} from '../../../../api/commerce/facet-search/facet-search-request.js'; +import {CategoryFacetSearchResponse} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; +import {SpecificFacetSearchResponse} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; +import {AsyncThunkOptions} from '../../../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../../../app/thunk-extra-arguments.js'; +import {requiredNonEmptyString} from '../../../../utils/validate-payload.js'; +import {FieldSuggestionsOrderState} from '../field-suggestions-order/field-suggestions-order-state.js'; +import {buildCategoryFacetSearchRequest} from './category/commerce-category-facet-search-request-builder.js'; +import {StateNeededForAnyFacetSearch} from './commerce-facet-search-state.js'; +import {buildFacetSearchRequest} from './regular/commerce-regular-facet-search-request-builder.js'; +import {StateNeededForRegularFacetSearch} from './regular/commerce-regular-facet-search-state.js'; type ExecuteCommerceFacetSearchThunkReturn = { facetId: string; diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-state.ts b/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-state.ts index b94c1733ce8..6f852d003cf 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-state.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/commerce-facet-search-state.ts @@ -1,10 +1,10 @@ import { CommerceFacetSetSection, CommerceQuerySection, -} from '../../../../state/state-sections'; -import {StateNeededByQueryCommerceAPI} from '../../common/actions'; -import {StateNeededForCategoryFacetSearch} from './category/commerce-category-facet-search-state'; -import {StateNeededForRegularFacetSearch} from './regular/commerce-regular-facet-search-state'; +} from '../../../../state/state-sections.js'; +import {StateNeededByQueryCommerceAPI} from '../../common/actions.js'; +import {StateNeededForCategoryFacetSearch} from './category/commerce-category-facet-search-state.js'; +import {StateNeededForRegularFacetSearch} from './regular/commerce-regular-facet-search-state.js'; export type CoreStateNeededForFacetSearch = StateNeededByQueryCommerceAPI & CommerceFacetSetSection & diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.test.ts b/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.test.ts index 8f8f3553452..73bfe3f9916 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.test.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.test.ts @@ -1,21 +1,22 @@ -import {NavigatorContext} from '../../../../../app/navigatorContextProvider'; -import * as Actions from '../../../../../features/commerce/common/actions'; -import {CommerceAppState} from '../../../../../state/commerce-app-state'; -import {buildMockCommerceState} from '../../../../../test/mock-commerce-state'; -import {buildMockFacetSearch} from '../../../../../test/mock-facet-search'; -import {buildMockFacetSearchRequestOptions} from '../../../../../test/mock-facet-search-request-options'; -import {buildMockNavigatorContextProvider} from '../../../../../test/mock-navigator-context-provider'; -import {buildFacetSearchRequest} from './commerce-regular-facet-search-request-builder'; +import {MockInstance} from 'vitest'; +import {NavigatorContext} from '../../../../../app/navigatorContextProvider.js'; +import * as Actions from '../../../../../features/commerce/common/actions.js'; +import {CommerceAppState} from '../../../../../state/commerce-app-state.js'; +import {buildMockCommerceState} from '../../../../../test/mock-commerce-state.js'; +import {buildMockFacetSearchRequestOptions} from '../../../../../test/mock-facet-search-request-options.js'; +import {buildMockFacetSearch} from '../../../../../test/mock-facet-search.js'; +import {buildMockNavigatorContextProvider} from '../../../../../test/mock-navigator-context-provider.js'; +import {buildFacetSearchRequest} from './commerce-regular-facet-search-request-builder.js'; describe('#buildFacetSearchRequest', () => { let state: CommerceAppState; let navigatorContext: NavigatorContext; let facetId: string; let query: string; - let buildCommerceAPIRequestMock: jest.SpyInstance; + let buildCommerceAPIRequestMock: MockInstance; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); facetId = '1'; query = 'test'; @@ -24,10 +25,7 @@ describe('#buildFacetSearchRequest', () => { options: {...buildMockFacetSearchRequestOptions(), query}, }); - buildCommerceAPIRequestMock = jest.spyOn( - Actions, - 'buildCommerceAPIRequest' - ); + buildCommerceAPIRequestMock = vi.spyOn(Actions, 'buildCommerceAPIRequest'); navigatorContext = buildMockNavigatorContextProvider()(); }); @@ -57,7 +55,7 @@ describe('#buildFacetSearchRequest', () => { }); it('when not building a field suggestion request, returned request includes all properties returned by #buildCommerceAPIRequest, plus the #query property', () => { - const buildCommerceAPIRequestMock = jest.spyOn( + const buildCommerceAPIRequestMock = vi.spyOn( Actions, 'buildCommerceAPIRequest' ); diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.ts b/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.ts index 3ef3c04d7b3..ce5dda6d0c4 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-request-builder.ts @@ -1,8 +1,8 @@ -import {CommerceFacetSearchRequest} from '../../../../../api/commerce/facet-search/facet-search-request'; -import {NavigatorContext} from '../../../../../app/navigatorContextProvider'; -import {buildCommerceAPIRequest} from '../../../common/actions'; -import {getFacetIdWithoutCommerceFieldSuggestionNamespace} from '../commerce-facet-search-actions'; -import {StateNeededForRegularFacetSearch} from './commerce-regular-facet-search-state'; +import {CommerceFacetSearchRequest} from '../../../../../api/commerce/facet-search/facet-search-request.js'; +import {NavigatorContext} from '../../../../../app/navigatorContextProvider.js'; +import {buildCommerceAPIRequest} from '../../../common/actions.js'; +import {getFacetIdWithoutCommerceFieldSuggestionNamespace} from '../commerce-facet-search-actions.js'; +import {StateNeededForRegularFacetSearch} from './commerce-regular-facet-search-state.js'; export const buildFacetSearchRequest = ( facetId: string, diff --git a/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-state.ts b/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-state.ts index 7e51183e66b..42a733fcc10 100644 --- a/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-state.ts +++ b/packages/headless/src/features/commerce/facets/facet-search-set/regular/commerce-regular-facet-search-state.ts @@ -1,5 +1,5 @@ -import {FacetSearchSection} from '../../../../../state/state-sections'; -import {CoreStateNeededForFacetSearch} from '../commerce-facet-search-state'; +import {FacetSearchSection} from '../../../../../state/state-sections.js'; +import {CoreStateNeededForFacetSearch} from '../commerce-facet-search-state.js'; export type StateNeededForRegularFacetSearch = CoreStateNeededForFacetSearch & FacetSearchSection; diff --git a/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducer-helpers.ts b/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducer-helpers.ts index 13d3fa08b6b..93cb4ab80dd 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducer-helpers.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducer-helpers.ts @@ -1,5 +1,5 @@ -import {CommerceFacetSetState} from './facet-set-state'; -import {CategoryFacetValueRequest} from './interfaces/request'; +import {CommerceFacetSetState} from './facet-set-state.js'; +import {CategoryFacetValueRequest} from './interfaces/request.js'; export function handleCategoryFacetNestedNumberOfValuesUpdate( state: CommerceFacetSetState, diff --git a/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducers.ts b/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducers.ts index 035b06172eb..f63567aa9cd 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducers.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/facet-set-reducers.ts @@ -1,16 +1,16 @@ -import {FacetValueState} from '../../../facets/facet-api/value'; -import {DateRangeRequest} from '../../../facets/range-facets/date-facet-set/interfaces/request'; -import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request'; -import {Parameters} from '../../parameters/parameters-actions'; -import {CommerceFacetSetState} from './facet-set-state'; +import {FacetValueState} from '../../../facets/facet-api/value.js'; +import {DateRangeRequest} from '../../../facets/range-facets/date-facet-set/interfaces/request.js'; +import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {Parameters} from '../../parameters/parameters-actions.js'; +import {CommerceFacetSetState} from './facet-set-state.js'; import { CategoryFacetRequest, CategoryFacetValueRequest, DateFacetRequest, NumericFacetRequest, RegularFacetRequest, -} from './interfaces/request'; -import {RegularFacetValue} from './interfaces/response'; +} from './interfaces/request.js'; +import {RegularFacetValue} from './interfaces/response.js'; export function restoreFromParameters( state: CommerceFacetSetState, diff --git a/packages/headless/src/features/commerce/facets/facet-set/facet-set-selector.ts b/packages/headless/src/features/commerce/facets/facet-set/facet-set-selector.ts index 1810f46abac..6f0f57cd008 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/facet-set-selector.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/facet-set-selector.ts @@ -1,6 +1,6 @@ import {createSelector} from '@reduxjs/toolkit'; -import {CommerceFacetSetSection} from '../../../../state/state-sections'; -import {AnyFacetRequest} from './interfaces/request'; +import {CommerceFacetSetSection} from '../../../../state/state-sections.js'; +import {AnyFacetRequest} from './interfaces/request.js'; export const facetRequestSelector = createSelector( (state: CommerceFacetSetSection, facetId: string) => ({ diff --git a/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.test.ts b/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.test.ts index 78f621496ca..0beae165eb2 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.test.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.test.ts @@ -3,54 +3,54 @@ import { DateRangeRequest, FacetValueRequest, NumericRangeRequest, -} from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet'; -import {buildMockCategoryFacetSearchResult} from '../../../../test/mock-category-facet-search-result'; -import {buildMockCommerceFacetRequest} from '../../../../test/mock-commerce-facet-request'; +} from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet.js'; +import {buildMockCategoryFacetSearchResult} from '../../../../test/mock-category-facet-search-result.js'; +import {buildMockCommerceFacetRequest} from '../../../../test/mock-commerce-facet-request.js'; import { buildMockCategoryFacetResponse, buildMockCommerceDateFacetResponse, buildMockCommerceNumericFacetResponse, buildMockCommerceRegularFacetResponse, -} from '../../../../test/mock-commerce-facet-response'; -import {buildMockCommerceFacetSlice} from '../../../../test/mock-commerce-facet-slice'; +} from '../../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceFacetSlice} from '../../../../test/mock-commerce-facet-slice.js'; import { buildMockCategoryFacetValue, buildMockCommerceDateFacetValue, buildMockCommerceNumericFacetValue, buildMockCommerceRegularFacetValue, -} from '../../../../test/mock-commerce-facet-value'; -import {buildSearchResponse} from '../../../../test/mock-commerce-search'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; -import {buildMockFacetSearchResult} from '../../../../test/mock-facet-search-result'; -import {buildFetchProductListingResponse} from '../../../../test/mock-product-listing'; -import {defaultNumberOfValuesIncrement} from '../../../facets/category-facet-set/category-facet-set-actions'; +} from '../../../../test/mock-commerce-facet-value.js'; +import {buildSearchResponse} from '../../../../test/mock-commerce-search.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; +import {buildMockFacetSearchResult} from '../../../../test/mock-facet-search-result.js'; +import {buildFetchProductListingResponse} from '../../../../test/mock-product-listing.js'; +import {defaultNumberOfValuesIncrement} from '../../../facets/category-facet-set/category-facet-set-actions.js'; import { FacetValueState, facetValueStates, -} from '../../../facets/facet-api/value'; -import {selectCategoryFacetSearchResult} from '../../../facets/facet-search-set/category/category-facet-search-actions'; +} from '../../../facets/facet-api/value.js'; +import {selectCategoryFacetSearchResult} from '../../../facets/facet-search-set/category/category-facet-search-actions.js'; import { excludeFacetSearchResult, selectFacetSearchResult, -} from '../../../facets/facet-search-set/specific/specific-facet-search-actions'; -import {convertFacetValueToRequest} from '../../../facets/facet-set/facet-set-slice'; -import * as FacetReducers from '../../../facets/generic/facet-reducer-helpers'; -import {convertToDateRangeRequests} from '../../../facets/range-facets/date-facet-set/date-facet-set-slice'; -import {findExactRangeValue} from '../../../facets/range-facets/generic/range-facet-reducers'; -import {convertToNumericRangeRequests} from '../../../facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {setContext, setView} from '../../context/context-actions'; -import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../../product-listing/product-listing-actions'; +} from '../../../facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {convertFacetValueToRequest} from '../../../facets/facet-set/facet-set-slice.js'; +import * as FacetReducers from '../../../facets/generic/facet-reducer-helpers.js'; +import {convertToDateRangeRequests} from '../../../facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {findExactRangeValue} from '../../../facets/range-facets/generic/range-facet-reducers.js'; +import {convertToNumericRangeRequests} from '../../../facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {setContext, setView} from '../../context/context-actions.js'; +import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../../product-listing/product-listing-actions.js'; import { fetchQuerySuggestions, FetchQuerySuggestionsThunkReturn, -} from '../../query-suggest/query-suggest-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions'; -import {executeSearch} from '../../search/search-actions'; +} from '../../query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions.js'; +import {executeSearch} from '../../search/search-actions.js'; import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, -} from '../category-facet/category-facet-actions'; +} from '../category-facet/category-facet-actions.js'; import { deselectAllValuesInCoreFacet, updateCoreFacetFreezeCurrentValues, @@ -58,34 +58,34 @@ import { updateCoreFacetNumberOfValues, updateAutoSelectionForAllCoreFacets, clearAllCoreFacets, -} from '../core-facet/core-facet-actions'; +} from '../core-facet/core-facet-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from '../date-facet/date-facet-actions'; -import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../facet-search-set/commerce-facet-search-actions'; +} from '../date-facet/date-facet-actions.js'; +import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../facet-search-set/commerce-facet-search-actions.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateNumericFacetValues, -} from '../numeric-facet/numeric-facet-actions'; +} from '../numeric-facet/numeric-facet-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../regular-facet/regular-facet-actions'; -import * as CommerceFacetReducers from './facet-set-reducer-helpers'; +} from '../regular-facet/regular-facet-actions.js'; +import * as CommerceFacetReducers from './facet-set-reducer-helpers.js'; import { commerceFacetSetReducer, convertCategoryFacetValueToRequest, -} from './facet-set-slice'; +} from './facet-set-slice.js'; import { CommerceFacetSetState, getCommerceFacetSetInitialState, -} from './facet-set-state'; -import {FacetType} from './interfaces/common'; -import {CategoryFacetValueRequest} from './interfaces/request'; -import {AnyFacetResponse, CategoryFacetValue} from './interfaces/response'; +} from './facet-set-state.js'; +import {FacetType} from './interfaces/common.js'; +import {CategoryFacetValueRequest} from './interfaces/request.js'; +import {AnyFacetResponse, CategoryFacetValue} from './interfaces/response.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type ActionCreator = (payload: any) => Action; @@ -1894,10 +1894,7 @@ describe('commerceFacetSetReducer', () => { }); describe('#updateCategoryFacetNumberOfValues', () => { it('calls #handleFacetUpdateNumberOfValues if there are no nested children', () => { - const spy = jest.spyOn( - FacetReducers, - 'handleFacetUpdateNumberOfValues' - ); + const spy = vi.spyOn(FacetReducers, 'handleFacetUpdateNumberOfValues'); const request = buildMockCommerceFacetRequest({ facetId, type: 'hierarchical', @@ -1916,7 +1913,7 @@ describe('commerceFacetSetReducer', () => { }); it('calls #handleCategoryFacetNestedNumberOfValuesUpdate if there are nested children', () => { - const spy = jest.spyOn( + const spy = vi.spyOn( CommerceFacetReducers, 'handleCategoryFacetNestedNumberOfValuesUpdate' ); diff --git a/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.ts b/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.ts index 316539bb494..f74142e0daa 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/facet-set-slice.ts @@ -4,29 +4,29 @@ import { DateRangeRequest, FacetValueRequest, NumericRangeRequest, -} from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet'; -import {defaultNumberOfValuesIncrement} from '../../../facets/category-facet-set/category-facet-set-actions'; -import {selectCategoryFacetSearchResult} from '../../../facets/facet-search-set/category/category-facet-search-actions'; +} from '../../../../controllers/commerce/core/facets/headless-core-commerce-facet.js'; +import {defaultNumberOfValuesIncrement} from '../../../facets/category-facet-set/category-facet-set-actions.js'; +import {selectCategoryFacetSearchResult} from '../../../facets/facet-search-set/category/category-facet-search-actions.js'; import { excludeFacetSearchResult, selectFacetSearchResult, -} from '../../../facets/facet-search-set/specific/specific-facet-search-actions'; -import {convertFacetValueToRequest} from '../../../facets/facet-set/facet-set-slice'; -import {handleFacetUpdateNumberOfValues} from '../../../facets/generic/facet-reducer-helpers'; -import {convertToDateRangeRequests} from '../../../facets/range-facets/date-facet-set/date-facet-set-slice'; -import {findExactRangeValue} from '../../../facets/range-facets/generic/range-facet-reducers'; -import {convertToNumericRangeRequests} from '../../../facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {setContext, setView} from '../../context/context-actions'; -import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../../product-listing/product-listing-actions'; -import {fetchQuerySuggestions} from '../../query-suggest/query-suggest-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions'; -import {executeSearch} from '../../search/search-actions'; -import '../category-facet/category-facet-actions'; +} from '../../../facets/facet-search-set/specific/specific-facet-search-actions.js'; +import {convertFacetValueToRequest} from '../../../facets/facet-set/facet-set-slice.js'; +import {handleFacetUpdateNumberOfValues} from '../../../facets/generic/facet-reducer-helpers.js'; +import {convertToDateRangeRequests} from '../../../facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {findExactRangeValue} from '../../../facets/range-facets/generic/range-facet-reducers.js'; +import {convertToNumericRangeRequests} from '../../../facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {setContext, setView} from '../../context/context-actions.js'; +import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../../product-listing/product-listing-actions.js'; +import {fetchQuerySuggestions} from '../../query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions.js'; +import {executeSearch} from '../../search/search-actions.js'; +import '../category-facet/category-facet-actions.js'; import { toggleSelectCategoryFacetValue, updateCategoryFacetNumberOfValues, -} from '../category-facet/category-facet-actions'; +} from '../category-facet/category-facet-actions.js'; import { deselectAllValuesInCoreFacet, updateCoreFacetFreezeCurrentValues, @@ -34,37 +34,37 @@ import { updateCoreFacetNumberOfValues, updateAutoSelectionForAllCoreFacets, clearAllCoreFacets, -} from '../core-facet/core-facet-actions'; +} from '../core-facet/core-facet-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from '../date-facet/date-facet-actions'; +} from '../date-facet/date-facet-actions.js'; import { executeCommerceFieldSuggest, getFacetIdWithCommerceFieldSuggestionNamespace, -} from '../facet-search-set/commerce-facet-search-actions'; +} from '../facet-search-set/commerce-facet-search-actions.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateManualNumericFacetRange, updateNumericFacetValues, -} from '../numeric-facet/numeric-facet-actions'; +} from '../numeric-facet/numeric-facet-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../regular-facet/regular-facet-actions'; -import {handleCategoryFacetNestedNumberOfValuesUpdate} from './facet-set-reducer-helpers'; +} from '../regular-facet/regular-facet-actions.js'; +import {handleCategoryFacetNestedNumberOfValuesUpdate} from './facet-set-reducer-helpers.js'; import { buildCategoryFacetValueRequest, buildSelectedFacetValueRequest, restoreFromParameters, selectPath, -} from './facet-set-reducers'; +} from './facet-set-reducers.js'; import { CommerceFacetSetState, getCommerceFacetSetInitialState, -} from './facet-set-state'; +} from './facet-set-state.js'; import { AnyFacetRequest, AnyFacetValueRequest, @@ -72,9 +72,9 @@ import { NumericFacetRequest, DateFacetRequest, CategoryFacetRequest, -} from './interfaces/request'; -import {CategoryFacetValue} from './interfaces/response'; -import {AnyFacetResponse} from './interfaces/response'; +} from './interfaces/request.js'; +import {CategoryFacetValue} from './interfaces/response.js'; +import {AnyFacetResponse} from './interfaces/response.js'; export const commerceFacetSetReducer = createReducer( getCommerceFacetSetInitialState(), diff --git a/packages/headless/src/features/commerce/facets/facet-set/facet-set-state.ts b/packages/headless/src/features/commerce/facets/facet-set/facet-set-state.ts index 81ab925503f..088e4bba98e 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/facet-set-state.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/facet-set-state.ts @@ -1,4 +1,4 @@ -import {AnyFacetRequest} from './interfaces/request'; +import {AnyFacetRequest} from './interfaces/request.js'; export type CommerceFacetSlice = { request: AnyFacetRequest; diff --git a/packages/headless/src/features/commerce/facets/facet-set/interfaces/request.ts b/packages/headless/src/features/commerce/facets/facet-set/interfaces/request.ts index 650d89a672b..ebe344f3a27 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/interfaces/request.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/interfaces/request.ts @@ -1,17 +1,17 @@ import { DateRangeRequest, NumericRangeRequest, -} from '../../../../../controllers/commerce/core/facets/headless-core-commerce-facet'; -import {BaseFacetValueRequest} from '../../../../facets/facet-api/request'; +} from '../../../../../controllers/commerce/core/facets/headless-core-commerce-facet.js'; +import {BaseFacetValueRequest} from '../../../../facets/facet-api/request.js'; import { FacetRequest, FacetValueRequest, -} from '../../../../facets/facet-set/interfaces/request'; +} from '../../../../facets/facet-set/interfaces/request.js'; import { CategoryFacetDelimitingCharacter, FacetType, NumericFacetExtraProperties, -} from './common'; +} from './common.js'; export type CategoryFacetRequest = BaseCommerceFacetRequest< CategoryFacetValueRequest, diff --git a/packages/headless/src/features/commerce/facets/facet-set/interfaces/response.ts b/packages/headless/src/features/commerce/facets/facet-set/interfaces/response.ts index bdb24c94c95..6ade7b0b585 100644 --- a/packages/headless/src/features/commerce/facets/facet-set/interfaces/response.ts +++ b/packages/headless/src/features/commerce/facets/facet-set/interfaces/response.ts @@ -1,9 +1,9 @@ -import {FacetValueState} from '../../../../facets/facet-api/value'; +import {FacetValueState} from '../../../../facets/facet-api/value.js'; import { CategoryFacetDelimitingCharacter, FacetType, NumericFacetExtraProperties, -} from './common'; +} from './common.js'; export type CategoryFacetResponse = BaseFacetResponse< CategoryFacetValue, diff --git a/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.test.ts b/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.test.ts index 3949b33a5d9..3fe06a4b447 100644 --- a/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.test.ts +++ b/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.test.ts @@ -1,11 +1,11 @@ import {AnyAction} from '@reduxjs/toolkit'; -import {fetchQuerySuggestions} from '../../query-suggest/query-suggest-actions'; -import {fieldSuggestionsOrderReducer} from './field-suggestions-order-slice'; +import {fetchQuerySuggestions} from '../../query-suggest/query-suggest-actions.js'; +import {fieldSuggestionsOrderReducer} from './field-suggestions-order-slice.js'; import { FieldSuggestionsFacet, FieldSuggestionsOrderState, getFieldSuggestionsOrderInitialState, -} from './field-suggestions-order-state'; +} from './field-suggestions-order-state.js'; describe('field suggestions order slice', () => { let state: FieldSuggestionsOrderState; diff --git a/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.ts b/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.ts index 2da16683808..a997ea48272 100644 --- a/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.ts +++ b/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {fetchQuerySuggestions} from '../../query-suggest/query-suggest-actions'; -import {getFieldSuggestionsOrderInitialState} from './field-suggestions-order-state'; +import {fetchQuerySuggestions} from '../../query-suggest/query-suggest-actions.js'; +import {getFieldSuggestionsOrderInitialState} from './field-suggestions-order-state.js'; export const fieldSuggestionsOrderReducer = createReducer( getFieldSuggestionsOrderInitialState(), diff --git a/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-state.ts b/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-state.ts index 6f2eb10a277..10f32acc9dc 100644 --- a/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-state.ts +++ b/packages/headless/src/features/commerce/facets/field-suggestions-order/field-suggestions-order-state.ts @@ -1,4 +1,4 @@ -import {FieldSuggestionsFacet} from '../../../../api/commerce/search/query-suggest/query-suggest-response'; +import {FieldSuggestionsFacet} from '../../../../api/commerce/search/query-suggest/query-suggest-response.js'; export type {FieldSuggestionsFacet}; export type FieldSuggestionsOrderState = FieldSuggestionsFacet[]; diff --git a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-selectors.ts b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-selectors.ts index 91fba6d8142..8b993f3c691 100644 --- a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-selectors.ts +++ b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-selectors.ts @@ -1,5 +1,5 @@ import {createSelector} from '@reduxjs/toolkit'; -import {ManualRangeSection} from '../../../../state/state-sections'; +import {ManualRangeSection} from '../../../../state/state-sections.js'; export const manualNumericFacetSelector = createSelector( (state: ManualRangeSection, facetId: string) => diff --git a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.test.ts b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.test.ts index 1210599e792..4fef64905ca 100644 --- a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.test.ts +++ b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.test.ts @@ -1,13 +1,13 @@ -import {buildMockCommerceState} from '../../../../test/mock-commerce-state'; -import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions'; -import {deselectAllValuesInCoreFacet} from '../core-facet/core-facet-actions'; -import {manualNumericFacetReducer} from './manual-numeric-facet-slice'; +import {buildMockCommerceState} from '../../../../test/mock-commerce-state.js'; +import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions.js'; +import {deselectAllValuesInCoreFacet} from '../core-facet/core-facet-actions.js'; +import {manualNumericFacetReducer} from './manual-numeric-facet-slice.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateManualNumericFacetRange, -} from './numeric-facet-actions'; +} from './numeric-facet-actions.js'; describe('manualNumericFacetSlice', () => { const someManualRange = { diff --git a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.ts b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.ts index 762de5cd36e..c2294129789 100644 --- a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.ts +++ b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-slice.ts @@ -1,17 +1,17 @@ import {createReducer} from '@reduxjs/toolkit'; -import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request'; -import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions'; -import {deselectAllValuesInCoreFacet} from '../core-facet/core-facet-actions'; +import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {restoreProductListingParameters} from '../../product-listing-parameters/product-listing-parameters-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameters-actions.js'; +import {deselectAllValuesInCoreFacet} from '../core-facet/core-facet-actions.js'; import { getManualNumericFacetInitialState, ManualNumericFacetSetState, -} from './manual-numeric-facet-state'; +} from './manual-numeric-facet-state.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateManualNumericFacetRange, -} from './numeric-facet-actions'; +} from './numeric-facet-actions.js'; export const manualNumericFacetReducer = createReducer( getManualNumericFacetInitialState(), diff --git a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-state.ts b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-state.ts index 3553ec58701..fc1028221d0 100644 --- a/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-state.ts +++ b/packages/headless/src/features/commerce/facets/numeric-facet/manual-numeric-facet-state.ts @@ -1,4 +1,4 @@ -import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request'; +import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request.js'; export interface ManualNumericFacetSetSlice { manualRange: NumericRangeRequest | undefined; diff --git a/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions-loader.ts b/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions-loader.ts index b94553b2b44..8d9f246f3e5 100644 --- a/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions-loader.ts +++ b/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice.js'; import { ToggleExcludeNumericFacetValuePayload, ToggleSelectNumericFacetValuePayload, @@ -8,7 +8,7 @@ import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateNumericFacetValues, -} from './numeric-facet-actions'; +} from './numeric-facet-actions.js'; export type { ToggleSelectNumericFacetValuePayload, diff --git a/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions.ts b/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions.ts index 3a02e555eaf..a4b2a01c6c6 100644 --- a/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions.ts +++ b/packages/headless/src/features/commerce/facets/numeric-facet/numeric-facet-actions.ts @@ -11,14 +11,14 @@ import { serializeSchemaValidationError, validatePayload, validatePayloadAndThrow, -} from '../../../../utils/validate-payload'; -import {numericFacetValueDefinition} from '../../../facets/range-facets/generic/range-facet-validate-payload'; -import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request'; +} from '../../../../utils/validate-payload.js'; +import {numericFacetValueDefinition} from '../../../facets/range-facets/generic/range-facet-validate-payload.js'; +import {NumericRangeRequest} from '../../../facets/range-facets/numeric-facet-set/interfaces/request.js'; import { ToggleSelectNumericFacetValueActionCreatorPayload, UpdateNumericFacetValuesActionCreatorPayload, validateManualNumericRanges, -} from '../../../facets/range-facets/numeric-facet-set/numeric-facet-actions'; +} from '../../../facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; export type ToggleSelectNumericFacetValuePayload = ToggleSelectNumericFacetValueActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions-loader.ts b/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions-loader.ts index 6b16b55be36..c51a27a0b0c 100644 --- a/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions-loader.ts +++ b/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice'; +import {CommerceEngine} from '../../../../app/commerce-engine/commerce-engine.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facet-set/facet-set-slice.js'; import { ToggleExcludeFacetValuePayload, ToggleSelectFacetValuePayload, toggleExcludeFacetValue, toggleSelectFacetValue, -} from './regular-facet-actions'; +} from './regular-facet-actions.js'; export type {ToggleExcludeFacetValuePayload, ToggleSelectFacetValuePayload}; diff --git a/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions.ts b/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions.ts index 755a4466caa..453f852958a 100644 --- a/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions.ts +++ b/packages/headless/src/features/commerce/facets/regular-facet/regular-facet-actions.ts @@ -3,9 +3,9 @@ import {createAction} from '@reduxjs/toolkit'; import { requiredNonEmptyString, validatePayload, -} from '../../../../utils/validate-payload'; -import {ToggleSelectFacetValueActionCreatorPayload} from '../../../facets/facet-set/facet-set-actions'; -import {facetValueDefinition} from '../../../facets/facet-set/facet-set-validate-payload'; +} from '../../../../utils/validate-payload.js'; +import {ToggleSelectFacetValueActionCreatorPayload} from '../../../facets/facet-set/facet-set-actions.js'; +import {facetValueDefinition} from '../../../facets/facet-set/facet-set-validate-payload.js'; export type ToggleExcludeFacetValuePayload = ToggleSelectFacetValueActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/instant-products/instant-products-actions-loader.ts b/packages/headless/src/features/commerce/instant-products/instant-products-actions-loader.ts index e2063981d84..6574ee10a2f 100644 --- a/packages/headless/src/features/commerce/instant-products/instant-products-actions-loader.ts +++ b/packages/headless/src/features/commerce/instant-products/instant-products-actions-loader.ts @@ -1,5 +1,5 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; import { ClearExpiredInstantProductsPayload, CoreInstantProductPayload, @@ -10,8 +10,8 @@ import { promoteChildToParent, registerInstantProducts, updateInstantProductsQuery, -} from './instant-products-actions'; -import {instantProductsReducer as instantProducts} from './instant-products-slice'; +} from './instant-products-actions.js'; +import {instantProductsReducer as instantProducts} from './instant-products-slice.js'; export type { ClearExpiredInstantProductsPayload, diff --git a/packages/headless/src/features/commerce/instant-products/instant-products-actions.ts b/packages/headless/src/features/commerce/instant-products/instant-products-actions.ts index 530fd82ac04..106317b7e5a 100644 --- a/packages/headless/src/features/commerce/instant-products/instant-products-actions.ts +++ b/packages/headless/src/features/commerce/instant-products/instant-products-actions.ts @@ -1,11 +1,11 @@ import {RecordValue, StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {ChildProduct} from '../../../api/commerce/common/product'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; import { validatePayload, requiredEmptyAllowedString, requiredNonEmptyString, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; export interface CoreInstantProductPayload { /** diff --git a/packages/headless/src/features/commerce/instant-products/instant-products-slice.test.ts b/packages/headless/src/features/commerce/instant-products/instant-products-slice.test.ts index 2275a703f58..199b81c61f8 100644 --- a/packages/headless/src/features/commerce/instant-products/instant-products-slice.test.ts +++ b/packages/headless/src/features/commerce/instant-products/instant-products-slice.test.ts @@ -1,24 +1,24 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; -import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response.js'; import { buildMockChildProduct, buildMockProduct, buildMockBaseProduct, -} from '../../../test/mock-product'; +} from '../../../test/mock-product.js'; import { fetchInstantProducts, QuerySearchCommerceAPIThunkReturn, -} from '../search/search-actions'; +} from '../search/search-actions.js'; import { promoteChildToParent, registerInstantProducts, updateInstantProductsQuery, -} from './instant-products-actions'; -import {instantProductsReducer} from './instant-products-slice'; +} from './instant-products-actions.js'; +import {instantProductsReducer} from './instant-products-slice.js'; import { InstantProductsCache, InstantProductsState, -} from './instant-products-state'; +} from './instant-products-state.js'; const id1 = 'search_box_1'; const id2 = 'search_box_2'; @@ -193,10 +193,10 @@ describe('instant products slice', () => { describe('when fulfilled', () => { beforeEach(() => { - jest.useFakeTimers().setSystemTime(new Date('2020-01-01')); + vi.useFakeTimers().setSystemTime(new Date('2020-01-01')); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('updates products in correct searchbox and query cache', () => { const query = 'some_query'; diff --git a/packages/headless/src/features/commerce/instant-products/instant-products-slice.ts b/packages/headless/src/features/commerce/instant-products/instant-products-slice.ts index d3059ea1cf1..5ed9ad31fb6 100644 --- a/packages/headless/src/features/commerce/instant-products/instant-products-slice.ts +++ b/packages/headless/src/features/commerce/instant-products/instant-products-slice.ts @@ -3,7 +3,7 @@ import { Product, BaseProduct, ChildProduct, -} from '../../../api/commerce/common/product'; +} from '../../../api/commerce/common/product.js'; import { clearExpiredItems, fetchItemsFulfilled, @@ -11,15 +11,15 @@ import { fetchItemsRejected, registerInstantItem, updateInstantItemQuery, -} from '../../instant-items/instant-items-slice'; -import {fetchInstantProducts} from '../search/search-actions'; +} from '../../instant-items/instant-items-slice.js'; +import {fetchInstantProducts} from '../search/search-actions.js'; import { clearExpiredProducts, promoteChildToParent, registerInstantProducts, updateInstantProductsQuery, -} from './instant-products-actions'; -import {getInstantProductsInitialState} from './instant-products-state'; +} from './instant-products-actions.js'; +import {getInstantProductsInitialState} from './instant-products-state.js'; export const instantProductsReducer = createReducer( getInstantProductsInitialState(), diff --git a/packages/headless/src/features/commerce/instant-products/instant-products-state.ts b/packages/headless/src/features/commerce/instant-products/instant-products-state.ts index e41d6629630..3f686e0e25a 100644 --- a/packages/headless/src/features/commerce/instant-products/instant-products-state.ts +++ b/packages/headless/src/features/commerce/instant-products/instant-products-state.ts @@ -1,10 +1,10 @@ import {SerializedError} from '@reduxjs/toolkit'; -import {CommerceAPIErrorResponse} from '../../../api/commerce/commerce-api-error-response'; -import {Product} from '../../../api/commerce/common/product'; +import {CommerceAPIErrorResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {Product} from '../../../api/commerce/common/product.js'; import { InstantItemsCache, InstantItemsState, -} from '../../instant-items/instant-items-state'; +} from '../../instant-items/instant-items-state.js'; export interface InstantProductsCache extends InstantItemsCache { error: CommerceAPIErrorResponse | SerializedError | null; diff --git a/packages/headless/src/features/commerce/pagination/pagination-actions-loader.ts b/packages/headless/src/features/commerce/pagination/pagination-actions-loader.ts index 38fdac06bc8..31d5e05a5da 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-actions-loader.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-actions-loader.ts @@ -1,5 +1,5 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; import { RegisterRecommendationsSlotPaginationPayload, NextPagePayload, @@ -11,8 +11,8 @@ import { selectPage, setPageSize, registerRecommendationsSlotPagination, -} from './pagination-actions'; -import {paginationReducer as commercePagination} from './pagination-slice'; +} from './pagination-actions.js'; +import {paginationReducer as commercePagination} from './pagination-slice.js'; export type { RegisterRecommendationsSlotPaginationPayload, diff --git a/packages/headless/src/features/commerce/pagination/pagination-actions.ts b/packages/headless/src/features/commerce/pagination/pagination-actions.ts index f9d4313a7d4..558b149c8ee 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-actions.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-actions.ts @@ -4,7 +4,7 @@ import { nonRequiredEmptyAllowedString, requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; export const slotIdDefinition = { slotId: nonRequiredEmptyAllowedString, diff --git a/packages/headless/src/features/commerce/pagination/pagination-selectors.test.ts b/packages/headless/src/features/commerce/pagination/pagination-selectors.test.ts index 8a745d2bfed..a757bcfedf3 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-selectors.test.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-selectors.test.ts @@ -1,4 +1,4 @@ -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; import { pagePrincipalSelector, pageRecommendationSelector, @@ -6,7 +6,7 @@ import { perPageRecommendationSelector, totalEntriesPrincipalSelector, totalEntriesRecommendationSelector, -} from './pagination-selectors'; +} from './pagination-selectors.js'; describe('commerce pagination selectors', () => { it('#perPagePrincipalSelector should return the perPage value from the principal section', () => { diff --git a/packages/headless/src/features/commerce/pagination/pagination-selectors.ts b/packages/headless/src/features/commerce/pagination/pagination-selectors.ts index 91a1a205b9b..51b13448c7c 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-selectors.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-selectors.ts @@ -1,5 +1,5 @@ import {createSelector} from '@reduxjs/toolkit'; -import {CommercePaginationSection} from '../../../state/state-sections'; +import {CommercePaginationSection} from '../../../state/state-sections.js'; export const perPagePrincipalSelector = createSelector( (state: Partial) => diff --git a/packages/headless/src/features/commerce/pagination/pagination-slice.test.ts b/packages/headless/src/features/commerce/pagination/pagination-slice.test.ts index 5c07f2b1b3b..ef7374d0037 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-slice.test.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-slice.test.ts @@ -1,44 +1,44 @@ -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {buildFetchProductListingResponse} from '../../../test/mock-product-listing'; -import {buildMockRecommendationsResponse} from '../../../test/mock-recommendations'; -import {setContext, setView} from '../context/context-actions'; -import {toggleSelectCategoryFacetValue} from '../facets/category-facet/category-facet-actions'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {buildFetchProductListingResponse} from '../../../test/mock-product-listing.js'; +import {buildMockRecommendationsResponse} from '../../../test/mock-recommendations.js'; +import {setContext, setView} from '../context/context-actions.js'; +import {toggleSelectCategoryFacetValue} from '../facets/category-facet/category-facet-actions.js'; import { clearAllCoreFacets, deselectAllValuesInCoreFacet, -} from '../facets/core-facet/core-facet-actions'; +} from '../facets/core-facet/core-facet-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../facets/date-facet/date-facet-actions'; +} from '../facets/date-facet/date-facet-actions.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../facets/numeric-facet/numeric-facet-actions'; +} from '../facets/numeric-facet/numeric-facet-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../facets/regular-facet/regular-facet-actions'; -import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../product-listing/product-listing-actions'; -import {fetchRecommendations} from '../recommendations/recommendations-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameters-actions'; -import {executeSearch} from '../search/search-actions'; -import {applySort} from '../sort/sort-actions'; +} from '../facets/regular-facet/regular-facet-actions.js'; +import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../product-listing/product-listing-actions.js'; +import {fetchRecommendations} from '../recommendations/recommendations-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {applySort} from '../sort/sort-actions.js'; import { nextPage, previousPage, registerRecommendationsSlotPagination, selectPage, setPageSize, -} from './pagination-actions'; -import {paginationReducer} from './pagination-slice'; +} from './pagination-actions.js'; +import {paginationReducer} from './pagination-slice.js'; import { CommercePaginationState, getCommercePaginationInitialSlice, getCommercePaginationInitialState, PaginationSlice, -} from './pagination-state'; +} from './pagination-state.js'; describe('pagination slice', () => { let state: CommercePaginationState; diff --git a/packages/headless/src/features/commerce/pagination/pagination-slice.ts b/packages/headless/src/features/commerce/pagination/pagination-slice.ts index 715bb3d8e47..daf24ac1a3b 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-slice.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-slice.ts @@ -1,41 +1,41 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setContext, setView} from '../context/context-actions'; -import {toggleSelectCategoryFacetValue} from '../facets/category-facet/category-facet-actions'; +import {setContext, setView} from '../context/context-actions.js'; +import {toggleSelectCategoryFacetValue} from '../facets/category-facet/category-facet-actions.js'; import { clearAllCoreFacets, deselectAllValuesInCoreFacet, -} from '../facets/core-facet/core-facet-actions'; +} from '../facets/core-facet/core-facet-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from '../facets/date-facet/date-facet-actions'; +} from '../facets/date-facet/date-facet-actions.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from '../facets/numeric-facet/numeric-facet-actions'; +} from '../facets/numeric-facet/numeric-facet-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from '../facets/regular-facet/regular-facet-actions'; -import {Parameters} from '../parameters/parameters-actions'; -import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../product-listing/product-listing-actions'; -import {fetchRecommendations} from '../recommendations/recommendations-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameters-actions'; -import {executeSearch} from '../search/search-actions'; -import {applySort} from '../sort/sort-actions'; +} from '../facets/regular-facet/regular-facet-actions.js'; +import {Parameters} from '../parameters/parameters-actions.js'; +import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../product-listing/product-listing-actions.js'; +import {fetchRecommendations} from '../recommendations/recommendations-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {applySort} from '../sort/sort-actions.js'; import { nextPage, previousPage, registerRecommendationsSlotPagination, selectPage, setPageSize, -} from './pagination-actions'; +} from './pagination-actions.js'; import { CommercePaginationState, getCommercePaginationInitialSlice, getCommercePaginationInitialState, -} from './pagination-state'; +} from './pagination-state.js'; export const paginationReducer = createReducer( getCommercePaginationInitialState(), diff --git a/packages/headless/src/features/commerce/parameters/parameters-actions.ts b/packages/headless/src/features/commerce/parameters/parameters-actions.ts index 6993ea9b3bd..05cd644f0d3 100644 --- a/packages/headless/src/features/commerce/parameters/parameters-actions.ts +++ b/packages/headless/src/features/commerce/parameters/parameters-actions.ts @@ -1,6 +1,6 @@ -import {DateRangeRequest} from '../../facets/range-facets/date-facet-set/interfaces/request'; -import {NumericRangeRequest} from '../../facets/range-facets/numeric-facet-set/interfaces/request'; -import {SortCriterion} from '../sort/sort'; +import {DateRangeRequest} from '../../facets/range-facets/date-facet-set/interfaces/request.js'; +import {NumericRangeRequest} from '../../facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {SortCriterion} from '../sort/sort.js'; export interface Parameters { /** diff --git a/packages/headless/src/features/commerce/parameters/parameters-selectors.ts b/packages/headless/src/features/commerce/parameters/parameters-selectors.ts index d593df39f2f..a29f7b8cfb8 100644 --- a/packages/headless/src/features/commerce/parameters/parameters-selectors.ts +++ b/packages/headless/src/features/commerce/parameters/parameters-selectors.ts @@ -1,26 +1,26 @@ -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; -import {CommerceFacetSetSection} from '../../../state/state-sections'; -import {findActiveValueAncestry} from '../../facets/category-facet-set/category-facet-utils'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; +import {CommerceFacetSetSection} from '../../../state/state-sections.js'; +import {findActiveValueAncestry} from '../../facets/category-facet-set/category-facet-utils.js'; import { getFacets, getSortCriteria, -} from '../../parameter-manager/parameter-manager-selectors'; -import {FacetType} from '../facets/facet-set/interfaces/common'; +} from '../../parameter-manager/parameter-manager-selectors.js'; +import {FacetType} from '../facets/facet-set/interfaces/common.js'; import { AnyFacetRequest, CategoryFacetRequest, DateFacetRequest, NumericFacetRequest, RegularFacetRequest, -} from '../facets/facet-set/interfaces/request'; -import {ManualNumericFacetSetState} from '../facets/numeric-facet/manual-numeric-facet-state'; +} from '../facets/facet-set/interfaces/request.js'; +import {ManualNumericFacetSetState} from '../facets/numeric-facet/manual-numeric-facet-state.js'; import { CommercePaginationState, getCommercePaginationInitialSlice, -} from '../pagination/pagination-state'; -import {getCommerceSortInitialState} from '../sort/sort-state'; -import {Parameters as ManagedParameters} from './parameters-actions'; +} from '../pagination/pagination-state.js'; +import {getCommerceSortInitialState} from '../sort/sort-state.js'; +import {Parameters as ManagedParameters} from './parameters-actions.js'; export function initialParametersSelector( state: CommerceEngine[typeof stateKey] diff --git a/packages/headless/src/features/commerce/parameters/parameters-serializer.test.ts b/packages/headless/src/features/commerce/parameters/parameters-serializer.test.ts index 3e72590c788..757617e4fb7 100644 --- a/packages/headless/src/features/commerce/parameters/parameters-serializer.test.ts +++ b/packages/headless/src/features/commerce/parameters/parameters-serializer.test.ts @@ -1,8 +1,8 @@ -import {buildDateRange} from '../../../controllers/core/facets/range-facet/date-facet/date-range'; -import {buildNumericRange} from '../../../controllers/core/facets/range-facet/numeric-facet/numeric-range'; -import {CommerceSearchParameters} from '../search-parameters/search-parameters-actions'; -import {buildFieldsSortCriterion, SortDirection} from '../sort/sort'; -import {searchSerializer} from './parameters-serializer'; +import {buildDateRange} from '../../../controllers/core/facets/range-facet/date-facet/date-range.js'; +import {buildNumericRange} from '../../../controllers/core/facets/range-facet/numeric-facet/numeric-range.js'; +import {CommerceSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {buildFieldsSortCriterion, SortDirection} from '../sort/sort.js'; +import {searchSerializer} from './parameters-serializer.js'; const someSpecialCharactersThatNeedsEncoding = [ '&', diff --git a/packages/headless/src/features/commerce/parameters/parameters-serializer.ts b/packages/headless/src/features/commerce/parameters/parameters-serializer.ts index e4f71fe1e71..57d11dae033 100644 --- a/packages/headless/src/features/commerce/parameters/parameters-serializer.ts +++ b/packages/headless/src/features/commerce/parameters/parameters-serializer.ts @@ -1,4 +1,4 @@ -import {isArray} from '../../../utils/utils'; +import {isArray} from '../../../utils/utils.js'; import { castUnknownObject, delimiter, @@ -13,17 +13,17 @@ import { serializeRangeFacets, serializeSpecialCharacters, splitOnFirstEqual, -} from '../../search-parameters/search-parameter-serializer'; -import {ProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions'; -import {CommerceSearchParameters} from '../search-parameters/search-parameters-actions'; +} from '../../search-parameters/search-parameter-serializer.js'; +import {ProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions.js'; +import {CommerceSearchParameters} from '../search-parameters/search-parameters-actions.js'; import { buildFieldsSortCriterion, buildRelevanceSortCriterion, SortBy, SortCriterion, SortDirection, -} from '../sort/sort'; -import {Parameters} from './parameters-actions'; +} from '../sort/sort.js'; +import {Parameters} from './parameters-actions.js'; const sortFieldAndDirectionSeparator = ' '; const sortFieldsJoiner = ','; diff --git a/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions-loader.ts b/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions-loader.ts index a25c1b1ea80..774a4b3011a 100644 --- a/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions-loader.ts +++ b/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions-loader.ts @@ -1,13 +1,13 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {facetOrderReducer as facetOrder} from '../../facets/facet-order/facet-order-slice'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facets/facet-set/facet-set-slice'; -import {paginationReducer as commercePagination} from '../pagination/pagination-slice'; -import {sortReducer as commerceSort} from '../sort/sort-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {facetOrderReducer as facetOrder} from '../../facets/facet-order/facet-order-slice.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facets/facet-set/facet-set-slice.js'; +import {paginationReducer as commercePagination} from '../pagination/pagination-slice.js'; +import {sortReducer as commerceSort} from '../sort/sort-slice.js'; import { RestoreProductListingParametersPayload, restoreProductListingParameters, -} from './product-listing-parameters-actions'; +} from './product-listing-parameters-actions.js'; export type {RestoreProductListingParametersPayload}; diff --git a/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions.ts b/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions.ts index 950553b33d7..1fabdb1d53c 100644 --- a/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions.ts +++ b/packages/headless/src/features/commerce/product-listing-parameters/product-listing-parameters-actions.ts @@ -1,7 +1,7 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; -import {Parameters} from '../parameters/parameters-actions'; -import {parametersDefinition} from '../parameters/parameters-schema'; +import {validatePayload} from '../../../utils/validate-payload.js'; +import {Parameters} from '../parameters/parameters-actions.js'; +import {parametersDefinition} from '../parameters/parameters-schema.js'; export type ProductListingParameters = Parameters; diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-actions-loader.ts b/packages/headless/src/features/commerce/product-listing/product-listing-actions-loader.ts index 16b265288fd..63570be73f1 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-actions-loader.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-actions-loader.ts @@ -1,15 +1,15 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {productListingReducer as productListing} from '../../../features/commerce/product-listing/product-listing-slice'; -import {QueryCommerceAPIThunkReturn} from '../common/actions'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {productListingReducer as productListing} from '../../../features/commerce/product-listing/product-listing-slice.js'; +import {QueryCommerceAPIThunkReturn} from '../common/actions.js'; import { PromoteChildToParentPayload, StateNeededByFetchProductListing, fetchMoreProducts, fetchProductListing, promoteChildToParent, -} from './product-listing-actions'; +} from './product-listing-actions.js'; /** * The product listing action creators. diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-actions.ts b/packages/headless/src/features/commerce/product-listing/product-listing-actions.ts index 1c4da426d55..9fc8cb4a4e3 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-actions.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-actions.ts @@ -3,20 +3,20 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { AsyncThunkCommerceOptions, isErrorResponse, -} from '../../../api/commerce/commerce-api-client'; -import {ChildProduct} from '../../../api/commerce/common/product'; -import {ProductListingSection} from '../../../state/state-sections'; -import {validatePayload} from '../../../utils/validate-payload'; +} from '../../../api/commerce/commerce-api-client.js'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {ProductListingSection} from '../../../state/state-sections.js'; +import {validatePayload} from '../../../utils/validate-payload.js'; import { buildCommerceAPIRequest, QueryCommerceAPIThunkReturn, ListingAndSearchStateNeededByQueryCommerceAPI, -} from '../common/actions'; -import {perPagePrincipalSelector} from '../pagination/pagination-selectors'; +} from '../common/actions.js'; +import {perPagePrincipalSelector} from '../pagination/pagination-selectors.js'; import { moreProductsAvailableSelector, numberOfProductsSelector, -} from './product-listing-selectors'; +} from './product-listing-selectors.js'; export type StateNeededByFetchProductListing = ListingAndSearchStateNeededByQueryCommerceAPI & ProductListingSection; diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-selectors.test.ts b/packages/headless/src/features/commerce/product-listing/product-listing-selectors.test.ts index a7495f695f2..a7167f08c5d 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-selectors.test.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-selectors.test.ts @@ -1,6 +1,6 @@ -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; -import {buildMockCommerceEngine} from '../../../test/mock-engine-v2'; -import {buildMockProduct} from '../../../test/mock-product'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; +import {buildMockCommerceEngine} from '../../../test/mock-engine-v2.js'; +import {buildMockProduct} from '../../../test/mock-product.js'; import { errorSelector, isLoadingSelector, @@ -9,7 +9,7 @@ import { requestIdSelector, responseIdSelector, responseIdSelectorFromEngine, -} from './product-listing-selectors'; +} from './product-listing-selectors.js'; describe('commerce product listing selectors', () => { it('#responseIdSelector should return the responseId value from the product listing section', () => { diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-selectors.ts b/packages/headless/src/features/commerce/product-listing/product-listing-selectors.ts index 96adf095d54..1cb8fbe7cbd 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-selectors.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-selectors.ts @@ -3,13 +3,13 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommerceEngineState, CommerceEngine, -} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; +} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; import { CommercePaginationSection, ProductListingSection, -} from '../../../state/state-sections'; -import {totalEntriesPrincipalSelector} from '../pagination/pagination-selectors'; +} from '../../../state/state-sections.js'; +import {totalEntriesPrincipalSelector} from '../pagination/pagination-selectors.js'; /** * Duplicate selector since the state is no longer accessible externally diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-slice.test.ts b/packages/headless/src/features/commerce/product-listing/product-listing-slice.test.ts index d231ee03ba6..0aa1dee1286 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-slice.test.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-slice.test.ts @@ -1,21 +1,22 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; -import {buildMockCommerceRegularFacetResponse} from '../../../test/mock-commerce-facet-response'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {buildMockCommerceRegularFacetResponse} from '../../../test/mock-commerce-facet-response.js'; +import {buildFetchProductListingResponse} from '../../../test/mock-product-listing.js'; import { buildMockChildProduct, buildMockProduct, buildMockBaseProduct, -} from '../../../test/mock-product'; -import {buildFetchProductListingResponse} from '../../../test/mock-product-listing'; +} from '../../../test/mock-product.js'; +import {setContext, setView} from '../context/context-actions.js'; import { fetchMoreProducts, fetchProductListing, promoteChildToParent, -} from './product-listing-actions'; -import {productListingReducer} from './product-listing-slice'; +} from './product-listing-actions.js'; +import {productListingReducer} from './product-listing-slice.js'; import { getProductListingInitialState, ProductListingState, -} from './product-listing-state'; +} from './product-listing-state.js'; describe('product-listing-slice', () => { let state: ProductListingState; @@ -314,4 +315,41 @@ describe('product-listing-slice', () => { ]); }); }); + it('on #setView, restores the initial state', () => { + state = { + error: {message: 'error', statusCode: 500, type: 'type'}, + isLoading: true, + products: [buildMockProduct({ec_name: 'product1'})], + facets: [buildMockCommerceRegularFacetResponse()], + responseId: 'response-id', + requestId: 'request-id', + }; + + const finalState = productListingReducer(state, setView({url: '/'})); + + expect(finalState).toEqual(getProductListingInitialState()); + }); + + it('on #setContext, restores the initial state', () => { + state = { + error: {message: 'error', statusCode: 500, type: 'type'}, + isLoading: true, + products: [buildMockProduct({ec_name: 'product1'})], + facets: [buildMockCommerceRegularFacetResponse()], + responseId: 'response-id', + requestId: 'request-id', + }; + + const finalState = productListingReducer( + state, + setContext({ + country: 'CA', + currency: 'CAD', + language: 'fr', + view: {url: '/'}, + }) + ); + + expect(finalState).toEqual(getProductListingInitialState()); + }); }); diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-slice.ts b/packages/headless/src/features/commerce/product-listing/product-listing-slice.ts index 72b95dceee7..98dbb3734d7 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-slice.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-slice.ts @@ -1,21 +1,22 @@ import {createReducer} from '@reduxjs/toolkit'; -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; import { Product, BaseProduct, ChildProduct, -} from '../../../api/commerce/common/product'; -import {CommerceSuccessResponse} from '../../../api/commerce/common/response'; -import {QueryCommerceAPIThunkReturn} from '../common/actions'; +} from '../../../api/commerce/common/product.js'; +import {CommerceSuccessResponse} from '../../../api/commerce/common/response.js'; +import {QueryCommerceAPIThunkReturn} from '../common/actions.js'; +import {setContext, setView} from '../context/context-actions.js'; import { fetchMoreProducts, fetchProductListing, promoteChildToParent, -} from './product-listing-actions'; +} from './product-listing-actions.js'; import { ProductListingState, getProductListingInitialState, -} from './product-listing-state'; +} from './product-listing-state.js'; export const productListingReducer = createReducer( getProductListingInitialState(), @@ -79,7 +80,9 @@ export const productListingReducer = createReducer( }; products.splice(currentParentIndex, 1, newParent); - }); + }) + .addCase(setView, () => getProductListingInitialState()) + .addCase(setContext, () => getProductListingInitialState()); } ); diff --git a/packages/headless/src/features/commerce/product-listing/product-listing-state.ts b/packages/headless/src/features/commerce/product-listing/product-listing-state.ts index 65c5229165b..eaa1573815f 100644 --- a/packages/headless/src/features/commerce/product-listing/product-listing-state.ts +++ b/packages/headless/src/features/commerce/product-listing/product-listing-state.ts @@ -1,6 +1,6 @@ -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {Product} from '../../../api/commerce/common/product'; -import {AnyFacetResponse} from '../facets/facet-set/interfaces/response'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {Product} from '../../../api/commerce/common/product.js'; +import {AnyFacetResponse} from '../facets/facet-set/interfaces/response.js'; export interface ProductListingState { error: CommerceAPIErrorStatusResponse | null; diff --git a/packages/headless/src/features/commerce/product-templates/product-templates-helpers.ts b/packages/headless/src/features/commerce/product-templates/product-templates-helpers.ts index 36f85e66b68..5a492ca4e9f 100644 --- a/packages/headless/src/features/commerce/product-templates/product-templates-helpers.ts +++ b/packages/headless/src/features/commerce/product-templates/product-templates-helpers.ts @@ -1,6 +1,6 @@ import {isArray, isNullOrUndefined} from '@coveo/bueno'; -import {ChildProduct, Product} from '../../../api/commerce/common/product'; -import {ProductTemplateCondition} from './product-templates-manager'; +import {ChildProduct, Product} from '../../../api/commerce/common/product.js'; +import {ProductTemplateCondition} from './product-templates-manager.js'; /** * Extracts a property from a product object. diff --git a/packages/headless/src/features/commerce/product-templates/product-templates-manager.ts b/packages/headless/src/features/commerce/product-templates/product-templates-manager.ts index 450dac400c1..306a3a9a5e8 100644 --- a/packages/headless/src/features/commerce/product-templates/product-templates-manager.ts +++ b/packages/headless/src/features/commerce/product-templates/product-templates-manager.ts @@ -1,9 +1,9 @@ -import {Product} from '../../../api/commerce/common/product'; +import {Product} from '../../../api/commerce/common/product.js'; import { buildTemplatesManager, Template, TemplateCondition, -} from '../../templates/templates-manager'; +} from '../../templates/templates-manager.js'; export type ProductTemplate = Template; export type ProductTemplateCondition = TemplateCondition; diff --git a/packages/headless/src/features/commerce/product/product-actions-loaders.ts b/packages/headless/src/features/commerce/product/product-actions-loaders.ts index 3bc93bcd31a..3fb5d19f9da 100644 --- a/packages/headless/src/features/commerce/product/product-actions-loaders.ts +++ b/packages/headless/src/features/commerce/product/product-actions-loaders.ts @@ -1,12 +1,12 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngineState} from '../../../app/commerce-engine/commerce-engine'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngineState} from '../../../app/commerce-engine/commerce-engine.js'; import { ProductClickPayload, ProductViewPayload, productClick, productView, -} from './product-actions'; +} from './product-actions.js'; export type {ProductClickPayload, ProductViewPayload}; diff --git a/packages/headless/src/features/commerce/product/product-actions.ts b/packages/headless/src/features/commerce/product/product-actions.ts index c146d1f5daf..c46bc031282 100644 --- a/packages/headless/src/features/commerce/product/product-actions.ts +++ b/packages/headless/src/features/commerce/product/product-actions.ts @@ -1,8 +1,8 @@ import {Ec, Product} from '@coveo/relay-event-types'; import {createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngineState} from '../../../app/commerce-engine/commerce-engine'; -import {getCurrency} from '../context/context-selector'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngineState} from '../../../app/commerce-engine/commerce-engine.js'; +import {getCurrency} from '../context/context-selector.js'; export type ProductViewPayload = Product; diff --git a/packages/headless/src/features/commerce/query-set/query-set-actions-loader.ts b/packages/headless/src/features/commerce/query-set/query-set-actions-loader.ts index 94d16b7ab42..236378332bd 100644 --- a/packages/headless/src/features/commerce/query-set/query-set-actions-loader.ts +++ b/packages/headless/src/features/commerce/query-set/query-set-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {querySetReducer} from '../../query-set/query-set-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {querySetReducer} from '../../query-set/query-set-slice.js'; import { RegisterQuerySetQueryPayload, UpdateQuerySetQueryPayload, registerQuerySetQuery, updateQuerySetQuery, -} from './query-set-actions'; +} from './query-set-actions.js'; export type {RegisterQuerySetQueryPayload, UpdateQuerySetQueryPayload}; diff --git a/packages/headless/src/features/commerce/query-set/query-set-actions.ts b/packages/headless/src/features/commerce/query-set/query-set-actions.ts index 6a8af822c5a..24a9dce8114 100644 --- a/packages/headless/src/features/commerce/query-set/query-set-actions.ts +++ b/packages/headless/src/features/commerce/query-set/query-set-actions.ts @@ -1,10 +1,10 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; +import {validatePayload} from '../../../utils/validate-payload.js'; import { RegisterQuerySetQueryActionCreatorPayload, UpdateQuerySetQueryActionCreatorPayload, querySetDefinition, -} from '../../query-set/query-set-actions'; +} from '../../query-set/query-set-actions.js'; export type RegisterQuerySetQueryPayload = RegisterQuerySetQueryActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/query-suggest/query-suggest-actions-loader.ts b/packages/headless/src/features/commerce/query-suggest/query-suggest-actions-loader.ts index 7cf792f25b2..9d284910f4c 100644 --- a/packages/headless/src/features/commerce/query-suggest/query-suggest-actions-loader.ts +++ b/packages/headless/src/features/commerce/query-suggest/query-suggest-actions-loader.ts @@ -1,6 +1,6 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; import { ClearQuerySuggestPayload, FetchQuerySuggestionsPayload, @@ -11,9 +11,9 @@ import { clearQuerySuggest, registerQuerySuggest, selectQuerySuggestion, -} from '../../../features/commerce/query-suggest/query-suggest-actions'; -import {querySuggestReducer as querySuggest} from '../../query-suggest/query-suggest-slice'; -import {fetchQuerySuggestions} from './query-suggest-actions'; +} from '../../../features/commerce/query-suggest/query-suggest-actions.js'; +import {querySuggestReducer as querySuggest} from '../../query-suggest/query-suggest-slice.js'; +import {fetchQuerySuggestions} from './query-suggest-actions.js'; export type { ClearQuerySuggestPayload, diff --git a/packages/headless/src/features/commerce/query-suggest/query-suggest-actions.ts b/packages/headless/src/features/commerce/query-suggest/query-suggest-actions.ts index 54616cb8df9..426624232bd 100644 --- a/packages/headless/src/features/commerce/query-suggest/query-suggest-actions.ts +++ b/packages/headless/src/features/commerce/query-suggest/query-suggest-actions.ts @@ -1,14 +1,14 @@ import {NumberValue} from '@coveo/bueno'; import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {getAnalyticsSource} from '../../../api/analytics/analytics-selectors'; +import {getAnalyticsSource} from '../../../api/analytics/analytics-selectors.js'; import { AsyncThunkCommerceOptions, getCommerceApiBaseUrl, isErrorResponse, -} from '../../../api/commerce/commerce-api-client'; -import {QuerySuggestRequest} from '../../../api/commerce/search/query-suggest/query-suggest-request'; -import {QuerySuggestSuccessResponse} from '../../../api/commerce/search/query-suggest/query-suggest-response'; -import {NavigatorContext} from '../../../app/navigatorContextProvider'; +} from '../../../api/commerce/commerce-api-client.js'; +import {QuerySuggestRequest} from '../../../api/commerce/search/query-suggest/query-suggest-request.js'; +import {QuerySuggestSuccessResponse} from '../../../api/commerce/search/query-suggest/query-suggest-response.js'; +import {NavigatorContext} from '../../../app/navigatorContextProvider.js'; import { CartSection, CommerceContextSection, @@ -16,19 +16,19 @@ import { CommerceConfigurationSection, QuerySetSection, VersionSection, -} from '../../../state/state-sections'; +} from '../../../state/state-sections.js'; import { requiredEmptyAllowedString, requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { ClearQuerySuggestActionCreatorPayload, FetchQuerySuggestionsActionCreatorPayload, RegisterQuerySuggestActionCreatorPayload, SelectQuerySuggestionActionCreatorPayload, -} from '../../query-suggest/query-suggest-actions'; -import {getProductsFromCartState} from '../context/cart/cart-state'; +} from '../../query-suggest/query-suggest-actions.js'; +import {getProductsFromCartState} from '../context/cart/cart-state.js'; export type ClearQuerySuggestPayload = ClearQuerySuggestActionCreatorPayload; diff --git a/packages/headless/src/features/commerce/query/query-actions-loader.ts b/packages/headless/src/features/commerce/query/query-actions-loader.ts index ef483af0772..2579ca32022 100644 --- a/packages/headless/src/features/commerce/query/query-actions-loader.ts +++ b/packages/headless/src/features/commerce/query/query-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {UpdateQueryPayload, updateQuery} from './query-actions'; -import {queryReducer as query} from './query-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {UpdateQueryPayload, updateQuery} from './query-actions.js'; +import {queryReducer as query} from './query-slice.js'; export type {UpdateQueryPayload}; diff --git a/packages/headless/src/features/commerce/query/query-actions.ts b/packages/headless/src/features/commerce/query/query-actions.ts index 911c38e22ce..13dd8227683 100644 --- a/packages/headless/src/features/commerce/query/query-actions.ts +++ b/packages/headless/src/features/commerce/query/query-actions.ts @@ -1,6 +1,6 @@ import {StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; +import {validatePayload} from '../../../utils/validate-payload.js'; export interface UpdateQueryPayload { /** diff --git a/packages/headless/src/features/commerce/query/query-slice.test.ts b/packages/headless/src/features/commerce/query/query-slice.test.ts index 7856835b2ff..de4359485d7 100644 --- a/packages/headless/src/features/commerce/query/query-slice.test.ts +++ b/packages/headless/src/features/commerce/query/query-slice.test.ts @@ -1,7 +1,10 @@ -import {restoreSearchParameters} from '../search-parameters/search-parameters-actions'; -import {updateQuery} from './query-actions'; -import {queryReducer} from './query-slice'; -import {CommerceQueryState, getCommerceQueryInitialState} from './query-state'; +import {restoreSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {updateQuery} from './query-actions.js'; +import {queryReducer} from './query-slice.js'; +import { + CommerceQueryState, + getCommerceQueryInitialState, +} from './query-state.js'; describe('query slice', () => { let state: CommerceQueryState; diff --git a/packages/headless/src/features/commerce/query/query-slice.ts b/packages/headless/src/features/commerce/query/query-slice.ts index 6f2e79cad95..991b3abde2f 100644 --- a/packages/headless/src/features/commerce/query/query-slice.ts +++ b/packages/headless/src/features/commerce/query/query-slice.ts @@ -1,8 +1,8 @@ import {createReducer} from '@reduxjs/toolkit'; -import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameters-actions'; -import {updateQuery} from './query-actions'; -import {getCommerceQueryInitialState} from './query-state'; +import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {updateQuery} from './query-actions.js'; +import {getCommerceQueryInitialState} from './query-state.js'; export const queryReducer = createReducer( getCommerceQueryInitialState(), diff --git a/packages/headless/src/features/commerce/recent-queries/recent-queries-actions-loader.ts b/packages/headless/src/features/commerce/recent-queries/recent-queries-actions-loader.ts index 4ade2bdd003..a2125167b56 100644 --- a/packages/headless/src/features/commerce/recent-queries/recent-queries-actions-loader.ts +++ b/packages/headless/src/features/commerce/recent-queries/recent-queries-actions-loader.ts @@ -1,11 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; import { RegisterRecentQueriesCreatorPayload, registerRecentQueries, clearRecentQueries, -} from '../../recent-queries/recent-queries-actions'; -import {recentQueriesReducer as recentQueries} from './recent-queries-slice'; +} from '../../recent-queries/recent-queries-actions.js'; +import {recentQueriesReducer as recentQueries} from './recent-queries-slice.js'; export type {RegisterRecentQueriesCreatorPayload}; diff --git a/packages/headless/src/features/commerce/recent-queries/recent-queries-actions.ts b/packages/headless/src/features/commerce/recent-queries/recent-queries-actions.ts index d0779f11f25..7f1bd1c7827 100644 --- a/packages/headless/src/features/commerce/recent-queries/recent-queries-actions.ts +++ b/packages/headless/src/features/commerce/recent-queries/recent-queries-actions.ts @@ -1,9 +1,9 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; +import {validatePayload} from '../../../utils/validate-payload.js'; import { RegisterRecentQueriesCreatorPayload, registerRecentQueriesPayloadDefinition, -} from '../../recent-queries/recent-queries-actions'; +} from '../../recent-queries/recent-queries-actions.js'; export const clearRecentQueries = createAction('commerce/recentQueries/clear'); diff --git a/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.test.ts b/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.test.ts index fc1df1af677..db096b1d429 100644 --- a/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.test.ts +++ b/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.test.ts @@ -1,15 +1,15 @@ -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {buildMockProduct} from '../../../test/mock-product'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {buildMockProduct} from '../../../test/mock-product.js'; import { RecentQueriesState, getRecentQueriesInitialState, -} from '../../recent-queries/recent-queries-state'; -import {executeSearch} from '../search/search-actions'; +} from '../../recent-queries/recent-queries-state.js'; +import {executeSearch} from '../search/search-actions.js'; import { clearRecentQueries, registerRecentQueries, -} from './recent-queries-actions'; -import {recentQueriesReducer} from './recent-queries-slice'; +} from './recent-queries-actions.js'; +import {recentQueriesReducer} from './recent-queries-slice.js'; describe('commerce/recent-queries-slice', () => { let state: RecentQueriesState; diff --git a/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.ts b/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.ts index 7b1304b610c..3c5cc687f1a 100644 --- a/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.ts +++ b/packages/headless/src/features/commerce/recent-queries/recent-queries-slice.ts @@ -3,13 +3,13 @@ import { handleClearRecentQueries, handleExecuteSearchFulfilled, handleRegisterQueries, -} from '../../recent-queries/recent-queries-slice'; -import {getRecentQueriesInitialState} from '../../recent-queries/recent-queries-state'; -import {executeSearch as commerceExecuteSearch} from '../search/search-actions'; +} from '../../recent-queries/recent-queries-slice.js'; +import {getRecentQueriesInitialState} from '../../recent-queries/recent-queries-state.js'; +import {executeSearch as commerceExecuteSearch} from '../search/search-actions.js'; import { clearRecentQueries, registerRecentQueries, -} from './recent-queries-actions'; +} from './recent-queries-actions.js'; export const recentQueriesReducer = createReducer( getRecentQueriesInitialState(), diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-actions-loader.ts b/packages/headless/src/features/commerce/recommendations/recommendations-actions-loader.ts index 854a1131cc3..f83aa9af3c1 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-actions-loader.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-actions-loader.ts @@ -1,6 +1,6 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; import { FetchMoreRecommendationsPayload, FetchRecommendationsPayload, @@ -12,8 +12,8 @@ import { fetchRecommendations, promoteChildToParent, registerRecommendationsSlot, -} from './recommendations-actions'; -import {recommendationsReducer as recommendations} from './recommendations-slice'; +} from './recommendations-actions.js'; +import {recommendationsReducer as recommendations} from './recommendations-slice.js'; export type { RegisterRecommendationsSlotPayload, diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-actions.ts b/packages/headless/src/features/commerce/recommendations/recommendations-actions.ts index 288011ae9b0..37ca8d2c9df 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-actions.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-actions.ts @@ -3,24 +3,24 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { AsyncThunkCommerceOptions, isErrorResponse, -} from '../../../api/commerce/commerce-api-client'; -import {ChildProduct} from '../../../api/commerce/common/product'; -import {CommerceRecommendationsRequest} from '../../../api/commerce/recommendations/recommendations-request'; -import {RecommendationsCommerceSuccessResponse} from '../../../api/commerce/recommendations/recommendations-response'; -import {NavigatorContext} from '../../../app/navigatorContextProvider'; -import {RecommendationsSection} from '../../../state/state-sections'; -import {validatePayload} from '../../../utils/validate-payload'; +} from '../../../api/commerce/commerce-api-client.js'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {CommerceRecommendationsRequest} from '../../../api/commerce/recommendations/recommendations-request.js'; +import {RecommendationsCommerceSuccessResponse} from '../../../api/commerce/recommendations/recommendations-response.js'; +import {NavigatorContext} from '../../../app/navigatorContextProvider.js'; +import {RecommendationsSection} from '../../../state/state-sections.js'; +import {validatePayload} from '../../../utils/validate-payload.js'; import { StateNeededByQueryCommerceAPI, buildBaseCommerceAPIRequest, -} from '../common/actions'; -import {getProductsFromCartPurchasedState} from '../context/cart/cart-state'; -import {perPageRecommendationSelector} from '../pagination/pagination-selectors'; -import {recommendationsSlotDefinition} from './recommendations'; +} from '../common/actions.js'; +import {getProductsFromCartPurchasedState} from '../context/cart/cart-state.js'; +import {perPageRecommendationSelector} from '../pagination/pagination-selectors.js'; import { moreRecommendationsAvailableSelector, numberOfRecommendationsSelector, -} from './recommendations-selectors'; +} from './recommendations-selectors.js'; +import {recommendationsSlotDefinition} from './recommendations.js'; export interface QueryRecommendationsCommerceAPIThunkReturn { /** The successful recommendations response. */ diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-selectors.test.ts b/packages/headless/src/features/commerce/recommendations/recommendations-selectors.test.ts index aec0d10c7dd..6f3291f9be0 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-selectors.test.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-selectors.test.ts @@ -1,10 +1,10 @@ -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; -import {buildMockProduct} from '../../../test/mock-product'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; +import {buildMockProduct} from '../../../test/mock-product.js'; import { isLoadingSelector, moreRecommendationsAvailableSelector, numberOfRecommendationsSelector, -} from './recommendations-selectors'; +} from './recommendations-selectors.js'; describe('commerce recommendations selectors', () => { it('#numberOfRecommendationsSelector should return the number of recommendations in the recommendations section', () => { diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-selectors.ts b/packages/headless/src/features/commerce/recommendations/recommendations-selectors.ts index 35234c7229d..fdd0d53573d 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-selectors.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-selectors.ts @@ -3,8 +3,8 @@ import {createSelector} from '@reduxjs/toolkit'; import { CommercePaginationSection, RecommendationsSection, -} from '../../../state/state-sections'; -import {totalEntriesRecommendationSelector} from '../pagination/pagination-selectors'; +} from '../../../state/state-sections.js'; +import {totalEntriesRecommendationSelector} from '../pagination/pagination-selectors.js'; export const numberOfRecommendationsSelector = createSelector( (state: Partial, slotId: string) => diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-slice.test.ts b/packages/headless/src/features/commerce/recommendations/recommendations-slice.test.ts index ba880debbd5..3c5e8aacd76 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-slice.test.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-slice.test.ts @@ -1,23 +1,23 @@ import {Action} from '@reduxjs/toolkit'; -import {ChildProduct} from '../../../api/commerce/common/product'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; import { buildMockChildProduct, buildMockProduct, buildMockBaseProduct, -} from '../../../test/mock-product'; -import {buildMockRecommendationsResponse} from '../../../test/mock-recommendations'; -import {buildMockRecommendationsSlice} from '../../../test/mock-recommendations-slice'; +} from '../../../test/mock-product.js'; +import {buildMockRecommendationsSlice} from '../../../test/mock-recommendations-slice.js'; +import {buildMockRecommendationsResponse} from '../../../test/mock-recommendations.js'; import { fetchMoreRecommendations, fetchRecommendations, promoteChildToParent, registerRecommendationsSlot, -} from './recommendations-actions'; -import {recommendationsReducer} from './recommendations-slice'; +} from './recommendations-actions.js'; +import {recommendationsReducer} from './recommendations-slice.js'; import { getRecommendationsInitialState, RecommendationsState, -} from './recommendations-state'; +} from './recommendations-state.js'; describe('recommendation-slice', () => { let state: RecommendationsState; diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-slice.ts b/packages/headless/src/features/commerce/recommendations/recommendations-slice.ts index 317e0e4bf6a..b1e3a5885e5 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-slice.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-slice.ts @@ -1,24 +1,24 @@ import {createReducer} from '@reduxjs/toolkit'; -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; import { BaseProduct, ChildProduct, Product, -} from '../../../api/commerce/common/product'; -import {RecommendationsCommerceSuccessResponse} from '../../../api/commerce/recommendations/recommendations-response'; +} from '../../../api/commerce/common/product.js'; +import {RecommendationsCommerceSuccessResponse} from '../../../api/commerce/recommendations/recommendations-response.js'; import { fetchRecommendations, registerRecommendationsSlot, fetchMoreRecommendations, promoteChildToParent, QueryRecommendationsCommerceAPIThunkReturn, -} from './recommendations-actions'; +} from './recommendations-actions.js'; import { getRecommendationsInitialState, getRecommendationsSliceInitialState, RecommendationsSlice, RecommendationsState, -} from './recommendations-state'; +} from './recommendations-state.js'; export const recommendationsReducer = createReducer( getRecommendationsInitialState(), diff --git a/packages/headless/src/features/commerce/recommendations/recommendations-state.ts b/packages/headless/src/features/commerce/recommendations/recommendations-state.ts index de797485cd9..ef4cfee5060 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations-state.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations-state.ts @@ -1,5 +1,5 @@ -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {Product} from '../../../api/commerce/common/product'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {Product} from '../../../api/commerce/common/product.js'; export interface RecommendationsSlice { headline: string; diff --git a/packages/headless/src/features/commerce/recommendations/recommendations.ts b/packages/headless/src/features/commerce/recommendations/recommendations.ts index 5133e325c47..d2abf9400a6 100644 --- a/packages/headless/src/features/commerce/recommendations/recommendations.ts +++ b/packages/headless/src/features/commerce/recommendations/recommendations.ts @@ -1,7 +1,7 @@ import {Schema} from '@coveo/bueno'; import {StringValue} from '@coveo/bueno'; -import {RecommendationsOptions} from '../../../controllers/commerce/recommendations/headless-recommendations'; -import {requiredNonEmptyString} from '../../../utils/validate-payload'; +import {RecommendationsOptions} from '../../../controllers/commerce/recommendations/headless-recommendations.js'; +import {requiredNonEmptyString} from '../../../utils/validate-payload.js'; export const recommendationsSlotDefinition = { slotId: requiredNonEmptyString, diff --git a/packages/headless/src/features/commerce/search-parameters/search-parameters-actions-loader.ts b/packages/headless/src/features/commerce/search-parameters/search-parameters-actions-loader.ts index c7783ebddc1..e89f322dd18 100644 --- a/packages/headless/src/features/commerce/search-parameters/search-parameters-actions-loader.ts +++ b/packages/headless/src/features/commerce/search-parameters/search-parameters-actions-loader.ts @@ -1,15 +1,15 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {facetOrderReducer as facetOrder} from '../../facets/facet-order/facet-order-slice'; -import {querySetReducer as querySet} from '../../query-set/query-set-slice'; -import {commerceFacetSetReducer as commerceFacetSet} from '../facets/facet-set/facet-set-slice'; -import {paginationReducer as commercePagination} from '../pagination/pagination-slice'; -import {queryReducer as query} from '../query/query-slice'; -import {sortReducer as commerceSort} from '../sort/sort-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {facetOrderReducer as facetOrder} from '../../facets/facet-order/facet-order-slice.js'; +import {querySetReducer as querySet} from '../../query-set/query-set-slice.js'; +import {commerceFacetSetReducer as commerceFacetSet} from '../facets/facet-set/facet-set-slice.js'; +import {paginationReducer as commercePagination} from '../pagination/pagination-slice.js'; +import {queryReducer as query} from '../query/query-slice.js'; +import {sortReducer as commerceSort} from '../sort/sort-slice.js'; import { RestoreSearchParametersPayload, restoreSearchParameters, -} from './search-parameters-actions'; +} from './search-parameters-actions.js'; export type {RestoreSearchParametersPayload}; diff --git a/packages/headless/src/features/commerce/search-parameters/search-parameters-actions.ts b/packages/headless/src/features/commerce/search-parameters/search-parameters-actions.ts index e4c50d36e33..baafa17e829 100644 --- a/packages/headless/src/features/commerce/search-parameters/search-parameters-actions.ts +++ b/packages/headless/src/features/commerce/search-parameters/search-parameters-actions.ts @@ -1,7 +1,7 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; -import {Parameters} from '../parameters/parameters-actions'; -import {searchParametersDefinition} from './search-parameters-schema'; +import {validatePayload} from '../../../utils/validate-payload.js'; +import {Parameters} from '../parameters/parameters-actions.js'; +import {searchParametersDefinition} from './search-parameters-schema.js'; /** * The parameters affecting the search response. diff --git a/packages/headless/src/features/commerce/search-parameters/search-parameters-schema.ts b/packages/headless/src/features/commerce/search-parameters/search-parameters-schema.ts index 382f9110c58..782b4c5026f 100644 --- a/packages/headless/src/features/commerce/search-parameters/search-parameters-schema.ts +++ b/packages/headless/src/features/commerce/search-parameters/search-parameters-schema.ts @@ -1,6 +1,6 @@ import {SchemaDefinition, StringValue} from '@coveo/bueno'; -import {parametersDefinition} from '../parameters/parameters-schema'; -import {CommerceSearchParameters} from './search-parameters-actions'; +import {parametersDefinition} from '../parameters/parameters-schema.js'; +import {CommerceSearchParameters} from './search-parameters-actions.js'; export const searchParametersDefinition: SchemaDefinition< Required diff --git a/packages/headless/src/features/commerce/search/search-actions-loader.ts b/packages/headless/src/features/commerce/search/search-actions-loader.ts index c521c304ecc..a81c8dda5b1 100644 --- a/packages/headless/src/features/commerce/search/search-actions-loader.ts +++ b/packages/headless/src/features/commerce/search/search-actions-loader.ts @@ -1,6 +1,7 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {StateNeededByExecuteSearch} from './search-actions-thunk-processor.js'; import { PrepareForSearchWithQueryPayload, PromoteChildToParentPayload, @@ -9,9 +10,8 @@ import { fetchMoreProducts, prepareForSearchWithQuery, promoteChildToParent, -} from './search-actions'; -import {StateNeededByExecuteSearch} from './search-actions-thunk-processor'; -import {commerceSearchReducer as commerceSearch} from './search-slice'; +} from './search-actions.js'; +import {commerceSearchReducer as commerceSearch} from './search-slice.js'; export type {PrepareForSearchWithQueryPayload}; diff --git a/packages/headless/src/features/commerce/search/search-actions-thunk-processor.test.ts b/packages/headless/src/features/commerce/search/search-actions-thunk-processor.test.ts index 6ec68568cea..6b1f19657ec 100644 --- a/packages/headless/src/features/commerce/search/search-actions-thunk-processor.test.ts +++ b/packages/headless/src/features/commerce/search/search-actions-thunk-processor.test.ts @@ -1,20 +1,21 @@ import {Relay} from '@coveo/relay'; import {Logger} from 'pino'; -import {CommerceAPIClient} from '../../../api/commerce/commerce-api-client'; -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response'; -import {defaultNodeJSNavigatorContextProvider} from '../../../app/navigatorContextProvider'; -import {CommerceAppState} from '../../../state/commerce-app-state'; -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; -import {buildMockProduct} from '../../../test/mock-product'; -import {buildCommerceAPIRequest} from '../common/actions'; -import {updateQuery} from '../query/query-actions'; -import {QuerySearchCommerceAPIThunkReturn} from './search-actions'; +import {Mock} from 'vitest'; +import {CommerceAPIClient} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response.js'; +import {defaultNodeJSNavigatorContextProvider} from '../../../app/navigatorContextProvider.js'; +import {CommerceAppState} from '../../../state/commerce-app-state.js'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; +import {buildMockProduct} from '../../../test/mock-product.js'; +import {buildCommerceAPIRequest} from '../common/actions.js'; +import {updateQuery} from '../query/query-actions.js'; import { AsyncThunkConfig, AsyncSearchThunkProcessor, -} from './search-actions-thunk-processor'; +} from './search-actions-thunk-processor.js'; +import {QuerySearchCommerceAPIThunkReturn} from './search-actions.js'; describe('commerce AsyncSearchThunkProcessor', () => { let config: AsyncThunkConfig; @@ -22,18 +23,18 @@ describe('commerce AsyncSearchThunkProcessor', () => { beforeEach(() => { state = buildMockCommerceState(); config = { - dispatch: jest.fn(), + dispatch: vi.fn(), extra: { - analyticsClientMiddleware: jest.fn(), - apiClient: {search: jest.fn()} as unknown as CommerceAPIClient, - logger: jest.fn() as unknown as Logger, - validatePayload: jest.fn(), - preprocessRequest: jest.fn(), - relay: jest.fn() as unknown as Relay, + analyticsClientMiddleware: vi.fn(), + apiClient: {search: vi.fn()} as unknown as CommerceAPIClient, + logger: vi.fn() as unknown as Logger, + validatePayload: vi.fn(), + preprocessRequest: vi.fn(), + relay: vi.fn() as unknown as Relay, navigatorContext: defaultNodeJSNavigatorContextProvider(), }, - getState: jest.fn().mockReturnValue(state), - rejectWithValue: jest.fn(), + getState: vi.fn().mockReturnValue(state), + rejectWithValue: vi.fn(), }; }); @@ -109,7 +110,7 @@ describe('commerce AsyncSearchThunkProcessor', () => { products: [buildMockProduct()], }); - (config.extra.apiClient.search as jest.Mock).mockReturnValue( + (config.extra.apiClient.search as Mock).mockReturnValue( Promise.resolve({success: responseAfterModification}) ); diff --git a/packages/headless/src/features/commerce/search/search-actions-thunk-processor.ts b/packages/headless/src/features/commerce/search/search-actions-thunk-processor.ts index e24711ab466..82f933b0a16 100644 --- a/packages/headless/src/features/commerce/search/search-actions-thunk-processor.ts +++ b/packages/headless/src/features/commerce/search/search-actions-thunk-processor.ts @@ -5,29 +5,29 @@ import { CommerceAPIClient, CommerceAPIResponse, isErrorResponse, -} from '../../../api/commerce/commerce-api-client'; -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {CommerceAPIRequest} from '../../../api/commerce/common/request'; -import {CommerceSearchRequest} from '../../../api/commerce/search/request'; -import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; +} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {CommerceAPIRequest} from '../../../api/commerce/common/request.js'; +import {CommerceSearchRequest} from '../../../api/commerce/search/request.js'; +import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; import { CommerceSearchSection, CommerceQuerySection, CommerceDidYouMeanSection, TriggerSection, -} from '../../../state/state-sections'; +} from '../../../state/state-sections.js'; import { ListingAndSearchStateNeededByQueryCommerceAPI, buildCommerceAPIRequest, -} from '../common/actions'; -import {updateQuery} from '../query/query-actions'; +} from '../common/actions.js'; +import {updateQuery} from '../query/query-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from '../triggers/triggers-actions'; -import {QuerySearchCommerceAPIThunkReturn} from './search-actions'; -import {queryExecutedFromResponseSelector} from './search-selectors'; +} from '../triggers/triggers-actions.js'; +import {QuerySearchCommerceAPIThunkReturn} from './search-actions.js'; +import {queryExecutedFromResponseSelector} from './search-selectors.js'; interface FetchedResponse { response: CommerceAPIResponse; diff --git a/packages/headless/src/features/commerce/search/search-actions.ts b/packages/headless/src/features/commerce/search/search-actions.ts index 46fb65c65cb..90d026bbfe4 100644 --- a/packages/headless/src/features/commerce/search/search-actions.ts +++ b/packages/headless/src/features/commerce/search/search-actions.ts @@ -3,28 +3,28 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { AsyncThunkCommerceOptions, isErrorResponse, -} from '../../../api/commerce/commerce-api-client'; -import {ChildProduct} from '../../../api/commerce/common/product'; -import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response'; -import {validatePayload} from '../../../utils/validate-payload'; -import {deselectAllNonBreadcrumbs} from '../../breadcrumb/breadcrumb-actions'; -import {buildCommerceAPIRequest} from '../common/actions'; +} from '../../../api/commerce/commerce-api-client.js'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response.js'; +import {validatePayload} from '../../../utils/validate-payload.js'; +import {deselectAllNonBreadcrumbs} from '../../breadcrumb/breadcrumb-actions.js'; +import {buildCommerceAPIRequest} from '../common/actions.js'; import { clearAllCoreFacets, updateAutoSelectionForAllCoreFacets, -} from '../facets/core-facet/core-facet-actions'; -import {selectPage} from '../pagination/pagination-actions'; -import {perPagePrincipalSelector} from '../pagination/pagination-selectors'; -import {UpdateQueryPayload, updateQuery} from '../query/query-actions'; +} from '../facets/core-facet/core-facet-actions.js'; +import {selectPage} from '../pagination/pagination-actions.js'; +import {perPagePrincipalSelector} from '../pagination/pagination-selectors.js'; +import {UpdateQueryPayload, updateQuery} from '../query/query-actions.js'; import { AsyncSearchThunkProcessor, StateNeededByExecuteSearch, -} from './search-actions-thunk-processor'; +} from './search-actions-thunk-processor.js'; import { querySelector, moreProductsAvailableSelector, numberOfProductsSelector, -} from './search-selectors'; +} from './search-selectors.js'; export interface QuerySearchCommerceAPIThunkReturn { /** The successful response. */ diff --git a/packages/headless/src/features/commerce/search/search-selectors.test.ts b/packages/headless/src/features/commerce/search/search-selectors.test.ts index 017814693e4..b3f25166129 100644 --- a/packages/headless/src/features/commerce/search/search-selectors.test.ts +++ b/packages/headless/src/features/commerce/search/search-selectors.test.ts @@ -1,7 +1,7 @@ -import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response'; -import {buildMockCommerceState} from '../../../test/mock-commerce-state'; -import {buildMockCommerceEngine} from '../../../test/mock-engine-v2'; -import {buildMockProduct} from '../../../test/mock-product'; +import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response.js'; +import {buildMockCommerceState} from '../../../test/mock-commerce-state.js'; +import {buildMockCommerceEngine} from '../../../test/mock-engine-v2.js'; +import {buildMockProduct} from '../../../test/mock-product.js'; import { moreProductsAvailableSelector, numberOfProductsSelector, @@ -9,7 +9,7 @@ import { requestIdSelector, responseIdSelector, responseIdSelectorFromEngine, -} from './search-selectors'; +} from './search-selectors.js'; describe('commerce search selectors', () => { it('#responseIdSelector should return the responseId value from the search section', () => { diff --git a/packages/headless/src/features/commerce/search/search-selectors.ts b/packages/headless/src/features/commerce/search/search-selectors.ts index 80066ca913d..7659979c616 100644 --- a/packages/headless/src/features/commerce/search/search-selectors.ts +++ b/packages/headless/src/features/commerce/search/search-selectors.ts @@ -1,24 +1,24 @@ import {isNullOrUndefined} from '@coveo/bueno'; import {createSelector} from '@reduxjs/toolkit'; -import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response'; +import {SearchCommerceSuccessResponse} from '../../../api/commerce/search/response.js'; import { CommerceEngine, CommerceEngineState, -} from '../../../app/commerce-engine/commerce-engine'; -import {stateKey} from '../../../app/state-key'; +} from '../../../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../../../app/state-key.js'; import { CommercePaginationSection, CommerceQuerySection, CommerceSearchSection, -} from '../../../state/state-sections'; -import {getQ} from '../../parameter-manager/parameter-manager-selectors'; -import {totalEntriesPrincipalSelector} from '../pagination/pagination-selectors'; +} from '../../../state/state-sections.js'; +import {getQ} from '../../parameter-manager/parameter-manager-selectors.js'; +import {totalEntriesPrincipalSelector} from '../pagination/pagination-selectors.js'; import { activeParametersSelector as coreActiveParametersSelector, enrichedParametersSelector as coreEnrichedParametersSelector, -} from '../parameters/parameters-selectors'; -import {getCommerceQueryInitialState} from '../query/query-state'; -import {CommerceSearchParameters} from '../search-parameters/search-parameters-actions'; +} from '../parameters/parameters-selectors.js'; +import {getCommerceQueryInitialState} from '../query/query-state.js'; +import {CommerceSearchParameters} from '../search-parameters/search-parameters-actions.js'; /** * Duplicate selector since the state is no longer accessible externally diff --git a/packages/headless/src/features/commerce/search/search-slice.test.ts b/packages/headless/src/features/commerce/search/search-slice.test.ts index 0c2be7ca96c..fd5aafdfecd 100644 --- a/packages/headless/src/features/commerce/search/search-slice.test.ts +++ b/packages/headless/src/features/commerce/search/search-slice.test.ts @@ -1,21 +1,22 @@ -import {ChildProduct} from '../../../api/commerce/common/product'; -import {buildMockCommerceRegularFacetResponse} from '../../../test/mock-commerce-facet-response'; -import {buildSearchResponse} from '../../../test/mock-commerce-search'; +import {ChildProduct} from '../../../api/commerce/common/product.js'; +import {buildMockCommerceRegularFacetResponse} from '../../../test/mock-commerce-facet-response.js'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; import { buildMockChildProduct, buildMockProduct, buildMockBaseProduct, -} from '../../../test/mock-product'; +} from '../../../test/mock-product.js'; +import {setContext, setView} from '../context/context-actions.js'; import { executeSearch, fetchMoreProducts, promoteChildToParent, -} from './search-actions'; -import {commerceSearchReducer} from './search-slice'; +} from './search-actions.js'; +import {commerceSearchReducer} from './search-slice.js'; import { CommerceSearchState, getCommerceSearchInitialState, -} from './search-state'; +} from './search-state.js'; describe('search-slice', () => { let state: CommerceSearchState; @@ -318,4 +319,48 @@ describe('search-slice', () => { ]); }); }); + it('on #setView, restores the initial state', () => { + state = { + error: {message: 'message', statusCode: 500, type: 'type'}, + isLoading: true, + requestId: 'request-id', + facets: [buildMockCommerceRegularFacetResponse()], + products: [ + buildMockProduct({ec_name: 'product1'}), + buildMockProduct({ec_name: 'product2'}), + ], + queryExecuted: 'query', + responseId: 'response-id', + }; + + const finalState = commerceSearchReducer(state, setView({url: '/'})); + + expect(finalState).toEqual(getCommerceSearchInitialState()); + }); + + it('on #setContext, restores the initial state', () => { + state = { + error: {message: 'message', statusCode: 500, type: 'type'}, + isLoading: true, + requestId: 'request-id', + facets: [buildMockCommerceRegularFacetResponse()], + products: [ + buildMockProduct({ec_name: 'product1'}), + buildMockProduct({ec_name: 'product2'}), + ], + queryExecuted: 'query', + responseId: 'response-id', + }; + const finalState = commerceSearchReducer( + state, + setContext({ + country: 'CA', + currency: 'CAD', + language: 'fr', + view: {url: '/'}, + }) + ); + + expect(finalState).toEqual(getCommerceSearchInitialState()); + }); }); diff --git a/packages/headless/src/features/commerce/search/search-slice.ts b/packages/headless/src/features/commerce/search/search-slice.ts index 03de594c5c8..4148307ec18 100644 --- a/packages/headless/src/features/commerce/search/search-slice.ts +++ b/packages/headless/src/features/commerce/search/search-slice.ts @@ -1,21 +1,22 @@ import {createReducer} from '@reduxjs/toolkit'; -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; import { Product, BaseProduct, ChildProduct, -} from '../../../api/commerce/common/product'; -import {CommerceSuccessResponse} from '../../../api/commerce/common/response'; +} from '../../../api/commerce/common/product.js'; +import {CommerceSuccessResponse} from '../../../api/commerce/common/response.js'; +import {setContext, setView} from '../context/context-actions.js'; import { QuerySearchCommerceAPIThunkReturn, executeSearch, fetchMoreProducts, promoteChildToParent, -} from './search-actions'; +} from './search-actions.js'; import { CommerceSearchState, getCommerceSearchInitialState, -} from './search-state'; +} from './search-state.js'; export const commerceSearchReducer = createReducer( getCommerceSearchInitialState(), @@ -87,7 +88,9 @@ export const commerceSearchReducer = createReducer( }; products.splice(currentParentIndex, 1, newParent); - }); + }) + .addCase(setView, () => getCommerceSearchInitialState()) + .addCase(setContext, () => getCommerceSearchInitialState()); } ); diff --git a/packages/headless/src/features/commerce/search/search-state.ts b/packages/headless/src/features/commerce/search/search-state.ts index fe1a3976647..2d387fe2040 100644 --- a/packages/headless/src/features/commerce/search/search-state.ts +++ b/packages/headless/src/features/commerce/search/search-state.ts @@ -1,6 +1,6 @@ -import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response'; -import {Product} from '../../../api/commerce/common/product'; -import {AnyFacetResponse} from '../facets/facet-set/interfaces/response'; +import {CommerceAPIErrorStatusResponse} from '../../../api/commerce/commerce-api-error-response.js'; +import {Product} from '../../../api/commerce/common/product.js'; +import {AnyFacetResponse} from '../facets/facet-set/interfaces/response.js'; export interface CommerceSearchState { error: CommerceAPIErrorStatusResponse | null; diff --git a/packages/headless/src/features/commerce/sort/sort-actions-loader.ts b/packages/headless/src/features/commerce/sort/sort-actions-loader.ts index eed7bdb9ae7..6c7959e4adf 100644 --- a/packages/headless/src/features/commerce/sort/sort-actions-loader.ts +++ b/packages/headless/src/features/commerce/sort/sort-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {ApplySortPayload, applySort} from './sort-actions'; -import {sortReducer as commerceSort} from './sort-slice'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {ApplySortPayload, applySort} from './sort-actions.js'; +import {sortReducer as commerceSort} from './sort-slice.js'; export type {ApplySortPayload}; diff --git a/packages/headless/src/features/commerce/sort/sort-actions.ts b/packages/headless/src/features/commerce/sort/sort-actions.ts index 12c305d3ecf..9fd64c7d288 100644 --- a/packages/headless/src/features/commerce/sort/sort-actions.ts +++ b/packages/headless/src/features/commerce/sort/sort-actions.ts @@ -1,7 +1,7 @@ import {EnumValue, SchemaDefinition} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; -import {SortBy, SortCriterion} from './sort'; +import {validatePayload} from '../../../utils/validate-payload.js'; +import {SortBy, SortCriterion} from './sort.js'; export type ApplySortPayload = SortCriterion; diff --git a/packages/headless/src/features/commerce/sort/sort-slice.test.ts b/packages/headless/src/features/commerce/sort/sort-slice.test.ts index 2fd7ade9dad..649991dc7d7 100644 --- a/packages/headless/src/features/commerce/sort/sort-slice.test.ts +++ b/packages/headless/src/features/commerce/sort/sort-slice.test.ts @@ -1,19 +1,19 @@ -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {buildFetchProductListingResponse} from '../../../test/mock-product-listing'; -import {SortBy, SortDirection} from '../../sort/sort'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {buildFetchProductListingResponse} from '../../../test/mock-product-listing.js'; +import {SortBy, SortDirection} from '../../sort/sort.js'; import { SetContextPayload, SetViewPayload, setContext, setView, -} from '../context/context-actions'; -import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../product-listing/product-listing-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameters-actions'; -import {executeSearch} from '../search/search-actions'; -import {applySort} from './sort-actions'; -import {sortReducer} from './sort-slice'; -import {CommerceSortState, getCommerceSortInitialState} from './sort-state'; +} from '../context/context-actions.js'; +import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../product-listing/product-listing-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {applySort} from './sort-actions.js'; +import {sortReducer} from './sort-slice.js'; +import {CommerceSortState, getCommerceSortInitialState} from './sort-state.js'; describe('product-listing-sort-slice', () => { const sort = { diff --git a/packages/headless/src/features/commerce/sort/sort-slice.ts b/packages/headless/src/features/commerce/sort/sort-slice.ts index d0398b26cfc..cd65879f3b7 100644 --- a/packages/headless/src/features/commerce/sort/sort-slice.ts +++ b/packages/headless/src/features/commerce/sort/sort-slice.ts @@ -1,19 +1,19 @@ import {type Draft as WritableDraft} from '@reduxjs/toolkit'; import {AnyAction, createReducer} from '@reduxjs/toolkit'; -import {SortOption} from '../../../api/commerce/common/sort'; +import {SortOption} from '../../../api/commerce/common/sort.js'; import { buildRelevanceSortCriterion, SortBy, SortCriterion, -} from '../../sort/sort'; -import {setContext, setView} from '../context/context-actions'; -import {Parameters} from '../parameters/parameters-actions'; -import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../product-listing/product-listing-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameters-actions'; -import {executeSearch} from '../search/search-actions'; -import {applySort} from './sort-actions'; -import {CommerceSortState, getCommerceSortInitialState} from './sort-state'; +} from '../../sort/sort.js'; +import {setContext, setView} from '../context/context-actions.js'; +import {Parameters} from '../parameters/parameters-actions.js'; +import {restoreProductListingParameters} from '../product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../product-listing/product-listing-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameters-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {applySort} from './sort-actions.js'; +import {CommerceSortState, getCommerceSortInitialState} from './sort-state.js'; export const sortReducer = createReducer( getCommerceSortInitialState(), diff --git a/packages/headless/src/features/commerce/sort/sort-state.ts b/packages/headless/src/features/commerce/sort/sort-state.ts index 30ce669095d..3664b0876e7 100644 --- a/packages/headless/src/features/commerce/sort/sort-state.ts +++ b/packages/headless/src/features/commerce/sort/sort-state.ts @@ -1,4 +1,4 @@ -import {buildRelevanceSortCriterion, SortCriterion} from './sort'; +import {buildRelevanceSortCriterion, SortCriterion} from './sort.js'; export interface CommerceSortState { appliedSort: SortCriterion; diff --git a/packages/headless/src/features/commerce/sort/sort.ts b/packages/headless/src/features/commerce/sort/sort.ts index b6c0076fb82..28f58246312 100644 --- a/packages/headless/src/features/commerce/sort/sort.ts +++ b/packages/headless/src/features/commerce/sort/sort.ts @@ -6,7 +6,7 @@ import { SortByFields as CoreSortByFields, SortByFieldsFields as CoreSortByFieldsFields, buildRelevanceSortCriterion, -} from '../../sort/sort'; +} from '../../sort/sort.js'; export type {SortByRelevance}; export {SortBy, SortDirection, buildRelevanceSortCriterion}; diff --git a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader.ts b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader.ts index 11ec0bd362e..041afc5ff44 100644 --- a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader.ts +++ b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader.ts @@ -1,7 +1,7 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../standalone-search-box-set/standalone-search-box-set-slice'; +import {AsyncThunkCommerceOptions} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../standalone-search-box-set/standalone-search-box-set-slice.js'; import { FetchRedirectUrlPayload, RegisterStandaloneSearchBoxPayload, @@ -11,7 +11,7 @@ import { registerStandaloneSearchBox, resetStandaloneSearchBox, updateStandaloneSearchBoxRedirectionUrl, -} from './standalone-search-box-set-actions'; +} from './standalone-search-box-set-actions.js'; export type { FetchRedirectUrlPayload, diff --git a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.ts b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.ts index b5288bfc518..5f6e3079b4a 100644 --- a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.ts +++ b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-actions.ts @@ -3,21 +3,21 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { AsyncThunkCommerceOptions, isErrorResponse, -} from '../../../api/commerce/commerce-api-client'; -import {CommerceSearchRequest} from '../../../api/commerce/search/request'; -import {isRedirectTrigger} from '../../../api/common/trigger'; -import {NavigatorContext} from '../../../app/navigatorContextProvider'; +} from '../../../api/commerce/commerce-api-client.js'; +import {CommerceSearchRequest} from '../../../api/commerce/search/request.js'; +import {isRedirectTrigger} from '../../../api/common/trigger.js'; +import {NavigatorContext} from '../../../app/navigatorContextProvider.js'; import { CartSection, CommerceContextSection, CommerceQuerySection, CommerceConfigurationSection, -} from '../../../state/state-sections'; +} from '../../../state/state-sections.js'; import { requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; -import {buildBaseCommerceAPIRequest} from '../common/actions'; +} from '../../../utils/validate-payload.js'; +import {buildBaseCommerceAPIRequest} from '../common/actions.js'; export type StateNeededForRedirect = CommerceConfigurationSection & CommerceContextSection & diff --git a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.test.ts b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.test.ts index 1acd2f2d33d..be972465186 100644 --- a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.test.ts +++ b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.test.ts @@ -1,12 +1,12 @@ -import {buildMockCommerceStandaloneSearchBoxEntry} from '../../../test/mock-commerce-standalone-search-box-entry'; +import {buildMockCommerceStandaloneSearchBoxEntry} from '../../../test/mock-commerce-standalone-search-box-entry.js'; import { fetchRedirectUrl, registerStandaloneSearchBox, resetStandaloneSearchBox, updateStandaloneSearchBoxRedirectionUrl, -} from './standalone-search-box-set-actions'; -import {commerceStandaloneSearchBoxSetReducer} from './standalone-search-box-set-slice'; -import {CommerceStandaloneSearchBoxSetState} from './standalone-search-box-set-state'; +} from './standalone-search-box-set-actions.js'; +import {commerceStandaloneSearchBoxSetReducer} from './standalone-search-box-set-slice.js'; +import {CommerceStandaloneSearchBoxSetState} from './standalone-search-box-set-state.js'; describe('commerce standalone search box slice', () => { const id = '1'; diff --git a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.ts b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.ts index 29a62d69f88..cfc702d6e3f 100644 --- a/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.ts +++ b/packages/headless/src/features/commerce/standalone-search-box-set/standalone-search-box-set-slice.ts @@ -4,11 +4,11 @@ import { registerStandaloneSearchBox, resetStandaloneSearchBox, updateStandaloneSearchBoxRedirectionUrl, -} from './standalone-search-box-set-actions'; +} from './standalone-search-box-set-actions.js'; import { getCommerceStandaloneSearchBoxSetInitialState, StandaloneSearchBoxEntry, -} from './standalone-search-box-set-state'; +} from './standalone-search-box-set-state.js'; export const commerceStandaloneSearchBoxSetReducer = createReducer( getCommerceStandaloneSearchBoxSetInitialState(), diff --git a/packages/headless/src/features/commerce/triggers/triggers-actions-loader.ts b/packages/headless/src/features/commerce/triggers/triggers-actions-loader.ts index f40e8936917..509fcfbb2dc 100644 --- a/packages/headless/src/features/commerce/triggers/triggers-actions-loader.ts +++ b/packages/headless/src/features/commerce/triggers/triggers-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine'; -import {ApplyQueryTriggerModificationPayload} from '../../triggers/triggers-actions'; +import {CommerceEngine} from '../../../app/commerce-engine/commerce-engine.js'; +import {ApplyQueryTriggerModificationPayload} from '../../triggers/triggers-actions.js'; import { UpdateIgnoreQueryTriggerPayload, applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from './triggers-actions'; -import {commerceTriggersReducer as triggers} from './triggers-slice'; +} from './triggers-actions.js'; +import {commerceTriggersReducer as triggers} from './triggers-slice.js'; export type { UpdateIgnoreQueryTriggerPayload, diff --git a/packages/headless/src/features/commerce/triggers/triggers-actions.ts b/packages/headless/src/features/commerce/triggers/triggers-actions.ts index dcc71604e22..34b5038f616 100644 --- a/packages/headless/src/features/commerce/triggers/triggers-actions.ts +++ b/packages/headless/src/features/commerce/triggers/triggers-actions.ts @@ -1,7 +1,10 @@ import {RecordValue, StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {nonEmptyString, validatePayload} from '../../../utils/validate-payload'; -import {ApplyQueryTriggerModificationPayload} from '../../triggers/triggers-actions'; +import { + nonEmptyString, + validatePayload, +} from '../../../utils/validate-payload.js'; +import {ApplyQueryTriggerModificationPayload} from '../../triggers/triggers-actions.js'; export type UpdateIgnoreQueryTriggerPayload = { /** diff --git a/packages/headless/src/features/commerce/triggers/triggers-slice.test.ts b/packages/headless/src/features/commerce/triggers/triggers-slice.test.ts index 1799b6aba4a..d81765f7a95 100644 --- a/packages/headless/src/features/commerce/triggers/triggers-slice.test.ts +++ b/packages/headless/src/features/commerce/triggers/triggers-slice.test.ts @@ -1,24 +1,24 @@ -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {buildMockExecuteTrigger} from '../../../test/mock-trigger-execute'; -import {buildMockNotifyTrigger} from '../../../test/mock-trigger-notify'; -import {buildMockQueryTrigger} from '../../../test/mock-trigger-query'; -import {buildMockRedirectTrigger} from '../../../test/mock-trigger-redirect'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {buildMockExecuteTrigger} from '../../../test/mock-trigger-execute.js'; +import {buildMockNotifyTrigger} from '../../../test/mock-trigger-notify.js'; +import {buildMockQueryTrigger} from '../../../test/mock-trigger-query.js'; +import {buildMockRedirectTrigger} from '../../../test/mock-trigger-redirect.js'; import { handleApplyQueryTriggerModification, handleFetchItemsFulfilled, handleFetchItemsPending, handleUpdateIgnoreQueryTrigger, -} from '../../triggers/triggers-slice-functions'; +} from '../../triggers/triggers-slice-functions.js'; import { TriggerState, getTriggerInitialState, -} from '../../triggers/triggers-state'; -import {executeSearch} from '../search/search-actions'; +} from '../../triggers/triggers-state.js'; +import {executeSearch} from '../search/search-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from './triggers-actions'; -import {commerceTriggersReducer} from './triggers-slice'; +} from './triggers-actions.js'; +import {commerceTriggersReducer} from './triggers-slice.js'; describe('commerce triggers slice', () => { let initialState: TriggerState; @@ -27,7 +27,7 @@ describe('commerce triggers slice', () => { let finalState: TriggerState; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); initialState = getTriggerInitialState(); initialStateCopy = JSON.parse( JSON.stringify(initialState) diff --git a/packages/headless/src/features/commerce/triggers/triggers-slice.ts b/packages/headless/src/features/commerce/triggers/triggers-slice.ts index 710ce4d0a59..a691ec6031f 100644 --- a/packages/headless/src/features/commerce/triggers/triggers-slice.ts +++ b/packages/headless/src/features/commerce/triggers/triggers-slice.ts @@ -4,13 +4,13 @@ import { handleFetchItemsFulfilled, handleFetchItemsPending, handleUpdateIgnoreQueryTrigger, -} from '../../triggers/triggers-slice-functions'; -import {getTriggerInitialState} from '../../triggers/triggers-state'; -import {executeSearch} from '../search/search-actions'; +} from '../../triggers/triggers-slice-functions.js'; +import {getTriggerInitialState} from '../../triggers/triggers-state.js'; +import {executeSearch} from '../search/search-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from './triggers-actions'; +} from './triggers-actions.js'; export const commerceTriggersReducer = createReducer( getTriggerInitialState(), diff --git a/packages/headless/src/features/configuration/analytics-params.ts b/packages/headless/src/features/configuration/analytics-params.ts index df3d863c735..410ffd5de67 100644 --- a/packages/headless/src/features/configuration/analytics-params.ts +++ b/packages/headless/src/features/configuration/analytics-params.ts @@ -1,8 +1,8 @@ import {EventDescription} from 'coveo.analytics'; -import {getAnalyticsSource} from '../../api/analytics/analytics-selectors'; -import {AnalyticsParam} from '../../api/search/search-api-params'; -import {NavigatorContext} from '../../app/navigatorContextProvider'; -import {AnalyticsState} from './configuration-state'; +import {getAnalyticsSource} from '../../api/analytics/analytics-selectors.js'; +import {AnalyticsParam} from '../../api/search/search-api-params.js'; +import {NavigatorContext} from '../../app/navigatorContextProvider.js'; +import {AnalyticsState} from './configuration-state.js'; export const fromAnalyticsStateToAnalyticsParams = ( s: AnalyticsState, diff --git a/packages/headless/src/features/configuration/configuration-actions-loader.ts b/packages/headless/src/features/configuration/configuration-actions-loader.ts index 4c4ac24e427..fffeeef7999 100644 --- a/packages/headless/src/features/configuration/configuration-actions-loader.ts +++ b/packages/headless/src/features/configuration/configuration-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {configuration} from '../../app/common-reducers'; -import {CoreEngine, CoreEngineNext} from '../../app/engine'; +import {configuration} from '../../app/common-reducers.js'; +import {CoreEngine, CoreEngineNext} from '../../app/engine.js'; import { disableAnalytics, enableAnalytics, @@ -13,7 +13,7 @@ import { updateBasicConfiguration, UpdateBasicConfigurationActionCreatorPayload, AnalyticsRuntimeEnvironment, -} from './configuration-actions'; +} from './configuration-actions.js'; export type { SetOriginLevel2ActionCreatorPayload, diff --git a/packages/headless/src/features/configuration/configuration-actions.ts b/packages/headless/src/features/configuration/configuration-actions.ts index 328e53f2fbf..99b54bec21b 100644 --- a/packages/headless/src/features/configuration/configuration-actions.ts +++ b/packages/headless/src/features/configuration/configuration-actions.ts @@ -8,14 +8,14 @@ import { } from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; import {IRuntimeEnvironment} from 'coveo.analytics'; -import {PlatformEnvironment} from '../../utils/url-utils'; +import {PlatformEnvironment} from '../../utils/url-utils.js'; import { nonEmptyString, validatePayload, requiredNonEmptyString, optionalNonEmptyVersionString, -} from '../../utils/validate-payload'; -import {COVEO_FRAMEWORK, CoveoFramework} from '../../utils/version'; +} from '../../utils/validate-payload.js'; +import {COVEO_FRAMEWORK, CoveoFramework} from '../../utils/version.js'; const originSchemaOnConfigUpdate = () => nonEmptyString; diff --git a/packages/headless/src/features/configuration/configuration-slice.test.ts b/packages/headless/src/features/configuration/configuration-slice.test.ts index 0ac1ff1ebb8..22ec852a972 100644 --- a/packages/headless/src/features/configuration/configuration-slice.test.ts +++ b/packages/headless/src/features/configuration/configuration-slice.test.ts @@ -1,5 +1,5 @@ -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {updateActiveTab} from '../tab-set/tab-set-actions'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {updateActiveTab} from '../tab-set/tab-set-actions.js'; import { updateBasicConfiguration, updateSearchConfiguration, @@ -8,14 +8,14 @@ import { updateAnalyticsConfiguration, setOriginLevel3, setOriginLevel2, -} from './configuration-actions'; -import {configurationReducer} from './configuration-slice'; +} from './configuration-actions.js'; +import {configurationReducer} from './configuration-slice.js'; import { ConfigurationState, getConfigurationInitialState, -} from './configuration-state'; +} from './configuration-state.js'; -jest.mock('../../api/analytics/coveo-analytics-utils'); +vi.mock('../../api/analytics/coveo-analytics-utils'); describe('configuration slice', () => { const initialState = getConfigurationInitialState(); diff --git a/packages/headless/src/features/configuration/configuration-slice.ts b/packages/headless/src/features/configuration/configuration-slice.ts index 70c4648bdfd..ad8068a5a5e 100644 --- a/packages/headless/src/features/configuration/configuration-slice.ts +++ b/packages/headless/src/features/configuration/configuration-slice.ts @@ -2,8 +2,8 @@ import {isNullOrUndefined} from '@coveo/bueno'; //@ts-expect-error package is just an alias resolved in esbuild import getMagicCookie from '@coveo/pendragon'; import {createReducer} from '@reduxjs/toolkit'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {updateActiveTab} from '../tab-set/tab-set-actions'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {updateActiveTab} from '../tab-set/tab-set-actions.js'; import { updateBasicConfiguration, updateSearchConfiguration, @@ -15,11 +15,11 @@ import { UpdateBasicConfigurationActionCreatorPayload, UpdateSearchConfigurationActionCreatorPayload, UpdateAnalyticsConfigurationActionCreatorPayload, -} from './configuration-actions'; +} from './configuration-actions.js'; import { getConfigurationInitialState, ConfigurationState, -} from './configuration-state'; +} from './configuration-state.js'; export const configurationReducer = createReducer( getConfigurationInitialState(), diff --git a/packages/headless/src/features/configuration/configuration-state.ts b/packages/headless/src/features/configuration/configuration-state.ts index 69c2f2f41fe..f0dccdf52e1 100644 --- a/packages/headless/src/features/configuration/configuration-state.ts +++ b/packages/headless/src/features/configuration/configuration-state.ts @@ -1,9 +1,9 @@ import {IRuntimeEnvironment} from 'coveo.analytics'; import dayjs from 'dayjs'; -import timezone from 'dayjs/plugin/timezone'; -import utc from 'dayjs/plugin/utc'; -import {PlatformEnvironment} from '../../utils/url-utils'; -import {CoveoFramework} from '../../utils/version'; +import timezone from 'dayjs/plugin/timezone.js'; +import utc from 'dayjs/plugin/utc.js'; +import {PlatformEnvironment} from '../../utils/url-utils.js'; +import {CoveoFramework} from '../../utils/version.js'; dayjs.extend(utc); dayjs.extend(timezone); diff --git a/packages/headless/src/features/configuration/legacy-analytics-params.ts b/packages/headless/src/features/configuration/legacy-analytics-params.ts index 91aaa44eb91..8d0c628f2fe 100644 --- a/packages/headless/src/features/configuration/legacy-analytics-params.ts +++ b/packages/headless/src/features/configuration/legacy-analytics-params.ts @@ -1,9 +1,9 @@ import {EventDescription} from 'coveo.analytics'; -import {getAnalyticsSource} from '../../api/analytics/analytics-selectors'; -import {getVisitorID} from '../../api/analytics/coveo-analytics-utils'; -import {getPageID} from '../../api/analytics/search-analytics'; -import {AnalyticsParam} from '../../api/search/search-api-params'; -import {AnalyticsState} from './configuration-state'; +import {getAnalyticsSource} from '../../api/analytics/analytics-selectors.js'; +import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js'; +import {getPageID} from '../../api/analytics/search-analytics.js'; +import {AnalyticsParam} from '../../api/search/search-api-params.js'; +import {AnalyticsState} from './configuration-state.js'; export const fromAnalyticsStateToAnalyticsParams = async ( s: AnalyticsState, diff --git a/packages/headless/src/features/configuration/search-configuration-actions-loader.ts b/packages/headless/src/features/configuration/search-configuration-actions-loader.ts index 2f67ff4349e..2e86cd3c786 100644 --- a/packages/headless/src/features/configuration/search-configuration-actions-loader.ts +++ b/packages/headless/src/features/configuration/search-configuration-actions-loader.ts @@ -1,13 +1,13 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {configuration} from '../../app/common-reducers'; -import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; +import {configuration} from '../../app/common-reducers.js'; +import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; import { updateSearchConfiguration, UpdateSearchConfigurationActionCreatorPayload, -} from './configuration-actions'; +} from './configuration-actions.js'; export type {UpdateSearchConfigurationActionCreatorPayload}; diff --git a/packages/headless/src/features/context/context-actions-loader.ts b/packages/headless/src/features/context/context-actions-loader.ts index 20693413e1f..bc91a51dc89 100644 --- a/packages/headless/src/features/context/context-actions-loader.ts +++ b/packages/headless/src/features/context/context-actions-loader.ts @@ -1,13 +1,13 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {contextReducer as context} from '../../features/context/context-slice'; +import {CoreEngine} from '../../app/engine.js'; +import {contextReducer as context} from '../../features/context/context-slice.js'; import { addContext, AddContextActionCreatorPayload, removeContext, setContext, -} from './context-actions'; -import {ContextPayload} from './context-state'; +} from './context-actions.js'; +import {ContextPayload} from './context-state.js'; export type {AddContextActionCreatorPayload}; diff --git a/packages/headless/src/features/context/context-actions.ts b/packages/headless/src/features/context/context-actions.ts index ef61881425c..dfa7bf312e3 100644 --- a/packages/headless/src/features/context/context-actions.ts +++ b/packages/headless/src/features/context/context-actions.ts @@ -3,8 +3,8 @@ import {createAction} from '@reduxjs/toolkit'; import { validatePayload, requiredNonEmptyString, -} from '../../utils/validate-payload'; -import {ContextPayload, ContextValue} from './context-state'; +} from '../../utils/validate-payload.js'; +import {ContextPayload, ContextValue} from './context-state.js'; const nonEmptyArray = new ArrayValue({ each: requiredNonEmptyString, diff --git a/packages/headless/src/features/context/context-slice.test.ts b/packages/headless/src/features/context/context-slice.test.ts index 0b14e6e42bc..8040c11796d 100644 --- a/packages/headless/src/features/context/context-slice.test.ts +++ b/packages/headless/src/features/context/context-slice.test.ts @@ -1,8 +1,8 @@ -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {setContext, addContext, removeContext} from './context-actions'; -import {contextReducer} from './context-slice'; -import {ContextState, getContextInitialState} from './context-state'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {setContext, addContext, removeContext} from './context-actions.js'; +import {contextReducer} from './context-slice.js'; +import {ContextState, getContextInitialState} from './context-state.js'; describe('context slice', () => { let state: ContextState; diff --git a/packages/headless/src/features/context/context-slice.ts b/packages/headless/src/features/context/context-slice.ts index 66d85b7780e..1774bb0a227 100644 --- a/packages/headless/src/features/context/context-slice.ts +++ b/packages/headless/src/features/context/context-slice.ts @@ -1,7 +1,7 @@ import {createReducer} from '@reduxjs/toolkit'; -import {change} from '../history/history-actions'; -import {setContext, addContext, removeContext} from './context-actions'; -import {getContextInitialState} from './context-state'; +import {change} from '../history/history-actions.js'; +import {setContext, addContext, removeContext} from './context-actions.js'; +import {getContextInitialState} from './context-state.js'; export const contextReducer = createReducer( getContextInitialState(), diff --git a/packages/headless/src/features/debug/debug-actions-loader.ts b/packages/headless/src/features/debug/debug-actions-loader.ts index c48006f5f38..e5082ecf82a 100644 --- a/packages/headless/src/features/debug/debug-actions-loader.ts +++ b/packages/headless/src/features/debug/debug-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {debugReducer as debug} from '../../features/debug/debug-slice'; -import {disableDebug, enableDebug} from './debug-actions'; +import {CoreEngine} from '../../app/engine.js'; +import {debugReducer as debug} from '../../features/debug/debug-slice.js'; +import {disableDebug, enableDebug} from './debug-actions.js'; /** * The debug action creators. diff --git a/packages/headless/src/features/debug/debug-selectors.ts b/packages/headless/src/features/debug/debug-selectors.ts index 25d6d6b3a6e..4baa09fe08c 100644 --- a/packages/headless/src/features/debug/debug-selectors.ts +++ b/packages/headless/src/features/debug/debug-selectors.ts @@ -1,5 +1,5 @@ -import {SearchSection} from '../../state/state-sections'; -import {parseRankingInfo} from './ranking-info-parser'; +import {SearchSection} from '../../state/state-sections.js'; +import {parseRankingInfo} from './ranking-info-parser.js'; export function rankingInformationSelector(state: SearchSection) { const results = state.search.response.results; diff --git a/packages/headless/src/features/debug/debug-slice.test.ts b/packages/headless/src/features/debug/debug-slice.test.ts index b1555e17324..67fd57e3693 100644 --- a/packages/headless/src/features/debug/debug-slice.test.ts +++ b/packages/headless/src/features/debug/debug-slice.test.ts @@ -1,7 +1,7 @@ -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {enableDebug, disableDebug} from './debug-actions'; -import {debugReducer} from './debug-slice'; -import {getDebugInitialState} from './debug-state'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {enableDebug, disableDebug} from './debug-actions.js'; +import {debugReducer} from './debug-slice.js'; +import {getDebugInitialState} from './debug-state.js'; describe('debug slice', () => { it('should have initial state', () => { diff --git a/packages/headless/src/features/debug/debug-slice.ts b/packages/headless/src/features/debug/debug-slice.ts index 5eef4ac8de1..88c79fa388c 100644 --- a/packages/headless/src/features/debug/debug-slice.ts +++ b/packages/headless/src/features/debug/debug-slice.ts @@ -1,7 +1,7 @@ import {createReducer} from '@reduxjs/toolkit'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {enableDebug, disableDebug} from './debug-actions'; -import {getDebugInitialState} from './debug-state'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {enableDebug, disableDebug} from './debug-actions.js'; +import {getDebugInitialState} from './debug-state.js'; export const debugReducer = createReducer(getDebugInitialState(), (builder) => { builder diff --git a/packages/headless/src/features/debug/ranking-info-parser.test.ts b/packages/headless/src/features/debug/ranking-info-parser.test.ts index a148549d749..5ad2e41153e 100644 --- a/packages/headless/src/features/debug/ranking-info-parser.test.ts +++ b/packages/headless/src/features/debug/ranking-info-parser.test.ts @@ -1,4 +1,4 @@ -import {parseRankingInfo} from './ranking-info-parser'; +import {parseRankingInfo} from './ranking-info-parser.js'; function createRankingInfoNoKeywords() { return `Document weights: diff --git a/packages/headless/src/features/debug/version-slice.ts b/packages/headless/src/features/debug/version-slice.ts index b5662b912f8..7cf94511217 100644 --- a/packages/headless/src/features/debug/version-slice.ts +++ b/packages/headless/src/features/debug/version-slice.ts @@ -1,4 +1,4 @@ import {createReducer} from '@reduxjs/toolkit'; -import {VERSION} from '../../utils/version'; +import {VERSION} from '../../utils/version.js'; export const versionReducer = createReducer(VERSION, (builder) => builder); diff --git a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions-loader.ts b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions-loader.ts index 92457ca0c39..e0f9d63db1b 100644 --- a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions-loader.ts +++ b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions-loader.ts @@ -1,13 +1,13 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {dictionaryFieldContextReducer as dictionaryFieldContext} from '../../features/dictionary-field-context/dictionary-field-context-slice'; +import {CoreEngine} from '../../app/engine.js'; +import {dictionaryFieldContextReducer as dictionaryFieldContext} from '../../features/dictionary-field-context/dictionary-field-context-slice.js'; import { addContext, AddDictionaryFieldContextActionCreatorPayload, removeContext, setContext, -} from './dictionary-field-context-actions'; -import {DictionaryFieldContextPayload} from './dictionary-field-context-state'; +} from './dictionary-field-context-actions.js'; +import {DictionaryFieldContextPayload} from './dictionary-field-context-state.js'; export type {AddDictionaryFieldContextActionCreatorPayload}; diff --git a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions.ts b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions.ts index 48be35d932b..5877f4a38b2 100644 --- a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions.ts +++ b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-actions.ts @@ -3,8 +3,8 @@ import {createAction} from '@reduxjs/toolkit'; import { requiredEmptyAllowedString, validatePayload, -} from '../../utils/validate-payload'; -import {DictionaryFieldContextPayload} from './dictionary-field-context-state'; +} from '../../utils/validate-payload.js'; +import {DictionaryFieldContextPayload} from './dictionary-field-context-state.js'; export const setContext = createAction( 'dictionaryFieldContext/set', diff --git a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.test.ts b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.test.ts index c8b933424c9..7fad8222c70 100644 --- a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.test.ts +++ b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.test.ts @@ -1,16 +1,19 @@ -import {change} from '../history/history-actions'; -import {getHistoryInitialState, HistoryState} from '../history/history-state'; +import {change} from '../history/history-actions.js'; +import { + getHistoryInitialState, + HistoryState, +} from '../history/history-state.js'; import { addContext, AddDictionaryFieldContextActionCreatorPayload, removeContext, setContext, -} from './dictionary-field-context-actions'; -import {dictionaryFieldContextReducer} from './dictionary-field-context-slice'; +} from './dictionary-field-context-actions.js'; +import {dictionaryFieldContextReducer} from './dictionary-field-context-slice.js'; import { DictionaryFieldContextPayload, DictionaryFieldContextState, -} from './dictionary-field-context-state'; +} from './dictionary-field-context-state.js'; describe('dictionary field context slice', () => { it('initializes state correctly', () => { diff --git a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.ts b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.ts index 13d31072f0d..aafbf9be530 100644 --- a/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.ts +++ b/packages/headless/src/features/dictionary-field-context/dictionary-field-context-slice.ts @@ -1,11 +1,11 @@ import {createReducer} from '@reduxjs/toolkit'; -import {change} from '../history/history-actions'; +import {change} from '../history/history-actions.js'; import { addContext, removeContext, setContext, -} from './dictionary-field-context-actions'; -import {getDictionaryFieldContextInitialState} from './dictionary-field-context-state'; +} from './dictionary-field-context-actions.js'; +import {getDictionaryFieldContextInitialState} from './dictionary-field-context-state.js'; export const dictionaryFieldContextReducer = createReducer( getDictionaryFieldContextInitialState(), diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-actions-loader.ts b/packages/headless/src/features/did-you-mean/did-you-mean-actions-loader.ts index 94bc487d4bb..88b5533748f 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-actions-loader.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {didYouMeanReducer as didYouMean} from '../../features/did-you-mean/did-you-mean-slice'; -import {queryReducer as query} from '../../features/query/query-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {didYouMeanReducer as didYouMean} from '../../features/did-you-mean/did-you-mean-slice.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; import { applyDidYouMeanCorrection, disableAutomaticQueryCorrection, @@ -9,8 +9,8 @@ import { enableAutomaticQueryCorrection, enableDidYouMean, setCorrectionMode, -} from './did-you-mean-actions'; -import {CorrectionMode} from './did-you-mean-state'; +} from './did-you-mean-actions.js'; +import {CorrectionMode} from './did-you-mean-state.js'; /** * The DidYouMean action creators. diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-actions.ts b/packages/headless/src/features/did-you-mean/did-you-mean-actions.ts index bae3402c53a..a283660cf85 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-actions.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-actions.ts @@ -3,8 +3,8 @@ import {createAction} from '@reduxjs/toolkit'; import { validatePayload, requiredNonEmptyString, -} from '../../utils/validate-payload'; -import {CorrectionMode} from './did-you-mean-state'; +} from '../../utils/validate-payload.js'; +import {CorrectionMode} from './did-you-mean-state.js'; export const enableDidYouMean = createAction('didYouMean/enable'); diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-analytics-actions.ts b/packages/headless/src/features/did-you-mean/did-you-mean-analytics-actions.ts index 3328e522cde..7c4b83de779 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-analytics-actions.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-analytics-actions.ts @@ -1,9 +1,9 @@ import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; //TODO: KIT-2859 export const logDidYouMeanClick = (): LegacySearchAction => diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.test.ts b/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.test.ts index 1d28e1d8340..56b5d62f11e 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.test.ts @@ -1,18 +1,18 @@ -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logDidYouMeanAutomatic, logDidYouMeanClick, -} from './did-you-mean-insight-analytics-actions'; +} from './did-you-mean-insight-analytics-actions.js'; -const mockLogDidYouMeanClick = jest.fn(); -const mockLogDidYouMeanAutomatic = jest.fn(); +const mockLogDidYouMeanClick = vi.fn(); +const mockLogDidYouMeanAutomatic = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logDidYouMeanClick: mockLogDidYouMeanClick, logDidYouMeanAutomatic: mockLogDidYouMeanAutomatic, @@ -20,7 +20,7 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -42,7 +42,7 @@ describe('did you mean insight analytics actions', () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); const configuration = getConfigurationInitialState(); configuration.analytics.analyticsMode = 'legacy'; engine = buildMockInsightEngine( diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.ts b/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.ts index ecadaa2251a..368a2affb69 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-insight-analytics-actions.ts @@ -1,9 +1,9 @@ import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export const logDidYouMeanClick = (): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.didYouMeanClick)( diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-selectors.ts b/packages/headless/src/features/did-you-mean/did-you-mean-selectors.ts index a52e1d3454f..962e7517a86 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-selectors.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-selectors.ts @@ -1,6 +1,6 @@ import {createSelector} from '@reduxjs/toolkit'; -import {DidYouMeanState as CommerceDidYouMeanState} from '../commerce/did-you-mean/did-you-mean-state'; -import {DidYouMeanState} from './did-you-mean-state'; +import {DidYouMeanState as CommerceDidYouMeanState} from '../commerce/did-you-mean/did-you-mean-state.js'; +import {DidYouMeanState} from './did-you-mean-state.js'; export const hasQueryCorrectionSelector = createSelector( (state: CommerceDidYouMeanState | DidYouMeanState) => diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-slice-functions.ts b/packages/headless/src/features/did-you-mean/did-you-mean-slice-functions.ts index 4b5c22c9dfc..c3055ae4747 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-slice-functions.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-slice-functions.ts @@ -2,8 +2,8 @@ import {Draft} from '@reduxjs/toolkit'; import { Correction, QueryCorrection, -} from '../../api/search/search/query-corrections'; -import {emptyNextCorrection} from './did-you-mean-state'; +} from '../../api/search/search/query-corrections.js'; +import {emptyNextCorrection} from './did-you-mean-state.js'; export const setToNonEmptyQueryCorrection = ( state: {queryCorrection: Draft; wasCorrectedTo: string}, diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-slice.test.ts b/packages/headless/src/features/did-you-mean/did-you-mean-slice.test.ts index c2e3ac50925..29a63d34b63 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-slice.test.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-slice.test.ts @@ -1,16 +1,19 @@ -import {buildMockSearch} from '../../test/mock-search'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {logSearchEvent} from '../analytics/analytics-actions'; -import {executeSearch} from '../search/search-actions'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {logSearchEvent} from '../analytics/analytics-actions.js'; +import {executeSearch} from '../search/search-actions.js'; import { enableDidYouMean, disableDidYouMean, disableAutomaticQueryCorrection, enableAutomaticQueryCorrection, setCorrectionMode, -} from './did-you-mean-actions'; -import {didYouMeanReducer} from './did-you-mean-slice'; -import {getDidYouMeanInitialState, DidYouMeanState} from './did-you-mean-state'; +} from './did-you-mean-actions.js'; +import {didYouMeanReducer} from './did-you-mean-slice.js'; +import { + getDidYouMeanInitialState, + DidYouMeanState, +} from './did-you-mean-state.js'; describe('did you mean slice', () => { let state: DidYouMeanState; diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-slice.ts b/packages/headless/src/features/did-you-mean/did-you-mean-slice.ts index a9792c2012a..32475fc9aff 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-slice.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-slice.ts @@ -1,5 +1,5 @@ import {createReducer} from '@reduxjs/toolkit'; -import {executeSearch} from '../search/search-actions'; +import {executeSearch} from '../search/search-actions.js'; import { enableDidYouMean, disableDidYouMean, @@ -7,13 +7,13 @@ import { enableAutomaticQueryCorrection, disableAutomaticQueryCorrection, setCorrectionMode, -} from './did-you-mean-actions'; -import {setToNonEmptyQueryCorrection} from './did-you-mean-slice-functions'; +} from './did-you-mean-actions.js'; +import {setToNonEmptyQueryCorrection} from './did-you-mean-slice-functions.js'; import { CorrectionMode, emptyLegacyCorrection, getDidYouMeanInitialState, -} from './did-you-mean-state'; +} from './did-you-mean-state.js'; export const didYouMeanReducer = createReducer( getDidYouMeanInitialState(), diff --git a/packages/headless/src/features/did-you-mean/did-you-mean-state.ts b/packages/headless/src/features/did-you-mean/did-you-mean-state.ts index 463859e4ec1..5f4acc4f0c0 100644 --- a/packages/headless/src/features/did-you-mean/did-you-mean-state.ts +++ b/packages/headless/src/features/did-you-mean/did-you-mean-state.ts @@ -1,7 +1,7 @@ import { Correction, QueryCorrection, -} from '../../api/search/search/query-corrections'; +} from '../../api/search/search/query-corrections.js'; /** * Define which query correction system to use diff --git a/packages/headless/src/features/document-suggestion/document-suggestion-actions-loader.ts b/packages/headless/src/features/document-suggestion/document-suggestion-actions-loader.ts index 49ff2597ced..a70eb325b52 100644 --- a/packages/headless/src/features/document-suggestion/document-suggestion-actions-loader.ts +++ b/packages/headless/src/features/document-suggestion/document-suggestion-actions-loader.ts @@ -1,12 +1,12 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client'; -import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine'; -import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice'; +import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client.js'; +import {CaseAssistEngine} from '../../app/case-assist-engine/case-assist-engine.js'; +import {documentSuggestionReducer as documentSuggestion} from '../../features/document-suggestion/document-suggestion-slice.js'; import { fetchDocumentSuggestions, FetchDocumentSuggestionsThunkReturn, StateNeededByFetchDocumentSuggestions, -} from './document-suggestion-actions'; +} from './document-suggestion-actions.js'; /** * The document suggestion action creators. diff --git a/packages/headless/src/features/document-suggestion/document-suggestion-actions.ts b/packages/headless/src/features/document-suggestion/document-suggestion-actions.ts index cafd27796d2..35ed0b90f25 100644 --- a/packages/headless/src/features/document-suggestion/document-suggestion-actions.ts +++ b/packages/headless/src/features/document-suggestion/document-suggestion-actions.ts @@ -1,11 +1,11 @@ import {createAsyncThunk} from '@reduxjs/toolkit'; -import {getVisitorID} from '../../api/analytics/coveo-analytics-utils'; -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {isErrorResponse} from '../../api/search/search-api-client'; -import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client'; -import {prepareContextFromFields} from '../../api/service/case-assist/case-assist-params'; -import {GetDocumentSuggestionsRequest} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-request'; -import {GetDocumentSuggestionsResponse} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response'; +import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {isErrorResponse} from '../../api/search/search-api-client.js'; +import {AsyncThunkCaseAssistOptions} from '../../api/service/case-assist/case-assist-api-client.js'; +import {prepareContextFromFields} from '../../api/service/case-assist/case-assist-params.js'; +import {GetDocumentSuggestionsRequest} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-request.js'; +import {GetDocumentSuggestionsResponse} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response.js'; import { CaseAssistConfigurationSection, DocumentSuggestionSection, @@ -13,7 +13,7 @@ import { DebugSection, CaseInputSection, CaseFieldSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; export interface FetchDocumentSuggestionsThunkReturn { /** The successful document suggestions response. */ diff --git a/packages/headless/src/features/document-suggestion/document-suggestion-slice.test.ts b/packages/headless/src/features/document-suggestion/document-suggestion-slice.test.ts index 25811d0d9c2..89632029f9c 100644 --- a/packages/headless/src/features/document-suggestion/document-suggestion-slice.test.ts +++ b/packages/headless/src/features/document-suggestion/document-suggestion-slice.test.ts @@ -1,14 +1,14 @@ import { DocumentSuggestionResponse, GetDocumentSuggestionsResponse, -} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response'; -import {buildMockDocumentSuggestion} from '../../test/mock-case-assist-document-suggestion'; -import {fetchDocumentSuggestions} from './document-suggestion-actions'; -import {documentSuggestionReducer} from './document-suggestion-slice'; +} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response.js'; +import {buildMockDocumentSuggestion} from '../../test/mock-case-assist-document-suggestion.js'; +import {fetchDocumentSuggestions} from './document-suggestion-actions.js'; +import {documentSuggestionReducer} from './document-suggestion-slice.js'; import { getDocumentSuggestionInitialState, DocumentSuggestionState, -} from './document-suggestion-state'; +} from './document-suggestion-state.js'; describe('document suggestion slice', () => { let state: DocumentSuggestionState; diff --git a/packages/headless/src/features/document-suggestion/document-suggestion-slice.ts b/packages/headless/src/features/document-suggestion/document-suggestion-slice.ts index bcb5b4614b6..c9ff1d995ce 100644 --- a/packages/headless/src/features/document-suggestion/document-suggestion-slice.ts +++ b/packages/headless/src/features/document-suggestion/document-suggestion-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {fetchDocumentSuggestions} from './document-suggestion-actions'; -import {getDocumentSuggestionInitialState} from './document-suggestion-state'; +import {fetchDocumentSuggestions} from './document-suggestion-actions.js'; +import {getDocumentSuggestionInitialState} from './document-suggestion-state.js'; export const documentSuggestionReducer = createReducer( getDocumentSuggestionInitialState(), diff --git a/packages/headless/src/features/document-suggestion/document-suggestion-state.ts b/packages/headless/src/features/document-suggestion/document-suggestion-state.ts index 162514689dd..e29e7d038a1 100644 --- a/packages/headless/src/features/document-suggestion/document-suggestion-state.ts +++ b/packages/headless/src/features/document-suggestion/document-suggestion-state.ts @@ -1,5 +1,5 @@ -import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client'; -import {DocumentSuggestionResponse} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response'; +import {CaseAssistAPIErrorStatusResponse} from '../../api/service/case-assist/case-assist-api-client.js'; +import {DocumentSuggestionResponse} from '../../api/service/case-assist/get-document-suggestions/get-document-suggestions-response.js'; export const getDocumentSuggestionInitialState = (): DocumentSuggestionState => ({ diff --git a/packages/headless/src/features/excerpt-length/excerpt-length-actions-loader.ts b/packages/headless/src/features/excerpt-length/excerpt-length-actions-loader.ts index a3035a6ff4c..aba1a2f660c 100644 --- a/packages/headless/src/features/excerpt-length/excerpt-length-actions-loader.ts +++ b/packages/headless/src/features/excerpt-length/excerpt-length-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {excerptLengthReducer as excerptLength} from '../../features/excerpt-length/excerpt-length-slice'; -import {setExcerptLength} from './excerpt-length-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {excerptLengthReducer as excerptLength} from '../../features/excerpt-length/excerpt-length-slice.js'; +import {setExcerptLength} from './excerpt-length-actions.js'; /** * The excerpt length action creators. diff --git a/packages/headless/src/features/excerpt-length/excerpt-length-actions.ts b/packages/headless/src/features/excerpt-length/excerpt-length-actions.ts index b53e6ddbab9..c72527b84df 100644 --- a/packages/headless/src/features/excerpt-length/excerpt-length-actions.ts +++ b/packages/headless/src/features/excerpt-length/excerpt-length-actions.ts @@ -1,6 +1,6 @@ import {NumberValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; export const setExcerptLength = createAction( 'excerptLength/set', diff --git a/packages/headless/src/features/excerpt-length/excerpt-length-slice.test.ts b/packages/headless/src/features/excerpt-length/excerpt-length-slice.test.ts index ab995588871..e8f9268c677 100644 --- a/packages/headless/src/features/excerpt-length/excerpt-length-slice.test.ts +++ b/packages/headless/src/features/excerpt-length/excerpt-length-slice.test.ts @@ -1,6 +1,6 @@ -import {setExcerptLength} from './excerpt-length-actions'; -import {excerptLengthReducer} from './excerpt-length-slice'; -import {getExcerptLengthInitialState} from './excerpt-length-state'; +import {setExcerptLength} from './excerpt-length-actions.js'; +import {excerptLengthReducer} from './excerpt-length-slice.js'; +import {getExcerptLengthInitialState} from './excerpt-length-state.js'; describe('excerpt length slice', () => { it('#setExcerptLength should set the value in the state', () => { diff --git a/packages/headless/src/features/excerpt-length/excerpt-length-slice.ts b/packages/headless/src/features/excerpt-length/excerpt-length-slice.ts index 575a45067ec..173efe5ab43 100644 --- a/packages/headless/src/features/excerpt-length/excerpt-length-slice.ts +++ b/packages/headless/src/features/excerpt-length/excerpt-length-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setExcerptLength} from './excerpt-length-actions'; -import {getExcerptLengthInitialState} from './excerpt-length-state'; +import {setExcerptLength} from './excerpt-length-actions.js'; +import {getExcerptLengthInitialState} from './excerpt-length-state.js'; export const excerptLengthReducer = createReducer( getExcerptLengthInitialState(), diff --git a/packages/headless/src/features/facet-options/facet-options-actions-loader.ts b/packages/headless/src/features/facet-options/facet-options-actions-loader.ts index 33876af8884..2f626069f58 100644 --- a/packages/headless/src/features/facet-options/facet-options-actions-loader.ts +++ b/packages/headless/src/features/facet-options/facet-options-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {facetOptionsReducer as facetOptions} from '../../features/facet-options/facet-options-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {facetOptionsReducer as facetOptions} from '../../features/facet-options/facet-options-slice.js'; import { updateFacetOptions, UpdateFacetOptionsActionCreatorPayload, @@ -8,7 +8,7 @@ import { DisableFacetActionCreatorPayload, enableFacet, disableFacet, -} from './facet-options-actions'; +} from './facet-options-actions.js'; export type { UpdateFacetOptionsActionCreatorPayload, diff --git a/packages/headless/src/features/facet-options/facet-options-actions.ts b/packages/headless/src/features/facet-options/facet-options-actions.ts index 71854ba9211..d9f0a99a831 100644 --- a/packages/headless/src/features/facet-options/facet-options-actions.ts +++ b/packages/headless/src/features/facet-options/facet-options-actions.ts @@ -1,7 +1,7 @@ import {BooleanValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; -import {facetIdDefinition} from '../facets/generic/facet-actions-validation'; +import {validatePayload} from '../../utils/validate-payload.js'; +import {facetIdDefinition} from '../facets/generic/facet-actions-validation.js'; export interface UpdateFacetOptionsActionCreatorPayload { /** diff --git a/packages/headless/src/features/facet-options/facet-options-selectors.ts b/packages/headless/src/features/facet-options/facet-options-selectors.ts index 9655744139a..8527bb3d1d0 100644 --- a/packages/headless/src/features/facet-options/facet-options-selectors.ts +++ b/packages/headless/src/features/facet-options/facet-options-selectors.ts @@ -1,4 +1,4 @@ -import {FacetOptionsSection} from '../../state/state-sections'; +import {FacetOptionsSection} from '../../state/state-sections.js'; export const isFacetEnabledSelector = ( state: FacetOptionsSection, diff --git a/packages/headless/src/features/facet-options/facet-options-slice.test.ts b/packages/headless/src/features/facet-options/facet-options-slice.test.ts index 4c969643f21..ec3ecafaee7 100644 --- a/packages/headless/src/features/facet-options/facet-options-slice.test.ts +++ b/packages/headless/src/features/facet-options/facet-options-slice.test.ts @@ -1,16 +1,16 @@ -import {buildMockFacetOptions} from '../../test/mock-facet-options'; -import {buildMockSearch} from '../../test/mock-search'; -import {logSearchEvent} from '../analytics/analytics-actions'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {executeSearch} from '../search/search-actions'; -import {updateActiveTab} from '../tab-set/tab-set-actions'; -import {updateFacetOptions} from './facet-options-actions'; -import {facetOptionsReducer} from './facet-options-slice'; +import {buildMockFacetOptions} from '../../test/mock-facet-options.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {logSearchEvent} from '../analytics/analytics-actions.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {executeSearch} from '../search/search-actions.js'; +import {updateActiveTab} from '../tab-set/tab-set-actions.js'; +import {updateFacetOptions} from './facet-options-actions.js'; +import {facetOptionsReducer} from './facet-options-slice.js'; import { FacetOptionsState, getFacetOptionsInitialState, -} from './facet-options-state'; +} from './facet-options-state.js'; describe('facet options slice', () => { let state: FacetOptionsState; diff --git a/packages/headless/src/features/facet-options/facet-options-slice.ts b/packages/headless/src/features/facet-options/facet-options-slice.ts index c37545c61d1..d4e07129555 100644 --- a/packages/headless/src/features/facet-options/facet-options-slice.ts +++ b/packages/headless/src/features/facet-options/facet-options-slice.ts @@ -1,23 +1,23 @@ import {createReducer} from '@reduxjs/toolkit'; -import {registerCategoryFacet} from '../facets/category-facet-set/category-facet-set-actions'; -import {registerFacet} from '../facets/facet-set/facet-set-actions'; -import {registerDateFacet} from '../facets/range-facets/date-facet-set/date-facet-actions'; -import {registerNumericFacet} from '../facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {change} from '../history/history-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {executeSearch} from '../search/search-actions'; -import {updateActiveTab} from '../tab-set/tab-set-actions'; +import {registerCategoryFacet} from '../facets/category-facet-set/category-facet-set-actions.js'; +import {registerFacet} from '../facets/facet-set/facet-set-actions.js'; +import {registerDateFacet} from '../facets/range-facets/date-facet-set/date-facet-actions.js'; +import {registerNumericFacet} from '../facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {change} from '../history/history-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {updateActiveTab} from '../tab-set/tab-set-actions.js'; import { disableFacet, enableFacet, updateFacetOptions, -} from './facet-options-actions'; +} from './facet-options-actions.js'; import { getFacetOptionsSliceInitialState, getFacetOptionsInitialState, FacetOptionsState, -} from './facet-options-state'; -import {isFacetIncludedOnTab} from './facet-options-utils'; +} from './facet-options-state.js'; +import {isFacetIncludedOnTab} from './facet-options-utils.js'; export const facetOptionsReducer = createReducer( getFacetOptionsInitialState(), @@ -72,14 +72,15 @@ export const facetOptionsReducer = createReducer( state.facets[action.payload].enabled = false; }) .addCase(restoreSearchParameters, (state, action) => { - for (const facetId in state.facets) { - const facet = state.facets[facetId]; - if (Object.keys({...facet.tabs}).length > 0) { - facet.enabled = isFacetIncludedOnTab( - facet.tabs, - action.payload.tab - ); - } + if (action.payload.tab) { + Object.entries(state.facets).forEach(([, facet]) => { + if (Object.keys(facet.tabs ?? {}).length > 0) { + facet.enabled = isFacetIncludedOnTab( + facet.tabs, + action.payload.tab + ); + } + }); } [ ...Object.keys(action.payload.f ?? {}), @@ -106,8 +107,11 @@ function handleRegisterFacetTabs( const newFacetState = { ...getFacetOptionsSliceInitialState(), tabs: tabs ?? {}, - enabled: isFacetIncludedOnTab(tabs, activeTab), }; + if (tabs && Object.keys(tabs).length > 0) { + newFacetState.enabled = isFacetIncludedOnTab(tabs, activeTab); + } + state.facets[facetId] = newFacetState; } diff --git a/packages/headless/src/features/facet-options/facet-options-utils.test.ts b/packages/headless/src/features/facet-options/facet-options-utils.test.ts index d5386502c49..e1a243f2a58 100644 --- a/packages/headless/src/features/facet-options/facet-options-utils.test.ts +++ b/packages/headless/src/features/facet-options/facet-options-utils.test.ts @@ -1,4 +1,4 @@ -import {isFacetIncludedOnTab} from './facet-options-utils'; +import {isFacetIncludedOnTab} from './facet-options-utils.js'; describe('isFacetIncludedOnTab', () => { it('returns true when facetTabs or activeTab is undefined', () => { diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions-loader.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions-loader.ts index d0de041d40b..f0288ff7f66 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions-loader.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions-loader.ts @@ -1,13 +1,13 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {AutomaticFacetGeneratorOptions} from '../../../controllers/facets/automatic-facet-generator/headless-automatic-facet-generator-options'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {AutomaticFacetGeneratorOptions} from '../../../controllers/facets/automatic-facet-generator/headless-automatic-facet-generator-options.js'; import { ToggleSelectAutomaticFacetValueActionCreatorPayload, setOptions, deselectAllAutomaticFacetValues, toggleSelectAutomaticFacetValue, -} from './automatic-facet-set-actions'; -import {automaticFacetSetReducer as automaticFacetSet} from './automatic-facet-set-slice'; +} from './automatic-facet-set-actions.js'; +import {automaticFacetSetReducer as automaticFacetSet} from './automatic-facet-set-slice.js'; /** * The action creators to manage automatic facets. diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts index 1bd174b3202..0692c7edf77 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts @@ -1,20 +1,20 @@ import {NumberValue, RecordValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {AutomaticFacetGeneratorOptions} from '../../../controllers/facets/automatic-facet-generator/headless-automatic-facet-generator-options'; +import {AutomaticFacetGeneratorOptions} from '../../../controllers/facets/automatic-facet-generator/headless-automatic-facet-generator-options.js'; import { requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; -import {facetValueDefinition} from '../facet-set/facet-set-validate-payload'; -import {FacetValue} from '../facet-set/interfaces/response'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; +} from '../../../utils/validate-payload.js'; +import {facetValueDefinition} from '../facet-set/facet-set-validate-payload.js'; +import {FacetValue} from '../facet-set/interfaces/response.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; import { DESIRED_COUNT_DEFAULT, DESIRED_COUNT_MAXIMUM, DESIRED_COUNT_MINIMUM, NUMBER_OF_VALUE_DEFAULT, NUMBER_OF_VALUE_MINIMUM, -} from './automatic-facet-set-constants'; +} from './automatic-facet-set-constants.js'; export interface ToggleSelectAutomaticFacetValueActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.test.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.test.ts index 46fa072ee15..43d2f3505bc 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.test.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.test.ts @@ -1,31 +1,31 @@ -import {AutomaticFacetGeneratorOptions} from '../../../controllers/facets/automatic-facet-generator/headless-automatic-facet-generator-options'; -import {buildMockAutomaticFacetResponse} from '../../../test/mock-automatic-facet-response'; -import {buildMockAutomaticFacetSlice} from '../../../test/mock-automatic-facet-slice'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {buildMockSearch} from '../../../test/mock-search'; -import {logSearchEvent} from '../../analytics/analytics-actions'; -import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions'; -import {executeSearch} from '../../search/search-actions'; -import {FacetValueState} from '../facet-api/value'; +import {AutomaticFacetGeneratorOptions} from '../../../controllers/facets/automatic-facet-generator/headless-automatic-facet-generator-options.js'; +import {buildMockAutomaticFacetResponse} from '../../../test/mock-automatic-facet-response.js'; +import {buildMockAutomaticFacetSlice} from '../../../test/mock-automatic-facet-slice.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {buildMockSearch} from '../../../test/mock-search.js'; +import {logSearchEvent} from '../../analytics/analytics-actions.js'; +import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../../search/search-actions.js'; +import {FacetValueState} from '../facet-api/value.js'; import { deselectAllAutomaticFacetValues, setOptions, toggleSelectAutomaticFacetValue, -} from './automatic-facet-set-actions'; +} from './automatic-facet-set-actions.js'; import { DESIRED_COUNT_MAXIMUM, DESIRED_COUNT_MINIMUM, NUMBER_OF_VALUE_MINIMUM, -} from './automatic-facet-set-constants'; +} from './automatic-facet-set-constants.js'; //import {DESIRED_COUNT_MINIMUM} from './automatic-facet-set-constants'; -import {automaticFacetSetReducer} from './automatic-facet-set-slice'; +import {automaticFacetSetReducer} from './automatic-facet-set-slice.js'; import { AutomaticFacetSetState, AutomaticFacetSlice, getAutomaticFacetSetInitialState, -} from './automatic-facet-set-state'; -import {AutomaticFacetResponse} from './interfaces/response'; +} from './automatic-facet-set-state.js'; +import {AutomaticFacetResponse} from './interfaces/response.js'; describe('automatic-facet-set slice', () => { let state: AutomaticFacetSetState; diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.ts index 2bbbb0a6541..eaaaf98d216 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-slice.ts @@ -1,16 +1,16 @@ import {createReducer} from '@reduxjs/toolkit'; -import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions'; -import {change} from '../../history/history-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions'; -import {executeSearch} from '../../search/search-actions'; -import {FacetValue} from '../facet-set/interfaces/response'; +import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions.js'; +import {change} from '../../history/history-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../../search/search-actions.js'; +import {FacetValue} from '../facet-set/interfaces/response.js'; import { deselectAllAutomaticFacetValues, setOptions, toggleSelectAutomaticFacetValue, -} from './automatic-facet-set-actions'; -import {getAutomaticFacetSetInitialState} from './automatic-facet-set-state'; -import {AutomaticFacetResponse} from './interfaces/response'; +} from './automatic-facet-set-actions.js'; +import {getAutomaticFacetSetInitialState} from './automatic-facet-set-state.js'; +import {AutomaticFacetResponse} from './interfaces/response.js'; export const automaticFacetSetReducer = createReducer( getAutomaticFacetSetInitialState(), diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-state.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-state.ts index becd0685a58..58db589a59f 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-state.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-state.ts @@ -1,8 +1,8 @@ import { DESIRED_COUNT_DEFAULT, NUMBER_OF_VALUE_DEFAULT, -} from './automatic-facet-set-constants'; -import {AutomaticFacetResponse} from './interfaces/response'; +} from './automatic-facet-set-constants.js'; +import {AutomaticFacetResponse} from './interfaces/response.js'; export type AutomaticFacetSlice = { response: AutomaticFacetResponse; diff --git a/packages/headless/src/features/facets/automatic-facet-set/interfaces/request.ts b/packages/headless/src/features/facets/automatic-facet-set/interfaces/request.ts index 4026e2b2a2d..129a5f892a2 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/interfaces/request.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/interfaces/request.ts @@ -1,4 +1,4 @@ -import {FacetValue} from '../../facet-set/interfaces/response'; +import {FacetValue} from '../../facet-set/interfaces/response.js'; export type AutomaticFacetRequest = { field: string; diff --git a/packages/headless/src/features/facets/automatic-facet-set/interfaces/response.ts b/packages/headless/src/features/facets/automatic-facet-set/interfaces/response.ts index 467506ef9ef..045e0827f90 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/interfaces/response.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/interfaces/response.ts @@ -1,5 +1,5 @@ -import {BaseFacetResponse} from '../../facet-api/response'; -import {FacetValue} from '../../facet-set/interfaces/response'; +import {BaseFacetResponse} from '../../facet-api/response.js'; +import {FacetValue} from '../../facet-set/interfaces/response.js'; export type AutomaticFacetResponse = Omit< BaseFacetResponse, diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.test.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.test.ts index 53b895b0799..146e4a37453 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.test.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.test.ts @@ -1,6 +1,6 @@ -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request'; -import {selectPath} from './category-facet-reducer-helpers'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request.js'; +import {selectPath} from './category-facet-reducer-helpers.js'; describe('category facet reducer helpers', () => { describe('#selectPath', () => { diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.ts index 780ad77709b..5944caf1a27 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-reducer-helpers.ts @@ -1,8 +1,8 @@ -import {CategoryFacetSetState} from './category-facet-set-state'; +import {CategoryFacetSetState} from './category-facet-set-state.js'; import { CategoryFacetRequest, CategoryFacetValueRequest, -} from './interfaces/request'; +} from './interfaces/request.js'; export function handleCategoryFacetDeselectAll( state: CategoryFacetSetState, diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions-loader.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions-loader.ts index ff405790baa..68c967317a8 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions-loader.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions-loader.ts @@ -1,10 +1,10 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {categoryFacetSetReducer as categoryFacetSet} from '../../../features/facets/category-facet-set/category-facet-set-slice.js'; import { UpdateFacetAutoSelectionActionCreatorPayload, updateFacetAutoSelection, -} from '../generic/facet-actions'; +} from '../generic/facet-actions.js'; import { deselectAllCategoryFacetValues, registerCategoryFacet, @@ -17,7 +17,7 @@ import { UpdateCategoryFacetNumberOfValuesActionCreatorPayload, UpdateCategoryFacetSortCriterionActionCreatorPayload, UpdateCategoryFacetBasePathActionCreatorPayload, -} from './category-facet-set-actions'; +} from './category-facet-set-actions.js'; export type { RegisterCategoryFacetActionCreatorPayload, diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions.ts index 22a54a5bfc8..beade1c32e0 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-actions.ts @@ -12,11 +12,11 @@ import { validatePayload, validatePayloadAndThrow, requiredNonEmptyString, -} from '../../../utils/validate-payload'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; -import {validateCategoryFacetValue} from './category-facet-validate-payload'; -import {CategoryFacetSortCriterion} from './interfaces/request'; -import {CategoryFacetValue} from './interfaces/response'; +} from '../../../utils/validate-payload.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; +import {validateCategoryFacetValue} from './category-facet-validate-payload.js'; +import {CategoryFacetSortCriterion} from './interfaces/request.js'; +import {CategoryFacetValue} from './interfaces/response.js'; export interface RegisterCategoryFacetActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-analytics-actions.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-analytics-actions.ts index d0f75929567..aebe50f89f8 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-analytics-actions.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-analytics-actions.ts @@ -1,17 +1,17 @@ import {ArrayValue} from '@coveo/bueno'; -import type {CategoryFacetMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; -import {SearchAppState} from '../../../state/search-app-state'; +import type {CategoryFacetMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; import { requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../analytics/search-action-cause'; -import {SearchAction} from '../../search/search-actions'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; +} from '../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../analytics/search-action-cause.js'; +import {SearchAction} from '../../search/search-actions.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; export interface LogCategoryFacetBreadcrumbActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.test.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.test.ts index 315415d54ae..8bdb8d20bc2 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.test.ts @@ -1,21 +1,21 @@ -import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockInsightEngine} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../../configuration/configuration-state'; -import {logCategoryFacetBreadcrumb} from './category-facet-set-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockInsightEngine} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../../configuration/configuration-state.js'; +import {logCategoryFacetBreadcrumb} from './category-facet-set-insight-analytics-actions.js'; -const mockLogBreadcrumbFacet = jest.fn(); +const mockLogBreadcrumbFacet = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logBreadcrumbFacet: mockLogBreadcrumbFacet, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.ts index a85fb3a9952..798be770593 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-insight-analytics-actions.ts @@ -1,18 +1,18 @@ import {ArrayValue} from '@coveo/bueno'; -import type {CategoryFacetMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; -import {InsightAppState} from '../../../state/insight-app-state'; +import type {CategoryFacetMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; +import {InsightAppState} from '../../../state/insight-app-state.js'; import { requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../../case-context/case-context-state'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; -import {LogCategoryFacetBreadcrumbActionCreatorPayload} from './category-facet-set-analytics-actions'; +} from '../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../../case-context/case-context-state.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; +import {LogCategoryFacetBreadcrumbActionCreatorPayload} from './category-facet-set-analytics-actions.js'; const categoryFacetBreadcrumbPayloadDefinition = { categoryFacetId: facetIdDefinition, diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.test.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.test.ts index 541d6a33a6f..8f728311881 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.test.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.test.ts @@ -1,16 +1,16 @@ -import {SearchAppState} from '../../../state/search-app-state'; -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response'; -import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {createMockState} from '../../../test/mock-state'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {createMockState} from '../../../test/mock-state.js'; import { categoryFacetResponseSelector, categoryFacetResponseSelectedValuesSelector, -} from './category-facet-set-selectors'; +} from './category-facet-set-selectors.js'; describe('category facet selectors', () => { const facetId = 'abc123'; diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.ts index 3773f769204..12da4ca1773 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-selectors.ts @@ -1,11 +1,11 @@ import { CategoryFacetSection, SearchSection, -} from '../../../state/state-sections'; -import {baseFacetResponseSelector} from '../facet-set/facet-set-selectors'; -import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response'; -import {findActiveValueAncestry} from './category-facet-utils'; -import {CategoryFacetResponse} from './interfaces/response'; +} from '../../../state/state-sections.js'; +import {baseFacetResponseSelector} from '../facet-set/facet-set-selectors.js'; +import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response.js'; +import {findActiveValueAncestry} from './category-facet-utils.js'; +import {CategoryFacetResponse} from './interfaces/response.js'; function isCategoryFacetResponse( state: CategoryFacetSection, diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.test.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.test.ts index 473a91f049a..568fa551a40 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.test.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.test.ts @@ -1,22 +1,21 @@ -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response'; -import {buildMockCategoryFacetSearchResult} from '../../../test/mock-category-facet-search-result'; -import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value'; -import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request'; -import {buildMockSearch} from '../../../test/mock-search'; -import {logSearchEvent} from '../../analytics/analytics-actions'; -import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions'; -import {change} from '../../history/history-actions'; -import {getHistoryInitialState} from '../../history/history-state'; -import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions'; -import {executeSearch, fetchFacetValues} from '../../search/search-actions'; -import {selectCategoryFacetSearchResult} from '../facet-search-set/category/category-facet-search-actions'; -import {FacetResponse} from '../facet-set/interfaces/response'; -import {updateFacetAutoSelection} from '../generic/facet-actions'; -import * as FacetReducers from '../generic/facet-reducer-helpers'; -import * as CategoryFacetReducers from './category-facet-reducer-helpers'; -import * as CategoryFacetReducerHelpers from './category-facet-reducer-helpers'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetResponse} from '../../../test/mock-category-facet-response.js'; +import {buildMockCategoryFacetSearchResult} from '../../../test/mock-category-facet-search-result.js'; +import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request.js'; +import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value.js'; +import {buildMockSearch} from '../../../test/mock-search.js'; +import {logSearchEvent} from '../../analytics/analytics-actions.js'; +import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions.js'; +import {change} from '../../history/history-actions.js'; +import {getHistoryInitialState} from '../../history/history-state.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions.js'; +import {executeSearch, fetchFacetValues} from '../../search/search-actions.js'; +import {selectCategoryFacetSearchResult} from '../facet-search-set/category/category-facet-search-actions.js'; +import {FacetResponse} from '../facet-set/interfaces/response.js'; +import {updateFacetAutoSelection} from '../generic/facet-actions.js'; +import * as FacetReducers from '../generic/facet-reducer-helpers.js'; +import * as CategoryFacetReducerHelpers from './category-facet-reducer-helpers.js'; import { registerCategoryFacet, toggleSelectCategoryFacetValue, @@ -25,13 +24,13 @@ import { updateCategoryFacetSortCriterion, RegisterCategoryFacetActionCreatorPayload, updateCategoryFacetBasePath, -} from './category-facet-set-actions'; -import {categoryFacetSetReducer} from './category-facet-set-slice'; +} from './category-facet-set-actions.js'; +import {categoryFacetSetReducer} from './category-facet-set-slice.js'; import { CategoryFacetSetState, getCategoryFacetSetInitialState, -} from './category-facet-set-state'; -import {CategoryFacetSortCriterion} from './interfaces/request'; +} from './category-facet-set-state.js'; +import {CategoryFacetSortCriterion} from './interfaces/request.js'; describe('category facet slice', () => { const facetId = '1'; @@ -118,14 +117,15 @@ describe('category facet slice', () => { }); it('dispatching #deselectAllBreadcrumbs calls #handleCategoryFacetDeselectAll for every facet', () => { - jest - .spyOn(CategoryFacetReducers, 'handleCategoryFacetDeselectAll') - .mockReset(); + vi.spyOn( + CategoryFacetReducerHelpers, + 'handleCategoryFacetDeselectAll' + ).mockReset(); categoryFacetSetReducer(state, deselectAllBreadcrumbs()); expect( - CategoryFacetReducers.handleCategoryFacetDeselectAll + CategoryFacetReducerHelpers.handleCategoryFacetDeselectAll ).toHaveBeenCalledTimes(2); }); }); @@ -203,7 +203,7 @@ describe('category facet slice', () => { describe('#restoreSearchParameters', () => { it('when a facet is found in the #cf payload, it sets #currentValues to a value built from the path', () => { - const spy = jest.spyOn(CategoryFacetReducerHelpers, 'selectPath'); + const spy = vi.spyOn(CategoryFacetReducerHelpers, 'selectPath'); const initialNumberOfValues = 5; const path = ['a']; @@ -231,7 +231,6 @@ describe('category facet slice', () => { }); it('when a facet is not found in the #cf payload, it sets #currentValues to an empty array', () => { - const spy = jest.spyOn(CategoryFacetReducerHelpers, 'selectPath'); const initialNumberOfValues = 5; const cf = {}; @@ -250,7 +249,6 @@ describe('category facet slice', () => { expect(finalState['geography']?.request.numberOfValues).toEqual( initialNumberOfValues ); - expect(spy).toHaveBeenCalled(); }); it('when a facet is not found in the #cf payload, it does not preventAutoSelection', () => { @@ -357,7 +355,7 @@ describe('category facet slice', () => { describe('#updateCategoryFacetNumberOfValues', () => { it('calls #handleFacetUpdateNumberOfValues if there are no nested children', () => { - jest.spyOn(FacetReducers, 'handleFacetUpdateNumberOfValues'); + vi.spyOn(FacetReducers, 'handleFacetUpdateNumberOfValues'); const request = buildMockCategoryFacetRequest({facetId}); state[facetId] = buildMockCategoryFacetSlice({request}); @@ -706,7 +704,7 @@ describe('category facet slice', () => { }); it('when the result is at the base path, currentValues only contains the selected value', () => { - const spy = jest.spyOn(CategoryFacetReducerHelpers, 'selectPath'); + const spy = vi.spyOn(CategoryFacetReducerHelpers, 'selectPath'); state[facetId]!.initialNumberOfValues = 10; const value = buildMockCategoryFacetSearchResult(); diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.ts index 59cceb6b268..5fbd432280e 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-slice.ts @@ -1,17 +1,17 @@ import {createReducer} from '@reduxjs/toolkit'; -import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions'; -import {disableFacet} from '../../facet-options/facet-options-actions'; -import {change} from '../../history/history-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions'; -import {executeSearch, fetchFacetValues} from '../../search/search-actions'; -import {selectCategoryFacetSearchResult} from '../facet-search-set/category/category-facet-search-actions'; -import {updateFacetAutoSelection} from '../generic/facet-actions'; -import {handleFacetUpdateNumberOfValues} from '../generic/facet-reducer-helpers'; -import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response'; +import {deselectAllBreadcrumbs} from '../../breadcrumb/breadcrumb-actions.js'; +import {disableFacet} from '../../facet-options/facet-options-actions.js'; +import {change} from '../../history/history-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions.js'; +import {executeSearch, fetchFacetValues} from '../../search/search-actions.js'; +import {selectCategoryFacetSearchResult} from '../facet-search-set/category/category-facet-search-actions.js'; +import {updateFacetAutoSelection} from '../generic/facet-actions.js'; +import {handleFacetUpdateNumberOfValues} from '../generic/facet-reducer-helpers.js'; +import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response.js'; import { handleCategoryFacetDeselectAll, selectPath, -} from './category-facet-reducer-helpers'; +} from './category-facet-reducer-helpers.js'; import { registerCategoryFacet, toggleSelectCategoryFacetValue, @@ -20,18 +20,18 @@ import { updateCategoryFacetSortCriterion, RegisterCategoryFacetActionCreatorPayload, updateCategoryFacetBasePath, -} from './category-facet-set-actions'; +} from './category-facet-set-actions.js'; import { CategoryFacetSetState, getCategoryFacetSetInitialState, -} from './category-facet-set-state'; -import {findActiveValueAncestry} from './category-facet-utils'; -import {CategoryFacetOptionalParameters} from './interfaces/options'; +} from './category-facet-set-state.js'; +import {findActiveValueAncestry} from './category-facet-utils.js'; +import {CategoryFacetOptionalParameters} from './interfaces/options.js'; import { CategoryFacetRequest, CategoryFacetValueRequest, -} from './interfaces/request'; -import {CategoryFacetResponse} from './interfaces/response'; +} from './interfaces/request.js'; +import {CategoryFacetResponse} from './interfaces/response.js'; export const categoryFacetSetReducer = createReducer( getCategoryFacetSetInitialState(), diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-set-state.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-set-state.ts index aa44116c62f..dfc0560ad01 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-set-state.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-set-state.ts @@ -1,4 +1,4 @@ -import {CategoryFacetRequest} from './interfaces/request'; +import {CategoryFacetRequest} from './interfaces/request.js'; export type CategoryFacetSlice = { request: CategoryFacetRequest; diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-utils.test.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-utils.test.ts index bf395955a34..0ea8d3d1484 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-utils.test.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-utils.test.ts @@ -1,6 +1,6 @@ -import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value'; -import {findActiveValueAncestry} from './category-facet-utils'; -import {CategoryFacetValue} from './interfaces/response'; +import {buildMockCategoryFacetValue} from '../../../test/mock-category-facet-value.js'; +import {findActiveValueAncestry} from './category-facet-utils.js'; +import {CategoryFacetValue} from './interfaces/response.js'; describe('#findActiveValueAncestry', () => { it("should return an empty array if there's no selected values", () => { diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-utils.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-utils.ts index fbc7d187776..1f717c91bfc 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-utils.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-utils.ts @@ -1,7 +1,7 @@ -import {CategoryFacetValue as CommerceCategoryFacetValue} from '../../commerce/facets/facet-set/interfaces/response'; -import {CategoryFacetValueCommon} from './interfaces/commons'; -import {CategoryFacetValueRequest} from './interfaces/request'; -import {CategoryFacetValue} from './interfaces/response'; +import {CategoryFacetValue as CommerceCategoryFacetValue} from '../../commerce/facets/facet-set/interfaces/response.js'; +import {CategoryFacetValueCommon} from './interfaces/commons.js'; +import {CategoryFacetValueRequest} from './interfaces/request.js'; +import {CategoryFacetValue} from './interfaces/response.js'; type GenericCategoryFacetValue = CategoryFacetValueRequest | CategoryFacetValue; diff --git a/packages/headless/src/features/facets/category-facet-set/category-facet-validate-payload.ts b/packages/headless/src/features/facets/category-facet-set/category-facet-validate-payload.ts index 3901fdef99a..fe4f9f80711 100644 --- a/packages/headless/src/features/facets/category-facet-set/category-facet-validate-payload.ts +++ b/packages/headless/src/features/facets/category-facet-set/category-facet-validate-payload.ts @@ -8,9 +8,9 @@ import { import { validatePayloadAndThrow, requiredNonEmptyString, -} from '../../../utils/validate-payload'; -import {FacetValueState} from '../facet-api/value'; -import {CategoryFacetValue} from './interfaces/response'; +} from '../../../utils/validate-payload.js'; +import {FacetValueState} from '../facet-api/value.js'; +import {CategoryFacetValue} from './interfaces/response.js'; export const categoryFacetValueDefinition = { state: new Value({required: true}), diff --git a/packages/headless/src/features/facets/category-facet-set/interfaces/commons.ts b/packages/headless/src/features/facets/category-facet-set/interfaces/commons.ts index 1a2354e0607..742bc372dda 100644 --- a/packages/headless/src/features/facets/category-facet-set/interfaces/commons.ts +++ b/packages/headless/src/features/facets/category-facet-set/interfaces/commons.ts @@ -1,4 +1,4 @@ -import {FacetValueState} from '../../facet-api/value'; +import {FacetValueState} from '../../facet-api/value.js'; export interface CategoryFacetValueCommon { /** diff --git a/packages/headless/src/features/facets/category-facet-set/interfaces/options.ts b/packages/headless/src/features/facets/category-facet-set/interfaces/options.ts index c732343b662..f9c69dfc9d8 100644 --- a/packages/headless/src/features/facets/category-facet-set/interfaces/options.ts +++ b/packages/headless/src/features/facets/category-facet-set/interfaces/options.ts @@ -1,4 +1,4 @@ -import {CategoryFacetRequest} from './request'; +import {CategoryFacetRequest} from './request.js'; export type CategoryFacetOptionalParameters = Pick< CategoryFacetRequest, diff --git a/packages/headless/src/features/facets/category-facet-set/interfaces/request.ts b/packages/headless/src/features/facets/category-facet-set/interfaces/request.ts index c3df0f87a2c..a6856f70038 100644 --- a/packages/headless/src/features/facets/category-facet-set/interfaces/request.ts +++ b/packages/headless/src/features/facets/category-facet-set/interfaces/request.ts @@ -5,8 +5,8 @@ import { Type, SortCriteria, BaseFacetValueRequest, -} from '../../facet-api/request'; -import {CategoryFacetValueCommon} from './commons'; +} from '../../facet-api/request.js'; +import {CategoryFacetValueCommon} from './commons.js'; export const categoryFacetSortCriteria: CategoryFacetSortCriterion[] = [ 'alphanumeric', diff --git a/packages/headless/src/features/facets/category-facet-set/interfaces/response.ts b/packages/headless/src/features/facets/category-facet-set/interfaces/response.ts index 5c8c0c366d5..fd44e4c6c00 100644 --- a/packages/headless/src/features/facets/category-facet-set/interfaces/response.ts +++ b/packages/headless/src/features/facets/category-facet-set/interfaces/response.ts @@ -1,7 +1,7 @@ -import {BaseFacetResponse} from '../../facet-api/response'; -import {CategoryFacetValueCommon} from './commons'; +import {BaseFacetResponse} from '../../facet-api/response.js'; +import {CategoryFacetValueCommon} from './commons.js'; -export type {CategoryFacetValueCommon} from './commons'; +export type {CategoryFacetValueCommon} from './commons.js'; export interface CategoryFacetValue extends CategoryFacetValueCommon { /** * The number of results that match the facet value. diff --git a/packages/headless/src/features/facets/facet-api/request.ts b/packages/headless/src/features/facets/facet-api/request.ts index 627f1e42246..8d0f999b957 100644 --- a/packages/headless/src/features/facets/facet-api/request.ts +++ b/packages/headless/src/features/facets/facet-api/request.ts @@ -1,5 +1,5 @@ -import {FacetSortOrder} from '../facet-set/interfaces/request'; -import {FacetValueState} from './value'; +import {FacetSortOrder} from '../facet-set/interfaces/request.js'; +import {FacetValueState} from './value.js'; export interface BaseFacetRequest { /** diff --git a/packages/headless/src/features/facets/facet-api/response.ts b/packages/headless/src/features/facets/facet-api/response.ts index 5e37f604b96..531676939aa 100644 --- a/packages/headless/src/features/facets/facet-api/response.ts +++ b/packages/headless/src/features/facets/facet-api/response.ts @@ -1,4 +1,4 @@ -import {FacetValueState} from './value'; +import {FacetValueState} from './value.js'; export interface BaseFacetResponse { facetId: string; diff --git a/packages/headless/src/features/facets/facet-order/facet-order-slice.test.ts b/packages/headless/src/features/facets/facet-order/facet-order-slice.test.ts index 9c8b8b7c259..7594197f4b2 100644 --- a/packages/headless/src/features/facets/facet-order/facet-order-slice.test.ts +++ b/packages/headless/src/features/facets/facet-order/facet-order-slice.test.ts @@ -1,21 +1,25 @@ import {Action, AnyAction} from '@reduxjs/toolkit'; -import {buildMockCommerceRegularFacetResponse} from '../../../test/mock-commerce-facet-response'; -import {buildMockCommerceRegularFacetValue} from '../../../test/mock-commerce-facet-value'; -import {buildSearchResponse} from '../../../test/mock-commerce-search'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {buildFetchProductListingResponse} from '../../../test/mock-product-listing'; -import {buildMockSearch} from '../../../test/mock-search'; -import {buildMockSearchResponse} from '../../../test/mock-search-response'; -import {Parameters} from '../../commerce/parameters/parameters-actions'; -import {restoreProductListingParameters} from '../../commerce/product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../../commerce/product-listing/product-listing-actions'; -import {restoreSearchParameters} from '../../commerce/search-parameters/search-parameters-actions'; -import {executeSearch as executeCommerceSearch} from '../../commerce/search/search-actions'; -import {change} from '../../history/history-actions'; -import {getHistoryInitialState} from '../../history/history-state'; -import {executeSearch} from '../../search/search-actions'; -import {facetOrderReducer} from './facet-order-slice'; -import {FacetOrderState, getFacetOrderInitialState} from './facet-order-state'; +import {buildMockCommerceRegularFacetResponse} from '../../../test/mock-commerce-facet-response.js'; +import {buildMockCommerceRegularFacetValue} from '../../../test/mock-commerce-facet-value.js'; +import {buildSearchResponse} from '../../../test/mock-commerce-search.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {buildFetchProductListingResponse} from '../../../test/mock-product-listing.js'; +import {buildMockSearchResponse} from '../../../test/mock-search-response.js'; +import {buildMockSearch} from '../../../test/mock-search.js'; +import {setContext, setView} from '../../commerce/context/context-actions.js'; +import {Parameters} from '../../commerce/parameters/parameters-actions.js'; +import {restoreProductListingParameters} from '../../commerce/product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../../commerce/product-listing/product-listing-actions.js'; +import {restoreSearchParameters} from '../../commerce/search-parameters/search-parameters-actions.js'; +import {executeSearch as executeCommerceSearch} from '../../commerce/search/search-actions.js'; +import {change} from '../../history/history-actions.js'; +import {getHistoryInitialState} from '../../history/history-state.js'; +import {executeSearch} from '../../search/search-actions.js'; +import {facetOrderReducer} from './facet-order-slice.js'; +import { + FacetOrderState, + getFacetOrderInitialState, +} from './facet-order-state.js'; describe('facet-order slice', () => { let state: FacetOrderState; @@ -149,4 +153,21 @@ describe('facet-order slice', () => { ]); }); }); + it('#setView restore the initial state', () => { + const facetIds = ['facetA', 'facetB']; + dispatchMockSearch(facetIds); + expect(state).toEqual(facetIds); + + dispatchMock(setView); + expect(state).toEqual(getFacetOrderInitialState()); + }); + + it('#setContext (commerce) restore the initial state', () => { + const facetIds = ['facetA', 'facetB']; + dispatchMockSearch(facetIds); + expect(state).toEqual(facetIds); + + dispatchMock(setContext); + expect(state).toEqual(getFacetOrderInitialState()); + }); }); diff --git a/packages/headless/src/features/facets/facet-order/facet-order-slice.ts b/packages/headless/src/features/facets/facet-order/facet-order-slice.ts index 7362c54a79e..163af49782d 100644 --- a/packages/headless/src/features/facets/facet-order/facet-order-slice.ts +++ b/packages/headless/src/features/facets/facet-order/facet-order-slice.ts @@ -1,12 +1,16 @@ import {AnyAction, createReducer} from '@reduxjs/toolkit'; -import {Parameters} from '../../commerce/parameters/parameters-actions'; -import {restoreProductListingParameters} from '../../commerce/product-listing-parameters/product-listing-parameters-actions'; -import {fetchProductListing} from '../../commerce/product-listing/product-listing-actions'; -import {restoreSearchParameters} from '../../commerce/search-parameters/search-parameters-actions'; -import {executeSearch as executeCommerceSearch} from '../../commerce/search/search-actions'; -import {change} from '../../history/history-actions'; -import {executeSearch} from '../../search/search-actions'; -import {FacetOrderState, getFacetOrderInitialState} from './facet-order-state'; +import {setContext, setView} from '../../commerce/context/context-actions.js'; +import {Parameters} from '../../commerce/parameters/parameters-actions.js'; +import {restoreProductListingParameters} from '../../commerce/product-listing-parameters/product-listing-parameters-actions.js'; +import {fetchProductListing} from '../../commerce/product-listing/product-listing-actions.js'; +import {restoreSearchParameters} from '../../commerce/search-parameters/search-parameters-actions.js'; +import {executeSearch as executeCommerceSearch} from '../../commerce/search/search-actions.js'; +import {change} from '../../history/history-actions.js'; +import {executeSearch} from '../../search/search-actions.js'; +import { + FacetOrderState, + getFacetOrderInitialState, +} from './facet-order-state.js'; export const facetOrderReducer = createReducer( getFacetOrderInitialState(), @@ -19,7 +23,9 @@ export const facetOrderReducer = createReducer( .addCase(restoreProductListingParameters, handleRestoreParameters) .addCase(change.fulfilled, (state, action) => { return action.payload?.facetOrder ?? state; - }); + }) + .addCase(setView, () => getFacetOrderInitialState()) + .addCase(setContext, () => getFacetOrderInitialState()); } ); diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-actions.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-actions.ts index a8958e677ce..493e49bef23 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-actions.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-actions.ts @@ -1,14 +1,14 @@ import {NumberValue, RecordValue, ArrayValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {CategoryFacetSearchResult} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; +import {CategoryFacetSearchResult} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; import { validatePayload, requiredNonEmptyString, requiredEmptyAllowedString, -} from '../../../../utils/validate-payload'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; -import {FacetSearchOptions} from '../facet-search-request-options'; -import {facetSearchOptionsDefinition} from '../generic/generic-facet-search-validate-payload'; +} from '../../../../utils/validate-payload.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; +import {FacetSearchOptions} from '../facet-search-request-options.js'; +import {facetSearchOptionsDefinition} from '../generic/generic-facet-search-validate-payload.js'; const categoryFacetSearchResultDefinition = { path: new ArrayValue({ diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.test.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.test.ts index 9af71345a28..1c96d91c92f 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.test.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.test.ts @@ -1,12 +1,12 @@ -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockCategoryFacetRequest} from '../../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSearch} from '../../../../test/mock-category-facet-search'; -import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValueRequest} from '../../../../test/mock-category-facet-value-request'; -import {buildMockNavigatorContextProvider} from '../../../../test/mock-navigator-context-provider'; -import {createMockState} from '../../../../test/mock-state'; -import {buildSearchRequest} from '../../../search/search-request'; -import {buildCategoryFacetSearchRequest} from './category-facet-search-request-builder'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSearch} from '../../../../test/mock-category-facet-search.js'; +import {buildMockCategoryFacetSlice} from '../../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../../../test/mock-category-facet-value-request.js'; +import {buildMockNavigatorContextProvider} from '../../../../test/mock-navigator-context-provider.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import {buildSearchRequest} from '../../../search/search-request.js'; +import {buildCategoryFacetSearchRequest} from './category-facet-search-request-builder.js'; describe('#buildCategoryFacetSearchRequest', () => { const id = '1'; diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.ts index cfc73737f0b..07f2a859e33 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-request-builder.ts @@ -1,9 +1,9 @@ -import {getSearchApiBaseUrl} from '../../../../api/platform-client'; -import {CategoryFacetSearchRequest} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-request'; -import {NavigatorContext} from '../../../../app/navigatorContextProvider'; -import {buildSearchRequest} from '../../../search/search-request'; -import {CategoryFacetRequest} from '../../category-facet-set/interfaces/request'; -import {StateNeededForCategoryFacetSearch} from '../generic/generic-facet-search-state'; +import {getSearchApiBaseUrl} from '../../../../api/platform-client.js'; +import {CategoryFacetSearchRequest} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-request.js'; +import {NavigatorContext} from '../../../../app/navigatorContextProvider.js'; +import {buildSearchRequest} from '../../../search/search-request.js'; +import {CategoryFacetRequest} from '../../category-facet-set/interfaces/request.js'; +import {StateNeededForCategoryFacetSearch} from '../generic/generic-facet-search-state.js'; export const buildCategoryFacetSearchRequest = async ( id: string, diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.test.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.test.ts index 937289306b8..4325b60184e 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.test.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.test.ts @@ -1,31 +1,31 @@ -import {buildMockFacetSearchResponse} from '../../../../test/mock-facet-search-response'; -import {QueryCommerceAPIThunkReturn} from '../../../commerce/common/actions'; +import {buildMockFacetSearchResponse} from '../../../../test/mock-facet-search-response.js'; +import {QueryCommerceAPIThunkReturn} from '../../../commerce/common/actions.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, -} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions'; -import {fetchQuerySuggestions} from '../../../commerce/query-suggest/query-suggest-actions'; +} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions.js'; +import {fetchQuerySuggestions} from '../../../commerce/query-suggest/query-suggest-actions.js'; import { executeSearch as executeCommerceSearch, QuerySearchCommerceAPIThunkReturn, -} from '../../../commerce/search/search-actions'; +} from '../../../commerce/search/search-actions.js'; import { executeSearch, ExecuteSearchThunkReturn, -} from '../../../search/search-actions'; -import * as FacetSearchReducerHelpers from '../facet-search-reducer-helpers'; +} from '../../../search/search-actions.js'; +import * as FacetSearchReducerHelpers from '../facet-search-reducer-helpers.js'; import { clearFacetSearch, executeFacetSearch, -} from '../generic/generic-facet-search-actions'; -import {updateFacetSearch} from '../specific/specific-facet-search-actions'; -import {registerCategoryFacetSearch} from './category-facet-search-actions'; -import {categoryFacetSearchSetReducer} from './category-facet-search-set-slice'; +} from '../generic/generic-facet-search-actions.js'; +import {updateFacetSearch} from '../specific/specific-facet-search-actions.js'; +import {registerCategoryFacetSearch} from './category-facet-search-actions.js'; +import {categoryFacetSearchSetReducer} from './category-facet-search-set-slice.js'; import { CategoryFacetSearchSetState, getCategoryFacetSearchSetInitialState, -} from './category-facet-search-set-state'; +} from './category-facet-search-set-state.js'; describe('CategoryFacetSearchSet slice', () => { const facetId = '1'; @@ -34,7 +34,7 @@ describe('CategoryFacetSearchSet slice', () => { let state: CategoryFacetSearchSetState; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); state = getCategoryFacetSearchSetInitialState(); }); @@ -44,7 +44,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#registerCategoryFacetSearch calls #handleFacetSearchRegistration', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRegistration'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRegistration'); facetSearchSetReducer(state, registerCategoryFacetSearch({facetId})); expect( FacetSearchReducerHelpers.handleFacetSearchRegistration @@ -52,7 +52,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#updateFacetSearch calls #handleFacetSearchUpdate', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchUpdate'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchUpdate'); facetSearchSetReducer(state, updateFacetSearch({facetId})); expect( FacetSearchReducerHelpers.handleFacetSearchUpdate @@ -60,7 +60,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceFacetSearch.pending calls #handleFacetSearchPending', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); const pendingAction = executeCommerceFacetSearch.pending(facetId, { facetId: '', facetSearchType: 'SEARCH', @@ -73,7 +73,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceFieldSuggest.pending calls #handleFacetSearchPending', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); const pendingAction = executeCommerceFieldSuggest.pending(facetId, { facetId, facetSearchType: 'SEARCH', @@ -86,7 +86,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeFacetSearch.pending calls #handleFacetSearchPending', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); const pendingAction = executeFacetSearch.pending(facetId, ''); facetSearchSetReducer(state, pendingAction); @@ -96,7 +96,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceFacetSearch.rejected calls #handleFacetSearchRejected', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); const rejectedAction = executeCommerceFacetSearch.rejected( {name: 'test', message: 'test'}, facetId, @@ -110,7 +110,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceFieldSuggest.rejected calls #handleFacetSearchRejected', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); const rejectedAction = executeCommerceFieldSuggest.rejected( {name: 'test', message: 'test'}, facetId, @@ -124,7 +124,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeFacetSearch.rejected calls #handleFacetSearchRejected', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); const rejectedAction = executeFacetSearch.rejected( {name: 'test', message: 'test'}, facetId, @@ -138,7 +138,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceFacetSearch.fulfilled calls #handleCommerceFacetSearchFulfilled', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleCommerceFacetSearchFulfilled'); + vi.spyOn(FacetSearchReducerHelpers, 'handleCommerceFacetSearchFulfilled'); const response = buildMockFacetSearchResponse(); const action = executeCommerceFacetSearch.fulfilled( {facetId, response: {success: response}}, @@ -153,7 +153,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceFieldSuggest.fulfilled calls #handleCommerceFacetFieldSuggestionsFulfilled', () => { - jest.spyOn( + vi.spyOn( FacetSearchReducerHelpers, 'handleCommerceFacetFieldSuggestionsFulfilled' ); @@ -171,7 +171,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#fetchQuerySuggestions.fulfilled calls #handleCommerceFetchQuerySuggestionsFulfilledForCategoryFacet', () => { - jest.spyOn( + vi.spyOn( FacetSearchReducerHelpers, 'handleCommerceFetchQuerySuggestionsFulfilledForCategoryFacet' ); @@ -196,7 +196,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeFacetSearch.fulfilled calls #handleFacetSearchFulfilled', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchFulfilled'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchFulfilled'); const response = buildMockFacetSearchResponse(); const action = executeFacetSearch.fulfilled({facetId, response}, '', ''); @@ -207,7 +207,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#clearFacetSearch calls #handleFacetSearchClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchClear'); facetSearchSetReducer(state, clearFacetSearch({facetId})); expect( @@ -216,7 +216,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#fetchProductListing.fulfilled calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); const action = fetchProductListing.fulfilled( {} as QueryCommerceAPIThunkReturn, '' @@ -229,7 +229,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeCommerceSearch.fulfilled calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); const action = executeCommerceSearch.fulfilled( {} as QuerySearchCommerceAPIThunkReturn, '' @@ -242,7 +242,7 @@ describe('CategoryFacetSearchSet slice', () => { }); it('#executeSearch.fulfilled calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); const action = executeSearch.fulfilled({} as ExecuteSearchThunkReturn, '', { legacy: null as never, }); diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.ts index 24a8ff93f78..dfd150d356d 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-slice.ts @@ -1,14 +1,14 @@ import {createReducer} from '@reduxjs/toolkit'; -import {CategoryFacetSearchResponse} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; +import {CategoryFacetSearchResponse} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, getFacetIdWithCommerceFieldSuggestionNamespace, -} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions'; -import {fetchQuerySuggestions} from '../../../commerce/query-suggest/query-suggest-actions'; -import {executeSearch as executeCommerceSearch} from '../../../commerce/search/search-actions'; -import {executeSearch} from '../../../search/search-actions'; +} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions.js'; +import {fetchQuerySuggestions} from '../../../commerce/query-suggest/query-suggest-actions.js'; +import {executeSearch as executeCommerceSearch} from '../../../commerce/search/search-actions.js'; +import {executeSearch} from '../../../search/search-actions.js'; import { handleFacetSearchRegistration, handleFacetSearchUpdate, @@ -20,14 +20,14 @@ import { handleCommerceFacetSearchFulfilled, handleCommerceFacetFieldSuggestionsFulfilled, handleCommerceFetchQuerySuggestionsFulfilledForCategoryFacet, -} from '../facet-search-reducer-helpers'; +} from '../facet-search-reducer-helpers.js'; import { clearFacetSearch, executeFacetSearch, -} from '../generic/generic-facet-search-actions'; -import {updateFacetSearch} from '../specific/specific-facet-search-actions'; -import {registerCategoryFacetSearch} from './category-facet-search-actions'; -import {getCategoryFacetSearchSetInitialState} from './category-facet-search-set-state'; +} from '../generic/generic-facet-search-actions.js'; +import {updateFacetSearch} from '../specific/specific-facet-search-actions.js'; +import {registerCategoryFacetSearch} from './category-facet-search-actions.js'; +import {getCategoryFacetSearchSetInitialState} from './category-facet-search-set-state.js'; export const categoryFacetSearchSetReducer = createReducer( getCategoryFacetSearchSetInitialState(), diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-state.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-state.ts index 935f4e3a469..f8be5fb4625 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-state.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-set-state.ts @@ -1,8 +1,8 @@ -import {CategoryFacetSearchResponse} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response'; +import {CategoryFacetSearchResponse} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-response.js'; import { FacetSearchSetState, FacetSearchState, -} from '../facet-search-reducer-helpers'; +} from '../facet-search-reducer-helpers.js'; export type CategoryFacetSearchState = FacetSearchState; diff --git a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-state-selector.ts b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-state-selector.ts index ed38c0c36a4..02ede269b7f 100644 --- a/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-state-selector.ts +++ b/packages/headless/src/features/facets/facet-search-set/category/category-facet-search-state-selector.ts @@ -1,6 +1,6 @@ import {createSelector} from '@reduxjs/toolkit'; -import {CategoryFacetSearchSection} from '../../../../state/state-sections'; -import {CategoryFacetSearchState} from './category-facet-search-set-state'; +import {CategoryFacetSearchSection} from '../../../../state/state-sections.js'; +import {CategoryFacetSearchState} from './category-facet-search-set-state.js'; export const categoryFacetSearchStateSelector = createSelector( (state: CategoryFacetSearchSection, facetId: string) => ({ diff --git a/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.test.ts b/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.test.ts index 719a12f4656..e02a0c34fae 100644 --- a/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.test.ts +++ b/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.test.ts @@ -1,8 +1,8 @@ -import {SpecificFacetSearchResponse} from '../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; -import {buildMockFacetSearch} from '../../../test/mock-facet-search'; -import {buildMockFacetSearchRequestOptions} from '../../../test/mock-facet-search-request-options'; -import {buildMockFacetSearchResponse} from '../../../test/mock-facet-search-response'; -import {buildMockFacetSearchResult} from '../../../test/mock-facet-search-result'; +import {SpecificFacetSearchResponse} from '../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; +import {buildMockFacetSearchRequestOptions} from '../../../test/mock-facet-search-request-options.js'; +import {buildMockFacetSearchResponse} from '../../../test/mock-facet-search-response.js'; +import {buildMockFacetSearchResult} from '../../../test/mock-facet-search-result.js'; +import {buildMockFacetSearch} from '../../../test/mock-facet-search.js'; import { handleFacetSearchRegistration, handleFacetSearchUpdate, @@ -12,11 +12,11 @@ import { handleFacetSearchClear, handleFacetSearchSetClear, defaultFacetSearchOptions, -} from './facet-search-reducer-helpers'; +} from './facet-search-reducer-helpers.js'; import { SpecificFacetSearchSetState, getFacetSearchSetInitialState, -} from './specific/specific-facet-search-set-state'; +} from './specific/specific-facet-search-set-state.js'; describe('FacetSearch slice', () => { const buildEmptyResponse = (): SpecificFacetSearchResponse => ({ diff --git a/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.ts b/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.ts index 024ca1e69b6..131e157ea55 100644 --- a/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.ts +++ b/packages/headless/src/features/facets/facet-search-set/facet-search-reducer-helpers.ts @@ -1,9 +1,9 @@ -import {CommerceAPIResponse} from '../../../api/commerce/commerce-api-client'; -import {FacetSearchRequestOptions} from '../../../api/search/facet-search/base/base-facet-search-request'; -import {FacetSearchResponse} from '../../../api/search/facet-search/facet-search-response'; -import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {FieldSuggestionsFacet} from '../../commerce/facets/field-suggestions-order/field-suggestions-order-state'; -import {FacetSearchOptions} from './facet-search-request-options'; +import {CommerceAPIResponse} from '../../../api/commerce/commerce-api-client.js'; +import {FacetSearchRequestOptions} from '../../../api/search/facet-search/base/base-facet-search-request.js'; +import {FacetSearchResponse} from '../../../api/search/facet-search/facet-search-response.js'; +import {getFacetIdWithCommerceFieldSuggestionNamespace} from '../../commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {FieldSuggestionsFacet} from '../../commerce/facets/field-suggestions-order/field-suggestions-order-state.js'; +import {FacetSearchOptions} from './facet-search-request-options.js'; export type FacetSearchState = { /** diff --git a/packages/headless/src/features/facets/facet-search-set/facet-search-request-options.ts b/packages/headless/src/features/facets/facet-search-set/facet-search-request-options.ts index 8cc423405cd..5a2666112ee 100644 --- a/packages/headless/src/features/facets/facet-search-set/facet-search-request-options.ts +++ b/packages/headless/src/features/facets/facet-search-set/facet-search-request-options.ts @@ -1,5 +1,5 @@ -import {FacetSearchRequestOptions} from '../../../api/search/facet-search/base/base-facet-search-request'; -import {BaseFacetRequest} from '../facet-api/request'; +import {FacetSearchRequestOptions} from '../../../api/search/facet-search/base/base-facet-search-request.js'; +import {BaseFacetRequest} from '../facet-api/request.js'; export type FacetSearchOptions = Pick & Partial; diff --git a/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-actions.ts b/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-actions.ts index 75397b1bc9b..dc634c718ff 100644 --- a/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-actions.ts +++ b/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-actions.ts @@ -3,24 +3,24 @@ import { createAction, createAsyncThunk, } from '@reduxjs/toolkit'; -import {CategoryFacetSearchRequest} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-request'; -import {FacetSearchResponse} from '../../../../api/search/facet-search/facet-search-response'; -import {SpecificFacetSearchRequest} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-request'; -import {FacetSearchAPIClient} from '../../../../api/search/search-api-client'; -import {AsyncThunkOptions} from '../../../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../../../app/thunk-extra-arguments'; +import {CategoryFacetSearchRequest} from '../../../../api/search/facet-search/category-facet-search/category-facet-search-request.js'; +import {FacetSearchResponse} from '../../../../api/search/facet-search/facet-search-response.js'; +import {SpecificFacetSearchRequest} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-request.js'; +import {FacetSearchAPIClient} from '../../../../api/search/search-api-client.js'; +import {AsyncThunkOptions} from '../../../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../../../app/thunk-extra-arguments.js'; import { requiredNonEmptyString, validatePayload, -} from '../../../../utils/validate-payload'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; -import {buildCategoryFacetSearchRequest} from '../category/category-facet-search-request-builder'; -import {buildSpecificFacetSearchRequest} from '../specific/specific-facet-search-request-builder'; +} from '../../../../utils/validate-payload.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; +import {buildCategoryFacetSearchRequest} from '../category/category-facet-search-request-builder.js'; +import {buildSpecificFacetSearchRequest} from '../specific/specific-facet-search-request-builder.js'; import { StateNeededForCategoryFacetSearch, StateNeededForFacetSearch, StateNeededForSpecificFacetSearch, -} from './generic-facet-search-state'; +} from './generic-facet-search-state.js'; type ExecuteFacetSearchThunkReturn = { facetId: string; diff --git a/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-state.ts b/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-state.ts index a4162a3b580..8de260522e6 100644 --- a/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-state.ts +++ b/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-state.ts @@ -4,7 +4,7 @@ import { ConfigurationSection, FacetSearchSection, FacetSection, -} from '../../../../state/state-sections'; +} from '../../../../state/state-sections.js'; export type StateNeededForSpecificFacetSearch = ConfigurationSection & FacetSearchSection & diff --git a/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-validate-payload.ts b/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-validate-payload.ts index 497bf088f61..04915aa079b 100644 --- a/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-validate-payload.ts +++ b/packages/headless/src/features/facets/facet-search-set/generic/generic-facet-search-validate-payload.ts @@ -1,5 +1,5 @@ import {RecordValue, NumberValue, StringValue} from '@coveo/bueno'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; export const facetSearchOptionsDefinition = { facetId: facetIdDefinition, diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-actions.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-actions.ts index e7a9e1b0b4a..ca90bfec84d 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-actions.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-actions.ts @@ -1,13 +1,13 @@ import {RecordValue, NumberValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {SpecificFacetSearchResult} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; +import {SpecificFacetSearchResult} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; import { validatePayload, requiredEmptyAllowedString, -} from '../../../../utils/validate-payload'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; -import {FacetSearchOptions} from '../facet-search-request-options'; -import {facetSearchOptionsDefinition} from '../generic/generic-facet-search-validate-payload'; +} from '../../../../utils/validate-payload.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; +import {FacetSearchOptions} from '../facet-search-request-options.js'; +import {facetSearchOptionsDefinition} from '../generic/generic-facet-search-validate-payload.js'; const selectFacetSearchResultPayloadDefinition = { facetId: facetIdDefinition, diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.test.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.test.ts index 70339d2057a..878792f7dbe 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.test.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.test.ts @@ -1,11 +1,11 @@ -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockFacetSearch} from '../../../../test/mock-facet-search'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {buildMockFacetValueRequest} from '../../../../test/mock-facet-value-request'; -import {buildMockNavigatorContextProvider} from '../../../../test/mock-navigator-context-provider'; -import {createMockState} from '../../../../test/mock-state'; -import {buildSearchRequest} from '../../../search/search-request'; -import {buildSpecificFacetSearchRequest} from './specific-facet-search-request-builder'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockFacetSearch} from '../../../../test/mock-facet-search.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../../test/mock-facet-value-request.js'; +import {buildMockNavigatorContextProvider} from '../../../../test/mock-navigator-context-provider.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import {buildSearchRequest} from '../../../search/search-request.js'; +import {buildSpecificFacetSearchRequest} from './specific-facet-search-request-builder.js'; describe('#buildSpecificFacetSearchRequest', () => { const id = '1'; diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.ts index 05b770111ab..41fab671cf1 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-request-builder.ts @@ -1,8 +1,8 @@ -import {getSearchApiBaseUrl} from '../../../../api/platform-client'; -import {SpecificFacetSearchRequest} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-request'; -import {NavigatorContext} from '../../../../app/navigatorContextProvider'; -import {buildSearchRequest} from '../../../search/search-request'; -import {StateNeededForSpecificFacetSearch} from '../generic/generic-facet-search-state'; +import {getSearchApiBaseUrl} from '../../../../api/platform-client.js'; +import {SpecificFacetSearchRequest} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-request.js'; +import {NavigatorContext} from '../../../../app/navigatorContextProvider.js'; +import {buildSearchRequest} from '../../../search/search-request.js'; +import {StateNeededForSpecificFacetSearch} from '../generic/generic-facet-search-state.js'; export const buildSpecificFacetSearchRequest = async ( id: string, diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.test.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.test.ts index 4ff1928a2af..a0c1902f3b0 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.test.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.test.ts @@ -1,28 +1,28 @@ -import {buildSearchResponse} from '../../../../test/mock-commerce-search'; -import {buildMockFacetSearchResponse} from '../../../../test/mock-facet-search-response'; -import {buildFetchProductListingResponse} from '../../../../test/mock-product-listing'; -import {setView} from '../../../commerce/context/context-actions'; -import {executeCommerceFacetSearch} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions'; -import {executeSearch as executeCommerceSearch} from '../../../commerce/search/search-actions'; +import {buildSearchResponse} from '../../../../test/mock-commerce-search.js'; +import {buildMockFacetSearchResponse} from '../../../../test/mock-facet-search-response.js'; +import {buildFetchProductListingResponse} from '../../../../test/mock-product-listing.js'; +import {setView} from '../../../commerce/context/context-actions.js'; +import {executeCommerceFacetSearch} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions.js'; +import {executeSearch as executeCommerceSearch} from '../../../commerce/search/search-actions.js'; import { executeSearch, ExecuteSearchThunkReturn, -} from '../../../search/search-actions'; -import * as FacetSearchReducerHelpers from '../facet-search-reducer-helpers'; +} from '../../../search/search-actions.js'; +import * as FacetSearchReducerHelpers from '../facet-search-reducer-helpers.js'; import { clearFacetSearch, executeFacetSearch, -} from '../generic/generic-facet-search-actions'; +} from '../generic/generic-facet-search-actions.js'; import { registerFacetSearch, updateFacetSearch, -} from './specific-facet-search-actions'; -import {specificFacetSearchSetReducer} from './specific-facet-search-set-slice'; +} from './specific-facet-search-actions.js'; +import {specificFacetSearchSetReducer} from './specific-facet-search-set-slice.js'; import { getFacetSearchSetInitialState, SpecificFacetSearchSetState, -} from './specific-facet-search-set-state'; +} from './specific-facet-search-set-state.js'; describe('FacetSearch slice', () => { const facetId = '1'; @@ -31,7 +31,7 @@ describe('FacetSearch slice', () => { let state: SpecificFacetSearchSetState; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); state = getFacetSearchSetInitialState(); }); @@ -41,7 +41,7 @@ describe('FacetSearch slice', () => { }); it('on #registerFacetSearch, calls #handleFacetSearchRegistration', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRegistration'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRegistration'); facetSearchSetReducer(state, registerFacetSearch({facetId})); expect( FacetSearchReducerHelpers.handleFacetSearchRegistration @@ -49,7 +49,7 @@ describe('FacetSearch slice', () => { }); it('on #updateFacetSearch, calls #handleFacetSearchUpdate', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchUpdate'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchUpdate'); facetSearchSetReducer(state, updateFacetSearch({facetId})); expect( FacetSearchReducerHelpers.handleFacetSearchUpdate @@ -57,7 +57,7 @@ describe('FacetSearch slice', () => { }); it('on #executeCommerceFacetSearch.pending, calls #handleFacetSearchPending', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); const pendingAction = executeCommerceFacetSearch.pending(facetId, { facetId, facetSearchType: 'SEARCH', @@ -70,7 +70,7 @@ describe('FacetSearch slice', () => { }); it('on #executeFacetSearch.pending, calls #handleFacetSearchPending', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchPending'); const pendingAction = executeFacetSearch.pending(facetId, ''); facetSearchSetReducer(state, pendingAction); @@ -80,7 +80,7 @@ describe('FacetSearch slice', () => { }); it('on #executeCommerceFacetSearch.rejected, calls #handleFacetSearchRejected', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); const rejectedAction = executeCommerceFacetSearch.rejected( {name: 'test', message: 'test'}, facetId, @@ -94,7 +94,7 @@ describe('FacetSearch slice', () => { }); it('on #executeFacetSearch.rejected, calls #handleFacetSearchRejected', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchRejected'); const rejectedAction = executeFacetSearch.rejected( {name: 'test', message: 'test'}, facetId, @@ -108,7 +108,7 @@ describe('FacetSearch slice', () => { }); it('on #executeCommerceFacetSearch.fulfilled, calls #handleCommerceFacetSearchFulfilled', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleCommerceFacetSearchFulfilled'); + vi.spyOn(FacetSearchReducerHelpers, 'handleCommerceFacetSearchFulfilled'); const response = buildMockFacetSearchResponse(); const action = executeCommerceFacetSearch.fulfilled( @@ -129,7 +129,7 @@ describe('FacetSearch slice', () => { }); it('on #executeFacetSearch.fulfilled, calls #handleFacetSearchFulfilled', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchFulfilled'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchFulfilled'); const response = buildMockFacetSearchResponse(); const action = executeFacetSearch.fulfilled({facetId, response}, '', ''); @@ -140,7 +140,7 @@ describe('FacetSearch slice', () => { }); it('on #clearFacetSearch, calls #handleFacetSearchClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchClear'); facetSearchSetReducer(state, clearFacetSearch({facetId})); expect( @@ -149,7 +149,7 @@ describe('FacetSearch slice', () => { }); it('on #executeSearch.fulfilled, calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); const action = executeSearch.fulfilled({} as ExecuteSearchThunkReturn, '', { legacy: null as never, }); @@ -161,7 +161,7 @@ describe('FacetSearch slice', () => { }); it('on #fetchProductListing.fulfilled, calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); const response = buildFetchProductListingResponse(); facetSearchSetReducer(state, fetchProductListing.fulfilled(response, '')); @@ -171,7 +171,7 @@ describe('FacetSearch slice', () => { }); it('on #executeCommerceSearch.fulfilled, calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); const response = buildSearchResponse(); facetSearchSetReducer(state, executeCommerceSearch.fulfilled(response, '')); @@ -181,7 +181,7 @@ describe('FacetSearch slice', () => { }); it('on #setView, calls #handleFacetSearchSetClear', () => { - jest.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); + vi.spyOn(FacetSearchReducerHelpers, 'handleFacetSearchSetClear'); facetSearchSetReducer(state, setView({url: ''})); expect( diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.ts index 98aadee0cc4..22d3b395b09 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-slice.ts @@ -1,15 +1,15 @@ import {createReducer} from '@reduxjs/toolkit'; -import {SpecificFacetSearchResponse} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; -import {setView} from '../../../commerce/context/context-actions'; +import {SpecificFacetSearchResponse} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; +import {setView} from '../../../commerce/context/context-actions.js'; import { executeCommerceFacetSearch, executeCommerceFieldSuggest, getFacetIdWithCommerceFieldSuggestionNamespace, -} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions'; -import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions'; -import {fetchQuerySuggestions} from '../../../commerce/query-suggest/query-suggest-actions'; -import {executeSearch as executeCommerceSearch} from '../../../commerce/search/search-actions'; -import {executeSearch} from '../../../search/search-actions'; +} from '../../../commerce/facets/facet-search-set/commerce-facet-search-actions.js'; +import {fetchProductListing} from '../../../commerce/product-listing/product-listing-actions.js'; +import {fetchQuerySuggestions} from '../../../commerce/query-suggest/query-suggest-actions.js'; +import {executeSearch as executeCommerceSearch} from '../../../commerce/search/search-actions.js'; +import {executeSearch} from '../../../search/search-actions.js'; import { handleCommerceFacetFieldSuggestionsFulfilled, handleCommerceFacetSearchFulfilled, @@ -21,16 +21,16 @@ import { handleFacetSearchRejected, handleFacetSearchSetClear, handleFacetSearchUpdate, -} from '../facet-search-reducer-helpers'; +} from '../facet-search-reducer-helpers.js'; import { clearFacetSearch, executeFacetSearch, -} from '../generic/generic-facet-search-actions'; +} from '../generic/generic-facet-search-actions.js'; import { registerFacetSearch, updateFacetSearch, -} from './specific-facet-search-actions'; -import {getFacetSearchSetInitialState} from './specific-facet-search-set-state'; +} from './specific-facet-search-actions.js'; +import {getFacetSearchSetInitialState} from './specific-facet-search-set-state.js'; export const specificFacetSearchSetReducer = createReducer( getFacetSearchSetInitialState(), diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-state.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-state.ts index 87029d97594..e6a0e52b41c 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-state.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-set-state.ts @@ -1,8 +1,8 @@ -import {SpecificFacetSearchResponse} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response'; +import {SpecificFacetSearchResponse} from '../../../../api/search/facet-search/specific-facet-search/specific-facet-search-response.js'; import { FacetSearchSetState, FacetSearchState, -} from '../facet-search-reducer-helpers'; +} from '../facet-search-reducer-helpers.js'; export type SpecificFacetSearchState = FacetSearchState; diff --git a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-state-selector.ts b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-state-selector.ts index d913e3b7c89..49b6cd0d53c 100644 --- a/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-state-selector.ts +++ b/packages/headless/src/features/facets/facet-search-set/specific/specific-facet-search-state-selector.ts @@ -1,6 +1,6 @@ import {createSelector} from '@reduxjs/toolkit'; -import {FacetSearchSection} from '../../../../state/state-sections'; -import {SpecificFacetSearchState} from './specific-facet-search-set-state'; +import {FacetSearchSection} from '../../../../state/state-sections.js'; +import {SpecificFacetSearchState} from './specific-facet-search-set-state.js'; export const specificFacetSearchStateSelector = createSelector( (state: FacetSearchSection, facetId: string) => ({ diff --git a/packages/headless/src/features/facets/facet-set/facet-set-actions-loader.ts b/packages/headless/src/features/facets/facet-set/facet-set-actions-loader.ts index 5646927374a..e7af65e14d7 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-actions-loader.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-actions-loader.ts @@ -1,10 +1,10 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../../app/search-engine/search-engine'; -import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice'; +import {SearchEngine} from '../../../app/search-engine/search-engine.js'; +import {facetSetReducer as facetSet} from '../../../features/facets/facet-set/facet-set-slice.js'; import { updateFacetAutoSelection, UpdateFacetAutoSelectionActionCreatorPayload, -} from '../generic/facet-actions'; +} from '../generic/facet-actions.js'; import { deselectAllFacetValues, registerFacet, @@ -20,7 +20,7 @@ import { UpdateFacetSortCriterionActionCreatorPayload, updateFreezeCurrentValues, UpdateFreezeCurrentValuesActionCreatorPayload, -} from './facet-set-actions'; +} from './facet-set-actions.js'; export type { RegisterFacetActionCreatorPayload, diff --git a/packages/headless/src/features/facets/facet-set/facet-set-actions.ts b/packages/headless/src/features/facets/facet-set/facet-set-actions.ts index a4d4a9b11a9..2d9c254b5eb 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-actions.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-actions.ts @@ -10,13 +10,13 @@ import {createAction} from '@reduxjs/toolkit'; import { allowedValues, customSort, -} from '../../../controllers/core/facets/_common/facet-option-definitions'; -import {validatePayload} from '../../../utils/validate-payload'; -import {FacetResultsMustMatch} from '../facet-api/request'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; -import {facetValueDefinition} from './facet-set-validate-payload'; -import {FacetSortCriterion} from './interfaces/request'; -import {FacetValue} from './interfaces/response'; +} from '../../../controllers/core/facets/_common/facet-option-definitions.js'; +import {validatePayload} from '../../../utils/validate-payload.js'; +import {FacetResultsMustMatch} from '../facet-api/request.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; +import {facetValueDefinition} from './facet-set-validate-payload.js'; +import {FacetSortCriterion} from './interfaces/request.js'; +import {FacetValue} from './interfaces/response.js'; export interface RegisterFacetActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.test.ts b/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.test.ts index 7f5cdd2aef0..1b991f7b0bd 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.test.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.test.ts @@ -1,20 +1,20 @@ -import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request'; -import {buildMockDateFacetRequest} from '../../../test/mock-date-facet-request'; -import {buildMockDateFacetSlice} from '../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../test/mock-date-facet-value'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request'; -import {buildMockNumericFacetRequest} from '../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetSlice} from '../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../test/mock-state'; +import {buildMockCategoryFacetRequest} from '../../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSlice} from '../../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../../test/mock-category-facet-value-request.js'; +import {buildMockDateFacetRequest} from '../../../test/mock-date-facet-request.js'; +import {buildMockDateFacetSlice} from '../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../test/mock-date-facet-value.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request.js'; +import {buildMockNumericFacetRequest} from '../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetSlice} from '../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../test/mock-state.js'; import { buildFacetSelectionChangeMetadata, buildFacetStateMetadata, -} from './facet-set-analytics-actions-utils'; +} from './facet-set-analytics-actions-utils.js'; describe('facet-set-analytics-action-utils', () => { describe('#buildFacetStateMetadata & #buildFacetSelectionChangeMetadata', () => { diff --git a/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.ts b/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.ts index 86bbbd4ebcf..8acaf67ed7f 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions-utils.ts @@ -1,33 +1,33 @@ -import {FacetStateMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; +import {FacetStateMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; import { AutomaticFacetSection, CategoryFacetSection, DateFacetSection, FacetSection, NumericFacetSection, -} from '../../../state/state-sections'; -import {getAutomaticFacetSetInitialState} from '../automatic-facet-set/automatic-facet-set-state'; -import {AutomaticFacetResponse} from '../automatic-facet-set/interfaces/response'; -import {categoryFacetRequestSelectedValuesSelector} from '../category-facet-set/category-facet-set-selectors'; -import {getCategoryFacetSetInitialState} from '../category-facet-set/category-facet-set-state'; -import {CategoryFacetRequest} from '../category-facet-set/interfaces/request'; -import {FacetType} from '../facet-api/request'; +} from '../../../state/state-sections.js'; +import {getAutomaticFacetSetInitialState} from '../automatic-facet-set/automatic-facet-set-state.js'; +import {AutomaticFacetResponse} from '../automatic-facet-set/interfaces/response.js'; +import {categoryFacetRequestSelectedValuesSelector} from '../category-facet-set/category-facet-set-selectors.js'; +import {getCategoryFacetSetInitialState} from '../category-facet-set/category-facet-set-state.js'; +import {CategoryFacetRequest} from '../category-facet-set/interfaces/request.js'; +import {FacetType} from '../facet-api/request.js'; import { AnyFacetRequest, AnyFacetValueRequest, -} from '../generic/interfaces/generic-facet-request'; -import {getDateFacetSetInitialState} from '../range-facets/date-facet-set/date-facet-set-state'; +} from '../generic/interfaces/generic-facet-request.js'; +import {getDateFacetSetInitialState} from '../range-facets/date-facet-set/date-facet-set-state.js'; import { DateFacetRequest, DateRangeRequest, -} from '../range-facets/date-facet-set/interfaces/request'; +} from '../range-facets/date-facet-set/interfaces/request.js'; import { NumericFacetRequest, NumericRangeRequest, -} from '../range-facets/numeric-facet-set/interfaces/request'; -import {getNumericFacetSetInitialState} from '../range-facets/numeric-facet-set/numeric-facet-set-state'; -import {getFacetSetInitialState} from './facet-set-state'; -import {FacetRequest, FacetValueRequest} from './interfaces/request'; +} from '../range-facets/numeric-facet-set/interfaces/request.js'; +import {getNumericFacetSetInitialState} from '../range-facets/numeric-facet-set/numeric-facet-set-state.js'; +import {getFacetSetInitialState} from './facet-set-state.js'; +import {FacetRequest, FacetValueRequest} from './interfaces/request.js'; export type SectionNeededForFacetMetadata = FacetSection & CategoryFacetSection & diff --git a/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions.ts b/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions.ts index 2ccff8c31b6..945300e804d 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-analytics-actions.ts @@ -2,21 +2,21 @@ import {Value} from '@coveo/bueno'; import { validatePayload, requiredNonEmptyString, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../analytics/search-action-cause'; -import {SearchAction} from '../../search/search-actions'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; -import {RangeFacetSortCriterion} from '../range-facets/generic/interfaces/request'; +} from '../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../analytics/search-action-cause.js'; +import {SearchAction} from '../../search/search-actions.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; +import {RangeFacetSortCriterion} from '../range-facets/generic/interfaces/request.js'; import { buildFacetBaseMetadata, getStateNeededForFacetMetadata, buildFacetSelectionChangeMetadata, -} from './facet-set-analytics-actions-utils'; -import {FacetSortCriterion} from './interfaces/request'; +} from './facet-set-analytics-actions-utils.js'; +import {FacetSortCriterion} from './interfaces/request.js'; export const logFacetShowMore = (facetId: string): LegacySearchAction => makeAnalyticsAction('analytics/facet/showMore', (client, state) => { diff --git a/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.test.ts b/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.test.ts index 8136e3b679b..8c11460ee8d 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.test.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.test.ts @@ -1,22 +1,22 @@ -import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments'; +import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {createMockState} from '../../../test/mock-state'; -import {updateFacetOptions} from '../../facet-options/facet-options-actions'; +} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {updateFacetOptions} from '../../facet-options/facet-options-actions.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from './facet-set-actions'; +} from './facet-set-actions.js'; import { executeToggleFacetExclude, executeToggleFacetSelect, -} from './facet-set-controller-actions'; +} from './facet-set-controller-actions.js'; -jest.mock('./facet-set-actions'); -jest.mock('../../facet-options/facet-options-actions'); +vi.mock('./facet-set-actions'); +vi.mock('../../facet-options/facet-options-actions'); describe('facet set controller actions', () => { let engine: MockedSearchEngine; @@ -31,7 +31,7 @@ describe('facet set controller actions', () => { await executeToggleFacetSelect({facetId, selection})( engine.dispatch, () => engine.state as Required, - {validatePayload: jest.fn()} as unknown as ThunkExtraArguments + {validatePayload: vi.fn()} as unknown as ThunkExtraArguments ); expect(toggleSelectFacetValue).toHaveBeenCalledWith({facetId, selection}); @@ -43,7 +43,7 @@ describe('facet set controller actions', () => { await executeToggleFacetExclude({facetId, selection})( engine.dispatch, () => engine.state as Required, - {validatePayload: jest.fn()} as unknown as ThunkExtraArguments + {validatePayload: vi.fn()} as unknown as ThunkExtraArguments ); expect(toggleExcludeFacetValue).toHaveBeenCalledWith({facetId, selection}); diff --git a/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.ts b/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.ts index de73427dd45..986681d8000 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-controller-actions.ts @@ -1,18 +1,18 @@ import {RecordValue} from '@coveo/bueno'; import {createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkOptions} from '../../../app/async-thunk-options'; +import {AsyncThunkOptions} from '../../../app/async-thunk-options.js'; import { ConfigurationSection, FacetSection, -} from '../../../state/state-sections'; -import {updateFacetOptions} from '../../facet-options/facet-options-actions'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; +} from '../../../state/state-sections.js'; +import {updateFacetOptions} from '../../facet-options/facet-options-actions.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; import { toggleExcludeFacetValue, toggleSelectFacetValue, -} from './facet-set-actions'; -import {facetValueDefinition} from './facet-set-validate-payload'; -import {FacetValue} from './interfaces/response'; +} from './facet-set-actions.js'; +import {facetValueDefinition} from './facet-set-validate-payload.js'; +import {FacetValue} from './interfaces/response.js'; const definition = { facetId: facetIdDefinition, diff --git a/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.test.ts b/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.test.ts index c4756616995..6de3748f210 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.test.ts @@ -1,10 +1,10 @@ -import {InsightEngine} from '../../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../../test/mock-engine-v2'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../../configuration/configuration-state'; +import {InsightEngine} from '../../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../../test/mock-engine-v2.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../../configuration/configuration-state.js'; import { logFacetBreadcrumb, logFacetClearAll, @@ -13,18 +13,18 @@ import { logFacetUpdateSort, logFacetShowMore, logFacetShowLess, -} from './facet-set-insight-analytics-actions'; - -const mockLogBreadcrumbFacet = jest.fn(); -const mockLogFacetSelect = jest.fn(); -const mockLogFacetDeselect = jest.fn(); -const mockLogFacetUpdateSort = jest.fn(); -const mockLogFacetClearAll = jest.fn(); -const mockLogFacetShowMore = jest.fn(); -const mockLogFacetShowLess = jest.fn(); - -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +} from './facet-set-insight-analytics-actions.js'; + +const mockLogBreadcrumbFacet = vi.fn(); +const mockLogFacetSelect = vi.fn(); +const mockLogFacetDeselect = vi.fn(); +const mockLogFacetUpdateSort = vi.fn(); +const mockLogFacetClearAll = vi.fn(); +const mockLogFacetShowMore = vi.fn(); +const mockLogFacetShowLess = vi.fn(); + +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logBreadcrumbFacet: mockLogBreadcrumbFacet, logFacetSelect: mockLogFacetSelect, @@ -37,7 +37,7 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -66,7 +66,7 @@ describe('facet set insight analytics actions', () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); const configuration = getConfigurationInitialState(); configuration.analytics.analyticsMode = 'legacy'; diff --git a/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.ts b/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.ts index a542ec84913..c2d12cd3dff 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-insight-analytics-actions.ts @@ -2,22 +2,22 @@ import {Value} from '@coveo/bueno'; import { validatePayload, requiredNonEmptyString, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../../case-context/case-context-state'; -import {facetIdDefinition} from '../generic/facet-actions-validation'; -import {RangeFacetSortCriterion} from '../range-facets/generic/interfaces/request'; -import {LogFacetBreadcrumbActionCreatorPayload} from './facet-set-analytics-actions'; +} from '../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../../case-context/case-context-state.js'; +import {facetIdDefinition} from '../generic/facet-actions-validation.js'; +import {RangeFacetSortCriterion} from '../range-facets/generic/interfaces/request.js'; import { buildFacetBaseMetadata, getStateNeededForFacetMetadata, buildFacetSelectionChangeMetadata, -} from './facet-set-analytics-actions-utils'; -import {FacetSortCriterion} from './interfaces/request'; +} from './facet-set-analytics-actions-utils.js'; +import {LogFacetBreadcrumbActionCreatorPayload} from './facet-set-analytics-actions.js'; +import {FacetSortCriterion} from './interfaces/request.js'; export const logFacetShowMore = (facetId: string): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.facetShowMore)( diff --git a/packages/headless/src/features/facets/facet-set/facet-set-insight-utils.ts b/packages/headless/src/features/facets/facet-set/facet-set-insight-utils.ts index 4a93f9ae717..2e6a7a7d20d 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-insight-utils.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-insight-utils.ts @@ -1,9 +1,9 @@ -import {FacetSelectionChangeMetadata} from './facet-set-analytics-actions-utils'; +import {FacetSelectionChangeMetadata} from './facet-set-analytics-actions-utils.js'; import { logFacetDeselect, logFacetSelect, -} from './facet-set-insight-analytics-actions'; -import {FacetValue} from './interfaces/response'; +} from './facet-set-insight-analytics-actions.js'; +import {FacetValue} from './interfaces/response.js'; export const isFacetValueSelected = (value: FacetValue) => { return value.state === 'selected'; diff --git a/packages/headless/src/features/facets/facet-set/facet-set-selectors.test.ts b/packages/headless/src/features/facets/facet-set/facet-set-selectors.test.ts index 7f819477511..ac26b614704 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-selectors.test.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-selectors.test.ts @@ -1,14 +1,14 @@ -import {SearchAppState} from '../../../state/search-app-state'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {createMockState} from '../../../test/mock-state'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {createMockState} from '../../../test/mock-state.js'; import { baseFacetResponseSelector, facetRequestSelector, facetResponseSelectedValuesSelector, -} from './facet-set-selectors'; +} from './facet-set-selectors.js'; describe('facet-set selectors', () => { it('#facetSelector gets the facet response by id', () => { diff --git a/packages/headless/src/features/facets/facet-set/facet-set-selectors.ts b/packages/headless/src/features/facets/facet-set/facet-set-selectors.ts index c51446c0d5e..4f9924ee347 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-selectors.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-selectors.ts @@ -1,7 +1,7 @@ -import {SearchSection} from '../../../state/state-sections'; -import {FacetSection} from '../../../state/state-sections'; -import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response'; -import {FacetResponse, FacetValue} from './interfaces/response'; +import {SearchSection} from '../../../state/state-sections.js'; +import {FacetSection} from '../../../state/state-sections.js'; +import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response.js'; +import {FacetResponse, FacetValue} from './interfaces/response.js'; function isFacetResponse( state: FacetSection, diff --git a/packages/headless/src/features/facets/facet-set/facet-set-slice.test.ts b/packages/headless/src/features/facets/facet-set/facet-set-slice.test.ts index 39d6c123323..f0421d08a04 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-slice.test.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-slice.test.ts @@ -1,31 +1,31 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../test/mock-facet-response'; -import {buildMockFacetSearchResult} from '../../../test/mock-facet-search-result'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../../test/mock-facet-value'; -import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request'; -import {buildMockSearch} from '../../../test/mock-search'; -import {logSearchEvent} from '../../analytics/analytics-actions'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../test/mock-facet-response.js'; +import {buildMockFacetSearchResult} from '../../../test/mock-facet-search-result.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request.js'; +import {buildMockFacetValue} from '../../../test/mock-facet-value.js'; +import {buildMockSearch} from '../../../test/mock-search.js'; +import {logSearchEvent} from '../../analytics/analytics-actions.js'; import { deselectAllBreadcrumbs, deselectAllNonBreadcrumbs, -} from '../../breadcrumb/breadcrumb-actions'; -import {change} from '../../history/history-actions'; -import {getHistoryInitialState} from '../../history/history-state'; -import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions'; +} from '../../breadcrumb/breadcrumb-actions.js'; +import {change} from '../../history/history-actions.js'; +import {getHistoryInitialState} from '../../history/history-state.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions.js'; import { executeSearch, ExecuteSearchThunkReturn, fetchFacetValues, -} from '../../search/search-actions'; +} from '../../search/search-actions.js'; import { excludeFacetSearchResult, selectFacetSearchResult, -} from '../facet-search-set/specific/specific-facet-search-actions'; -import {updateFacetAutoSelection} from '../generic/facet-actions'; -import * as FacetReducers from '../generic/facet-reducer-helpers'; -import {FacetValueState, facetValueStates} from './../facet-api/value'; +} from '../facet-search-set/specific/specific-facet-search-actions.js'; +import {updateFacetAutoSelection} from '../generic/facet-actions.js'; +import * as FacetReducers from '../generic/facet-reducer-helpers.js'; +import {FacetValueState, facetValueStates} from './../facet-api/value.js'; import { registerFacet, toggleSelectFacetValue, @@ -36,10 +36,13 @@ import { updateFacetIsFieldExpanded, updateFreezeCurrentValues, RegisterFacetActionCreatorPayload, -} from './facet-set-actions'; -import {facetSetReducer, convertFacetValueToRequest} from './facet-set-slice'; -import {FacetSetState, getFacetSetInitialState} from './facet-set-state'; -import {FacetResponse} from './interfaces/response'; +} from './facet-set-actions.js'; +import { + facetSetReducer, + convertFacetValueToRequest, +} from './facet-set-slice.js'; +import {FacetSetState, getFacetSetInitialState} from './facet-set-state.js'; +import {FacetResponse} from './interfaces/response.js'; describe('facet-set slice', () => { let state: FacetSetState; @@ -402,7 +405,7 @@ describe('facet-set slice', () => { }); it('dispatching #deselectAllFacetValues calls #handleFacetDeselectAll', () => { - jest.spyOn(FacetReducers, 'handleFacetDeselectAll'); + vi.spyOn(FacetReducers, 'handleFacetDeselectAll'); facetSetReducer(state, deselectAllFacetValues('1')); expect(FacetReducers.handleFacetDeselectAll).toHaveBeenCalledTimes(1); @@ -424,7 +427,7 @@ describe('facet-set slice', () => { }); it('dispatching #deselectAllBreadcrumbs calls #handleFacetDeselectAll for every facet', () => { - jest.spyOn(FacetReducers, 'handleFacetDeselectAll').mockReset(); + vi.spyOn(FacetReducers, 'handleFacetDeselectAll').mockReset(); state['1'] = buildMockFacetSlice(); state['2'] = buildMockFacetSlice(); @@ -434,7 +437,7 @@ describe('facet-set slice', () => { }); it('dispatching #deselectAllBreadcrumbs does not call #handleFacetDeselectAll for a facet where hasBreadcrumbs is false', () => { - jest.spyOn(FacetReducers, 'handleFacetDeselectAll').mockReset(); + vi.spyOn(FacetReducers, 'handleFacetDeselectAll').mockReset(); state['1'] = buildMockFacetSlice({ hasBreadcrumbs: false, @@ -445,7 +448,7 @@ describe('facet-set slice', () => { }); it('dispatching #deselectAllBreadcrumbs does not call #handleFacetDeselectAll for a facet where hasBreadcrumbs is false', () => { - jest.spyOn(FacetReducers, 'handleFacetDeselectAll').mockReset(); + vi.spyOn(FacetReducers, 'handleFacetDeselectAll').mockReset(); state['1'] = buildMockFacetSlice({ hasBreadcrumbs: false, @@ -462,7 +465,7 @@ describe('facet-set slice', () => { }); it('dispatching #updateFacetSortCriterion calls #handleFacetSortCriterionUpdate', () => { - jest.spyOn(FacetReducers, 'handleFacetSortCriterionUpdate'); + vi.spyOn(FacetReducers, 'handleFacetSortCriterionUpdate'); const action = updateFacetSortCriterion({ facetId: '1', criterion: 'alphanumeric', @@ -475,7 +478,7 @@ describe('facet-set slice', () => { }); it('dispatching #updateFacetNumberOfValues calls #handleFacetUpdateNumberOfValues', () => { - jest.spyOn(FacetReducers, 'handleFacetUpdateNumberOfValues'); + vi.spyOn(FacetReducers, 'handleFacetUpdateNumberOfValues'); facetSetReducer( state, updateFacetNumberOfValues({ diff --git a/packages/headless/src/features/facets/facet-set/facet-set-slice.ts b/packages/headless/src/features/facets/facet-set/facet-set-slice.ts index 3a175fbb418..e8cba394580 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-slice.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-slice.ts @@ -2,22 +2,22 @@ import {createReducer, type Draft as WritableDraft} from '@reduxjs/toolkit'; import { deselectAllBreadcrumbs, deselectAllNonBreadcrumbs, -} from '../../breadcrumb/breadcrumb-actions'; -import {disableFacet} from '../../facet-options/facet-options-actions'; -import {change} from '../../history/history-actions'; -import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions'; -import {executeSearch, fetchFacetValues} from '../../search/search-actions'; +} from '../../breadcrumb/breadcrumb-actions.js'; +import {disableFacet} from '../../facet-options/facet-options-actions.js'; +import {change} from '../../history/history-actions.js'; +import {restoreSearchParameters} from '../../search-parameters/search-parameter-actions.js'; +import {executeSearch, fetchFacetValues} from '../../search/search-actions.js'; import { excludeFacetSearchResult, selectFacetSearchResult, -} from '../facet-search-set/specific/specific-facet-search-actions'; -import {updateFacetAutoSelection} from '../generic/facet-actions'; +} from '../facet-search-set/specific/specific-facet-search-actions.js'; +import {updateFacetAutoSelection} from '../generic/facet-actions.js'; import { handleFacetSortCriterionUpdate, handleFacetDeselectAll, handleFacetUpdateNumberOfValues, -} from '../generic/facet-reducer-helpers'; -import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response'; +} from '../generic/facet-reducer-helpers.js'; +import {AnyFacetResponse} from '../generic/interfaces/generic-facet-response.js'; import { registerFacet, toggleSelectFacetValue, @@ -28,14 +28,14 @@ import { updateFacetIsFieldExpanded, updateFreezeCurrentValues, RegisterFacetActionCreatorPayload, -} from './facet-set-actions'; +} from './facet-set-actions.js'; import { getFacetSetInitialState, getFacetSetSliceInitialState, -} from './facet-set-state'; -import {FacetOptionalParameters} from './interfaces/options'; -import {FacetRequest, FacetValueRequest} from './interfaces/request'; -import {FacetValue, FacetResponse} from './interfaces/response'; +} from './facet-set-state.js'; +import {FacetOptionalParameters} from './interfaces/options.js'; +import {FacetRequest, FacetValueRequest} from './interfaces/request.js'; +import {FacetValue, FacetResponse} from './interfaces/response.js'; export const facetSetReducer = createReducer( getFacetSetInitialState(), diff --git a/packages/headless/src/features/facets/facet-set/facet-set-state.ts b/packages/headless/src/features/facets/facet-set/facet-set-state.ts index dace1aeebba..b9104c05a17 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-state.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-state.ts @@ -1,4 +1,4 @@ -import {FacetRequest} from './interfaces/request'; +import {FacetRequest} from './interfaces/request.js'; export type FacetSlice = { request: FacetRequest; diff --git a/packages/headless/src/features/facets/facet-set/facet-set-utils.ts b/packages/headless/src/features/facets/facet-set/facet-set-utils.ts index f431fd4c3f4..e1a3fd44148 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-utils.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-utils.ts @@ -1,4 +1,5 @@ -import {SearchAction} from '../../search/search-actions'; +import {SearchAction} from '../../search/search-actions.js'; +import {FacetSelectionChangeMetadata} from './facet-set-analytics-actions-utils.js'; import { facetDeselect, facetExclude, @@ -8,9 +9,8 @@ import { logFacetExclude, logFacetSelect, logFacetUnexclude, -} from './facet-set-analytics-actions'; -import {FacetSelectionChangeMetadata} from './facet-set-analytics-actions-utils'; -import {FacetValue} from './interfaces/response'; +} from './facet-set-analytics-actions.js'; +import {FacetValue} from './interfaces/response.js'; export const isFacetValueSelected = (value: FacetValue) => { return value.state === 'selected'; diff --git a/packages/headless/src/features/facets/facet-set/facet-set-validate-payload.ts b/packages/headless/src/features/facets/facet-set/facet-set-validate-payload.ts index bea36e900f1..4b2edcf5967 100644 --- a/packages/headless/src/features/facets/facet-set/facet-set-validate-payload.ts +++ b/packages/headless/src/features/facets/facet-set/facet-set-validate-payload.ts @@ -1,5 +1,5 @@ import {NumberValue} from '@coveo/bueno'; -import {requiredNonEmptyString} from '../../../utils/validate-payload'; +import {requiredNonEmptyString} from '../../../utils/validate-payload.js'; export const facetValueDefinition = { value: requiredNonEmptyString, diff --git a/packages/headless/src/features/facets/facet-set/interfaces/options.ts b/packages/headless/src/features/facets/facet-set/interfaces/options.ts index df66bfda5de..adbafa3d539 100644 --- a/packages/headless/src/features/facets/facet-set/interfaces/options.ts +++ b/packages/headless/src/features/facets/facet-set/interfaces/options.ts @@ -1,4 +1,4 @@ -import {FacetOptions} from '../../../../controllers/core/facets/facet/headless-core-facet-options'; +import {FacetOptions} from '../../../../controllers/core/facets/facet/headless-core-facet-options.js'; export type FacetOptionalParameters = Required< Pick< diff --git a/packages/headless/src/features/facets/facet-set/interfaces/request.ts b/packages/headless/src/features/facets/facet-set/interfaces/request.ts index 0e484a3aa37..de5a551122e 100644 --- a/packages/headless/src/features/facets/facet-set/interfaces/request.ts +++ b/packages/headless/src/features/facets/facet-set/interfaces/request.ts @@ -9,7 +9,7 @@ import { AllowedValues, CustomSort, SpecificSortCriteriaExplicitAlphanumeric, -} from '../../facet-api/request'; +} from '../../facet-api/request.js'; export const facetSortCriteria: FacetSortCriterion[] = [ 'score', diff --git a/packages/headless/src/features/facets/facet-set/interfaces/response.ts b/packages/headless/src/features/facets/facet-set/interfaces/response.ts index 1ceb20ca500..a4ce2d20f31 100644 --- a/packages/headless/src/features/facets/facet-set/interfaces/response.ts +++ b/packages/headless/src/features/facets/facet-set/interfaces/response.ts @@ -1,4 +1,4 @@ -import {BaseFacetValue, BaseFacetResponse} from '../../facet-api/response'; +import {BaseFacetValue, BaseFacetResponse} from '../../facet-api/response.js'; export interface FacetValue extends BaseFacetValue { value: string; diff --git a/packages/headless/src/features/facets/generic/facet-actions-validation.ts b/packages/headless/src/features/facets/generic/facet-actions-validation.ts index c21064921d6..c7dc2a80699 100644 --- a/packages/headless/src/features/facets/generic/facet-actions-validation.ts +++ b/packages/headless/src/features/facets/generic/facet-actions-validation.ts @@ -1,3 +1,3 @@ -import {requiredNonEmptyString} from '../../../utils/validate-payload'; +import {requiredNonEmptyString} from '../../../utils/validate-payload.js'; export const facetIdDefinition = requiredNonEmptyString; diff --git a/packages/headless/src/features/facets/generic/facet-actions.ts b/packages/headless/src/features/facets/generic/facet-actions.ts index 197f947c20b..4d86e02d3ca 100644 --- a/packages/headless/src/features/facets/generic/facet-actions.ts +++ b/packages/headless/src/features/facets/generic/facet-actions.ts @@ -1,6 +1,6 @@ import {BooleanValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../utils/validate-payload'; +import {validatePayload} from '../../../utils/validate-payload.js'; export interface UpdateFacetAutoSelectionActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/generic/facet-generic-analytics-actions.ts b/packages/headless/src/features/facets/generic/facet-generic-analytics-actions.ts index 338b07c4506..0021f7b4d66 100644 --- a/packages/headless/src/features/facets/generic/facet-generic-analytics-actions.ts +++ b/packages/headless/src/features/facets/generic/facet-generic-analytics-actions.ts @@ -1,7 +1,7 @@ import { makeAnalyticsAction, LegacySearchAction, -} from '../../analytics/analytics-utils'; +} from '../../analytics/analytics-utils.js'; //TODO: KIT-2859 export const logClearBreadcrumbs = (): LegacySearchAction => diff --git a/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.test.ts b/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.test.ts index fbe0e5fed00..13c05846c13 100644 --- a/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.test.ts @@ -1,20 +1,20 @@ -import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../../configuration/configuration-state'; -import {logClearBreadcrumbs} from './facet-generic-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../../configuration/configuration-state.js'; +import {logClearBreadcrumbs} from './facet-generic-insight-analytics-actions.js'; -const mockLogBreadcrumbResetAll = jest.fn(); +const mockLogBreadcrumbResetAll = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logBreadcrumbResetAll: mockLogBreadcrumbResetAll, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.ts b/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.ts index 4e2f9677110..8c6e290b426 100644 --- a/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.ts +++ b/packages/headless/src/features/facets/generic/facet-generic-insight-analytics-actions.ts @@ -1,9 +1,9 @@ import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../../case-context/case-context-state'; +} from '../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../../case-context/case-context-state.js'; export const logClearBreadcrumbs = (): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.breadcrumbResetAll)( diff --git a/packages/headless/src/features/facets/generic/facet-reducer-helpers.test.ts b/packages/headless/src/features/facets/generic/facet-reducer-helpers.test.ts index feea4fc25c5..60cb6630172 100644 --- a/packages/headless/src/features/facets/generic/facet-reducer-helpers.test.ts +++ b/packages/headless/src/features/facets/generic/facet-reducer-helpers.test.ts @@ -1,12 +1,12 @@ -import {buildMockFacetRequest} from '../../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../../test/mock-facet-slice'; -import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request'; -import {FacetRequest} from '../facet-set/interfaces/request'; +import {buildMockFacetRequest} from '../../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../../test/mock-facet-slice.js'; +import {buildMockFacetValueRequest} from '../../../test/mock-facet-value-request.js'; +import {FacetRequest} from '../facet-set/interfaces/request.js'; import { handleFacetSortCriterionUpdate, handleFacetDeselectAll, handleFacetUpdateNumberOfValues, -} from './facet-reducer-helpers'; +} from './facet-reducer-helpers.js'; describe('generic facet reducers', () => { describe('#handleFacetSortCriterionUpdate', () => { diff --git a/packages/headless/src/features/facets/generic/facet-reducer-helpers.ts b/packages/headless/src/features/facets/generic/facet-reducer-helpers.ts index 5c79b096e01..75692aad39a 100644 --- a/packages/headless/src/features/facets/generic/facet-reducer-helpers.ts +++ b/packages/headless/src/features/facets/generic/facet-reducer-helpers.ts @@ -1,7 +1,7 @@ -import {AnyFacetRequest as AnyCommerceFacetRequest} from '../../commerce/facets/facet-set/interfaces/request'; -import {FacetRequest} from '../facet-set/interfaces/request'; -import {AnyFacetRequest} from './interfaces/generic-facet-request'; -import {AnyFacetSlice} from './interfaces/generic-facet-section'; +import {AnyFacetRequest as AnyCommerceFacetRequest} from '../../commerce/facets/facet-set/interfaces/request.js'; +import {FacetRequest} from '../facet-set/interfaces/request.js'; +import {AnyFacetRequest} from './interfaces/generic-facet-request.js'; +import {AnyFacetSlice} from './interfaces/generic-facet-section.js'; export type SpecificFacetState< SliceType extends AnyFacetSlice = AnyFacetSlice, diff --git a/packages/headless/src/features/facets/generic/interfaces/generic-facet-request.ts b/packages/headless/src/features/facets/generic/interfaces/generic-facet-request.ts index 5c926699dae..d1291191760 100644 --- a/packages/headless/src/features/facets/generic/interfaces/generic-facet-request.ts +++ b/packages/headless/src/features/facets/generic/interfaces/generic-facet-request.ts @@ -1,15 +1,15 @@ import { CategoryFacetRequest, CategoryFacetValueRequest, -} from '../../category-facet-set/interfaces/request'; +} from '../../category-facet-set/interfaces/request.js'; import { FacetRequest, FacetValueRequest, -} from '../../facet-set/interfaces/request'; -import {DateRangeRequest} from '../../range-facets/date-facet-set/interfaces/request'; -import {RangeFacetRequest} from '../../range-facets/generic/interfaces/range-facet'; -import {NumericRangeRequest} from '../../range-facets/numeric-facet-set/interfaces/request'; -import {AnyFacetSetState} from './generic-facet-section'; +} from '../../facet-set/interfaces/request.js'; +import {DateRangeRequest} from '../../range-facets/date-facet-set/interfaces/request.js'; +import {RangeFacetRequest} from '../../range-facets/generic/interfaces/range-facet.js'; +import {NumericRangeRequest} from '../../range-facets/numeric-facet-set/interfaces/request.js'; +import {AnyFacetSetState} from './generic-facet-section.js'; export type AnyFacetRequest = | FacetRequest diff --git a/packages/headless/src/features/facets/generic/interfaces/generic-facet-response.ts b/packages/headless/src/features/facets/generic/interfaces/generic-facet-response.ts index 6fa036d9a79..94fa4898d47 100644 --- a/packages/headless/src/features/facets/generic/interfaces/generic-facet-response.ts +++ b/packages/headless/src/features/facets/generic/interfaces/generic-facet-response.ts @@ -1,11 +1,14 @@ import { CategoryFacetResponse, CategoryFacetValue, -} from '../../category-facet-set/interfaces/response'; -import {FacetResponse, FacetValue} from '../../facet-set/interfaces/response'; -import {DateFacetValue} from '../../range-facets/date-facet-set/interfaces/response'; -import {RangeFacetResponse} from '../../range-facets/generic/interfaces/range-facet'; -import {NumericFacetValue} from '../../range-facets/numeric-facet-set/interfaces/response'; +} from '../../category-facet-set/interfaces/response.js'; +import { + FacetResponse, + FacetValue, +} from '../../facet-set/interfaces/response.js'; +import {DateFacetValue} from '../../range-facets/date-facet-set/interfaces/response.js'; +import {RangeFacetResponse} from '../../range-facets/generic/interfaces/range-facet.js'; +import {NumericFacetValue} from '../../range-facets/numeric-facet-set/interfaces/response.js'; export type AnyFacetResponse = | FacetResponse diff --git a/packages/headless/src/features/facets/generic/interfaces/generic-facet-section.ts b/packages/headless/src/features/facets/generic/interfaces/generic-facet-section.ts index 55406349fb5..089d5aa6141 100644 --- a/packages/headless/src/features/facets/generic/interfaces/generic-facet-section.ts +++ b/packages/headless/src/features/facets/generic/interfaces/generic-facet-section.ts @@ -3,11 +3,11 @@ import { DateFacetSection, FacetSection, NumericFacetSection, -} from '../../../../state/state-sections'; -import {CategoryFacetSlice} from '../../category-facet-set/category-facet-set-state'; -import {FacetSlice} from '../../facet-set/facet-set-state'; -import {DateFacetSlice} from '../../range-facets/date-facet-set/date-facet-set-state'; -import {NumericFacetSlice} from '../../range-facets/numeric-facet-set/numeric-facet-set-state'; +} from '../../../../state/state-sections.js'; +import {CategoryFacetSlice} from '../../category-facet-set/category-facet-set-state.js'; +import {FacetSlice} from '../../facet-set/facet-set-state.js'; +import {DateFacetSlice} from '../../range-facets/date-facet-set/date-facet-set-state.js'; +import {NumericFacetSlice} from '../../range-facets/numeric-facet-set/numeric-facet-set-state.js'; export type AllFacetSections = FacetSection & NumericFacetSection & diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions-loader.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions-loader.ts index 55fbc0c8ff8..a1e5ca52555 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions-loader.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../../../app/engine'; -import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice'; +import {CoreEngine} from '../../../../app/engine.js'; +import {dateFacetSetReducer as dateFacetSet} from '../../../../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; import { deselectAllDateFacetValues, registerDateFacet, @@ -12,7 +12,7 @@ import { UpdateDateFacetValuesActionCreatorPayload, updateDateFacetValues, toggleExcludeDateFacetValue, -} from './date-facet-actions'; +} from './date-facet-actions.js'; export type { RegisterDateFacetActionCreatorPayload, diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.test.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.test.ts index 0628bb5c706..5a316312bf2 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.test.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.test.ts @@ -1,6 +1,6 @@ -import {buildDateRange} from '../../../../controllers/facets/range-facet/date-facet/headless-date-facet'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; -import {validateManualDateRanges} from './date-facet-actions'; +import {buildDateRange} from '../../../../controllers/facets/range-facet/date-facet/headless-date-facet.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; +import {validateManualDateRanges} from './date-facet-actions.js'; describe('validateManualDateRanges', () => { it('should not throw when the start is lower or equal than the end', () => { diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.ts index b0da6495bcc..20f9b93840d 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-actions.ts @@ -7,28 +7,28 @@ import { StringValue, } from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {parseDate} from '../../../../api/search/date/date-format'; +import {parseDate} from '../../../../api/search/date/date-format.js'; import { formatRelativeDateForSearchApi, isRelativeDateFormat, -} from '../../../../api/search/date/relative-date'; -import {buildDateRange} from '../../../../controllers/core/facets/range-facet/date-facet/date-range'; +} from '../../../../api/search/date/relative-date.js'; +import {buildDateRange} from '../../../../controllers/core/facets/range-facet/date-facet/date-range.js'; import { validatePayload, requiredNonEmptyString, validatePayloadAndThrow, serializeSchemaValidationError, -} from '../../../../utils/validate-payload'; -import {deselectAllFacetValues} from '../../facet-set/facet-set-actions'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; +} from '../../../../utils/validate-payload.js'; +import {deselectAllFacetValues} from '../../facet-set/facet-set-actions.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; import { RangeFacetSortCriterion, RangeFacetRangeAlgorithm, -} from '../generic/interfaces/request'; -import {updateRangeFacetSortCriterion} from '../generic/range-facet-actions'; -import {dateFacetValueDefinition} from '../generic/range-facet-validate-payload'; -import {DateRangeRequest} from './interfaces/request'; -import {DateFacetValue} from './interfaces/response'; +} from '../generic/interfaces/request.js'; +import {updateRangeFacetSortCriterion} from '../generic/range-facet-actions.js'; +import {dateFacetValueDefinition} from '../generic/range-facet-validate-payload.js'; +import {DateRangeRequest} from './interfaces/request.js'; +import {DateFacetValue} from './interfaces/response.js'; export interface RegisterDateFacetActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-analytics-actions.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-analytics-actions.ts index 14c2a2bc2ce..b93aa4c492e 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-analytics-actions.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-analytics-actions.ts @@ -1,14 +1,14 @@ -import {validatePayload} from '../../../../utils/validate-payload'; +import {validatePayload} from '../../../../utils/validate-payload.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../../../analytics/analytics-utils'; +} from '../../../analytics/analytics-utils.js'; import { getRangeFacetMetadata, rangeBreadcrumbFacet, -} from '../generic/range-facet-analytics-actions'; -import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload'; -import {DateFacetValue} from './interfaces/response'; +} from '../generic/range-facet-analytics-actions.js'; +import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload.js'; +import {DateFacetValue} from './interfaces/response.js'; export interface LogDateFacetBreadcrumbActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.test.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.test.ts index 874468f98a2..7fe0905955c 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.test.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.test.ts @@ -1,27 +1,27 @@ -import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; +import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {createMockState} from '../../../../test/mock-state'; -import {updateFacetOptions} from '../../../facet-options/facet-options-actions'; +} from '../../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import {updateFacetOptions} from '../../../facet-options/facet-options-actions.js'; import { executeToggleRangeFacetExclude, executeToggleRangeFacetSelect, -} from '../generic/range-facet-controller-actions'; +} from '../generic/range-facet-controller-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from './date-facet-actions'; +} from './date-facet-actions.js'; import { executeToggleDateFacetExclude, executeToggleDateFacetSelect, -} from './date-facet-controller-actions'; +} from './date-facet-controller-actions.js'; -jest.mock('../generic/range-facet-controller-actions'); -jest.mock('../../../facet-options/facet-options-actions'); -jest.mock('./date-facet-actions'); +vi.mock('../generic/range-facet-controller-actions'); +vi.mock('../../../facet-options/facet-options-actions'); +vi.mock('./date-facet-actions'); describe('date facet controller actions', () => { let engine: MockedSearchEngine; @@ -36,7 +36,7 @@ describe('date facet controller actions', () => { executeToggleDateFacetSelect({facetId, selection})( engine.dispatch, () => engine.state as Required, - {validatePayload: jest.fn()} as unknown as ThunkExtraArguments + {validatePayload: vi.fn()} as unknown as ThunkExtraArguments ); expect(toggleSelectDateFacetValue).toHaveBeenCalledWith({ facetId, @@ -54,7 +54,7 @@ describe('date facet controller actions', () => { executeToggleDateFacetExclude({facetId, selection})( engine.dispatch, () => engine.state as Required, - {validatePayload: jest.fn()} as unknown as ThunkExtraArguments + {validatePayload: vi.fn()} as unknown as ThunkExtraArguments ); expect(toggleExcludeDateFacetValue).toHaveBeenCalledWith({ diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.ts index a1820f121ed..48f2de60aa6 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-controller-actions.ts @@ -1,22 +1,22 @@ import {RecordValue} from '@coveo/bueno'; import {createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkOptions} from '../../../../app/async-thunk-options'; +import {AsyncThunkOptions} from '../../../../app/async-thunk-options.js'; import { ConfigurationSection, DateFacetSection, -} from '../../../../state/state-sections'; -import {updateFacetOptions} from '../../../facet-options/facet-options-actions'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; +} from '../../../../state/state-sections.js'; +import {updateFacetOptions} from '../../../facet-options/facet-options-actions.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; import { executeToggleRangeFacetExclude, executeToggleRangeFacetSelect, -} from '../generic/range-facet-controller-actions'; -import {dateFacetValueDefinition} from '../generic/range-facet-validate-payload'; +} from '../generic/range-facet-controller-actions.js'; +import {dateFacetValueDefinition} from '../generic/range-facet-validate-payload.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, -} from './date-facet-actions'; -import {DateFacetValue} from './interfaces/response'; +} from './date-facet-actions.js'; +import {DateFacetValue} from './interfaces/response.js'; const definition = { facetId: facetIdDefinition, diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.test.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.test.ts index 525bca65d2d..c1fa22d7b81 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.test.ts @@ -1,23 +1,23 @@ -import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments'; -import {buildMockDateFacetRequest} from '../../../../test/mock-date-facet-request'; -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; -import {buildMockInsightEngine} from '../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../../../configuration/configuration-state'; -import {logDateFacetBreadcrumb} from './date-facet-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments.js'; +import {buildMockDateFacetRequest} from '../../../../test/mock-date-facet-request.js'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; +import {buildMockInsightEngine} from '../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../../../configuration/configuration-state.js'; +import {logDateFacetBreadcrumb} from './date-facet-insight-analytics-actions.js'; -const mockLogBreadcrumbFacet = jest.fn(); +const mockLogBreadcrumbFacet = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logBreadcrumbFacet: mockLogBreadcrumbFacet, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.ts index 52b9dac3d6b..72aaa4b3b35 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.ts @@ -1,13 +1,13 @@ -import {validatePayload} from '../../../../utils/validate-payload'; +import {validatePayload} from '../../../../utils/validate-payload.js'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../../../case-context/case-context-state'; -import {getRangeFacetMetadata} from '../generic/range-facet-analytics-actions'; -import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload'; -import {LogDateFacetBreadcrumbActionCreatorPayload} from './date-facet-analytics-actions'; +} from '../../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../../../case-context/case-context-state.js'; +import {getRangeFacetMetadata} from '../generic/range-facet-analytics-actions.js'; +import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload.js'; +import {LogDateFacetBreadcrumbActionCreatorPayload} from './date-facet-analytics-actions.js'; export const logDateFacetBreadcrumb = ( payload: LogDateFacetBreadcrumbActionCreatorPayload diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.test.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.test.ts index 1909dd4392b..3f8d356583e 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.test.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.test.ts @@ -1,17 +1,17 @@ -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockDateFacetRequest} from '../../../../test/mock-date-facet-request'; -import {buildMockDateFacetResponse} from '../../../../test/mock-date-facet-response'; -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; -import {buildMockFacetRequest} from '../../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {createMockState} from '../../../../test/mock-state'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockDateFacetRequest} from '../../../../test/mock-date-facet-request.js'; +import {buildMockDateFacetResponse} from '../../../../test/mock-date-facet-response.js'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; +import {buildMockFacetRequest} from '../../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {createMockState} from '../../../../test/mock-state.js'; import { dateFacetExcludedValuesSelector, dateFacetResponseSelector, dateFacetSelectedValuesSelector, -} from './date-facet-selectors'; +} from './date-facet-selectors.js'; describe('date facet selectors', () => { const facetId = 'abc123'; diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.ts index d1826f474d2..8481e28df44 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-selectors.ts @@ -1,10 +1,10 @@ import { DateFacetSection, SearchSection, -} from '../../../../state/state-sections'; -import {baseFacetResponseSelector} from '../../facet-set/facet-set-selectors'; -import {AnyFacetResponse} from '../../generic/interfaces/generic-facet-response'; -import {DateFacetResponse, DateFacetValue} from './interfaces/response'; +} from '../../../../state/state-sections.js'; +import {baseFacetResponseSelector} from '../../facet-set/facet-set-selectors.js'; +import {AnyFacetResponse} from '../../generic/interfaces/generic-facet-response.js'; +import {DateFacetResponse, DateFacetValue} from './interfaces/response.js'; function isDateFacetResponse( state: SearchSection & DateFacetSection, diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.test.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.test.ts index 799e02009d7..55b8ae2eb06 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.test.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.test.ts @@ -1,14 +1,14 @@ -import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value'; -import {buildMockSearch} from '../../../../test/mock-search'; -import {logSearchEvent} from '../../../analytics/analytics-actions'; -import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions'; -import {change} from '../../../history/history-actions'; -import {getHistoryInitialState} from '../../../history/history-state'; -import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions'; -import {executeSearch} from '../../../search/search-actions'; -import * as FacetReducers from '../../generic/facet-reducer-helpers'; -import * as RangeFacetReducers from '../generic/range-facet-reducers'; +import {buildMockDateFacetSlice} from '../../../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../../../test/mock-date-facet-value.js'; +import {buildMockSearch} from '../../../../test/mock-search.js'; +import {logSearchEvent} from '../../../analytics/analytics-actions.js'; +import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions.js'; +import {change} from '../../../history/history-actions.js'; +import {getHistoryInitialState} from '../../../history/history-state.js'; +import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../../../search/search-actions.js'; +import * as FacetReducers from '../../generic/facet-reducer-helpers.js'; +import * as RangeFacetReducers from '../generic/range-facet-reducers.js'; import { registerDateFacet, toggleSelectDateFacetValue, @@ -16,12 +16,12 @@ import { deselectAllDateFacetValues, RegisterDateFacetActionCreatorPayload, updateDateFacetValues, -} from './date-facet-actions'; -import {dateFacetSetReducer} from './date-facet-set-slice'; +} from './date-facet-actions.js'; +import {dateFacetSetReducer} from './date-facet-set-slice.js'; import { DateFacetSetState, getDateFacetSetInitialState, -} from './date-facet-set-state'; +} from './date-facet-set-state.js'; describe('date-facet-set slice', () => { let state: DateFacetSetState; @@ -31,7 +31,7 @@ describe('date-facet-set slice', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('initializes the set to an empty object', () => { @@ -80,7 +80,7 @@ describe('date-facet-set slice', () => { }); it('#restoreSearchParameters restores the #nf payload correctly', () => { - const spy = jest.spyOn( + const spy = vi.spyOn( RangeFacetReducers, 'handleRangeFacetSearchParameterRestoration' ); @@ -101,7 +101,7 @@ describe('date-facet-set slice', () => { it('#toggleSelectDateFacetValue calls #toggleSelectRangeValue', () => { const facetId = '1'; const selection = buildMockDateFacetValue(); - jest.spyOn(RangeFacetReducers, 'toggleSelectRangeValue'); + vi.spyOn(RangeFacetReducers, 'toggleSelectRangeValue'); dateFacetSetReducer( state, @@ -112,7 +112,7 @@ describe('date-facet-set slice', () => { }); it('#updateDateFacetValues calls #updateRangeValues', () => { - jest.spyOn(RangeFacetReducers, 'updateRangeValues'); + vi.spyOn(RangeFacetReducers, 'updateRangeValues'); const action = updateDateFacetValues({facetId: '1', values: []}); dateFacetSetReducer(state, action); @@ -120,7 +120,7 @@ describe('date-facet-set slice', () => { }); it('#deselectAllDateFacetValues calls #handleRangeFacetDeselectAll', () => { - jest.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll'); + vi.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll'); const action = deselectAllDateFacetValues('1'); dateFacetSetReducer(state, action); @@ -130,7 +130,7 @@ describe('date-facet-set slice', () => { }); it('dispatching #deselectAllBreadcrumbs calls #handleRangeFacetDeselectAll for every date facet', () => { - jest.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll').mockReset(); + vi.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll').mockReset(); state['1'] = buildMockDateFacetSlice(); state['2'] = buildMockDateFacetSlice(); @@ -142,7 +142,7 @@ describe('date-facet-set slice', () => { }); it('#updateDateFacetSortCriterion calls #handleFacetSortCriterionUpdate', () => { - jest.spyOn(FacetReducers, 'handleFacetSortCriterionUpdate'); + vi.spyOn(FacetReducers, 'handleFacetSortCriterionUpdate'); const action = updateDateFacetSortCriterion({ facetId: '1', @@ -156,7 +156,7 @@ describe('date-facet-set slice', () => { }); it('#executeSearch.fulfilled calls #onRangeFacetRequestFulfilled', () => { - jest.spyOn(RangeFacetReducers, 'onRangeFacetRequestFulfilled'); + vi.spyOn(RangeFacetReducers, 'onRangeFacetRequestFulfilled'); const search = buildMockSearch(); dateFacetSetReducer( diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.ts index 25139931086..d2b532a0a22 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-slice.ts @@ -1,10 +1,10 @@ import {createReducer} from '@reduxjs/toolkit'; -import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions'; -import {disableFacet} from '../../../facet-options/facet-options-actions'; -import {change} from '../../../history/history-actions'; -import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions'; -import {executeSearch} from '../../../search/search-actions'; -import {handleFacetSortCriterionUpdate} from '../../generic/facet-reducer-helpers'; +import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions.js'; +import {disableFacet} from '../../../facet-options/facet-options-actions.js'; +import {change} from '../../../history/history-actions.js'; +import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../../../search/search-actions.js'; +import {handleFacetSortCriterionUpdate} from '../../generic/facet-reducer-helpers.js'; import { registerRangeFacet, toggleSelectRangeValue, @@ -14,7 +14,7 @@ import { handleRangeFacetSearchParameterRestoration, updateRangeValues, toggleExcludeRangeValue, -} from '../generic/range-facet-reducers'; +} from '../generic/range-facet-reducers.js'; import { registerDateFacet, toggleSelectDateFacetValue, @@ -23,13 +23,13 @@ import { RegisterDateFacetActionCreatorPayload, updateDateFacetValues, toggleExcludeDateFacetValue, -} from './date-facet-actions'; +} from './date-facet-actions.js'; import { getDateFacetSetInitialState, getDateFacetSetSliceInitialState, -} from './date-facet-set-state'; -import {DateFacetRequest, DateRangeRequest} from './interfaces/request'; -import {DateFacetResponse, DateFacetValue} from './interfaces/response'; +} from './date-facet-set-state.js'; +import {DateFacetRequest, DateRangeRequest} from './interfaces/request.js'; +import {DateFacetResponse, DateFacetValue} from './interfaces/response.js'; export const dateFacetSetReducer = createReducer( getDateFacetSetInitialState(), diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-state.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-state.ts index 0689d630048..9b8a7f2a6dc 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-state.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/date-facet-set-state.ts @@ -1,4 +1,4 @@ -import {DateFacetRequest} from './interfaces/request'; +import {DateFacetRequest} from './interfaces/request.js'; export type DateFacetSlice = { request: DateFacetRequest; diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/request.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/request.ts index 5986417e6e9..4e34b13811c 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/request.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/request.ts @@ -1,7 +1,7 @@ -import {CurrentValues, Type} from '../../../facet-api/request'; -import {FacetValueState} from '../../../facet-api/value'; -import {AnyFacetRequest} from '../../../generic/interfaces/generic-facet-request'; -import {BaseRangeFacetRequest} from '../../generic/interfaces/request'; +import {CurrentValues, Type} from '../../../facet-api/request.js'; +import {FacetValueState} from '../../../facet-api/value.js'; +import {AnyFacetRequest} from '../../../generic/interfaces/generic-facet-request.js'; +import {BaseRangeFacetRequest} from '../../generic/interfaces/request.js'; /** * The options defining a value to display in a `DateFacet`. diff --git a/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/response.ts b/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/response.ts index e4a5b640148..e45e274b1db 100644 --- a/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/response.ts +++ b/packages/headless/src/features/facets/range-facets/date-facet-set/interfaces/response.ts @@ -1,5 +1,5 @@ -import {BaseFacetResponse} from '../../../facet-api/response'; -import {FacetValueState} from '../../../facet-api/value'; +import {BaseFacetResponse} from '../../../facet-api/response.js'; +import {FacetValueState} from '../../../facet-api/value.js'; export interface DateFacetValue { /** diff --git a/packages/headless/src/features/facets/range-facets/generic/interfaces/options.ts b/packages/headless/src/features/facets/range-facets/generic/interfaces/options.ts index efedd88c705..68878250c0d 100644 --- a/packages/headless/src/features/facets/range-facets/generic/interfaces/options.ts +++ b/packages/headless/src/features/facets/range-facets/generic/interfaces/options.ts @@ -1,5 +1,5 @@ -import {RangeFacetRequest} from './range-facet'; -import {AutomaticRanges} from './request'; +import {RangeFacetRequest} from './range-facet.js'; +import {AutomaticRanges} from './request.js'; type RangeFacetRequiredParameters = Pick< RangeFacetRequest, diff --git a/packages/headless/src/features/facets/range-facets/generic/interfaces/range-facet.ts b/packages/headless/src/features/facets/range-facets/generic/interfaces/range-facet.ts index 3e82c814654..2b264b9c08d 100644 --- a/packages/headless/src/features/facets/range-facets/generic/interfaces/range-facet.ts +++ b/packages/headless/src/features/facets/range-facets/generic/interfaces/range-facet.ts @@ -1,23 +1,23 @@ -import {RegisterDateFacetActionCreatorPayload} from '../../date-facet-set/date-facet-actions'; -import {DateFacetSetState} from '../../date-facet-set/date-facet-set-state'; +import {RegisterDateFacetActionCreatorPayload} from '../../date-facet-set/date-facet-actions.js'; +import {DateFacetSetState} from '../../date-facet-set/date-facet-set-state.js'; import { DateFacetRequest, DateRangeRequest, -} from '../../date-facet-set/interfaces/request'; +} from '../../date-facet-set/interfaces/request.js'; import { DateFacetValue, DateFacetResponse, -} from '../../date-facet-set/interfaces/response'; +} from '../../date-facet-set/interfaces/response.js'; import { NumericFacetRequest, NumericRangeRequest, -} from '../../numeric-facet-set/interfaces/request'; +} from '../../numeric-facet-set/interfaces/request.js'; import { NumericFacetValue, NumericFacetResponse, -} from '../../numeric-facet-set/interfaces/response'; -import {RegisterNumericFacetActionCreatorPayload} from '../../numeric-facet-set/numeric-facet-actions'; -import {NumericFacetSetState} from '../../numeric-facet-set/numeric-facet-set-state'; +} from '../../numeric-facet-set/interfaces/response.js'; +import {RegisterNumericFacetActionCreatorPayload} from '../../numeric-facet-set/numeric-facet-actions.js'; +import {NumericFacetSetState} from '../../numeric-facet-set/numeric-facet-set-state.js'; export type RangeFacetRequest = DateFacetRequest | NumericFacetRequest; export type RangeValueRequest = DateRangeRequest | NumericRangeRequest; diff --git a/packages/headless/src/features/facets/range-facets/generic/interfaces/request.ts b/packages/headless/src/features/facets/range-facets/generic/interfaces/request.ts index 7e39413cd56..41b03234daf 100644 --- a/packages/headless/src/features/facets/range-facets/generic/interfaces/request.ts +++ b/packages/headless/src/features/facets/range-facets/generic/interfaces/request.ts @@ -3,7 +3,7 @@ import { SortCriteria, BaseFacetValueRequest, RangeAlgorithm, -} from '../../../facet-api/request'; +} from '../../../facet-api/request.js'; export const rangeFacetSortCriteria: RangeFacetSortCriterion[] = [ 'ascending', diff --git a/packages/headless/src/features/facets/range-facets/generic/interfaces/response.ts b/packages/headless/src/features/facets/range-facets/generic/interfaces/response.ts index 0dcf307abeb..da7a9f4e534 100644 --- a/packages/headless/src/features/facets/range-facets/generic/interfaces/response.ts +++ b/packages/headless/src/features/facets/range-facets/generic/interfaces/response.ts @@ -1,4 +1,4 @@ -import {BaseFacetValue} from '../../../facet-api/response'; +import {BaseFacetValue} from '../../../facet-api/response.js'; export interface RangeValue extends BaseFacetValue { start: T; diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-actions.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-actions.ts index c1db48877be..be442746acf 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-actions.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-actions.ts @@ -1,8 +1,8 @@ import {Value} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../../utils/validate-payload'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; -import {RangeFacetSortCriterion} from './interfaces/request'; +import {validatePayload} from '../../../../utils/validate-payload.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; +import {RangeFacetSortCriterion} from './interfaces/request.js'; export const updateRangeFacetSortCriterion = createAction( 'rangeFacet/updateSortCriterion', diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-analytics-actions.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-analytics-actions.ts index 6391722eb08..39ad5845f59 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-analytics-actions.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-analytics-actions.ts @@ -1,8 +1,8 @@ -import type {FacetRangeMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; -import {SearchAppState} from '../../../../state/search-app-state'; -import {SearchPageEvents} from '../../../analytics/search-action-cause'; -import {SearchAction} from '../../../search/search-actions'; -import {RangeFacetSelectionPayload} from './range-facet-validate-payload'; +import type {FacetRangeMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {SearchPageEvents} from '../../../analytics/search-action-cause.js'; +import {SearchAction} from '../../../search/search-actions.js'; +import {RangeFacetSelectionPayload} from './range-facet-validate-payload.js'; export const getRangeFacetMetadata = ( state: Partial, diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-controller-actions.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-controller-actions.ts index 4c5317d8eaa..0f864439a4b 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-controller-actions.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-controller-actions.ts @@ -1,9 +1,9 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../../../utils/validate-payload'; +import {validatePayload} from '../../../../utils/validate-payload.js'; import { RangeFacetSelectionPayload, rangeFacetSelectionPayloadDefinition, -} from './range-facet-validate-payload'; +} from './range-facet-validate-payload.js'; export const executeToggleRangeFacetSelect = createAction( 'rangeFacet/executeToggleSelect', diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-analytics-actions.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-analytics-actions.ts index 2cdbaadfb99..6b3b43b0fe2 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-analytics-actions.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-analytics-actions.ts @@ -1,6 +1,6 @@ -import type {FacetRangeMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; -import {InsightAppState} from '../../../../state/insight-app-state'; -import {RangeFacetSelectionPayload} from './range-facet-validate-payload'; +import type {FacetRangeMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; +import {InsightAppState} from '../../../../state/insight-app-state.js'; +import {RangeFacetSelectionPayload} from './range-facet-validate-payload.js'; export const getRangeFacetMetadata = ( state: Partial, diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-utils.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-utils.ts index 7796658ed59..91396e832de 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-utils.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-insight-utils.ts @@ -1,10 +1,10 @@ -import {FacetSelectionChangeMetadata} from '../../facet-set/facet-set-analytics-actions-utils'; +import {FacetSelectionChangeMetadata} from '../../facet-set/facet-set-analytics-actions-utils.js'; import { logFacetDeselect, logFacetSelect, -} from '../../facet-set/facet-set-insight-analytics-actions'; -import {RangeFacetValue} from './interfaces/range-facet'; -import {isRangeFacetValueSelected} from './range-facet-utils'; +} from '../../facet-set/facet-set-insight-analytics-actions.js'; +import {RangeFacetValue} from './interfaces/range-facet.js'; +import {isRangeFacetValueSelected} from './range-facet-utils.js'; export const getInsightAnalyticsActionForToggleRangeFacetSelect = ( facetId: string, diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.test.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.test.ts index 413fe529c7a..2d668857ab2 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.test.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.test.ts @@ -1,15 +1,15 @@ -import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; +import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; import { NumericFacetRequest, NumericRangeRequest, -} from '../numeric-facet-set/interfaces/request'; -import {NumericFacetValue} from '../numeric-facet-set/interfaces/response'; -import {RegisterNumericFacetActionCreatorPayload} from '../numeric-facet-set/numeric-facet-actions'; -import {NumericFacetSlice} from '../numeric-facet-set/numeric-facet-set-state'; -import {AutomaticRangeFacetOptions} from './interfaces/options'; +} from '../numeric-facet-set/interfaces/request.js'; +import {NumericFacetValue} from '../numeric-facet-set/interfaces/response.js'; +import {RegisterNumericFacetActionCreatorPayload} from '../numeric-facet-set/numeric-facet-actions.js'; +import {NumericFacetSlice} from '../numeric-facet-set/numeric-facet-set-state.js'; +import {AutomaticRangeFacetOptions} from './interfaces/options.js'; import { registerRangeFacet, toggleSelectRangeValue, @@ -17,7 +17,7 @@ import { handleRangeFacetDeselectAll, handleRangeFacetSearchParameterRestoration, updateRangeValues, -} from './range-facet-reducers'; +} from './range-facet-reducers.js'; describe('range facet reducers', () => { let state: Record = {}; diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.ts index 199bb44cc05..c4fd6380e1b 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-reducers.ts @@ -1,10 +1,10 @@ -import {RangeFacetOptionalParameters} from './interfaces/options'; +import {RangeFacetOptionalParameters} from './interfaces/options.js'; import { RangeFacetRequest, RangeFacetResponse, RangeFacetValue, RangeValueRequest, -} from './interfaces/range-facet'; +} from './interfaces/range-facet.js'; type RangeFacetSlice< RequestType extends RangeFacetRequest = RangeFacetRequest, diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-utils.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-utils.ts index 05c78e008e8..bf90cc2ec59 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-utils.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-utils.ts @@ -1,4 +1,5 @@ -import {SearchAction} from '../../../search/search-actions'; +import {SearchAction} from '../../../search/search-actions.js'; +import {FacetSelectionChangeMetadata} from '../../facet-set/facet-set-analytics-actions-utils.js'; import { facetDeselect, facetExclude, @@ -8,9 +9,8 @@ import { logFacetExclude, logFacetSelect, logFacetUnexclude, -} from '../../facet-set/facet-set-analytics-actions'; -import {FacetSelectionChangeMetadata} from '../../facet-set/facet-set-analytics-actions-utils'; -import {RangeFacetValue} from './interfaces/range-facet'; +} from '../../facet-set/facet-set-analytics-actions.js'; +import {RangeFacetValue} from './interfaces/range-facet.js'; export const isRangeFacetValueSelected = (selection: RangeFacetValue) => { return selection.state === 'selected'; diff --git a/packages/headless/src/features/facets/range-facets/generic/range-facet-validate-payload.ts b/packages/headless/src/features/facets/range-facets/generic/range-facet-validate-payload.ts index b10480ce2ef..14e7698aacc 100644 --- a/packages/headless/src/features/facets/range-facets/generic/range-facet-validate-payload.ts +++ b/packages/headless/src/features/facets/range-facets/generic/range-facet-validate-payload.ts @@ -1,7 +1,7 @@ import {NumberValue, BooleanValue, RecordValue} from '@coveo/bueno'; -import {requiredNonEmptyString} from '../../../../utils/validate-payload'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; -import {RangeFacetValue} from './interfaces/range-facet'; +import {requiredNonEmptyString} from '../../../../utils/validate-payload.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; +import {RangeFacetValue} from './interfaces/range-facet.js'; export const numericFacetValueDefinition = { state: requiredNonEmptyString, diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/request.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/request.ts index 2ff8a4f7fc7..b13e333b12f 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/request.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/request.ts @@ -1,6 +1,6 @@ -import {CurrentValues, Type} from '../../../facet-api/request'; -import {FacetValueState} from '../../../facet-api/value'; -import {BaseRangeFacetRequest} from '../../generic/interfaces/request'; +import {CurrentValues, Type} from '../../../facet-api/request.js'; +import {FacetValueState} from '../../../facet-api/value.js'; +import {BaseRangeFacetRequest} from '../../generic/interfaces/request.js'; /** * The options defining a value to display in a `NumericFacet`. diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/response.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/response.ts index 4d9a989aad0..f65bca9728a 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/response.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/interfaces/response.ts @@ -1,5 +1,5 @@ -import {BaseFacetResponse} from '../../../facet-api/response'; -import {FacetValueState} from '../../../facet-api/value'; +import {BaseFacetResponse} from '../../../facet-api/response.js'; +import {FacetValueState} from '../../../facet-api/value.js'; export interface NumericFacetValue { /** diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.ts index d3312f5a750..0de399cacba 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../../../app/engine'; -import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; +import {CoreEngine} from '../../../../app/engine.js'; +import {numericFacetSetReducer as numericFacetSet} from '../../../../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; import { deselectAllNumericFacetValues, registerNumericFacet, @@ -12,7 +12,7 @@ import { UpdateNumericFacetSortCriterionActionCreatorPayload, updateNumericFacetValues, UpdateNumericFacetValuesActionCreatorPayload, -} from './numeric-facet-actions'; +} from './numeric-facet-actions.js'; export type { RegisterNumericFacetActionCreatorPayload, diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.test.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.test.ts index f65197c6fc8..e394bf3c669 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.test.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.test.ts @@ -1,5 +1,5 @@ -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {validateManualNumericRanges} from './numeric-facet-actions'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {validateManualNumericRanges} from './numeric-facet-actions.js'; describe('validateManualNumericRanges', () => { it('should not throw when the start is lower or equal than the end', () => { diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.ts index 8dd6b3691e9..0e5fe8ccc23 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-actions.ts @@ -12,17 +12,17 @@ import { requiredNonEmptyString, serializeSchemaValidationError, validatePayloadAndThrow, -} from '../../../../utils/validate-payload'; -import {deselectAllFacetValues} from '../../facet-set/facet-set-actions'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; +} from '../../../../utils/validate-payload.js'; +import {deselectAllFacetValues} from '../../facet-set/facet-set-actions.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; import { RangeFacetRangeAlgorithm, RangeFacetSortCriterion, -} from '../generic/interfaces/request'; -import {updateRangeFacetSortCriterion} from '../generic/range-facet-actions'; -import {numericFacetValueDefinition} from '../generic/range-facet-validate-payload'; -import {NumericRangeRequest} from './interfaces/request'; -import {NumericFacetValue} from './interfaces/response'; +} from '../generic/interfaces/request.js'; +import {updateRangeFacetSortCriterion} from '../generic/range-facet-actions.js'; +import {numericFacetValueDefinition} from '../generic/range-facet-validate-payload.js'; +import {NumericRangeRequest} from './interfaces/request.js'; +import {NumericFacetValue} from './interfaces/response.js'; export interface RegisterNumericFacetActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.ts index 87016b39aef..8e1227601fc 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.ts @@ -1,14 +1,14 @@ -import {validatePayload} from '../../../../utils/validate-payload'; +import {validatePayload} from '../../../../utils/validate-payload.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../../../analytics/analytics-utils'; +} from '../../../analytics/analytics-utils.js'; import { getRangeFacetMetadata, rangeBreadcrumbFacet, -} from '../generic/range-facet-analytics-actions'; -import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload'; -import {NumericFacetValue} from './interfaces/response'; +} from '../generic/range-facet-analytics-actions.js'; +import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload.js'; +import {NumericFacetValue} from './interfaces/response.js'; export interface LogNumericFacetBreadcrumbActionCreatorPayload { /** diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.test.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.test.ts index 7372225a44a..265e34b0f36 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.test.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.test.ts @@ -1,21 +1,21 @@ -import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments'; +import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../../../test/mock-engine-v2'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../test/mock-state'; -import {updateFacetOptions} from '../../../facet-options/facet-options-actions'; -import {executeToggleRangeFacetSelect} from '../generic/range-facet-controller-actions'; -import {toggleSelectNumericFacetValue} from './numeric-facet-actions'; +} from '../../../../test/mock-engine-v2.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; +import {updateFacetOptions} from '../../../facet-options/facet-options-actions.js'; +import {executeToggleRangeFacetSelect} from '../generic/range-facet-controller-actions.js'; +import {toggleSelectNumericFacetValue} from './numeric-facet-actions.js'; import { executeToggleNumericFacetSelect, executeToggleNumericFacetExclude, -} from './numeric-facet-controller-actions'; +} from './numeric-facet-controller-actions.js'; -jest.mock('../generic/range-facet-controller-actions'); -jest.mock('./numeric-facet-actions'); -jest.mock('../../../facet-options/facet-options-actions'); +vi.mock('../generic/range-facet-controller-actions'); +vi.mock('./numeric-facet-actions'); +vi.mock('../../../facet-options/facet-options-actions'); describe('numeric facet controller actions', () => { let engine: MockedSearchEngine; @@ -30,7 +30,7 @@ describe('numeric facet controller actions', () => { await executeToggleNumericFacetSelect({facetId, selection})( engine.dispatch, () => engine.state as Required, - {validatePayload: jest.fn()} as unknown as ThunkExtraArguments + {validatePayload: vi.fn()} as unknown as ThunkExtraArguments ); expect(toggleSelectNumericFacetValue).toHaveBeenCalledWith({ facetId, @@ -45,7 +45,7 @@ describe('numeric facet controller actions', () => { await executeToggleNumericFacetExclude({facetId, selection})( engine.dispatch, () => engine.state as Required, - {validatePayload: jest.fn()} as unknown as ThunkExtraArguments + {validatePayload: vi.fn()} as unknown as ThunkExtraArguments ); expect(toggleSelectNumericFacetValue).toHaveBeenCalledWith({ facetId, diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.ts index c6cb6a7e1f3..eba220602e1 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-controller-actions.ts @@ -1,22 +1,22 @@ import {RecordValue} from '@coveo/bueno'; import {createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkOptions} from '../../../../app/async-thunk-options'; +import {AsyncThunkOptions} from '../../../../app/async-thunk-options.js'; import { ConfigurationSection, NumericFacetSection, -} from '../../../../state/state-sections'; -import {updateFacetOptions} from '../../../facet-options/facet-options-actions'; -import {facetIdDefinition} from '../../generic/facet-actions-validation'; +} from '../../../../state/state-sections.js'; +import {updateFacetOptions} from '../../../facet-options/facet-options-actions.js'; +import {facetIdDefinition} from '../../generic/facet-actions-validation.js'; import { executeToggleRangeFacetExclude, executeToggleRangeFacetSelect, -} from '../generic/range-facet-controller-actions'; -import {numericFacetValueDefinition} from '../generic/range-facet-validate-payload'; -import {NumericFacetValue} from './interfaces/response'; +} from '../generic/range-facet-controller-actions.js'; +import {numericFacetValueDefinition} from '../generic/range-facet-validate-payload.js'; +import {NumericFacetValue} from './interfaces/response.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, -} from './numeric-facet-actions'; +} from './numeric-facet-actions.js'; const definition = { facetId: facetIdDefinition, diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.test.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.test.ts index ab7e887a188..2a6d8d82297 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.test.ts @@ -1,23 +1,23 @@ -import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../../../test/mock-insight-state'; -import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {getConfigurationInitialState} from '../../../configuration/configuration-state'; -import {logNumericFacetBreadcrumb} from './numeric-facet-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../../../test/mock-insight-state.js'; +import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {getConfigurationInitialState} from '../../../configuration/configuration-state.js'; +import {logNumericFacetBreadcrumb} from './numeric-facet-insight-analytics-actions.js'; -const mockLogBreadcrumbFacet = jest.fn(); +const mockLogBreadcrumbFacet = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logBreadcrumbFacet: mockLogBreadcrumbFacet, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.ts index 7ca66cb5163..5409dc7e412 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.ts @@ -1,13 +1,13 @@ -import {validatePayload} from '../../../../utils/validate-payload'; +import {validatePayload} from '../../../../utils/validate-payload.js'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../../../analytics/analytics-utils'; -import {SearchPageEvents} from '../../../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../../../case-context/case-context-state'; -import {getRangeFacetMetadata} from '../generic/range-facet-insight-analytics-actions'; -import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload'; -import {LogNumericFacetBreadcrumbActionCreatorPayload} from './numeric-facet-analytics-actions'; +} from '../../../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../../../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../../../case-context/case-context-state.js'; +import {getRangeFacetMetadata} from '../generic/range-facet-insight-analytics-actions.js'; +import {rangeFacetSelectionPayloadDefinition} from '../generic/range-facet-validate-payload.js'; +import {LogNumericFacetBreadcrumbActionCreatorPayload} from './numeric-facet-analytics-actions.js'; export const logNumericFacetBreadcrumb = ( payload: LogNumericFacetBreadcrumbActionCreatorPayload diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.test.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.test.ts index 4eaf7ab1cd3..ba1f8333eaf 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.test.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.test.ts @@ -1,17 +1,17 @@ -import {SearchAppState} from '../../../../state/search-app-state'; -import {buildMockFacetRequest} from '../../../../test/mock-facet-request'; -import {buildMockFacetResponse} from '../../../../test/mock-facet-response'; -import {buildMockFacetSlice} from '../../../../test/mock-facet-slice'; -import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response'; -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {createMockState} from '../../../../test/mock-state'; +import {SearchAppState} from '../../../../state/search-app-state.js'; +import {buildMockFacetRequest} from '../../../../test/mock-facet-request.js'; +import {buildMockFacetResponse} from '../../../../test/mock-facet-response.js'; +import {buildMockFacetSlice} from '../../../../test/mock-facet-slice.js'; +import {buildMockNumericFacetRequest} from '../../../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetResponse} from '../../../../test/mock-numeric-facet-response.js'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {createMockState} from '../../../../test/mock-state.js'; import { numericFacetExcludedValuesSelector, numericFacetResponseSelector, numericFacetSelectedValuesSelector, -} from './numeric-facet-selectors'; +} from './numeric-facet-selectors.js'; describe('numeric facet selectors', () => { const facetId = 'abc123'; diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.ts index ad828ff0323..c4acac29b40 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-selectors.ts @@ -1,10 +1,13 @@ import { NumericFacetSection, SearchSection, -} from '../../../../state/state-sections'; -import {baseFacetResponseSelector} from '../../facet-set/facet-set-selectors'; -import {AnyFacetResponse} from '../../generic/interfaces/generic-facet-response'; -import {NumericFacetResponse, NumericFacetValue} from './interfaces/response'; +} from '../../../../state/state-sections.js'; +import {baseFacetResponseSelector} from '../../facet-set/facet-set-selectors.js'; +import {AnyFacetResponse} from '../../generic/interfaces/generic-facet-response.js'; +import { + NumericFacetResponse, + NumericFacetValue, +} from './interfaces/response.js'; function isNumericFacetResponse( state: SearchSection & NumericFacetSection, diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.test.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.test.ts index 8d0d4c91259..42d21a558d9 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.test.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.test.ts @@ -1,14 +1,14 @@ -import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice'; -import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value'; -import {buildMockSearch} from '../../../../test/mock-search'; -import {logSearchEvent} from '../../../analytics/analytics-actions'; -import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions'; -import {change} from '../../../history/history-actions'; -import {getHistoryInitialState} from '../../../history/history-state'; -import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions'; -import {executeSearch} from '../../../search/search-actions'; -import * as FacetReducers from '../../generic/facet-reducer-helpers'; -import * as RangeFacetReducers from '../generic/range-facet-reducers'; +import {buildMockNumericFacetSlice} from '../../../../test/mock-numeric-facet-slice.js'; +import {buildMockNumericFacetValue} from '../../../../test/mock-numeric-facet-value.js'; +import {buildMockSearch} from '../../../../test/mock-search.js'; +import {logSearchEvent} from '../../../analytics/analytics-actions.js'; +import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions.js'; +import {change} from '../../../history/history-actions.js'; +import {getHistoryInitialState} from '../../../history/history-state.js'; +import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../../../search/search-actions.js'; +import * as FacetReducers from '../../generic/facet-reducer-helpers.js'; +import * as RangeFacetReducers from '../generic/range-facet-reducers.js'; import { registerNumericFacet, toggleSelectNumericFacetValue, @@ -17,12 +17,12 @@ import { RegisterNumericFacetActionCreatorPayload, updateNumericFacetValues, toggleExcludeNumericFacetValue, -} from './numeric-facet-actions'; -import {numericFacetSetReducer} from './numeric-facet-set-slice'; +} from './numeric-facet-actions.js'; +import {numericFacetSetReducer} from './numeric-facet-set-slice.js'; import { NumericFacetSetState, getNumericFacetSetInitialState, -} from './numeric-facet-set-state'; +} from './numeric-facet-set-state.js'; describe('numeric-facet-set slice', () => { let state: NumericFacetSetState; @@ -32,7 +32,7 @@ describe('numeric-facet-set slice', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('initializes the set to an empty object', () => { @@ -84,7 +84,7 @@ describe('numeric-facet-set slice', () => { }); it('#restoreSearchParameters restores the #nf payload correctly', () => { - const spy = jest.spyOn( + const spy = vi.spyOn( RangeFacetReducers, 'handleRangeFacetSearchParameterRestoration' ); @@ -105,7 +105,7 @@ describe('numeric-facet-set slice', () => { it('#toggleSelectNumericFacetValue calls #toggleSelectRangeValue', () => { const facetId = '1'; const selection = buildMockNumericFacetValue(); - jest.spyOn(RangeFacetReducers, 'toggleSelectRangeValue'); + vi.spyOn(RangeFacetReducers, 'toggleSelectRangeValue'); numericFacetSetReducer( state, @@ -118,7 +118,7 @@ describe('numeric-facet-set slice', () => { it('#toggleExcludeNumericFacetValue calls #toggleExcludeRangeValue', () => { const facetId = '1'; const selection = buildMockNumericFacetValue(); - jest.spyOn(RangeFacetReducers, 'toggleExcludeRangeValue'); + vi.spyOn(RangeFacetReducers, 'toggleExcludeRangeValue'); numericFacetSetReducer( state, @@ -129,7 +129,7 @@ describe('numeric-facet-set slice', () => { }); it('#deselectAllNumericFacetValues calls #handleRangeFacetDeselectAll', () => { - jest.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll'); + vi.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll'); const action = deselectAllNumericFacetValues('1'); numericFacetSetReducer(state, action); @@ -139,7 +139,7 @@ describe('numeric-facet-set slice', () => { }); it('#updateNumericFacetValues calls #updateRangeValues', () => { - jest.spyOn(RangeFacetReducers, 'updateRangeValues'); + vi.spyOn(RangeFacetReducers, 'updateRangeValues'); const action = updateNumericFacetValues({facetId: '1', values: []}); numericFacetSetReducer(state, action); @@ -147,7 +147,7 @@ describe('numeric-facet-set slice', () => { }); it('dispatching #deselectAllBreadcrumbs calls #handleRangeFacetDeselectAll for every numeric facet', () => { - jest.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll').mockReset(); + vi.spyOn(RangeFacetReducers, 'handleRangeFacetDeselectAll').mockReset(); state['1'] = buildMockNumericFacetSlice(); state['2'] = buildMockNumericFacetSlice(); @@ -159,7 +159,7 @@ describe('numeric-facet-set slice', () => { }); it('#updateNumericFacetSortCriterion calls #handleFacetSortCriterionUpdate', () => { - jest.spyOn(FacetReducers, 'handleFacetSortCriterionUpdate'); + vi.spyOn(FacetReducers, 'handleFacetSortCriterionUpdate'); const action = updateNumericFacetSortCriterion({ facetId: '1', @@ -173,7 +173,7 @@ describe('numeric-facet-set slice', () => { }); it('#executeSearch.fulfilled calls #onRangeFacetRequestFulfilled', () => { - jest.spyOn(RangeFacetReducers, 'onRangeFacetRequestFulfilled'); + vi.spyOn(RangeFacetReducers, 'onRangeFacetRequestFulfilled'); const search = buildMockSearch(); numericFacetSetReducer( diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.ts index 04ed5b8ba08..5f3679f701c 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.ts @@ -1,10 +1,10 @@ import {createReducer} from '@reduxjs/toolkit'; -import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions'; -import {disableFacet} from '../../../facet-options/facet-options-actions'; -import {change} from '../../../history/history-actions'; -import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions'; -import {executeSearch} from '../../../search/search-actions'; -import {handleFacetSortCriterionUpdate} from '../../generic/facet-reducer-helpers'; +import {deselectAllBreadcrumbs} from '../../../breadcrumb/breadcrumb-actions.js'; +import {disableFacet} from '../../../facet-options/facet-options-actions.js'; +import {change} from '../../../history/history-actions.js'; +import {restoreSearchParameters} from '../../../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../../../search/search-actions.js'; +import {handleFacetSortCriterionUpdate} from '../../generic/facet-reducer-helpers.js'; import { registerRangeFacet, toggleSelectRangeValue, @@ -14,9 +14,15 @@ import { handleRangeFacetSearchParameterRestoration, updateRangeValues, toggleExcludeRangeValue, -} from '../generic/range-facet-reducers'; -import {NumericFacetRequest, NumericRangeRequest} from './interfaces/request'; -import {NumericFacetResponse, NumericFacetValue} from './interfaces/response'; +} from '../generic/range-facet-reducers.js'; +import { + NumericFacetRequest, + NumericRangeRequest, +} from './interfaces/request.js'; +import { + NumericFacetResponse, + NumericFacetValue, +} from './interfaces/response.js'; import { registerNumericFacet, toggleSelectNumericFacetValue, @@ -25,11 +31,11 @@ import { RegisterNumericFacetActionCreatorPayload, updateNumericFacetValues, toggleExcludeNumericFacetValue, -} from './numeric-facet-actions'; +} from './numeric-facet-actions.js'; import { getNumericFacetSetInitialState, getNumericFacetSetSliceInitialState, -} from './numeric-facet-set-state'; +} from './numeric-facet-set-state.js'; export const numericFacetSetReducer = createReducer( getNumericFacetSetInitialState(), diff --git a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.ts b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.ts index 8514566d8d5..f658b4e14bb 100644 --- a/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.ts +++ b/packages/headless/src/features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.ts @@ -1,4 +1,4 @@ -import {NumericFacetRequest} from './interfaces/request'; +import {NumericFacetRequest} from './interfaces/request.js'; export type NumericFacetSlice = { request: NumericFacetRequest; diff --git a/packages/headless/src/features/fields/fields-actions-loader.ts b/packages/headless/src/features/fields/fields-actions-loader.ts index 70cb0079a56..0174f050f37 100644 --- a/packages/headless/src/features/fields/fields-actions-loader.ts +++ b/packages/headless/src/features/fields/fields-actions-loader.ts @@ -1,15 +1,15 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {FieldDescription} from '../../api/search/fields/fields-response'; -import {AsyncThunkSearchOptions} from '../../api/search/search-api-client'; -import {CoreEngine} from '../../app/engine'; -import {fieldsReducer as fields} from '../../features/fields/fields-slice'; -import {ConfigurationSection} from '../../state/state-sections'; +import {FieldDescription} from '../../api/search/fields/fields-response.js'; +import {AsyncThunkSearchOptions} from '../../api/search/search-api-client.js'; +import {CoreEngine} from '../../app/engine.js'; +import {fieldsReducer as fields} from '../../features/fields/fields-slice.js'; +import {ConfigurationSection} from '../../state/state-sections.js'; import { registerFieldsToInclude, enableFetchAllFields, disableFetchAllFields, fetchFieldsDescription, -} from './fields-actions'; +} from './fields-actions.js'; /** * The field action creators. diff --git a/packages/headless/src/features/fields/fields-actions.ts b/packages/headless/src/features/fields/fields-actions.ts index 6bddc67cc56..bd157d25c4c 100644 --- a/packages/headless/src/features/fields/fields-actions.ts +++ b/packages/headless/src/features/fields/fields-actions.ts @@ -1,15 +1,15 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {FieldDescription} from '../../api/search/fields/fields-response'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {FieldDescription} from '../../api/search/fields/fields-response.js'; import { AsyncThunkSearchOptions, isErrorResponse, -} from '../../api/search/search-api-client'; -import {ConfigurationSection} from '../../state/state-sections'; +} from '../../api/search/search-api-client.js'; +import {ConfigurationSection} from '../../state/state-sections.js'; import { validatePayload, nonEmptyStringArray, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export const registerFieldsToInclude = createAction( 'fields/registerFieldsToInclude', diff --git a/packages/headless/src/features/fields/fields-slice.test.ts b/packages/headless/src/features/fields/fields-slice.test.ts index 0f3a1b65b0a..1a8c155adda 100644 --- a/packages/headless/src/features/fields/fields-slice.test.ts +++ b/packages/headless/src/features/fields/fields-slice.test.ts @@ -1,19 +1,19 @@ -import {SearchAPIClient} from '../../api/search/search-api-client'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {SearchAPIClient} from '../../api/search/search-api-client.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockFieldDescription} from '../../test/mock-field-description'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockFieldDescription} from '../../test/mock-field-description.js'; +import {createMockState} from '../../test/mock-state.js'; import { disableFetchAllFields, enableFetchAllFields, fetchFieldsDescription, registerFieldsToInclude, -} from './fields-actions'; -import {fieldsReducer} from './fields-slice'; -import {FieldsState, getFieldsInitialState} from './fields-state'; +} from './fields-actions.js'; +import {fieldsReducer} from './fields-slice.js'; +import {FieldsState, getFieldsInitialState} from './fields-state.js'; describe('fields slice', () => { it('should have initial state', () => { @@ -62,7 +62,7 @@ describe('fields slice', () => { beforeEach(() => { e = buildMockSearchEngine(createMockState()); apiClient = { - fieldDescriptions: jest.fn(), + fieldDescriptions: vi.fn(), } as unknown as SearchAPIClient; }); diff --git a/packages/headless/src/features/fields/fields-slice.ts b/packages/headless/src/features/fields/fields-slice.ts index 516489f2370..ad7052f503c 100644 --- a/packages/headless/src/features/fields/fields-slice.ts +++ b/packages/headless/src/features/fields/fields-slice.ts @@ -1,13 +1,13 @@ import {createReducer} from '@reduxjs/toolkit'; -import {registerFolding} from '../folding/folding-actions'; -import {getFoldingInitialState} from '../folding/folding-state'; +import {registerFolding} from '../folding/folding-actions.js'; +import {getFoldingInitialState} from '../folding/folding-state.js'; import { disableFetchAllFields, enableFetchAllFields, fetchFieldsDescription, registerFieldsToInclude, -} from './fields-actions'; -import {getFieldsInitialState} from './fields-state'; +} from './fields-actions.js'; +import {getFieldsInitialState} from './fields-state.js'; export const fieldsReducer = createReducer(getFieldsInitialState(), (builder) => builder diff --git a/packages/headless/src/features/fields/fields-state.ts b/packages/headless/src/features/fields/fields-state.ts index 63f46274a25..4e79e650c99 100644 --- a/packages/headless/src/features/fields/fields-state.ts +++ b/packages/headless/src/features/fields/fields-state.ts @@ -1,4 +1,4 @@ -import {FieldDescription} from '../../api/search/fields/fields-response'; +import {FieldDescription} from '../../api/search/fields/fields-response.js'; export interface FieldsState { /** diff --git a/packages/headless/src/features/folding/folding-actions-loader.ts b/packages/headless/src/features/folding/folding-actions-loader.ts index 23b6ccaa24a..0fce98eae37 100644 --- a/packages/headless/src/features/folding/folding-actions-loader.ts +++ b/packages/headless/src/features/folding/folding-actions-loader.ts @@ -1,14 +1,14 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkSearchOptions} from '../../api/search/search-api-client'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {foldingReducer as folding} from '../../features/folding/folding-slice'; +import {AsyncThunkSearchOptions} from '../../api/search/search-api-client.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {foldingReducer as folding} from '../../features/folding/folding-slice.js'; import { registerFolding, RegisterFoldingActionCreatorPayload, loadCollection, LoadCollectionFulfilledReturn, StateNeededByLoadCollection, -} from './folding-actions'; +} from './folding-actions.js'; export type {RegisterFoldingActionCreatorPayload}; diff --git a/packages/headless/src/features/folding/folding-actions.ts b/packages/headless/src/features/folding/folding-actions.ts index 1c023b1f38d..7031a3e36b2 100644 --- a/packages/headless/src/features/folding/folding-actions.ts +++ b/packages/headless/src/features/folding/folding-actions.ts @@ -3,18 +3,18 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { AsyncThunkSearchOptions, isErrorResponse, -} from '../../api/search/search-api-client'; -import {Result} from '../../api/search/search/result'; +} from '../../api/search/search-api-client.js'; +import {Result} from '../../api/search/search/result.js'; import { ConfigurationSection, FoldingSection, QuerySection, -} from '../../state/state-sections'; -import {validatePayload} from '../../utils/validate-payload'; -import {buildSearchAndFoldingLoadCollectionRequest as legacyBuildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/legacy/search-and-folding-request'; -import {buildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/search-and-folding-request'; -import {ResultWithFolding} from './folding-slice'; -import {CollectionId} from './folding-state'; +} from '../../state/state-sections.js'; +import {validatePayload} from '../../utils/validate-payload.js'; +import {buildSearchAndFoldingLoadCollectionRequest as legacyBuildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/legacy/search-and-folding-request.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/search-and-folding-request.js'; +import {ResultWithFolding} from './folding-slice.js'; +import {CollectionId} from './folding-state.js'; export interface RegisterFoldingActionCreatorPayload { /** diff --git a/packages/headless/src/features/folding/folding-analytics-actions.ts b/packages/headless/src/features/folding/folding-analytics-actions.ts index ef21d7e46d3..d551f2107e1 100644 --- a/packages/headless/src/features/folding/folding-analytics-actions.ts +++ b/packages/headless/src/features/folding/folding-analytics-actions.ts @@ -1,14 +1,14 @@ -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { ClickAction, CustomAction, makeAnalyticsAction, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; import { documentIdentifier, partialDocumentInformation, validateResultPayload, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; export const logShowMoreFoldedResults = (result: Result): ClickAction => makeAnalyticsAction('analytics/folding/showMore', (client, state) => { diff --git a/packages/headless/src/features/folding/folding-insight-analytics-actions.test.ts b/packages/headless/src/features/folding/folding-insight-analytics-actions.test.ts index ba47fdf0d0d..5ee14ab73f9 100644 --- a/packages/headless/src/features/folding/folding-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/folding/folding-insight-analytics-actions.test.ts @@ -1,32 +1,32 @@ -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { MockedInsightEngine, buildMockInsightEngine, -} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logShowMoreFoldedResults, logShowLessFoldedResults, -} from './folding-insight-analytics-actions'; -import {getFoldingInitialState} from './folding-state'; +} from './folding-insight-analytics-actions.js'; +import {getFoldingInitialState} from './folding-state.js'; -const mockLogShowMoreFoldedResults = jest.fn(); -const mockLogShowLessFoldedResults = jest.fn(); +const mockLogShowMoreFoldedResults = vi.fn(); +const mockLogShowLessFoldedResults = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ + disable: vi.fn(), logShowMoreFoldedResults: mockLogShowMoreFoldedResults, logShowLessFoldedResults: mockLogShowLessFoldedResults, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -111,7 +111,7 @@ describe('folding insight analytics actions', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('should log #logShowMoreFoldedResults with the result payload', async () => { diff --git a/packages/headless/src/features/folding/folding-insight-analytics-actions.ts b/packages/headless/src/features/folding/folding-insight-analytics-actions.ts index adeea3d1203..c381f4bc117 100644 --- a/packages/headless/src/features/folding/folding-insight-analytics-actions.ts +++ b/packages/headless/src/features/folding/folding-insight-analytics-actions.ts @@ -1,13 +1,13 @@ -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { documentIdentifier, InsightAction, makeInsightAnalyticsActionFactory, partialDocumentInformation, validateResultPayload, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export const logShowMoreFoldedResults = (result: Result): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.showMoreFoldedResults)( diff --git a/packages/headless/src/features/folding/folding-slice.test.ts b/packages/headless/src/features/folding/folding-slice.test.ts index 141c40284eb..3e17c037eae 100644 --- a/packages/headless/src/features/folding/folding-slice.test.ts +++ b/packages/headless/src/features/folding/folding-slice.test.ts @@ -1,21 +1,21 @@ import {Action} from '@reduxjs/toolkit'; -import {SearchAPIClient} from '../../api/search/search-api-client'; -import {Result} from '../../api/search/search/result'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {SearchAPIClient} from '../../api/search/search-api-client.js'; +import {Result} from '../../api/search/search/result.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockResultWithFolding} from '../../test/mock-result-with-folding'; -import {buildMockSearch} from '../../test/mock-search'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {createMockState} from '../../test/mock-state'; -import {executeSearch, fetchMoreResults} from '../search/search-actions'; -import {loadCollection} from './folding-actions'; -import {foldingReducer, ResultWithFolding} from './folding-slice'; -import {FoldedResult, FoldingFields, FoldingState} from './folding-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider.js'; +import {buildMockResultWithFolding} from '../../test/mock-result-with-folding.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {createMockState} from '../../test/mock-state.js'; +import {executeSearch, fetchMoreResults} from '../search/search-actions.js'; +import {loadCollection} from './folding-actions.js'; +import {foldingReducer, ResultWithFolding} from './folding-slice.js'; +import {FoldedResult, FoldingFields, FoldingState} from './folding-state.js'; interface MockFoldingHierarchy { name: string; @@ -186,7 +186,7 @@ describe('folding slice', () => { beforeEach(() => { apiClient = { - search: jest.fn().mockResolvedValue({success: {results: []}}), + search: vi.fn().mockResolvedValue({success: {results: []}}), } as unknown as SearchAPIClient; mockEngine = buildMockSearchEngine(createMockState()); }); diff --git a/packages/headless/src/features/folding/folding-slice.ts b/packages/headless/src/features/folding/folding-slice.ts index 293eaedee5e..a5f40e67cd6 100644 --- a/packages/headless/src/features/folding/folding-slice.ts +++ b/packages/headless/src/features/folding/folding-slice.ts @@ -1,12 +1,12 @@ import {createReducer} from '@reduxjs/toolkit'; -import {Result} from '../../api/search/search/result'; -import {isArray} from '../../utils/utils'; +import {Result} from '../../api/search/search/result.js'; +import {isArray} from '../../utils/utils.js'; import { executeSearch, fetchMoreResults, fetchPage, -} from '../search/search-actions'; -import {loadCollection, registerFolding} from './folding-actions'; +} from '../search/search-actions.js'; +import {loadCollection, registerFolding} from './folding-actions.js'; import { FoldedCollection, CollectionId, @@ -14,8 +14,8 @@ import { FoldingFields, getFoldingInitialState, FoldingState, -} from './folding-state'; -import {getAllIncludedResultsFrom} from './folding-utils'; +} from './folding-state.js'; +import {getAllIncludedResultsFrom} from './folding-utils.js'; export interface ResultWithFolding extends Result { parentResult: ResultWithFolding | null; diff --git a/packages/headless/src/features/folding/folding-state.ts b/packages/headless/src/features/folding/folding-state.ts index 1ea2553ac37..73c0a20a886 100644 --- a/packages/headless/src/features/folding/folding-state.ts +++ b/packages/headless/src/features/folding/folding-state.ts @@ -1,4 +1,4 @@ -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; export type CollectionId = string; diff --git a/packages/headless/src/features/folding/folding-utils.ts b/packages/headless/src/features/folding/folding-utils.ts index b5482f817c1..5095d2ff63a 100644 --- a/packages/headless/src/features/folding/folding-utils.ts +++ b/packages/headless/src/features/folding/folding-utils.ts @@ -1,5 +1,5 @@ -import {removeDuplicates} from '../../utils/utils'; -import {ResultWithFolding} from './folding-slice'; +import {removeDuplicates} from '../../utils/utils.js'; +import {ResultWithFolding} from './folding-slice.js'; export function getAllIncludedResultsFrom(relevantResult: ResultWithFolding) { const foldedResults = getChildResultsRecursively(relevantResult); diff --git a/packages/headless/src/features/folding/insight-folding-actions-loader.ts b/packages/headless/src/features/folding/insight-folding-actions-loader.ts index f1c6d321719..2abc9dd0817 100644 --- a/packages/headless/src/features/folding/insight-folding-actions-loader.ts +++ b/packages/headless/src/features/folding/insight-folding-actions-loader.ts @@ -1,14 +1,14 @@ import {PayloadAction, AsyncThunkAction} from '@reduxjs/toolkit'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {foldingReducer as folding} from '../../features/folding/folding-slice'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {foldingReducer as folding} from '../../features/folding/folding-slice.js'; import { registerFolding, loadCollection, StateNeededByLoadCollection, LoadCollectionFulfilledReturn, RegisterFoldingActionCreatorPayload, -} from './insight-folding-actions'; +} from './insight-folding-actions.js'; export type {RegisterFoldingActionCreatorPayload}; diff --git a/packages/headless/src/features/folding/insight-folding-actions.ts b/packages/headless/src/features/folding/insight-folding-actions.ts index c913b8ca285..7caee9d910a 100644 --- a/packages/headless/src/features/folding/insight-folding-actions.ts +++ b/packages/headless/src/features/folding/insight-folding-actions.ts @@ -1,22 +1,22 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {isErrorResponse} from '../../api/search/search-api-client'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; +import {isErrorResponse} from '../../api/search/search-api-client.js'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; import { ConfigurationSection, FoldingSection, InsightConfigurationSection, QuerySection, -} from '../../state/state-sections'; -import {validatePayload} from '../../utils/validate-payload'; +} from '../../state/state-sections.js'; +import {validatePayload} from '../../utils/validate-payload.js'; import { RegisterFoldingActionCreatorPayload, foldingOptionsSchemaDefinition, LoadCollectionFulfilledReturn, -} from '../folding/folding-actions'; -import {ResultWithFolding} from '../folding/folding-slice'; -import {CollectionId} from '../folding/folding-state'; -import {fetchFromAPI} from '../insight-search/insight-search-actions'; -import {buildInsightLoadCollectionRequest} from '../insight-search/insight-search-request'; +} from '../folding/folding-actions.js'; +import {ResultWithFolding} from '../folding/folding-slice.js'; +import {CollectionId} from '../folding/folding-state.js'; +import {fetchFromAPI} from '../insight-search/insight-search-actions.js'; +import {buildInsightLoadCollectionRequest} from '../insight-search/insight-search-request.js'; export type { RegisterFoldingActionCreatorPayload, diff --git a/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-analytics-actions.test.ts.snap b/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-analytics-actions.test.ts.snap index 849fa2e0824..444222198b1 100644 --- a/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logCopyGeneratedAnswer with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logCopyGeneratedAnswer with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -13,7 +13,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logDislikeGeneratedAnswer with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logDislikeGeneratedAnswer with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -26,7 +26,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerCollapse with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerCollapse with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -39,7 +39,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerExpand with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerExpand with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -52,7 +52,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerFeedback with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerFeedback with the right payload 1`] = ` [ "Qna.SubmitRgaFeedback", { @@ -72,7 +72,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerHideAnswers with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerHideAnswers with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -85,7 +85,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerShowAnswers with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerShowAnswers with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -98,7 +98,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logHoverCitation with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logHoverCitation with the right payload 1`] = ` [ "Qna.CitationHover", { @@ -115,7 +115,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logLikeGeneratedAnswer with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logLikeGeneratedAnswer with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -128,7 +128,7 @@ exports[`generated answer analytics actions when analyticsMode is \`next\` shoul ] `; -exports[`generated answer analytics actions when analyticsMode is \`next\` should log #logOpenGeneratedAnswerSource with the right payload 1`] = ` +exports[`generated answer analytics actions > when analyticsMode is \`next\` > should log #logOpenGeneratedAnswerSource with the right payload 1`] = ` [ "Qna.CitationClick", { diff --git a/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-insight-analytics-actions.test.ts.snap b/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-insight-analytics-actions.test.ts.snap index 971814fc8cb..67dafd98bec 100644 --- a/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-insight-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/generated-answer/__snapshots__/generated-answer-insight-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logCopyGeneratedAnswer with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logCopyGeneratedAnswer with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -13,7 +13,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logDislikeGeneratedAnswer with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logDislikeGeneratedAnswer with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -26,7 +26,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerCollapse with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerCollapse with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -39,7 +39,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerExpand with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerExpand with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -52,7 +52,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerFeedback with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerFeedback with the right payload 1`] = ` [ "Qna.SubmitRgaFeedback", { @@ -72,7 +72,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerHideAnswers with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerHideAnswers with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -85,7 +85,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logGeneratedAnswerShowAnswers with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logGeneratedAnswerShowAnswers with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -98,7 +98,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logHoverCitation with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logHoverCitation with the right payload 1`] = ` [ "Qna.CitationHover", { @@ -115,7 +115,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logLikeGeneratedAnswer with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logLikeGeneratedAnswer with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -128,7 +128,7 @@ exports[`generated answer insight analytics actions when analyticsMode is \`next ] `; -exports[`generated answer insight analytics actions when analyticsMode is \`next\` should log #logOpenGeneratedAnswerSource with the right payload 1`] = ` +exports[`generated answer insight analytics actions > when analyticsMode is \`next\` > should log #logOpenGeneratedAnswerSource with the right payload 1`] = ` [ "Qna.CitationClick", { diff --git a/packages/headless/src/features/generated-answer/generated-answer-actions-loader.ts b/packages/headless/src/features/generated-answer/generated-answer-actions-loader.ts index ef9d928a1f2..add1fc91d17 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-actions-loader.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {resetAnswer} from './generated-answer-actions'; -import {generatedAnswerReducer as generatedAnswer} from './generated-answer-slice'; +import {CoreEngine} from '../../app/engine.js'; +import {resetAnswer} from './generated-answer-actions.js'; +import {generatedAnswerReducer as generatedAnswer} from './generated-answer-slice.js'; /** * The generated answer action creators. diff --git a/packages/headless/src/features/generated-answer/generated-answer-actions.test.ts b/packages/headless/src/features/generated-answer/generated-answer-actions.test.ts index 6b91efc1f0b..7891fb915ce 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-actions.test.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-actions.test.ts @@ -1,4 +1,4 @@ -import {buildMockCitation} from '../../test/mock-citation'; +import {buildMockCitation} from '../../test/mock-citation.js'; import { setIsVisible, setIsLoading, @@ -8,15 +8,16 @@ import { updateResponseFormat, registerFieldsToIncludeInCitations, setAnswerContentFormat, -} from './generated-answer-actions'; + setIsEnabled, +} from './generated-answer-actions.js'; import { GeneratedContentFormat, generatedContentFormat, -} from './generated-response-format'; +} from './generated-response-format.js'; describe('generated answer', () => { afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('#updateError', () => { @@ -92,6 +93,12 @@ describe('generated answer', () => { }); }); + describe('#setIsEnabled', () => { + it('should accept a valid payload', () => { + expect(() => setIsEnabled(true)).not.toThrow(); + }); + }); + describe('#setAnswerContentFormat', () => { test.each(generatedContentFormat)( 'should accept a valid payload with format: "%i"', diff --git a/packages/headless/src/features/generated-answer/generated-answer-actions.ts b/packages/headless/src/features/generated-answer/generated-answer-actions.ts index 86c41273edd..955b4219d7e 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-actions.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-actions.ts @@ -6,7 +6,7 @@ import { StringValue, } from '@coveo/bueno'; import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkGeneratedAnswerOptions} from '../../api/generated-answer/generated-answer-client'; +import {AsyncThunkGeneratedAnswerOptions} from '../../api/generated-answer/generated-answer-client.js'; import { GeneratedAnswerCitationsPayload, GeneratedAnswerEndOfStreamPayload, @@ -14,25 +14,25 @@ import { GeneratedAnswerMessagePayload, GeneratedAnswerPayloadType, GeneratedAnswerStreamEventData, -} from '../../api/generated-answer/generated-answer-event-payload'; -import {GeneratedAnswerStreamRequest} from '../../api/generated-answer/generated-answer-request'; +} from '../../api/generated-answer/generated-answer-event-payload.js'; +import {GeneratedAnswerStreamRequest} from '../../api/generated-answer/generated-answer-request.js'; import { ConfigurationSection, DebugSection, GeneratedAnswerSection, SearchSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; import { nonEmptyStringArray, validatePayload, -} from '../../utils/validate-payload'; -import {logGeneratedAnswerStreamEnd} from './generated-answer-analytics-actions'; -import {buildStreamingRequest} from './generated-answer-request'; +} from '../../utils/validate-payload.js'; +import {logGeneratedAnswerStreamEnd} from './generated-answer-analytics-actions.js'; +import {buildStreamingRequest} from './generated-answer-request.js'; import { GeneratedContentFormat, GeneratedResponseFormat, generatedContentFormat, -} from './generated-response-format'; +} from './generated-response-format.js'; type StateNeededByGeneratedAnswerStream = ConfigurationSection & SearchSection & @@ -65,6 +65,11 @@ export const setIsVisible = createAction( (payload: boolean) => validatePayload(payload, booleanValue) ); +export const setIsEnabled = createAction( + 'generatedAnswer/setIsEnabled', + (payload: boolean) => validatePayload(payload, booleanValue) +); + export const updateMessage = createAction( 'generatedAnswer/updateMessage', (payload: GeneratedAnswerMessagePayload) => diff --git a/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.test.ts b/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.test.ts index ddc2cedd611..61a3d07c7a4 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.test.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.test.ts @@ -1,14 +1,14 @@ import {createRelay} from '@coveo/relay'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {GeneratedAnswerCitation} from '../../controllers/generated-answer/headless-generated-answer'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {GeneratedAnswerCitation} from '../../controllers/generated-answer/headless-generated-answer.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {createMockState} from '../../test/mock-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {createMockState} from '../../test/mock-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logCopyGeneratedAnswer, logDislikeGeneratedAnswer, @@ -23,65 +23,65 @@ import { logGeneratedAnswerExpand, logGeneratedAnswerCollapse, GeneratedAnswerFeedback, -} from './generated-answer-analytics-actions'; -import {getGeneratedAnswerInitialState} from './generated-answer-state'; +} from './generated-answer-analytics-actions.js'; +import {getGeneratedAnswerInitialState} from './generated-answer-state.js'; -const mockLogFunction = jest.fn(); -const mockMakeGeneratedAnswerFeedbackSubmit = jest.fn(() => ({ +const mockLogFunction = vi.fn(); +const mockMakeGeneratedAnswerFeedbackSubmit = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeRetryGeneratedAnswer = jest.fn(() => ({ +const mockMakeRetryGeneratedAnswer = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeOpenGeneratedAnswerSource = jest.fn(() => ({ +const mockMakeOpenGeneratedAnswerSource = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerSourceHover = jest.fn(() => ({ +const mockMakeGeneratedAnswerSourceHover = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeLikeGeneratedAnswer = jest.fn(() => ({ +const mockMakeLikeGeneratedAnswer = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeDislikeGeneratedAnswer = jest.fn(() => ({ +const mockMakeDislikeGeneratedAnswer = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerStreamEnd = jest.fn(() => ({ +const mockMakeGeneratedAnswerStreamEnd = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerShowAnswers = jest.fn(() => ({ +const mockMakeGeneratedAnswerShowAnswers = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerHideAnswers = jest.fn(() => ({ +const mockMakeGeneratedAnswerHideAnswers = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerCopyToClipboard = jest.fn(() => ({ +const mockMakeGeneratedAnswerCopyToClipboard = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerExpand = jest.fn(() => ({ +const mockMakeGeneratedAnswerExpand = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerCollapse = jest.fn(() => ({ +const mockMakeGeneratedAnswerCollapse = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeGeneratedAnswerFeedbackSubmitV2 = jest.fn(() => ({ +const mockMakeGeneratedAnswerFeedbackSubmitV2 = vi.fn(() => ({ log: mockLogFunction, })); -const emit = jest.fn(); +const emit = vi.fn(); -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); -jest.mock('coveo.analytics', () => { - const mockCoveoSearchPageClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCoveoSearchPageClient = vi.fn(() => ({ + disable: vi.fn(), makeGeneratedAnswerFeedbackSubmit: mockMakeGeneratedAnswerFeedbackSubmit, makeRetryGeneratedAnswer: mockMakeRetryGeneratedAnswer, makeOpenGeneratedAnswerSource: mockMakeOpenGeneratedAnswerSource, @@ -100,7 +100,7 @@ jest.mock('coveo.analytics', () => { return { CoveoSearchPageClient: mockCoveoSearchPageClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -137,7 +137,7 @@ describe('generated answer analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts b/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts index 04f659f0aaf..097bb6fc966 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-analytics-actions.ts @@ -3,13 +3,13 @@ import { CustomAction, LegacySearchAction, makeAnalyticsAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; import { citationSourceSelector, generativeQuestionAnsweringIdSelector, -} from './generated-answer-selectors'; +} from './generated-answer-selectors.js'; export type GeneratedAnswerFeedbackOption = 'yes' | 'unknown' | 'no'; diff --git a/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.test.ts b/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.test.ts index e82d46d75ba..38ba5081678 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.test.ts @@ -1,14 +1,14 @@ import {createRelay} from '@coveo/relay'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {GeneratedAnswerFeedback} from './generated-answer-analytics-actions'; +} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {GeneratedAnswerFeedback} from './generated-answer-analytics-actions.js'; import { logGeneratedAnswerFeedback, logRetryGeneratedAnswer, @@ -22,38 +22,38 @@ import { logCopyGeneratedAnswer, logGeneratedAnswerExpand, logGeneratedAnswerCollapse, -} from './generated-answer-insight-analytics-actions'; -import {getGeneratedAnswerInitialState} from './generated-answer-state'; - -const mockLogGeneratedAnswerFeedbackSubmit = jest.fn(); -const mockLogRetryGeneratedAnswer = jest.fn(); -const mockLogOpenGeneratedAnswerSource = jest.fn(); -const mockLogHoverCitation = jest.fn(); -const mockLogLikeGeneratedAnswer = jest.fn(); -const mockLogDislikeGeneratedAnswer = jest.fn(); -const mockLogGeneratedAnswerStreamEnd = jest.fn(); -const mockLogGeneratedAnswerShowAnswers = jest.fn(); -const mockLogGeneratedAnswerHideAnswers = jest.fn(); -const mockLogCopyGeneratedAnswer = jest.fn(); -const mockLogGeneratedAnswerExpand = jest.fn(); -const mockLogGeneratedAnswerCollapse = jest.fn(); -const mockLogGeneratedAnswerFeedbackSubmitV2 = jest.fn(); -const emit = jest.fn(); - -jest.mock('@coveo/relay'); - -jest.mocked(createRelay).mockReturnValue({ +} from './generated-answer-insight-analytics-actions.js'; +import {getGeneratedAnswerInitialState} from './generated-answer-state.js'; + +const mockLogGeneratedAnswerFeedbackSubmit = vi.fn(); +const mockLogRetryGeneratedAnswer = vi.fn(); +const mockLogOpenGeneratedAnswerSource = vi.fn(); +const mockLogHoverCitation = vi.fn(); +const mockLogLikeGeneratedAnswer = vi.fn(); +const mockLogDislikeGeneratedAnswer = vi.fn(); +const mockLogGeneratedAnswerStreamEnd = vi.fn(); +const mockLogGeneratedAnswerShowAnswers = vi.fn(); +const mockLogGeneratedAnswerHideAnswers = vi.fn(); +const mockLogCopyGeneratedAnswer = vi.fn(); +const mockLogGeneratedAnswerExpand = vi.fn(); +const mockLogGeneratedAnswerCollapse = vi.fn(); +const mockLogGeneratedAnswerFeedbackSubmitV2 = vi.fn(); +const emit = vi.fn(); + +vi.mock('@coveo/relay'); + +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ + disable: vi.fn(), logGeneratedAnswerFeedbackSubmit: mockLogGeneratedAnswerFeedbackSubmit, logRetryGeneratedAnswer: mockLogRetryGeneratedAnswer, logOpenGeneratedAnswerSource: mockLogOpenGeneratedAnswerSource, @@ -71,7 +71,7 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -131,7 +131,7 @@ describe('generated answer insight analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.ts b/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.ts index 9e6c603bfef..e93e0249376 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-insight-analytics-actions.ts @@ -2,14 +2,14 @@ import {Qna} from '@coveo/relay-event-types'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; -import {GeneratedAnswerFeedback} from './generated-answer-analytics-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; +import {GeneratedAnswerFeedback} from './generated-answer-analytics-actions.js'; import { citationSourceSelector, generativeQuestionAnsweringIdSelector, -} from './generated-answer-selectors'; +} from './generated-answer-selectors.js'; const RGAType = 'RGA'; diff --git a/packages/headless/src/features/generated-answer/generated-answer-request.ts b/packages/headless/src/features/generated-answer/generated-answer-request.ts index 07e6bbf2edc..eac0c4c1afc 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-request.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-request.ts @@ -1,10 +1,10 @@ -import {GeneratedAnswerStreamRequest} from '../../api/generated-answer/generated-answer-request'; -import {getOrganizationEndpoint} from '../../api/platform-client'; +import {GeneratedAnswerStreamRequest} from '../../api/generated-answer/generated-answer-request.js'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; import { ConfigurationSection, GeneratedAnswerSection, SearchSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; type StateNeededByGeneratedAnswerStream = ConfigurationSection & SearchSection & diff --git a/packages/headless/src/features/generated-answer/generated-answer-selectors.test.ts b/packages/headless/src/features/generated-answer/generated-answer-selectors.test.ts index a5930be3633..ca32ffe8a41 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-selectors.test.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-selectors.test.ts @@ -1,9 +1,9 @@ -import {streamAnswerAPIStateMock} from '../../api/knowledge/tests/stream-answer-api-state-mock'; -import {SearchAppState} from '../../state/search-app-state'; -import {generativeQuestionAnsweringIdSelector} from './generated-answer-selectors'; +import {streamAnswerAPIStateMock} from '../../api/knowledge/tests/stream-answer-api-state-mock.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {generativeQuestionAnsweringIdSelector} from './generated-answer-selectors.js'; -jest.mock('../../api/knowledge/stream-answer-api', () => ({ - ...jest.requireActual>>( +vi.mock('../../api/knowledge/stream-answer-api', () => ({ + ...vi.importActual>>( '../../api/knowledge/stream-answer-api' ), selectAnswer: (_state: Partial) => ({ @@ -16,7 +16,7 @@ jest.mock('../../api/knowledge/stream-answer-api', () => ({ describe('generated-answer-selectors', () => { describe('generativeQuestionAnsweringIdSelector', () => { afterAll(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('returns the answerId if an answer configuration id is in state', () => { const state = { diff --git a/packages/headless/src/features/generated-answer/generated-answer-selectors.ts b/packages/headless/src/features/generated-answer/generated-answer-selectors.ts index b92b904464e..e377bae1f96 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-selectors.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-selectors.ts @@ -3,14 +3,14 @@ import {createSelector} from '@reduxjs/toolkit'; import { selectAnswer, StateNeededByAnswerAPI, -} from '../../api/knowledge/stream-answer-api'; -import {GeneratedAnswerCitation} from '../../controllers/generated-answer/headless-generated-answer'; -import {SearchAppState} from '../../state/search-app-state'; +} from '../../api/knowledge/stream-answer-api.js'; +import {GeneratedAnswerCitation} from '../../controllers/generated-answer/headless-generated-answer.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { GeneratedAnswerSection, SearchSection, -} from '../../state/state-sections'; -import {selectQuery} from '../query/query-selectors'; +} from '../../state/state-sections.js'; +import {selectQuery} from '../query/query-selectors.js'; export const generativeQuestionAnsweringIdSelector = ( state: Partial diff --git a/packages/headless/src/features/generated-answer/generated-answer-slice.test.ts b/packages/headless/src/features/generated-answer/generated-answer-slice.test.ts index 7ba0c6aecfc..9da0ef917ac 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-slice.test.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-slice.test.ts @@ -1,5 +1,5 @@ -import {RETRYABLE_STREAM_ERROR_CODE} from '../../api/generated-answer/generated-answer-client'; -import {buildMockCitation} from '../../test/mock-citation'; +import {RETRYABLE_STREAM_ERROR_CODE} from '../../api/generated-answer/generated-answer-client.js'; +import {buildMockCitation} from '../../test/mock-citation.js'; import { dislikeGeneratedAnswer, likeGeneratedAnswer, @@ -19,14 +19,15 @@ import { setIsAnswerGenerated, expandGeneratedAnswer, collapseGeneratedAnswer, -} from './generated-answer-actions'; -import {generatedAnswerReducer} from './generated-answer-slice'; -import {getGeneratedAnswerInitialState} from './generated-answer-state'; + setIsEnabled, +} from './generated-answer-actions.js'; +import {generatedAnswerReducer} from './generated-answer-slice.js'; +import {getGeneratedAnswerInitialState} from './generated-answer-state.js'; import { GeneratedContentFormat, GeneratedResponseFormat, generatedContentFormat, -} from './generated-response-format'; +} from './generated-response-format.js'; const baseState = getGeneratedAnswerInitialState(); @@ -224,6 +225,7 @@ describe('generated answer slice', () => { const persistentGeneratedAnswerState = { isVisible: false, responseFormat, + isEnabled: true, fieldsToIncludeInCitations: ['foo'], }; const state = { @@ -472,6 +474,26 @@ describe('generated answer slice', () => { }); }); + describe('#setIsEnabled', () => { + it('should set isEnabled to true when given true', () => { + const finalState = generatedAnswerReducer( + {...baseState, isEnabled: false}, + setIsEnabled(true) + ); + + expect(finalState.isEnabled).toEqual(true); + }); + + it('should set isEnabled to false when given false', () => { + const finalState = generatedAnswerReducer( + {...baseState, isEnabled: true}, + setIsEnabled(false) + ); + + expect(finalState.isEnabled).toEqual(false); + }); + }); + describe('#setIsAnswerGenerated', () => { it('should set isAnswerGenerated to true when given true', () => { const finalState = generatedAnswerReducer( diff --git a/packages/headless/src/features/generated-answer/generated-answer-slice.ts b/packages/headless/src/features/generated-answer/generated-answer-slice.ts index 52530cc1d8d..5df51460027 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-slice.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {RETRYABLE_STREAM_ERROR_CODE} from '../../api/generated-answer/generated-answer-client'; -import {GeneratedAnswerCitation} from '../../api/generated-answer/generated-answer-event-payload'; +import {RETRYABLE_STREAM_ERROR_CODE} from '../../api/generated-answer/generated-answer-client.js'; +import {GeneratedAnswerCitation} from '../../api/generated-answer/generated-answer-event-payload.js'; import { closeGeneratedAnswerFeedbackModal, dislikeGeneratedAnswer, @@ -22,8 +22,9 @@ import { expandGeneratedAnswer, collapseGeneratedAnswer, updateAnswerConfigurationId, -} from './generated-answer-actions'; -import {getGeneratedAnswerInitialState} from './generated-answer-state'; + setIsEnabled, +} from './generated-answer-actions.js'; +import {getGeneratedAnswerInitialState} from './generated-answer-state.js'; export const generatedAnswerReducer = createReducer( getGeneratedAnswerInitialState(), @@ -32,6 +33,9 @@ export const generatedAnswerReducer = createReducer( .addCase(setIsVisible, (state, {payload}) => { state.isVisible = payload; }) + .addCase(setIsEnabled, (state, {payload}) => { + state.isEnabled = payload; + }) .addCase(setId, (state, {payload}) => { state.id = payload.id; }) diff --git a/packages/headless/src/features/generated-answer/generated-answer-state.ts b/packages/headless/src/features/generated-answer/generated-answer-state.ts index c98e4805999..d16c488fbf4 100644 --- a/packages/headless/src/features/generated-answer/generated-answer-state.ts +++ b/packages/headless/src/features/generated-answer/generated-answer-state.ts @@ -1,8 +1,8 @@ -import {GeneratedAnswerCitation} from '../../api/generated-answer/generated-answer-event-payload'; +import {GeneratedAnswerCitation} from '../../api/generated-answer/generated-answer-event-payload.js'; import { GeneratedContentFormat, GeneratedResponseFormat, -} from './generated-response-format'; +} from './generated-response-format.js'; export interface GeneratedAnswerState { id: string; @@ -18,6 +18,10 @@ export interface GeneratedAnswerState { * Determines if the generated answer is streaming. */ isStreaming: boolean; + /** + * Determines if the generated answer is enabled. + */ + isEnabled: boolean; /** * The generated answer. */ @@ -82,6 +86,7 @@ export function getGeneratedAnswerInitialState(): GeneratedAnswerState { return { id: '', isVisible: true, + isEnabled: true, isLoading: false, isStreaming: false, citations: [], diff --git a/packages/headless/src/features/history/history-actions-loader.ts b/packages/headless/src/features/history/history-actions-loader.ts index 3cbce3422a9..cb705f6e93a 100644 --- a/packages/headless/src/features/history/history-actions-loader.ts +++ b/packages/headless/src/features/history/history-actions-loader.ts @@ -1,8 +1,8 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {facetOrderReducer as facetOrder} from '../../features/facets/facet-order/facet-order-slice'; -import {history} from '../../features/history/history-slice'; -import {back, forward} from './history-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {facetOrderReducer as facetOrder} from '../../features/facets/facet-order/facet-order-slice.js'; +import {history} from '../../features/history/history-slice.js'; +import {back, forward} from './history-actions.js'; /** * The history action creators. diff --git a/packages/headless/src/features/history/history-actions.ts b/packages/headless/src/features/history/history-actions.ts index dbfb0f4aa17..2743a7e1828 100644 --- a/packages/headless/src/features/history/history-actions.ts +++ b/packages/headless/src/features/history/history-actions.ts @@ -1,6 +1,6 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {SearchAppState} from '../../state/search-app-state'; -import {HistoryState} from './history-state'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {HistoryState} from './history-state.js'; export const undo = createAction('history/undo'); export const redo = createAction('history/redo'); diff --git a/packages/headless/src/features/history/history-analytics-actions.ts b/packages/headless/src/features/history/history-analytics-actions.ts index 721bcde17fd..66bf7c7bed9 100644 --- a/packages/headless/src/features/history/history-analytics-actions.ts +++ b/packages/headless/src/features/history/history-analytics-actions.ts @@ -1,10 +1,10 @@ -import {SearchPageEvents as LegacySearchPageEvents} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; +import {SearchPageEvents as LegacySearchPageEvents} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; //TODO: KIT-2859 export const logNavigateForward = (): LegacySearchAction => diff --git a/packages/headless/src/features/history/history-slice.test.ts b/packages/headless/src/features/history/history-slice.test.ts index 2c3ddbf2f4b..fa4c360f8f2 100644 --- a/packages/headless/src/features/history/history-slice.test.ts +++ b/packages/headless/src/features/history/history-slice.test.ts @@ -1,21 +1,21 @@ import {Reducer} from '@reduxjs/toolkit'; -import {undoable, StateWithHistory, makeHistory} from '../../app/undoable'; -import {buildMockAdvancedSearchQueriesState} from '../../test/mock-advanced-search-queries-state'; -import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice'; -import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice'; -import {buildMockCategoryFacetValueRequest} from '../../test/mock-category-facet-value-request'; -import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice'; -import {buildMockQueryState} from '../../test/mock-query-state'; -import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value'; -import {buildMockTabSlice} from '../../test/mock-tab-state'; -import {redo, snapshot, undo} from './history-actions'; -import {historyReducer} from './history-slice'; -import {getHistoryInitialState, HistoryState} from './history-state'; +import {undoable, StateWithHistory, makeHistory} from '../../app/undoable.js'; +import {buildMockAdvancedSearchQueriesState} from '../../test/mock-advanced-search-queries-state.js'; +import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice.js'; +import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice.js'; +import {buildMockCategoryFacetValueRequest} from '../../test/mock-category-facet-value-request.js'; +import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice.js'; +import {buildMockQueryState} from '../../test/mock-query-state.js'; +import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value.js'; +import {buildMockTabSlice} from '../../test/mock-tab-state.js'; +import {redo, snapshot, undo} from './history-actions.js'; +import {historyReducer} from './history-slice.js'; +import {getHistoryInitialState, HistoryState} from './history-state.js'; describe('history slice', () => { let undoableReducer: Reducer>; diff --git a/packages/headless/src/features/history/history-slice.ts b/packages/headless/src/features/history/history-slice.ts index 2caf8e7a4a8..5522c67cede 100644 --- a/packages/headless/src/features/history/history-slice.ts +++ b/packages/headless/src/features/history/history-slice.ts @@ -1,24 +1,24 @@ import {createReducer} from '@reduxjs/toolkit'; -import {undoable} from '../../app/undoable'; -import {SortState} from '../../controllers/sort/headless-sort'; -import {arrayEqual} from '../../utils/compare-utils'; -import {AdvancedSearchQueriesState} from '../advanced-search-queries/advanced-search-queries-state'; -import {ContextState} from '../context/context-state'; -import {DictionaryFieldContextState} from '../dictionary-field-context/dictionary-field-context-state'; -import {AutomaticFacetSetState} from '../facets/automatic-facet-set/automatic-facet-set-state'; -import {CategoryFacetSetState} from '../facets/category-facet-set/category-facet-set-state'; -import {findActiveValueAncestry} from '../facets/category-facet-set/category-facet-utils'; -import {FacetValue} from '../facets/facet-set/interfaces/response'; -import {AnyFacetSetState} from '../facets/generic/interfaces/generic-facet-section'; -import {PaginationState} from '../pagination/pagination-state'; -import {QueryState} from '../query/query-state'; +import {undoable} from '../../app/undoable.js'; +import {SortState} from '../../controllers/sort/headless-sort.js'; +import {arrayEqual} from '../../utils/compare-utils.js'; +import {AdvancedSearchQueriesState} from '../advanced-search-queries/advanced-search-queries-state.js'; +import {ContextState} from '../context/context-state.js'; +import {DictionaryFieldContextState} from '../dictionary-field-context/dictionary-field-context-state.js'; +import {AutomaticFacetSetState} from '../facets/automatic-facet-set/automatic-facet-set-state.js'; +import {CategoryFacetSetState} from '../facets/category-facet-set/category-facet-set-state.js'; +import {findActiveValueAncestry} from '../facets/category-facet-set/category-facet-utils.js'; +import {FacetValue} from '../facets/facet-set/interfaces/response.js'; +import {AnyFacetSetState} from '../facets/generic/interfaces/generic-facet-section.js'; +import {PaginationState} from '../pagination/pagination-state.js'; +import {QueryState} from '../query/query-state.js'; import { StaticFilterSetState, StaticFilterSlice, -} from '../static-filter-set/static-filter-set-state'; -import {TabSetState} from '../tab-set/tab-set-state'; -import {snapshot, redo, undo} from './history-actions'; -import {getHistoryInitialState, HistoryState} from './history-state'; +} from '../static-filter-set/static-filter-set-state.js'; +import {TabSetState} from '../tab-set/tab-set-state.js'; +import {snapshot, redo, undo} from './history-actions.js'; +import {getHistoryInitialState, HistoryState} from './history-state.js'; // TODO: https://coveord.atlassian.net/browse/KIT-2969: // Should be able to remove most of the code in this file following changes history management change diff --git a/packages/headless/src/features/history/history-state.ts b/packages/headless/src/features/history/history-state.ts index 952c42b1422..2d1be137ead 100644 --- a/packages/headless/src/features/history/history-state.ts +++ b/packages/headless/src/features/history/history-state.ts @@ -1,23 +1,23 @@ -import {SearchParametersState} from '../../state/search-app-state'; -import {getAdvancedSearchQueriesInitialState} from '../advanced-search-queries/advanced-search-queries-state'; -import {getContextInitialState} from '../context/context-state'; -import {getDebugInitialState} from '../debug/debug-state'; -import {getDictionaryFieldContextInitialState} from '../dictionary-field-context/dictionary-field-context-state'; -import {getFacetOptionsInitialState} from '../facet-options/facet-options-state'; -import {getAutomaticFacetSetInitialState} from '../facets/automatic-facet-set/automatic-facet-set-state'; -import {getCategoryFacetSetInitialState} from '../facets/category-facet-set/category-facet-set-state'; -import {getFacetOrderInitialState} from '../facets/facet-order/facet-order-state'; -import {getFacetSetInitialState} from '../facets/facet-set/facet-set-state'; -import {getDateFacetSetInitialState} from '../facets/range-facets/date-facet-set/date-facet-set-state'; -import {getNumericFacetSetInitialState} from '../facets/range-facets/numeric-facet-set/numeric-facet-set-state'; -import {getPaginationInitialState} from '../pagination/pagination-state'; -import {getPipelineInitialState} from '../pipeline/pipeline-state'; -import {getQuerySetInitialState} from '../query-set/query-set-state'; -import {getQueryInitialState} from '../query/query-state'; -import {getSearchHubInitialState} from '../search-hub/search-hub-state'; -import {getSortCriteriaInitialState} from '../sort-criteria/sort-criteria-state'; -import {getStaticFilterSetInitialState} from '../static-filter-set/static-filter-set-state'; -import {getTabSetInitialState} from '../tab-set/tab-set-state'; +import {SearchParametersState} from '../../state/search-app-state.js'; +import {getAdvancedSearchQueriesInitialState} from '../advanced-search-queries/advanced-search-queries-state.js'; +import {getContextInitialState} from '../context/context-state.js'; +import {getDebugInitialState} from '../debug/debug-state.js'; +import {getDictionaryFieldContextInitialState} from '../dictionary-field-context/dictionary-field-context-state.js'; +import {getFacetOptionsInitialState} from '../facet-options/facet-options-state.js'; +import {getAutomaticFacetSetInitialState} from '../facets/automatic-facet-set/automatic-facet-set-state.js'; +import {getCategoryFacetSetInitialState} from '../facets/category-facet-set/category-facet-set-state.js'; +import {getFacetOrderInitialState} from '../facets/facet-order/facet-order-state.js'; +import {getFacetSetInitialState} from '../facets/facet-set/facet-set-state.js'; +import {getDateFacetSetInitialState} from '../facets/range-facets/date-facet-set/date-facet-set-state.js'; +import {getNumericFacetSetInitialState} from '../facets/range-facets/numeric-facet-set/numeric-facet-set-state.js'; +import {getPaginationInitialState} from '../pagination/pagination-state.js'; +import {getPipelineInitialState} from '../pipeline/pipeline-state.js'; +import {getQuerySetInitialState} from '../query-set/query-set-state.js'; +import {getQueryInitialState} from '../query/query-state.js'; +import {getSearchHubInitialState} from '../search-hub/search-hub-state.js'; +import {getSortCriteriaInitialState} from '../sort-criteria/sort-criteria-state.js'; +import {getStaticFilterSetInitialState} from '../static-filter-set/static-filter-set-state.js'; +import {getTabSetInitialState} from '../tab-set/tab-set-state.js'; export interface HistoryState extends SearchParametersState { facetOrder: string[]; diff --git a/packages/headless/src/features/insight-configuration/insight-configuration-actions.ts b/packages/headless/src/features/insight-configuration/insight-configuration-actions.ts index 3141b05b124..66a497fe1c8 100644 --- a/packages/headless/src/features/insight-configuration/insight-configuration-actions.ts +++ b/packages/headless/src/features/insight-configuration/insight-configuration-actions.ts @@ -2,7 +2,7 @@ import {createAction} from '@reduxjs/toolkit'; import { requiredNonEmptyString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export interface SetInsightConfigurationActionCreatorPayload { /** diff --git a/packages/headless/src/features/insight-configuration/insight-configuration-slice.test.ts b/packages/headless/src/features/insight-configuration/insight-configuration-slice.test.ts index 01776e28cd7..24afcefc521 100644 --- a/packages/headless/src/features/insight-configuration/insight-configuration-slice.test.ts +++ b/packages/headless/src/features/insight-configuration/insight-configuration-slice.test.ts @@ -1,9 +1,9 @@ -import {setInsightConfiguration} from './insight-configuration-actions'; -import {insightConfigurationReducer} from './insight-configuration-slice'; +import {setInsightConfiguration} from './insight-configuration-actions.js'; +import {insightConfigurationReducer} from './insight-configuration-slice.js'; import { getInsightConfigurationInitialState, InsightConfigurationState, -} from './insight-configuration-state'; +} from './insight-configuration-state.js'; describe('insight configuration slice', () => { let state: InsightConfigurationState; diff --git a/packages/headless/src/features/insight-configuration/insight-configuration-slice.ts b/packages/headless/src/features/insight-configuration/insight-configuration-slice.ts index 903f6f5dcda..c3d8e59652b 100644 --- a/packages/headless/src/features/insight-configuration/insight-configuration-slice.ts +++ b/packages/headless/src/features/insight-configuration/insight-configuration-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {setInsightConfiguration} from './insight-configuration-actions'; -import {getInsightConfigurationInitialState} from './insight-configuration-state'; +import {setInsightConfiguration} from './insight-configuration-actions.js'; +import {getInsightConfigurationInitialState} from './insight-configuration-state.js'; export const insightConfigurationReducer = createReducer( getInsightConfigurationInitialState(), diff --git a/packages/headless/src/features/insight-interface/insight-interface-actions-loader.ts b/packages/headless/src/features/insight-interface/insight-interface-actions-loader.ts index 1240f5e6c55..b762c2ecef7 100644 --- a/packages/headless/src/features/insight-interface/insight-interface-actions-loader.ts +++ b/packages/headless/src/features/insight-interface/insight-interface-actions-loader.ts @@ -1,12 +1,12 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {insightInterfaceReducer as insightInterface} from '../../features/insight-interface/insight-interface-slice.js'; import { fetchInterface, FetchInterfaceThunkReturn, StateNeededByFetchInterface, -} from './insight-interface-actions'; +} from './insight-interface-actions.js'; /** * The Insight interface action creators. diff --git a/packages/headless/src/features/insight-interface/insight-interface-actions.ts b/packages/headless/src/features/insight-interface/insight-interface-actions.ts index bb1d67aed89..0becd1eea95 100644 --- a/packages/headless/src/features/insight-interface/insight-interface-actions.ts +++ b/packages/headless/src/features/insight-interface/insight-interface-actions.ts @@ -1,14 +1,14 @@ import {createAsyncThunk} from '@reduxjs/toolkit'; -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {isErrorResponse} from '../../api/search/search-api-client'; -import {GetInsightInterfaceConfigRequest} from '../../api/service/insight/get-interface/get-interface-config-request'; -import {GetInsightInterfaceConfigResponse} from '../../api/service/insight/get-interface/get-interface-config-response'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {isErrorResponse} from '../../api/search/search-api-client.js'; +import {GetInsightInterfaceConfigRequest} from '../../api/service/insight/get-interface/get-interface-config-request.js'; +import {GetInsightInterfaceConfigResponse} from '../../api/service/insight/get-interface/get-interface-config-response.js'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; import { ConfigurationSection, InsightConfigurationSection, -} from '../../state/state-sections'; -import {setSearchHub} from '../search-hub/search-hub-actions'; +} from '../../state/state-sections.js'; +import {setSearchHub} from '../search-hub/search-hub-actions.js'; export interface FetchInterfaceThunkReturn { /** The successful get interface response. */ diff --git a/packages/headless/src/features/insight-interface/insight-interface-slice.test.ts b/packages/headless/src/features/insight-interface/insight-interface-slice.test.ts index f1baa58068b..b68d03224c5 100644 --- a/packages/headless/src/features/insight-interface/insight-interface-slice.test.ts +++ b/packages/headless/src/features/insight-interface/insight-interface-slice.test.ts @@ -1,6 +1,6 @@ -import {fetchInterface} from './insight-interface-actions'; -import {insightInterfaceReducer} from './insight-interface-slice'; -import {getInsightInterfaceInitialState} from './insight-interface-state'; +import {fetchInterface} from './insight-interface-actions.js'; +import {insightInterfaceReducer} from './insight-interface-slice.js'; +import {getInsightInterfaceInitialState} from './insight-interface-state.js'; describe('insight interface slice', () => { const requestId = 'some-request-id'; diff --git a/packages/headless/src/features/insight-interface/insight-interface-slice.ts b/packages/headless/src/features/insight-interface/insight-interface-slice.ts index a3c6a191b4b..6fd06c54fec 100644 --- a/packages/headless/src/features/insight-interface/insight-interface-slice.ts +++ b/packages/headless/src/features/insight-interface/insight-interface-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {fetchInterface} from './insight-interface-actions'; -import {getInsightInterfaceInitialState} from './insight-interface-state'; +import {fetchInterface} from './insight-interface-actions.js'; +import {getInsightInterfaceInitialState} from './insight-interface-state.js'; export const insightInterfaceReducer = createReducer( getInsightInterfaceInitialState(), diff --git a/packages/headless/src/features/insight-interface/insight-interface-state.ts b/packages/headless/src/features/insight-interface/insight-interface-state.ts index 5ab5da7b98a..b7046efb358 100644 --- a/packages/headless/src/features/insight-interface/insight-interface-state.ts +++ b/packages/headless/src/features/insight-interface/insight-interface-state.ts @@ -1,5 +1,5 @@ -import {InsightInterface} from '../../api/service/insight/get-interface/get-interface-config-response'; -import {InsightAPIErrorStatusResponse} from '../../api/service/insight/insight-api-client'; +import {InsightInterface} from '../../api/service/insight/get-interface/get-interface-config-response.js'; +import {InsightAPIErrorStatusResponse} from '../../api/service/insight/insight-api-client.js'; export const getInsightInterfaceInitialState = (): InsightInterfaceState => ({ loading: false, diff --git a/packages/headless/src/features/insight-search/__snapshots__/insight-analytics-actions.test.ts.snap b/packages/headless/src/features/insight-search/__snapshots__/insight-analytics-actions.test.ts.snap index 19d2b47e823..d148f11d001 100644 --- a/packages/headless/src/features/insight-search/__snapshots__/insight-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/insight-search/__snapshots__/insight-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`insight analytics actions when analyticsMode is \`next\` logCreateArticle should call relay.emit properly 1`] = ` +exports[`insight analytics actions > when analyticsMode is \`next\` > logCreateArticle > should call relay.emit properly 1`] = ` [ "InsightPanel.CreateArticle", { @@ -14,7 +14,7 @@ exports[`insight analytics actions when analyticsMode is \`next\` logCreateArtic ] `; -exports[`insight analytics actions when analyticsMode is \`next\` logExpandToFullUI should call relay.emit properly 1`] = ` +exports[`insight analytics actions > when analyticsMode is \`next\` > logExpandToFullUI > should call relay.emit properly 1`] = ` [ "InsightPanel.ExpandToFullUI", { diff --git a/packages/headless/src/features/insight-search/insight-analytics-actions.test.ts b/packages/headless/src/features/insight-search/insight-analytics-actions.test.ts index b4caf34779d..831bc71b7f7 100644 --- a/packages/headless/src/features/insight-search/insight-analytics-actions.test.ts +++ b/packages/headless/src/features/insight-search/insight-analytics-actions.test.ts @@ -1,26 +1,26 @@ import {createRelay} from '@coveo/relay'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logExpandToFullUI, logInsightCreateArticle, logOpenUserActions, -} from './insight-analytics-actions'; +} from './insight-analytics-actions.js'; -const mockLogCreateArticle = jest.fn(); -const mockLogExpandtoFullUI = jest.fn(); -const mockLogOpenUserActions = jest.fn(); -const emit = jest.fn(); +const mockLogCreateArticle = vi.fn(); +const mockLogExpandtoFullUI = vi.fn(); +const mockLogOpenUserActions = vi.fn(); +const emit = vi.fn(); -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ + disable: vi.fn(), logExpandToFullUI: mockLogExpandtoFullUI, logCreateArticle: mockLogCreateArticle, logOpenUserActions: mockLogOpenUserActions, @@ -28,16 +28,16 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); @@ -61,7 +61,7 @@ describe('insight analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/insight-search/insight-analytics-actions.ts b/packages/headless/src/features/insight-search/insight-analytics-actions.ts index 6d2c3397bb6..d67fd30e4b0 100644 --- a/packages/headless/src/features/insight-search/insight-analytics-actions.ts +++ b/packages/headless/src/features/insight-search/insight-analytics-actions.ts @@ -2,13 +2,13 @@ import {InsightPanel} from '@coveo/relay-event-types'; import { requiredNonEmptyString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export interface CreateArticleMetadata { articleType: string; diff --git a/packages/headless/src/features/insight-search/insight-query-set-actions-loader.ts b/packages/headless/src/features/insight-search/insight-query-set-actions-loader.ts index 8d79347bf33..2aa3e4c889f 100644 --- a/packages/headless/src/features/insight-search/insight-query-set-actions-loader.ts +++ b/packages/headless/src/features/insight-search/insight-query-set-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {querySetReducer as querySet} from '../../features/query-set/query-set-slice'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {querySetReducer as querySet} from '../../features/query-set/query-set-slice.js'; import { registerQuerySetQuery, RegisterQuerySetQueryActionCreatorPayload, updateQuerySetQuery, UpdateQuerySetQueryActionCreatorPayload, -} from '../query-set/query-set-actions'; +} from '../query-set/query-set-actions.js'; export type { RegisterQuerySetQueryActionCreatorPayload, diff --git a/packages/headless/src/features/insight-search/insight-query-suggest-request.ts b/packages/headless/src/features/insight-search/insight-query-suggest-request.ts index bdb76f6a054..54d01b43016 100644 --- a/packages/headless/src/features/insight-search/insight-query-suggest-request.ts +++ b/packages/headless/src/features/insight-search/insight-query-suggest-request.ts @@ -1,15 +1,15 @@ import { historyStore, getVisitorID, -} from '../../api/analytics/coveo-analytics-utils'; -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {InsightQuerySuggestRequest} from '../../api/service/insight/query-suggest/query-suggest-request'; -import {InsightAppState} from '../../state/insight-app-state'; +} from '../../api/analytics/coveo-analytics-utils.js'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {InsightQuerySuggestRequest} from '../../api/service/insight/query-suggest/query-suggest-request.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; import { ConfigurationSection, InsightConfigurationSection, -} from '../../state/state-sections'; -import {fromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params'; +} from '../../state/state-sections.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params.js'; type StateNeededByQuerySuggest = ConfigurationSection & InsightConfigurationSection & diff --git a/packages/headless/src/features/insight-search/insight-result-preview-request-builder.test.ts b/packages/headless/src/features/insight-search/insight-result-preview-request-builder.test.ts index 47088d50e68..20d5de08561 100644 --- a/packages/headless/src/features/insight-search/insight-result-preview-request-builder.test.ts +++ b/packages/headless/src/features/insight-search/insight-result-preview-request-builder.test.ts @@ -1,11 +1,11 @@ -import {HtmlRequestOptions} from '../../api/search/html/html-request'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {getQueryInitialState} from '../query/query-state'; -import {getResultPreviewInitialState} from '../result-preview/result-preview-state'; +import {HtmlRequestOptions} from '../../api/search/html/html-request.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {getQueryInitialState} from '../query/query-state.js'; +import {getResultPreviewInitialState} from '../result-preview/result-preview-state.js'; import { buildInsightResultPreviewRequest, StateNeededByInsightHtmlEndpoint, -} from './insight-result-preview-request-builder'; +} from './insight-result-preview-request-builder.js'; describe('ResultPreviewRequestBuilder', () => { let state: StateNeededByInsightHtmlEndpoint; diff --git a/packages/headless/src/features/insight-search/insight-result-preview-request-builder.ts b/packages/headless/src/features/insight-search/insight-result-preview-request-builder.ts index 45a164dfcac..23308859f2e 100644 --- a/packages/headless/src/features/insight-search/insight-result-preview-request-builder.ts +++ b/packages/headless/src/features/insight-search/insight-result-preview-request-builder.ts @@ -1,12 +1,12 @@ -import {getVisitorID} from '../../api/analytics/coveo-analytics-utils'; -import {getOrganizationEndpoint} from '../../api/platform-client'; +import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; import { HtmlRequest, HtmlRequestOptions, -} from '../../api/search/html/html-request'; -import {baseInsightUrl} from '../../api/service/insight/insight-params'; -import {InsightConfigurationSection} from '../../state/state-sections'; -import {StateNeededByHtmlEndpoint} from '../result-preview/result-preview-request-builder'; +} from '../../api/search/html/html-request.js'; +import {baseInsightUrl} from '../../api/service/insight/insight-params.js'; +import {InsightConfigurationSection} from '../../state/state-sections.js'; +import {StateNeededByHtmlEndpoint} from '../result-preview/result-preview-request-builder.js'; export type StateNeededByInsightHtmlEndpoint = StateNeededByHtmlEndpoint & InsightConfigurationSection; diff --git a/packages/headless/src/features/insight-search/insight-search-actions-loader.ts b/packages/headless/src/features/insight-search/insight-search-actions-loader.ts index 9f4a9991010..9e14ccbecf2 100644 --- a/packages/headless/src/features/insight-search/insight-search-actions-loader.ts +++ b/packages/headless/src/features/insight-search/insight-search-actions-loader.ts @@ -1,26 +1,26 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {InsightAction} from '../analytics/analytics-utils'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {InsightAction} from '../analytics/analytics-utils.js'; import { FetchQuerySuggestionsActionCreatorPayload, FetchQuerySuggestionsThunkReturn, RegisterQuerySuggestActionCreatorPayload, registerQuerySuggest, -} from '../query-suggest/query-suggest-actions'; -import {ExecuteSearchThunkReturn} from '../search/legacy/search-actions'; +} from '../query-suggest/query-suggest-actions.js'; +import {ExecuteSearchThunkReturn} from '../search/legacy/search-actions.js'; import { StateNeededByExecuteSearch, StateNeededByQuerySuggest, fetchQuerySuggestions, -} from './insight-search-actions'; +} from './insight-search-actions.js'; import { executeSearch, fetchFacetValues, fetchMoreResults, fetchPage, -} from './legacy/insight-search-actions'; +} from './legacy/insight-search-actions.js'; export type { FetchQuerySuggestionsActionCreatorPayload, diff --git a/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.test.ts b/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.test.ts index 98a8c1fba7e..c39d2ebfc8a 100644 --- a/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.test.ts +++ b/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.test.ts @@ -1,24 +1,28 @@ import {Relay} from '@coveo/relay'; import {Logger} from 'pino'; -import {InsightAPIClient} from '../../api/service/insight/insight-api-client'; -import {InsightQueryRequest} from '../../api/service/insight/query/query-request'; -import {defaultNodeJSNavigatorContextProvider} from '../../app/navigatorContextProvider'; -import {buildMockInsightQueryRequest} from '../../test/mock-insight-request'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {getInsightConfigurationInitialState} from '../insight-configuration/insight-configuration-state'; -import {updateQuery} from '../query/query-actions'; -import {ExecuteSearchThunkReturn} from '../search/search-actions'; -import {MappedSearchRequest, SearchMappings} from '../search/search-mappings'; +import {Mock} from 'vitest'; +import {InsightAPIClient} from '../../api/service/insight/insight-api-client.js'; +import {InsightQueryRequest} from '../../api/service/insight/query/query-request.js'; +import {defaultNodeJSNavigatorContextProvider} from '../../app/navigatorContextProvider.js'; +import {buildMockInsightQueryRequest} from '../../test/mock-insight-request.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {getInsightConfigurationInitialState} from '../insight-configuration/insight-configuration-state.js'; +import {updateQuery} from '../query/query-actions.js'; +import {ExecuteSearchThunkReturn} from '../search/search-actions.js'; +import { + MappedSearchRequest, + SearchMappings, +} from '../search/search-mappings.js'; import { AsyncInsightSearchThunkProcessor, AsyncThunkConfig, -} from './insight-search-actions-thunk-processor'; -import {logQueryError} from './insight-search-analytics-actions'; +} from './insight-search-actions-thunk-processor.js'; +import {logQueryError} from './insight-search-analytics-actions.js'; -jest.mock('./insight-search-analytics-actions'); +vi.mock('./insight-search-analytics-actions'); const initialSearchMappings: () => SearchMappings = () => ({ dateFacetValueMap: {}, @@ -29,17 +33,17 @@ describe('AsyncInsightSearchThunkProcessor', () => { const results = [buildMockResult({uniqueId: '123'})]; beforeEach(() => { config = { - dispatch: jest.fn(), + dispatch: vi.fn(), extra: { - analyticsClientMiddleware: jest.fn(), - apiClient: {query: jest.fn()} as unknown as InsightAPIClient, - logger: jest.fn() as unknown as Logger, - validatePayload: jest.fn(), - preprocessRequest: jest.fn(), - relay: jest.fn() as unknown as Relay, + analyticsClientMiddleware: vi.fn(), + apiClient: {query: vi.fn()} as unknown as InsightAPIClient, + logger: vi.fn() as unknown as Logger, + validatePayload: vi.fn(), + preprocessRequest: vi.fn(), + relay: vi.fn() as unknown as Relay, navigatorContext: defaultNodeJSNavigatorContextProvider(), }, - getState: jest.fn().mockReturnValue({ + getState: vi.fn().mockReturnValue({ insightConfiguration: getInsightConfigurationInitialState(), configuration: getConfigurationInitialState(), search: buildMockSearchState({ @@ -51,7 +55,7 @@ describe('AsyncInsightSearchThunkProcessor', () => { automaticallyCorrectQuery: true, }, }), - rejectWithValue: jest.fn(), + rejectWithValue: vi.fn(), }; }); @@ -134,7 +138,7 @@ describe('AsyncInsightSearchThunkProcessor', () => { results: [buildMockResult({uniqueId: '123'})], }); - (config.extra.apiClient.query as jest.Mock).mockReturnValue( + (config.extra.apiClient.query as Mock).mockReturnValue( Promise.resolve({success: responseAfterCorrection}) ); diff --git a/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.ts b/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.ts index e6dc0b0a027..0df681862aa 100644 --- a/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.ts +++ b/packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.ts @@ -3,28 +3,28 @@ import { SearchOptions, isErrorResponse, isSuccessResponse, -} from '../../api/search/search-api-client'; +} from '../../api/search/search-api-client.js'; import { InsightAPIClient, InsightAPIErrorStatusResponse, -} from '../../api/service/insight/insight-api-client'; -import {InsightQueryRequest} from '../../api/service/insight/query/query-request'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions'; -import {emptyLegacyCorrection} from '../did-you-mean/did-you-mean-state'; -import {snapshot} from '../history/history-actions'; -import {extractHistory} from '../history/history-state'; -import {updateQuery} from '../query/query-actions'; -import {ExecuteSearchThunkReturn} from '../search/search-actions'; +} from '../../api/service/insight/insight-api-client.js'; +import {InsightQueryRequest} from '../../api/service/insight/query/query-request.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions.js'; +import {emptyLegacyCorrection} from '../did-you-mean/did-you-mean-state.js'; +import {snapshot} from '../history/history-actions.js'; +import {extractHistory} from '../history/history-state.js'; +import {updateQuery} from '../query/query-actions.js'; +import {ExecuteSearchThunkReturn} from '../search/search-actions.js'; import { ErrorResponse, MappedSearchRequest, SuccessResponse, mapSearchResponse, -} from '../search/search-mappings'; -import {StateNeededByExecuteSearch} from './insight-search-actions'; -import {logQueryError} from './insight-search-analytics-actions'; -import {buildInsightSearchRequest} from './insight-search-request'; +} from '../search/search-mappings.js'; +import {StateNeededByExecuteSearch} from './insight-search-actions.js'; +import {logQueryError} from './insight-search-analytics-actions.js'; +import {buildInsightSearchRequest} from './insight-search-request.js'; export interface AsyncThunkConfig { getState: () => StateNeededByExecuteSearch; diff --git a/packages/headless/src/features/insight-search/insight-search-actions.ts b/packages/headless/src/features/insight-search/insight-search-actions.ts index 91ec5465636..683a8ec8f2f 100644 --- a/packages/headless/src/features/insight-search/insight-search-actions.ts +++ b/packages/headless/src/features/insight-search/insight-search-actions.ts @@ -1,14 +1,14 @@ import {createAsyncThunk} from '@reduxjs/toolkit'; -import {historyStore} from '../../api/analytics/coveo-analytics-utils'; +import {historyStore} from '../../api/analytics/coveo-analytics-utils.js'; import { SearchOptions, isErrorResponse, -} from '../../api/search/search-api-client'; +} from '../../api/search/search-api-client.js'; import { AsyncThunkInsightOptions, InsightAPIClient, -} from '../../api/service/insight/insight-api-client'; -import {InsightQueryRequest} from '../../api/service/insight/query/query-request'; +} from '../../api/service/insight/insight-api-client.js'; +import {InsightQueryRequest} from '../../api/service/insight/query/query-request.js'; import { CategoryFacetSection, ConfigurationSection, @@ -28,35 +28,38 @@ import { SearchSection, SortSection, TabSection, -} from '../../state/state-sections'; -import {requiredNonEmptyString} from '../../utils/validate-payload'; -import {InsightAction as LegacyInsightAction} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; +} from '../../state/state-sections.js'; +import {requiredNonEmptyString} from '../../utils/validate-payload.js'; +import {InsightAction as LegacyInsightAction} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; import { FetchQuerySuggestionsActionCreatorPayload, FetchQuerySuggestionsThunkReturn, -} from '../query-suggest/query-suggest-actions'; -import {ExecuteSearchThunkReturn, SearchAction} from '../search/search-actions'; +} from '../query-suggest/query-suggest-actions.js'; +import { + ExecuteSearchThunkReturn, + SearchAction, +} from '../search/search-actions.js'; import { MappedSearchRequest, mapSearchResponse, -} from '../search/search-mappings'; -import {buildInsightQuerySuggestRequest} from './insight-query-suggest-request'; +} from '../search/search-mappings.js'; +import {buildInsightQuerySuggestRequest} from './insight-query-suggest-request.js'; import { AsyncInsightSearchThunkProcessor, AsyncThunkConfig, -} from './insight-search-actions-thunk-processor'; +} from './insight-search-actions-thunk-processor.js'; import { buildInsightFetchFacetValuesRequest, buildInsightFetchMoreResultsRequest, buildInsightSearchRequest, -} from './insight-search-request'; +} from './insight-search-request.js'; import { legacyExecuteSearch, legacyFetchPage, legacyFetchFacetValues, legacyFetchMoreResults, -} from './legacy/insight-search-actions'; +} from './legacy/insight-search-actions.js'; export type StateNeededByExecuteSearch = ConfigurationSection & InsightConfigurationSection & diff --git a/packages/headless/src/features/insight-search/insight-search-analytics-actions-loader.ts b/packages/headless/src/features/insight-search/insight-search-analytics-actions-loader.ts index c628b1a1711..cd328095828 100644 --- a/packages/headless/src/features/insight-search/insight-search-analytics-actions-loader.ts +++ b/packages/headless/src/features/insight-search/insight-search-analytics-actions-loader.ts @@ -1,7 +1,7 @@ -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {InsightAction} from '../analytics/analytics-utils'; -import {logExpandToFullUI} from './insight-analytics-actions'; -import {logContextChanged} from './insight-search-analytics-actions'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {InsightAction} from '../analytics/analytics-utils.js'; +import {logExpandToFullUI} from './insight-analytics-actions.js'; +import {logContextChanged} from './insight-search-analytics-actions.js'; /** * The Insight Search analytics action creators. diff --git a/packages/headless/src/features/insight-search/insight-search-analytics-actions.test.ts b/packages/headless/src/features/insight-search/insight-search-analytics-actions.test.ts index 938ae3b0496..41e63faac70 100644 --- a/packages/headless/src/features/insight-search/insight-search-analytics-actions.test.ts +++ b/packages/headless/src/features/insight-search/insight-search-analytics-actions.test.ts @@ -1,27 +1,27 @@ -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {InsightAppState} from '../../state/insight-app-state'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {getCaseContextInitialState} from '../case-context/case-context-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {getQueryInitialState} from '../query/query-state'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {getCaseContextInitialState} from '../case-context/case-context-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {getQueryInitialState} from '../query/query-state.js'; import { logContextChanged, logFetchMoreResults, logInsightInterfaceChange, logInsightInterfaceLoad, logQueryError, -} from './insight-search-analytics-actions'; +} from './insight-search-analytics-actions.js'; -const mockLogContextChanged = jest.fn(); -const mockLogFetchMoreResults = jest.fn(); -const mockLogQueryError = jest.fn(); -const mockLogInterfaceLoad = jest.fn(); -const mockLogInterfaceChange = jest.fn(); +const mockLogContextChanged = vi.fn(); +const mockLogFetchMoreResults = vi.fn(); +const mockLogQueryError = vi.fn(); +const mockLogInterfaceLoad = vi.fn(); +const mockLogInterfaceChange = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logContextChanged: mockLogContextChanged, logFetchMoreResults: mockLogFetchMoreResults, @@ -32,7 +32,7 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/insight-search/insight-search-analytics-actions.ts b/packages/headless/src/features/insight-search/insight-search-analytics-actions.ts index 200fbec9930..8c28383fcd5 100644 --- a/packages/headless/src/features/insight-search/insight-search-analytics-actions.ts +++ b/packages/headless/src/features/insight-search/insight-search-analytics-actions.ts @@ -1,11 +1,11 @@ -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; -import {getQueryInitialState} from '../query/query-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; +import {getQueryInitialState} from '../query/query-state.js'; export const logFetchMoreResults = (): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.browseResults)( diff --git a/packages/headless/src/features/insight-search/insight-search-request.test.ts b/packages/headless/src/features/insight-search/insight-search-request.test.ts index ac12670b4f9..2f89e5fdd32 100644 --- a/packages/headless/src/features/insight-search/insight-search-request.test.ts +++ b/packages/headless/src/features/insight-search/insight-search-request.test.ts @@ -1,21 +1,24 @@ -import {InsightAppState} from '../../state/insight-app-state'; -import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice'; -import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request'; -import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice'; -import {buildMockTabSlice} from '../../test/mock-tab-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {CollectionId, getFoldingInitialState} from '../folding/folding-state'; -import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants'; +import {InsightAppState} from '../../state/insight-app-state.js'; +import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice.js'; +import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request.js'; +import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice.js'; +import {buildMockTabSlice} from '../../test/mock-tab-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import { + CollectionId, + getFoldingInitialState, +} from '../folding/folding-state.js'; +import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants.js'; import { buildInsightSearchRequest, buildInsightLoadCollectionRequest, -} from './insight-search-request'; +} from './insight-search-request.js'; describe('insight search request', () => { let state: InsightAppState; diff --git a/packages/headless/src/features/insight-search/insight-search-request.ts b/packages/headless/src/features/insight-search/insight-search-request.ts index 02264d2929c..467fa3d95ec 100644 --- a/packages/headless/src/features/insight-search/insight-search-request.ts +++ b/packages/headless/src/features/insight-search/insight-search-request.ts @@ -1,16 +1,19 @@ import {EventDescription} from 'coveo.analytics'; -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {InsightQueryRequest} from '../../api/service/insight/query/query-request'; -import {InsightAppState} from '../../state/insight-app-state'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {InsightQueryRequest} from '../../api/service/insight/query/query-request.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; import { ConfigurationSection, InsightConfigurationSection, -} from '../../state/state-sections'; -import {fromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params'; -import {getFacetRequests} from '../facets/generic/interfaces/generic-facet-request'; -import {CollectionId} from '../folding/folding-state'; -import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants'; -import {MappedSearchRequest, mapSearchRequest} from '../search/search-mappings'; +} from '../../state/state-sections.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params.js'; +import {getFacetRequests} from '../facets/generic/interfaces/generic-facet-request.js'; +import {CollectionId} from '../folding/folding-state.js'; +import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants.js'; +import { + MappedSearchRequest, + mapSearchRequest, +} from '../search/search-mappings.js'; type StateNeededBySearchRequest = ConfigurationSection & InsightConfigurationSection & diff --git a/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.test.ts b/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.test.ts index 9aafe0a38ec..a1699e42cd5 100644 --- a/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.test.ts +++ b/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.test.ts @@ -1,30 +1,31 @@ import {Relay} from '@coveo/relay'; import {Logger} from 'pino'; -import {InsightAPIClient} from '../../../api/service/insight/insight-api-client'; -import {InsightQueryRequest} from '../../../api/service/insight/query/query-request'; -import {defaultNodeJSNavigatorContextProvider} from '../../../app/navigatorContextProvider'; -import {buildMockInsightQueryRequest} from '../../../test/mock-insight-request'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildMockSearchResponse} from '../../../test/mock-search-response'; -import {buildMockSearchState} from '../../../test/mock-search-state'; -import {getConfigurationInitialState} from '../../configuration/configuration-state'; -import {getInsightConfigurationInitialState} from '../../insight-configuration/insight-configuration-state'; -import {updateQuery} from '../../query/query-actions'; -import {ExecuteSearchThunkReturn} from '../../search/legacy/search-actions'; +import {Mock} from 'vitest'; +import {InsightAPIClient} from '../../../api/service/insight/insight-api-client.js'; +import {InsightQueryRequest} from '../../../api/service/insight/query/query-request.js'; +import {defaultNodeJSNavigatorContextProvider} from '../../../app/navigatorContextProvider.js'; +import {buildMockInsightQueryRequest} from '../../../test/mock-insight-request.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../../test/mock-search-state.js'; +import {getConfigurationInitialState} from '../../configuration/configuration-state.js'; +import {getInsightConfigurationInitialState} from '../../insight-configuration/insight-configuration-state.js'; +import {updateQuery} from '../../query/query-actions.js'; +import {ExecuteSearchThunkReturn} from '../../search/legacy/search-actions.js'; import { MappedSearchRequest, SearchMappings, -} from '../../search/search-mappings'; +} from '../../search/search-mappings.js'; import { logFetchMoreResults, logQueryError, -} from '../insight-search-analytics-actions'; +} from '../insight-search-analytics-actions.js'; import { AsyncInsightSearchThunkProcessor, AsyncThunkConfig, -} from './insight-search-actions-thunk-processor'; +} from './insight-search-actions-thunk-processor.js'; -jest.mock('../insight-search-analytics-actions'); +vi.mock('../insight-search-analytics-actions'); const initialSearchMappings: () => SearchMappings = () => ({ dateFacetValueMap: {}, @@ -36,17 +37,17 @@ describe('AsyncInsightSearchThunkProcessor', () => { beforeEach(() => { config = { analyticsAction: logFetchMoreResults(), - dispatch: jest.fn(), + dispatch: vi.fn(), extra: { - analyticsClientMiddleware: jest.fn(), - apiClient: {query: jest.fn()} as unknown as InsightAPIClient, - logger: jest.fn() as unknown as Logger, - validatePayload: jest.fn(), - preprocessRequest: jest.fn(), - relay: jest.fn() as unknown as Relay, + analyticsClientMiddleware: vi.fn(), + apiClient: {query: vi.fn()} as unknown as InsightAPIClient, + logger: vi.fn() as unknown as Logger, + validatePayload: vi.fn(), + preprocessRequest: vi.fn(), + relay: vi.fn() as unknown as Relay, navigatorContext: defaultNodeJSNavigatorContextProvider(), }, - getState: jest.fn().mockReturnValue({ + getState: vi.fn().mockReturnValue({ insightConfiguration: getInsightConfigurationInitialState(), configuration: getConfigurationInitialState(), search: buildMockSearchState({ @@ -58,7 +59,7 @@ describe('AsyncInsightSearchThunkProcessor', () => { automaticallyCorrectQuery: true, }, }), - rejectWithValue: jest.fn(), + rejectWithValue: vi.fn(), }; }); @@ -145,7 +146,7 @@ describe('AsyncInsightSearchThunkProcessor', () => { results: [buildMockResult({uniqueId: '123'})], }); - (config.extra.apiClient.query as jest.Mock).mockReturnValue( + (config.extra.apiClient.query as Mock).mockReturnValue( Promise.resolve({success: responseAfterCorrection}) ); diff --git a/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.ts b/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.ts index e198ec86f70..17ba02290e6 100644 --- a/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.ts +++ b/packages/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.ts @@ -1,36 +1,36 @@ import {ThunkDispatch, AnyAction} from '@reduxjs/toolkit'; -import {StateNeededByInsightAnalyticsProvider} from '../../../api/analytics/insight-analytics'; +import {StateNeededByInsightAnalyticsProvider} from '../../../api/analytics/insight-analytics.js'; import { SearchOptions, isErrorResponse, isSuccessResponse, -} from '../../../api/search/search-api-client'; -import {SearchResponseSuccess} from '../../../api/search/search/search-response'; +} from '../../../api/search/search-api-client.js'; +import {SearchResponseSuccess} from '../../../api/search/search/search-response.js'; import { InsightAPIClient, InsightAPIErrorStatusResponse, -} from '../../../api/service/insight/insight-api-client'; -import {InsightQueryRequest} from '../../../api/service/insight/query/query-request'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; -import {AnalyticsAsyncThunk} from '../../analytics/analytics-utils'; -import {applyDidYouMeanCorrection} from '../../did-you-mean/did-you-mean-actions'; -import {logDidYouMeanAutomatic} from '../../did-you-mean/did-you-mean-insight-analytics-actions'; -import {emptyLegacyCorrection} from '../../did-you-mean/did-you-mean-state'; -import {snapshot} from '../../history/history-actions'; -import {extractHistory} from '../../history/history-state'; -import {updateQuery} from '../../query/query-actions'; -import {getQueryInitialState} from '../../query/query-state'; -import {ExecuteSearchThunkReturn} from '../../search/legacy/search-actions'; +} from '../../../api/service/insight/insight-api-client.js'; +import {InsightQueryRequest} from '../../../api/service/insight/query/query-request.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; +import {AnalyticsAsyncThunk} from '../../analytics/analytics-utils.js'; +import {applyDidYouMeanCorrection} from '../../did-you-mean/did-you-mean-actions.js'; +import {logDidYouMeanAutomatic} from '../../did-you-mean/did-you-mean-insight-analytics-actions.js'; +import {emptyLegacyCorrection} from '../../did-you-mean/did-you-mean-state.js'; +import {snapshot} from '../../history/history-actions.js'; +import {extractHistory} from '../../history/history-state.js'; +import {updateQuery} from '../../query/query-actions.js'; +import {getQueryInitialState} from '../../query/query-state.js'; +import {ExecuteSearchThunkReturn} from '../../search/legacy/search-actions.js'; import { ErrorResponse, MappedSearchRequest, SuccessResponse, mapSearchResponse, -} from '../../search/search-mappings'; -import {getSearchInitialState} from '../../search/search-state'; -import {StateNeededByExecuteSearch} from '../insight-search-actions'; -import {logQueryError} from '../insight-search-analytics-actions'; -import {buildInsightSearchRequest} from '../insight-search-request'; +} from '../../search/search-mappings.js'; +import {getSearchInitialState} from '../../search/search-state.js'; +import {StateNeededByExecuteSearch} from '../insight-search-actions.js'; +import {logQueryError} from '../insight-search-analytics-actions.js'; +import {buildInsightSearchRequest} from '../insight-search-request.js'; export interface AsyncThunkConfig { getState: () => StateNeededByExecuteSearch; diff --git a/packages/headless/src/features/insight-search/legacy/insight-search-actions.ts b/packages/headless/src/features/insight-search/legacy/insight-search-actions.ts index e8f4c6a65d6..7cc7341e8b5 100644 --- a/packages/headless/src/features/insight-search/legacy/insight-search-actions.ts +++ b/packages/headless/src/features/insight-search/legacy/insight-search-actions.ts @@ -1,18 +1,18 @@ import {createAsyncThunk} from '@reduxjs/toolkit'; -import {AsyncThunkInsightOptions} from '../../../api/service/insight/insight-api-client'; -import {InsightAction} from '../../analytics/analytics-utils'; -import {ExecuteSearchThunkReturn} from '../../search/legacy/search-actions'; +import {AsyncThunkInsightOptions} from '../../../api/service/insight/insight-api-client.js'; +import {InsightAction} from '../../analytics/analytics-utils.js'; +import {ExecuteSearchThunkReturn} from '../../search/legacy/search-actions.js'; import { StateNeededByExecuteSearch, addEntryInActionsHistory, -} from '../insight-search-actions'; -import {logFetchMoreResults} from '../insight-search-analytics-actions'; +} from '../insight-search-actions.js'; +import {logFetchMoreResults} from '../insight-search-analytics-actions.js'; import { buildInsightFetchFacetValuesRequest, buildInsightFetchMoreResultsRequest, buildInsightSearchRequest, -} from '../insight-search-request'; -import {AsyncInsightSearchThunkProcessor} from './insight-search-actions-thunk-processor'; +} from '../insight-search-request.js'; +import {AsyncInsightSearchThunkProcessor} from './insight-search-actions-thunk-processor.js'; export async function legacyExecuteSearch( state: StateNeededByExecuteSearch, diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-actions.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-actions.ts index b5a94bd86d6..eac264606f6 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-actions.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-actions.ts @@ -1,14 +1,14 @@ import {ArrayValue, StringValue} from '@coveo/bueno'; import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {isErrorResponse} from '../../api/search/search-api-client'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; -import {InsightUserActionsResponse} from '../../api/service/insight/user-actions/user-actions-response'; +import {isErrorResponse} from '../../api/search/search-api-client.js'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; +import {InsightUserActionsResponse} from '../../api/service/insight/user-actions/user-actions-response.js'; import { ConfigurationSection, InsightUserActionsSection, -} from '../../state/state-sections'; -import {nonEmptyString, validatePayload} from '../../utils/validate-payload'; -import {buildFetchUserActionsRequest} from './insight-user-actions-request'; +} from '../../state/state-sections.js'; +import {nonEmptyString, validatePayload} from '../../utils/validate-payload.js'; +import {buildFetchUserActionsRequest} from './insight-user-actions-request.js'; export interface RegisterUserActionsPayload { ticketCreationDate: string; diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-loader.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-loader.ts index f69c5bf12ec..f7edf62804c 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-loader.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-loader.ts @@ -1,14 +1,14 @@ import {PayloadAction, AsyncThunkAction} from '@reduxjs/toolkit'; -import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client'; -import {CoreEngine} from '../../app/engine'; -import {insightUserActionsReducer as insightUserActions} from '../../features/insight-user-actions/insight-user-actions-slice'; +import {AsyncThunkInsightOptions} from '../../api/service/insight/insight-api-client.js'; +import {CoreEngine} from '../../app/engine.js'; +import {insightUserActionsReducer as insightUserActions} from '../../features/insight-user-actions/insight-user-actions-slice.js'; import { registerUserActions, fetchUserActions, RegisterUserActionsPayload, StateNeededByFetchUserActions, FetchUserActionsThunkReturn, -} from './insight-user-actions-actions'; +} from './insight-user-actions-actions.js'; export type {RegisterUserActionsPayload}; export interface InsightUserActionsActionCreators { diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.test.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.test.ts index 90f9032a5c8..2003a14e4d0 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.test.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.test.ts @@ -1,3 +1,4 @@ +import {MockInstance} from 'vitest'; import { mapAndSortActionsByMostRecent, isActionWithinSessionThreshold, @@ -5,12 +6,12 @@ import { splitActionsIntoTimelineSessions, shouldExcludeAction, insertSessionInTimeline, -} from './insight-user-actions-preprocessing'; +} from './insight-user-actions-preprocessing.js'; import { UserActionTimeline, UserActionType, UserSession, -} from './insight-user-actions-state'; +} from './insight-user-actions-state.js'; const createRelativeDate = (date: Date, minutes: number, seconds: number) => { const totalSeconds = seconds + minutes * 60; @@ -225,10 +226,10 @@ describe('insight user actions preprocessing', () => { }); describe('when a rawUserAction cannot be parsed', () => { - let consoleWarnSpy: jest.SpyInstance; + let consoleWarnSpy: MockInstance; beforeAll(() => { - consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(); + consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(); }); afterAll(() => { diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.ts index cf4a15fe027..e34c71f0e90 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-preprocessing.ts @@ -4,7 +4,7 @@ import { UserActionTimeline, UserActionType, UserSession, -} from './insight-user-actions-state'; +} from './insight-user-actions-state.js'; const SECOND = 1000; const MINUTE = SECOND * 60; diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-request.test.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-request.test.ts index ac380a1c932..4b0083f696d 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-request.test.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-request.test.ts @@ -1,7 +1,7 @@ -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {InsightAppState} from '../../state/insight-app-state'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildFetchUserActionsRequest} from './insight-user-actions-request'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildFetchUserActionsRequest} from './insight-user-actions-request.js'; describe('insight user actions request', () => { let state: InsightAppState; diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-request.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-request.ts index 851a6eead49..46d18fee812 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-request.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-request.ts @@ -1,6 +1,6 @@ -import {getOrganizationEndpoint} from '../../api/platform-client'; -import {InsightUserActionsRequest} from '../../api/service/insight/user-actions/user-actions-request'; -import {StateNeededByFetchUserActions} from './insight-user-actions-actions'; +import {getOrganizationEndpoint} from '../../api/platform-client.js'; +import {InsightUserActionsRequest} from '../../api/service/insight/user-actions/user-actions-request.js'; +import {StateNeededByFetchUserActions} from './insight-user-actions-actions.js'; export const buildFetchUserActionsRequest = async ( state: StateNeededByFetchUserActions, diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.test.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.test.ts index e5834dcaec9..201e4a22f8b 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.test.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.test.ts @@ -1,9 +1,9 @@ import { fetchUserActions, registerUserActions, -} from './insight-user-actions-actions'; -import {insightUserActionsReducer} from './insight-user-actions-slice'; -import {getInsightUserActionsInitialState} from './insight-user-actions-state'; +} from './insight-user-actions-actions.js'; +import {insightUserActionsReducer} from './insight-user-actions-slice.js'; +import {getInsightUserActionsInitialState} from './insight-user-actions-state.js'; describe('insight user actions slice', () => { const requestId = 'some-request-id'; diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.ts index b7ce724c45b..12bd2f04638 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-slice.ts @@ -2,9 +2,9 @@ import {createReducer} from '@reduxjs/toolkit'; import { fetchUserActions, registerUserActions, -} from './insight-user-actions-actions'; -import {preprocessUserActionsData} from './insight-user-actions-preprocessing'; -import {getInsightUserActionsInitialState} from './insight-user-actions-state'; +} from './insight-user-actions-actions.js'; +import {preprocessUserActionsData} from './insight-user-actions-preprocessing.js'; +import {getInsightUserActionsInitialState} from './insight-user-actions-state.js'; export const insightUserActionsReducer = createReducer( getInsightUserActionsInitialState(), diff --git a/packages/headless/src/features/insight-user-actions/insight-user-actions-state.ts b/packages/headless/src/features/insight-user-actions/insight-user-actions-state.ts index de039b5262c..f2cf5b82bab 100644 --- a/packages/headless/src/features/insight-user-actions/insight-user-actions-state.ts +++ b/packages/headless/src/features/insight-user-actions/insight-user-actions-state.ts @@ -1,4 +1,4 @@ -import {InsightAPIErrorStatusResponse} from '../../api/service/insight/insight-api-client'; +import {InsightAPIErrorStatusResponse} from '../../api/service/insight/insight-api-client.js'; export interface UserActionTimeline { precedingSessions: UserSession[]; diff --git a/packages/headless/src/features/instant-items/instant-items-slice.ts b/packages/headless/src/features/instant-items/instant-items-slice.ts index 41340ff220f..9c9b2a22fa9 100644 --- a/packages/headless/src/features/instant-items/instant-items-slice.ts +++ b/packages/headless/src/features/instant-items/instant-items-slice.ts @@ -2,7 +2,7 @@ import { InstantItemsCache, InstantItemsState, hasExpired, -} from './instant-items-state'; +} from './instant-items-state.js'; type InstantItemsStateWithCache = InstantItemsState< Record diff --git a/packages/headless/src/features/instant-results/__snapshots__/instant-result-analytics-actions.test.ts.snap b/packages/headless/src/features/instant-results/__snapshots__/instant-result-analytics-actions.test.ts.snap index e25cca6a89c..ac66ae75f4b 100644 --- a/packages/headless/src/features/instant-results/__snapshots__/instant-result-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/instant-results/__snapshots__/instant-result-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`instant result analytics actions #logRecommendationOpen when analyticsMode is \`legacy\` should call coveo.analytics.makeRecommendationOpen properly 1`] = ` +exports[`instant result analytics actions > #logRecommendationOpen > when analyticsMode is \`legacy\` should call coveo.analytics.makeRecommendationOpen properly 1`] = ` [ { "collectionName": "example collectionName", @@ -21,7 +21,7 @@ exports[`instant result analytics actions #logRecommendationOpen when analyticsM ] `; -exports[`instant result analytics actions #logRecommendationOpen when analyticsMode is \`next\` should call relay.emit properly 1`] = ` +exports[`instant result analytics actions > #logRecommendationOpen > when analyticsMode is \`next\` should call relay.emit properly 1`] = ` [ "itemClick", { @@ -34,7 +34,7 @@ exports[`instant result analytics actions #logRecommendationOpen when analyticsM "url": "example documentUrl", }, "position": 1, - "searchUid": "", + "searchUid": "example searchUid", }, ] `; diff --git a/packages/headless/src/features/instant-results/instant-result-analytics-actions.test.ts b/packages/headless/src/features/instant-results/instant-result-analytics-actions.test.ts index 849a251dfd6..514b0472e3c 100644 --- a/packages/headless/src/features/instant-results/instant-result-analytics-actions.test.ts +++ b/packages/headless/src/features/instant-results/instant-result-analytics-actions.test.ts @@ -4,31 +4,33 @@ import { SearchEngine, buildSearchEngine, getSampleSearchEngineConfiguration, -} from '../../app/search-engine/search-engine'; -import {buildMockNonEmptyResult} from '../../test/mock-result'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {logInstantResultOpen} from './instant-result-analytics-actions'; +} from '../../app/search-engine/search-engine.js'; +import {buildMockNonEmptyResult} from '../../test/mock-result.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {logInstantResultOpen} from './instant-result-analytics-actions.js'; -jest.mock('@coveo/relay'); -jest.mock('coveo.analytics'); +vi.mock('@coveo/relay'); +vi.mock('coveo.analytics'); describe('instant result analytics actions', () => { describe('#logRecommendationOpen', () => { - const testResult = buildMockNonEmptyResult(); + const testResult = buildMockNonEmptyResult({ + searchUid: 'example searchUid', + }); let engine: SearchEngine; - const makeDocumentOpen = jest.fn(); - const emit = jest.fn(); + const makeDocumentOpen = vi.fn(); + const emit = vi.fn(); beforeEach(() => { - jest.mocked(CoveoSearchPageClient).mockReturnValue({ + vi.mocked(CoveoSearchPageClient).mockReturnValue({ makeDocumentOpen, } as unknown as CoveoSearchPageClient); - jest.mocked(createRelay).mockReturnValue({ + vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); }); diff --git a/packages/headless/src/features/instant-results/instant-result-analytics-actions.ts b/packages/headless/src/features/instant-results/instant-result-analytics-actions.ts index fe37c0faada..018b7d1adca 100644 --- a/packages/headless/src/features/instant-results/instant-result-analytics-actions.ts +++ b/packages/headless/src/features/instant-results/instant-result-analytics-actions.ts @@ -2,8 +2,8 @@ import {ItemClick} from '@coveo/relay-event-types'; import { InstantResultsAnalyticsProvider, StateNeededByInstantResultsAnalyticsProvider, -} from '../../api/analytics/instant-result-analytics'; -import {Result} from '../../api/search/search/result'; +} from '../../api/analytics/instant-result-analytics.js'; +import {Result} from '../../api/search/search/result.js'; import { partialDocumentInformation, documentIdentifier, @@ -11,9 +11,9 @@ import { makeAnalyticsAction, InstantResultsSearchAction, InstantResultsClickAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; export const logInstantResultOpen = ( result: Result @@ -36,7 +36,7 @@ export const logInstantResultOpen = ( const docInfo = partialDocumentInformation(result, state); const docId = documentIdentifier(result); return { - searchUid: state.search?.response.searchUid ?? '', + searchUid: result.searchUid ?? '', position: docInfo.documentPosition, actionCause: 'open', itemMetadata: { diff --git a/packages/headless/src/features/instant-results/instant-results-actions-loader.ts b/packages/headless/src/features/instant-results/instant-results-actions-loader.ts index 7aace16ccc9..996d39cd2a5 100644 --- a/packages/headless/src/features/instant-results/instant-results-actions-loader.ts +++ b/packages/headless/src/features/instant-results/instant-results-actions-loader.ts @@ -1,17 +1,17 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {instantResultsReducer as instantResults} from '../../features/instant-results/instant-results-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {instantResultsReducer as instantResults} from '../../features/instant-results/instant-results-slice.js'; import { UpdateInstantResultQueryActionCreatorPayload, RegisterInstantResultActionCreatorPayload, clearExpiredResults, ClearExpiredInstantResultsActionCreatorPayload, FetchInstantResultsActionCreatorPayload, -} from './instant-results-actions'; +} from './instant-results-actions.js'; import { registerInstantResults, updateInstantResultsQuery, -} from './instant-results-actions'; +} from './instant-results-actions.js'; export type { UpdateInstantResultQueryActionCreatorPayload, diff --git a/packages/headless/src/features/instant-results/instant-results-actions.ts b/packages/headless/src/features/instant-results/instant-results-actions.ts index 6a361a2a3ba..e3ef0e84856 100644 --- a/packages/headless/src/features/instant-results/instant-results-actions.ts +++ b/packages/headless/src/features/instant-results/instant-results-actions.ts @@ -1,12 +1,12 @@ import {createAction} from '@reduxjs/toolkit'; -import {Result} from '../../api/search/search/result'; -import {InstantResultSection} from '../../state/state-sections'; +import {Result} from '../../api/search/search/result.js'; +import {InstantResultSection} from '../../state/state-sections.js'; import { validatePayload, requiredEmptyAllowedString, requiredNonEmptyString, -} from '../../utils/validate-payload'; -import {StateNeededByExecuteSearch} from '../search/search-actions-thunk-processor'; +} from '../../utils/validate-payload.js'; +import {StateNeededByExecuteSearch} from '../search/search-actions-thunk-processor.js'; export interface RegisterInstantResultActionCreatorPayload { /** diff --git a/packages/headless/src/features/instant-results/instant-results-slice.test.ts b/packages/headless/src/features/instant-results/instant-results-slice.test.ts index 48ff0da8b19..2a15e787a52 100644 --- a/packages/headless/src/features/instant-results/instant-results-slice.test.ts +++ b/packages/headless/src/features/instant-results/instant-results-slice.test.ts @@ -1,11 +1,11 @@ -import {buildMockResult} from '../../test/mock-result'; -import {fetchInstantResults} from '../search/search-actions'; +import {buildMockResult} from '../../test/mock-result.js'; +import {fetchInstantResults} from '../search/search-actions.js'; import { registerInstantResults, updateInstantResultsQuery, -} from './instant-results-actions'; -import {instantResultsReducer} from './instant-results-slice'; -import {InstantResultCache} from './instant-results-state'; +} from './instant-results-actions.js'; +import {instantResultsReducer} from './instant-results-slice.js'; +import {InstantResultCache} from './instant-results-state.js'; const id1 = 'search_box_1'; const id2 = 'search_box_2'; @@ -184,16 +184,16 @@ describe('instant results slice', () => { describe('when fulfilled', () => { beforeEach(() => { - jest.useFakeTimers().setSystemTime(new Date('2020-01-01')); + vi.useFakeTimers().setSystemTime(new Date('2020-01-01')); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('updates results in correct searchbox and query cache', () => { const query = 'some_query'; const action = fetchInstantResults.fulfilled( { - results: [buildMockResult()], + results: [buildMockResult({searchUid: 'someid'})], searchUid: 'someid', totalCountFiltered: 1, duration: 2, @@ -221,7 +221,7 @@ describe('instant results slice', () => { const expectedState = makeState({ isLoading: false, error: null, - results: [buildMockResult()], + results: [buildMockResult({searchUid: 'someid'})], expiresAt: 0, isActive: true, searchUid: 'someid', @@ -233,7 +233,8 @@ describe('instant results slice', () => { expectedState ); }); - it('sets correct isLoading, error and expiresAt properties', () => { + + it('sets correct isLoading, error, searchUid and expiresAt properties', () => { const query = 'some_query'; const action = fetchInstantResults.fulfilled( { @@ -262,7 +263,7 @@ describe('instant results slice', () => { const expectedState = makeState({ isLoading: false, error: null, - results: [buildMockResult()], + results: [buildMockResult({searchUid: 'someid'})], expiresAt: Date.now() + 10000, isActive: true, searchUid: 'someid', diff --git a/packages/headless/src/features/instant-results/instant-results-slice.ts b/packages/headless/src/features/instant-results/instant-results-slice.ts index 92bf7685f3d..67e43d29113 100644 --- a/packages/headless/src/features/instant-results/instant-results-slice.ts +++ b/packages/headless/src/features/instant-results/instant-results-slice.ts @@ -6,14 +6,14 @@ import { fetchItemsRejected, registerInstantItem, updateInstantItemQuery, -} from '../instant-items/instant-items-slice'; -import {fetchInstantResults} from '../search/search-actions'; +} from '../instant-items/instant-items-slice.js'; +import {fetchInstantResults} from '../search/search-actions.js'; import { clearExpiredResults, registerInstantResults, updateInstantResultsQuery, -} from './instant-results-actions'; -import {getInstantResultsInitialState} from './instant-results-state'; +} from './instant-results-actions.js'; +import {getInstantResultsInitialState} from './instant-results-state.js'; export const instantResultsReducer = createReducer( getInstantResultsInitialState(), @@ -31,7 +31,10 @@ export const instantResultsReducer = createReducer( fetchItemsPending(action.meta.arg, state, {results: []}); }); builder.addCase(fetchInstantResults.fulfilled, (state, action) => { - const {results} = action.payload; + const results = action.payload.results.map((result) => ({ + ...result, + searchUid: action.payload.searchUid, + })); fetchItemsFulfilled({...action.payload, ...action.meta.arg}, state, { results, }); diff --git a/packages/headless/src/features/instant-results/instant-results-state.ts b/packages/headless/src/features/instant-results/instant-results-state.ts index b6bb8317f97..7fa97c22966 100644 --- a/packages/headless/src/features/instant-results/instant-results-state.ts +++ b/packages/headless/src/features/instant-results/instant-results-state.ts @@ -1,10 +1,10 @@ import {SerializedError} from '@reduxjs/toolkit'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {Result} from '../../api/search/search/result'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {Result} from '../../api/search/search/result.js'; import { InstantItemsCache, InstantItemsState, -} from '../instant-items/instant-items-state'; +} from '../instant-items/instant-items-state.js'; export interface InstantResultCache extends InstantItemsCache { error: SearchAPIErrorWithStatusCode | SerializedError | null; diff --git a/packages/headless/src/features/pagination/pagination-actions-loader.ts b/packages/headless/src/features/pagination/pagination-actions-loader.ts index 579e64fbc72..60071f88959 100644 --- a/packages/headless/src/features/pagination/pagination-actions-loader.ts +++ b/packages/headless/src/features/pagination/pagination-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {paginationReducer as pagination} from '../../features/pagination/pagination-slice'; +import {CoreEngine} from '../../app/engine.js'; +import {paginationReducer as pagination} from '../../features/pagination/pagination-slice.js'; import { nextPage, previousPage, @@ -8,7 +8,7 @@ import { registerPage, updateNumberOfResults, updatePage, -} from './pagination-actions'; +} from './pagination-actions.js'; /** * The pagination action creators. diff --git a/packages/headless/src/features/pagination/pagination-actions.ts b/packages/headless/src/features/pagination/pagination-actions.ts index c7b8f69eb74..eba19fee63a 100644 --- a/packages/headless/src/features/pagination/pagination-actions.ts +++ b/packages/headless/src/features/pagination/pagination-actions.ts @@ -1,6 +1,6 @@ import {NumberValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; const numberValue = new NumberValue({required: true, min: 0}); diff --git a/packages/headless/src/features/pagination/pagination-analytics-actions.ts b/packages/headless/src/features/pagination/pagination-analytics-actions.ts index 513379c196e..861d06d474b 100644 --- a/packages/headless/src/features/pagination/pagination-analytics-actions.ts +++ b/packages/headless/src/features/pagination/pagination-analytics-actions.ts @@ -1,12 +1,12 @@ -import {PaginationSection} from '../../state/state-sections'; +import {PaginationSection} from '../../state/state-sections.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; -import {currentPageSelector} from './pagination-selectors'; -import {getPaginationInitialState} from './pagination-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; +import {currentPageSelector} from './pagination-selectors.js'; +import {getPaginationInitialState} from './pagination-state.js'; export const logPagerResize = (): LegacySearchAction => makeAnalyticsAction('analytics/pager/resize', (client, state) => diff --git a/packages/headless/src/features/pagination/pagination-insight-analytics-actions.test.ts b/packages/headless/src/features/pagination/pagination-insight-analytics-actions.test.ts index 82c3839da8a..56d17cf4a7e 100644 --- a/packages/headless/src/features/pagination/pagination-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/pagination/pagination-insight-analytics-actions.test.ts @@ -1,22 +1,22 @@ -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {InsightAppState} from '../../state/insight-app-state'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockPagination} from '../../test/mock-pagination'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {InsightAppState} from '../../state/insight-app-state.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockPagination} from '../../test/mock-pagination.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logPageNext, logPageNumber, logPagePrevious, -} from './pagination-insight-analytics-actions'; +} from './pagination-insight-analytics-actions.js'; -const mockLogPagerNumber = jest.fn(); -const mockLogPagerNext = jest.fn(); -const mockLogPagerPrevious = jest.fn(); +const mockLogPagerNumber = vi.fn(); +const mockLogPagerNext = vi.fn(); +const mockLogPagerPrevious = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logPagerNumber: mockLogPagerNumber, logPagerNext: mockLogPagerNext, @@ -25,7 +25,7 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -71,7 +71,7 @@ describe('pagination insight analytics actions', () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); engine = buildMockInsightEngine(buildMockInsightState(insightState)); }); diff --git a/packages/headless/src/features/pagination/pagination-insight-analytics-actions.ts b/packages/headless/src/features/pagination/pagination-insight-analytics-actions.ts index 1fa504846f3..c71bae6a2bf 100644 --- a/packages/headless/src/features/pagination/pagination-insight-analytics-actions.ts +++ b/packages/headless/src/features/pagination/pagination-insight-analytics-actions.ts @@ -1,11 +1,11 @@ -import {PaginationSection} from '../../state/state-sections'; +import {PaginationSection} from '../../state/state-sections.js'; import { makeInsightAnalyticsActionFactory, InsightAction, -} from '../analytics/analytics-utils'; -import {LegacySearchPageEvents} from '../analytics/legacy-search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; -import {currentPageSelector} from './pagination-selectors'; +} from '../analytics/analytics-utils.js'; +import {LegacySearchPageEvents} from '../analytics/legacy-search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; +import {currentPageSelector} from './pagination-selectors.js'; export const logPageNumber = (): InsightAction => makeInsightAnalyticsActionFactory(LegacySearchPageEvents.pagerNumber)( diff --git a/packages/headless/src/features/pagination/pagination-selectors.test.ts b/packages/headless/src/features/pagination/pagination-selectors.test.ts index 78e3c8f3ede..3872540e0eb 100644 --- a/packages/headless/src/features/pagination/pagination-selectors.test.ts +++ b/packages/headless/src/features/pagination/pagination-selectors.test.ts @@ -1,12 +1,12 @@ -import {SearchAppState} from '../../state/search-app-state'; -import {createMockState} from '../../test/mock-state'; -import {maximumNumberOfResultsFromIndex} from './pagination-constants'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {createMockState} from '../../test/mock-state.js'; +import {maximumNumberOfResultsFromIndex} from './pagination-constants.js'; import { currentPageSelector, maxPageSelector, currentPagesSelector, -} from './pagination-selectors'; -import {calculateFirstResult} from './pagination-slice'; +} from './pagination-selectors.js'; +import {calculateFirstResult} from './pagination-slice.js'; describe('pagination selectors', () => { let state: SearchAppState; diff --git a/packages/headless/src/features/pagination/pagination-selectors.ts b/packages/headless/src/features/pagination/pagination-selectors.ts index 6e82fdba1d2..5c45179e037 100644 --- a/packages/headless/src/features/pagination/pagination-selectors.ts +++ b/packages/headless/src/features/pagination/pagination-selectors.ts @@ -1,6 +1,6 @@ -import {PaginationSection} from '../../state/state-sections'; -import {minimumPage} from './pagination-constants'; -import {calculatePage, calculateMaxPage} from './pagination-slice'; +import {PaginationSection} from '../../state/state-sections.js'; +import {minimumPage} from './pagination-constants.js'; +import {calculatePage, calculateMaxPage} from './pagination-slice.js'; interface Range { start: number; diff --git a/packages/headless/src/features/pagination/pagination-slice.test.ts b/packages/headless/src/features/pagination/pagination-slice.test.ts index 7c88148f61b..0e9e7c59f2a 100644 --- a/packages/headless/src/features/pagination/pagination-slice.test.ts +++ b/packages/headless/src/features/pagination/pagination-slice.test.ts @@ -1,39 +1,39 @@ import {Action} from '@reduxjs/toolkit'; -import {buildMockSearch} from '../../test/mock-search'; -import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions'; -import {toggleSelectAutomaticFacetValue} from '../facets/automatic-facet-set/automatic-facet-set-actions'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions.js'; +import {toggleSelectAutomaticFacetValue} from '../facets/automatic-facet-set/automatic-facet-set-actions.js'; import { deselectAllCategoryFacetValues, toggleSelectCategoryFacetValue, -} from '../facets/category-facet-set/category-facet-set-actions'; -import {selectCategoryFacetSearchResult} from '../facets/facet-search-set/category/category-facet-search-actions'; +} from '../facets/category-facet-set/category-facet-set-actions.js'; +import {selectCategoryFacetSearchResult} from '../facets/facet-search-set/category/category-facet-search-actions.js'; import { excludeFacetSearchResult, selectFacetSearchResult, -} from '../facets/facet-search-set/specific/specific-facet-search-actions'; +} from '../facets/facet-search-set/specific/specific-facet-search-actions.js'; import { deselectAllDateFacetValues, toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from '../facets/range-facets/date-facet-set/date-facet-actions'; +} from '../facets/range-facets/date-facet-set/date-facet-actions.js'; import { toggleSelectNumericFacetValue, deselectAllNumericFacetValues, updateNumericFacetValues, toggleExcludeNumericFacetValue, -} from '../facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {logSearchboxSubmit} from '../query/query-analytics-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {executeSearch} from '../search/search-actions'; -import {updateActiveTab} from '../tab-set/tab-set-actions'; +} from '../facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {logSearchboxSubmit} from '../query/query-analytics-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {updateActiveTab} from '../tab-set/tab-set-actions.js'; import { deselectAllFacetValues, toggleExcludeFacetValue, toggleSelectFacetValue, -} from './../facets/facet-set/facet-set-actions'; +} from './../facets/facet-set/facet-set-actions.js'; import { registerNumberOfResults, updateNumberOfResults, @@ -41,9 +41,12 @@ import { registerPage, previousPage, nextPage, -} from './pagination-actions'; -import {paginationReducer, calculatePage} from './pagination-slice'; -import {getPaginationInitialState, PaginationState} from './pagination-state'; +} from './pagination-actions.js'; +import {paginationReducer, calculatePage} from './pagination-slice.js'; +import { + getPaginationInitialState, + PaginationState, +} from './pagination-state.js'; describe('pagination slice', () => { let state: PaginationState; diff --git a/packages/headless/src/features/pagination/pagination-slice.ts b/packages/headless/src/features/pagination/pagination-slice.ts index bc3746732e3..97fed0b0a7e 100644 --- a/packages/headless/src/features/pagination/pagination-slice.ts +++ b/packages/headless/src/features/pagination/pagination-slice.ts @@ -1,34 +1,34 @@ import {createReducer} from '@reduxjs/toolkit'; -import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions'; -import {toggleSelectAutomaticFacetValue} from '../facets/automatic-facet-set/automatic-facet-set-actions'; +import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions.js'; +import {toggleSelectAutomaticFacetValue} from '../facets/automatic-facet-set/automatic-facet-set-actions.js'; import { deselectAllCategoryFacetValues, toggleSelectCategoryFacetValue, -} from '../facets/category-facet-set/category-facet-set-actions'; -import {selectCategoryFacetSearchResult} from '../facets/facet-search-set/category/category-facet-search-actions'; +} from '../facets/category-facet-set/category-facet-set-actions.js'; +import {selectCategoryFacetSearchResult} from '../facets/facet-search-set/category/category-facet-search-actions.js'; import { excludeFacetSearchResult, selectFacetSearchResult, -} from '../facets/facet-search-set/specific/specific-facet-search-actions'; +} from '../facets/facet-search-set/specific/specific-facet-search-actions.js'; import { toggleExcludeDateFacetValue, toggleSelectDateFacetValue, updateDateFacetValues, -} from '../facets/range-facets/date-facet-set/date-facet-actions'; +} from '../facets/range-facets/date-facet-set/date-facet-actions.js'; import { toggleExcludeNumericFacetValue, toggleSelectNumericFacetValue, updateNumericFacetValues, -} from '../facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {change} from '../history/history-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {executeSearch} from '../search/search-actions'; -import {updateActiveTab} from '../tab-set/tab-set-actions'; +} from '../facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {change} from '../history/history-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../search/search-actions.js'; +import {updateActiveTab} from '../tab-set/tab-set-actions.js'; import { deselectAllFacetValues, toggleExcludeFacetValue, toggleSelectFacetValue, -} from './../facets/facet-set/facet-set-actions'; +} from './../facets/facet-set/facet-set-actions.js'; import { registerNumberOfResults, updateNumberOfResults, @@ -36,12 +36,15 @@ import { registerPage, previousPage, nextPage, -} from './pagination-actions'; +} from './pagination-actions.js'; import { maximumNumberOfResultsFromIndex, minimumPage, -} from './pagination-constants'; -import {getPaginationInitialState, PaginationState} from './pagination-state'; +} from './pagination-constants.js'; +import { + getPaginationInitialState, + PaginationState, +} from './pagination-state.js'; export const paginationReducer = createReducer( getPaginationInitialState(), diff --git a/packages/headless/src/features/pipeline/pipeline-actions-loader.ts b/packages/headless/src/features/pipeline/pipeline-actions-loader.ts index 8233c9d6f09..20f3b90182c 100644 --- a/packages/headless/src/features/pipeline/pipeline-actions-loader.ts +++ b/packages/headless/src/features/pipeline/pipeline-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice'; -import {setPipeline} from './pipeline-actions'; +import {CoreEngine} from '../../app/engine.js'; +import {pipelineReducer as pipeline} from '../../features/pipeline/pipeline-slice.js'; +import {setPipeline} from './pipeline-actions.js'; /** * The pipeline action creators. diff --git a/packages/headless/src/features/pipeline/pipeline-actions.ts b/packages/headless/src/features/pipeline/pipeline-actions.ts index b029cc8b183..744e3636ba2 100644 --- a/packages/headless/src/features/pipeline/pipeline-actions.ts +++ b/packages/headless/src/features/pipeline/pipeline-actions.ts @@ -1,6 +1,6 @@ import {StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; export const setPipeline = createAction('pipeline/set', (payload: string) => validatePayload( diff --git a/packages/headless/src/features/pipeline/pipeline-slice.test.ts b/packages/headless/src/features/pipeline/pipeline-slice.test.ts index c2478644238..9d365d5d8fe 100644 --- a/packages/headless/src/features/pipeline/pipeline-slice.test.ts +++ b/packages/headless/src/features/pipeline/pipeline-slice.test.ts @@ -1,9 +1,9 @@ -import {updateSearchConfiguration} from '../configuration/configuration-actions'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {setPipeline} from './pipeline-actions'; -import {pipelineReducer} from './pipeline-slice'; -import {getPipelineInitialState} from './pipeline-state'; +import {updateSearchConfiguration} from '../configuration/configuration-actions.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {setPipeline} from './pipeline-actions.js'; +import {pipelineReducer} from './pipeline-slice.js'; +import {getPipelineInitialState} from './pipeline-state.js'; describe('pipeline slice', () => { it('should have initial state', () => { diff --git a/packages/headless/src/features/pipeline/pipeline-slice.ts b/packages/headless/src/features/pipeline/pipeline-slice.ts index 120e6042ea4..2482c2520bb 100644 --- a/packages/headless/src/features/pipeline/pipeline-slice.ts +++ b/packages/headless/src/features/pipeline/pipeline-slice.ts @@ -1,8 +1,8 @@ import {createReducer} from '@reduxjs/toolkit'; -import {updateSearchConfiguration} from '../configuration/configuration-actions'; -import {change} from '../history/history-actions'; -import {setPipeline} from './pipeline-actions'; -import {getPipelineInitialState} from './pipeline-state'; +import {updateSearchConfiguration} from '../configuration/configuration-actions.js'; +import {change} from '../history/history-actions.js'; +import {setPipeline} from './pipeline-actions.js'; +import {getPipelineInitialState} from './pipeline-state.js'; export const pipelineReducer = createReducer( getPipelineInitialState(), diff --git a/packages/headless/src/features/query-set/query-set-actions-loader.ts b/packages/headless/src/features/query-set/query-set-actions-loader.ts index 566c477b1c1..6fd74951b53 100644 --- a/packages/headless/src/features/query-set/query-set-actions-loader.ts +++ b/packages/headless/src/features/query-set/query-set-actions-loader.ts @@ -1,12 +1,12 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {querySetReducer as querySet} from '../../features/query-set/query-set-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {querySetReducer as querySet} from '../../features/query-set/query-set-slice.js'; import { registerQuerySetQuery, RegisterQuerySetQueryActionCreatorPayload, updateQuerySetQuery, UpdateQuerySetQueryActionCreatorPayload, -} from './query-set-actions'; +} from './query-set-actions.js'; export type { RegisterQuerySetQueryActionCreatorPayload, diff --git a/packages/headless/src/features/query-set/query-set-actions.ts b/packages/headless/src/features/query-set/query-set-actions.ts index 862822ea1ee..95f99db3e92 100644 --- a/packages/headless/src/features/query-set/query-set-actions.ts +++ b/packages/headless/src/features/query-set/query-set-actions.ts @@ -3,7 +3,7 @@ import { validatePayload, requiredNonEmptyString, requiredEmptyAllowedString, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export const querySetDefinition = { id: requiredNonEmptyString, diff --git a/packages/headless/src/features/query-set/query-set-slice.test.ts b/packages/headless/src/features/query-set/query-set-slice.test.ts index fb400bfd733..3b4f9174e05 100644 --- a/packages/headless/src/features/query-set/query-set-slice.test.ts +++ b/packages/headless/src/features/query-set/query-set-slice.test.ts @@ -1,22 +1,25 @@ -import {SearchCommerceSuccessResponse} from '../../api/commerce/search/response'; -import {buildMockSearch} from '../../test/mock-search'; -import {selectQuerySuggestion as selectCommerceQuerySuggestion} from '../commerce/query-suggest/query-suggest-actions'; -import {restoreSearchParameters as commerceRestoreSearchParameters} from '../commerce/search-parameters/search-parameters-actions'; +import {SearchCommerceSuccessResponse} from '../../api/commerce/search/response.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {selectQuerySuggestion as selectCommerceQuerySuggestion} from '../commerce/query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters as commerceRestoreSearchParameters} from '../commerce/search-parameters/search-parameters-actions.js'; import { QuerySearchCommerceAPIThunkReturn, executeSearch as commerceExecuteSearch, -} from '../commerce/search/search-actions'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; +} from '../commerce/search/search-actions.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; import { ExecuteSearchThunkReturn, executeSearch, -} from '../search/search-actions'; -import {registerQuerySetQuery, updateQuerySetQuery} from './query-set-actions'; -import {querySetReducer} from './query-set-slice'; -import {getQuerySetInitialState, QuerySetState} from './query-set-state'; +} from '../search/search-actions.js'; +import { + registerQuerySetQuery, + updateQuerySetQuery, +} from './query-set-actions.js'; +import {querySetReducer} from './query-set-slice.js'; +import {getQuerySetInitialState, QuerySetState} from './query-set-state.js'; describe('querySet slice', () => { let state: QuerySetState; diff --git a/packages/headless/src/features/query-set/query-set-slice.ts b/packages/headless/src/features/query-set/query-set-slice.ts index c82d3db2e95..c3146ab3186 100644 --- a/packages/headless/src/features/query-set/query-set-slice.ts +++ b/packages/headless/src/features/query-set/query-set-slice.ts @@ -3,26 +3,26 @@ import {createReducer} from '@reduxjs/toolkit'; import { registerQuerySetQuery as registerCommerceQuerySetQuery, updateQuerySetQuery as updateCommerceQuerySetQuery, -} from '../commerce/query-set/query-set-actions'; -import {selectQuerySuggestion as selectCommerceQuerySuggestion} from '../commerce/query-suggest/query-suggest-actions'; +} from '../commerce/query-set/query-set-actions.js'; +import {selectQuerySuggestion as selectCommerceQuerySuggestion} from '../commerce/query-suggest/query-suggest-actions.js'; import { CommerceSearchParameters, restoreSearchParameters as commerceRestoreSearchParameters, -} from '../commerce/search-parameters/search-parameters-actions'; -import {executeSearch as commerceExecuteSearch} from '../commerce/search/search-actions'; -import {change} from '../history/history-actions'; -import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions'; +} from '../commerce/search-parameters/search-parameters-actions.js'; +import {executeSearch as commerceExecuteSearch} from '../commerce/search/search-actions.js'; +import {change} from '../history/history-actions.js'; +import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions.js'; import { SearchParameters, restoreSearchParameters, -} from '../search-parameters/search-parameter-actions'; -import {executeSearch} from '../search/search-actions'; +} from '../search-parameters/search-parameter-actions.js'; +import {executeSearch} from '../search/search-actions.js'; import { RegisterQuerySetQueryActionCreatorPayload, registerQuerySetQuery, updateQuerySetQuery, -} from './query-set-actions'; -import {getQuerySetInitialState, QuerySetState} from './query-set-state'; +} from './query-set-actions.js'; +import {getQuerySetInitialState, QuerySetState} from './query-set-state.js'; export const querySetReducer = createReducer( getQuerySetInitialState(), diff --git a/packages/headless/src/features/query-suggest/query-suggest-actions-loader.ts b/packages/headless/src/features/query-suggest/query-suggest-actions-loader.ts index 43f39d04c64..b4da4c78323 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-actions-loader.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-actions-loader.ts @@ -1,8 +1,8 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkSearchOptions} from '../../api/search/search-api-client'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {querySetReducer as querySet} from '../../features/query-set/query-set-slice'; -import {querySuggestReducer as querySuggest} from '../../features/query-suggest/query-suggest-slice'; +import {AsyncThunkSearchOptions} from '../../api/search/search-api-client.js'; +import {CoreEngine} from '../../app/engine.js'; +import {querySetReducer as querySet} from '../../features/query-set/query-set-slice.js'; +import {querySuggestReducer as querySuggest} from '../../features/query-suggest/query-suggest-slice.js'; import { clearQuerySuggest, ClearQuerySuggestActionCreatorPayload, @@ -14,7 +14,7 @@ import { selectQuerySuggestion, SelectQuerySuggestionActionCreatorPayload, StateNeededByQuerySuggest, -} from './query-suggest-actions'; +} from './query-suggest-actions.js'; export type { ClearQuerySuggestActionCreatorPayload, @@ -79,7 +79,7 @@ export interface QuerySuggestActionCreators { * @returns An object holding the action creators. */ export function loadQuerySuggestActions( - engine: SearchEngine + engine: CoreEngine ): QuerySuggestActionCreators { engine.addReducers({querySuggest, querySet}); diff --git a/packages/headless/src/features/query-suggest/query-suggest-actions.ts b/packages/headless/src/features/query-suggest/query-suggest-actions.ts index 52f61ce7b33..9333740bd6d 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-actions.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-actions.ts @@ -3,15 +3,15 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { getVisitorID, historyStore, -} from '../../api/analytics/coveo-analytics-utils'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {QuerySuggestRequest} from '../../api/search/query-suggest/query-suggest-request'; -import {QuerySuggestSuccessResponse} from '../../api/search/query-suggest/query-suggest-response'; +} from '../../api/analytics/coveo-analytics-utils.js'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {QuerySuggestRequest} from '../../api/search/query-suggest/query-suggest-request.js'; +import {QuerySuggestSuccessResponse} from '../../api/search/query-suggest/query-suggest-response.js'; import { isErrorResponse, AsyncThunkSearchOptions, -} from '../../api/search/search-api-client'; -import {NavigatorContext} from '../../app/navigatorContextProvider'; +} from '../../api/search/search-api-client.js'; +import {NavigatorContext} from '../../app/navigatorContextProvider.js'; import { ConfigurationSection, ContextSection, @@ -19,14 +19,14 @@ import { QuerySetSection, QuerySuggestionSection, SearchHubSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; import { validatePayload, requiredNonEmptyString, requiredEmptyAllowedString, -} from '../../utils/validate-payload'; -import {fromAnalyticsStateToAnalyticsParams} from '../configuration/analytics-params'; -import {fromAnalyticsStateToAnalyticsParams as legacyFromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params'; +} from '../../utils/validate-payload.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../configuration/analytics-params.js'; +import {fromAnalyticsStateToAnalyticsParams as legacyFromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params.js'; export type StateNeededByQuerySuggest = ConfigurationSection & QuerySuggestionSection & @@ -43,7 +43,7 @@ export interface QuerySuggestionID { export interface RegisterQuerySuggestActionCreatorPayload { /** - * A unique identifier for the new query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). + * A unique identifier for the new query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). Usually, this will be the ID of the search box controller that requests the query suggestions. */ id: string; @@ -71,7 +71,7 @@ export const unregisterQuerySuggest = createAction( export interface SelectQuerySuggestionActionCreatorPayload { /** - * The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). + * The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). Usually, this will be the ID of the search box controller that requests the query suggestions. */ id: string; @@ -92,7 +92,7 @@ export const selectQuerySuggestion = createAction( export interface ClearQuerySuggestActionCreatorPayload { /** - * The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). + * The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). Usually, this will be the ID of the search box controller that requests the query suggestions. */ id: string; } @@ -105,7 +105,7 @@ export const clearQuerySuggest = createAction( export interface FetchQuerySuggestionsActionCreatorPayload { /** - * The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). + * The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`). Usually, this will be the ID of the search box controller that requests the query suggestions. */ id: string; } diff --git a/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.test.ts b/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.test.ts index 39765d89b1e..65a3dd7b98e 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.test.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.test.ts @@ -1,8 +1,8 @@ -import {SearchAppState} from '../../state/search-app-state'; -import {buildMockQuerySuggest} from '../../test/mock-query-suggest'; -import {buildMockQuerySuggestCompletion} from '../../test/mock-query-suggest-completion'; -import {createMockState} from '../../test/mock-state'; -import {buildOmniboxSuggestionMetadata} from './query-suggest-analytics-actions'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {buildMockQuerySuggestCompletion} from '../../test/mock-query-suggest-completion.js'; +import {buildMockQuerySuggest} from '../../test/mock-query-suggest.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildOmniboxSuggestionMetadata} from './query-suggest-analytics-actions.js'; describe('#buildOmniboxSuggestionMetadata', () => { const id = '1'; diff --git a/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.ts b/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.ts index 2f29fe5b24b..6bb795bbf77 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-analytics-actions.ts @@ -1,11 +1,11 @@ -import type {OmniboxSuggestionsMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents'; -import {SearchAppState} from '../../state/search-app-state'; +import type {OmniboxSuggestionsMetadata} from 'coveo.analytics/dist/definitions/searchPage/searchPageEvents.js'; +import {SearchAppState} from '../../state/search-app-state.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; export interface LogQuerySuggestionClickActionCreatorPayload { /** diff --git a/packages/headless/src/features/query-suggest/query-suggest-slice.test.ts b/packages/headless/src/features/query-suggest/query-suggest-slice.test.ts index 46e1a6d5e52..18387d63f7d 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-slice.test.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-slice.test.ts @@ -1,19 +1,19 @@ -import {QuerySuggestCompletion} from '../../api/search/query-suggest/query-suggest-response'; -import {buildMockQuerySuggest} from '../../test/mock-query-suggest'; -import {buildMockQuerySuggestCompletion} from '../../test/mock-query-suggest-completion'; -import {buildMockSearchApiErrorWithStatusCode} from '../../test/mock-search-api-error-with-status-code'; +import {QuerySuggestCompletion} from '../../api/search/query-suggest/query-suggest-response.js'; +import {buildMockQuerySuggestCompletion} from '../../test/mock-query-suggest-completion.js'; +import {buildMockQuerySuggest} from '../../test/mock-query-suggest.js'; +import {buildMockSearchApiErrorWithStatusCode} from '../../test/mock-search-api-error-with-status-code.js'; import { fetchQuerySuggestions as fetchCommerceQuerySuggestions, registerQuerySuggest as registerCommerceQuerySuggest, clearQuerySuggest as clearCommerceQuerySuggest, -} from '../commerce/query-suggest/query-suggest-actions'; +} from '../commerce/query-suggest/query-suggest-actions.js'; import { clearQuerySuggest, fetchQuerySuggestions, registerQuerySuggest, -} from './query-suggest-actions'; -import {querySuggestReducer} from './query-suggest-slice'; -import {QuerySuggestSet} from './query-suggest-state'; +} from './query-suggest-actions.js'; +import {querySuggestReducer} from './query-suggest-slice.js'; +import {QuerySuggestSet} from './query-suggest-state.js'; describe('querySuggest slice', () => { let state: QuerySuggestSet; diff --git a/packages/headless/src/features/query-suggest/query-suggest-slice.ts b/packages/headless/src/features/query-suggest/query-suggest-slice.ts index 93a365e1707..3ce5148346d 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-slice.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-slice.ts @@ -4,7 +4,7 @@ import { clearQuerySuggest as clearCommerceQuerySuggest, fetchQuerySuggestions as fetchCommerceQuerySuggestions, registerQuerySuggest as registerCommerceQuerySuggest, -} from '../commerce/query-suggest/query-suggest-actions'; +} from '../commerce/query-suggest/query-suggest-actions.js'; import { ClearQuerySuggestActionCreatorPayload, RegisterQuerySuggestActionCreatorPayload, @@ -12,12 +12,12 @@ import { fetchQuerySuggestions, registerQuerySuggest, unregisterQuerySuggest, -} from './query-suggest-actions'; +} from './query-suggest-actions.js'; import { getQuerySuggestSetInitialState, QuerySuggestSet, QuerySuggestState, -} from './query-suggest-state'; +} from './query-suggest-state.js'; export const querySuggestReducer = createReducer( getQuerySuggestSetInitialState(), diff --git a/packages/headless/src/features/query-suggest/query-suggest-state.ts b/packages/headless/src/features/query-suggest/query-suggest-state.ts index a45d8b4a795..6fb5509886d 100644 --- a/packages/headless/src/features/query-suggest/query-suggest-state.ts +++ b/packages/headless/src/features/query-suggest/query-suggest-state.ts @@ -1,5 +1,5 @@ -import {QuerySuggestCompletion} from '../../api/search/query-suggest/query-suggest-response'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; +import {QuerySuggestCompletion} from '../../api/search/query-suggest/query-suggest-response.js'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; export interface QuerySuggestState { /** diff --git a/packages/headless/src/features/query/query-actions-loader.ts b/packages/headless/src/features/query/query-actions-loader.ts index b7d158ed2a8..e267d5edddb 100644 --- a/packages/headless/src/features/query/query-actions-loader.ts +++ b/packages/headless/src/features/query/query-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {queryReducer as query} from '../../features/query/query-slice'; -import {updateQuery, UpdateQueryActionCreatorPayload} from './query-actions'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {queryReducer as query} from '../../features/query/query-slice.js'; +import {updateQuery, UpdateQueryActionCreatorPayload} from './query-actions.js'; export type {UpdateQueryActionCreatorPayload}; diff --git a/packages/headless/src/features/query/query-actions.ts b/packages/headless/src/features/query/query-actions.ts index a2ad2a72017..94ca0f54379 100644 --- a/packages/headless/src/features/query/query-actions.ts +++ b/packages/headless/src/features/query/query-actions.ts @@ -1,6 +1,6 @@ import {BooleanValue, StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; export interface UpdateQueryActionCreatorPayload { /** diff --git a/packages/headless/src/features/query/query-analytics-actions.ts b/packages/headless/src/features/query/query-analytics-actions.ts index 9be740ba47b..8db2ba5be79 100644 --- a/packages/headless/src/features/query/query-analytics-actions.ts +++ b/packages/headless/src/features/query/query-analytics-actions.ts @@ -1,9 +1,9 @@ import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; //TODO: KIT-2859 export const logSearchboxSubmit = (): LegacySearchAction => diff --git a/packages/headless/src/features/query/query-insight-analytics-actions.test.ts b/packages/headless/src/features/query/query-insight-analytics-actions.test.ts index 9c8e1f8110b..9bc56100979 100644 --- a/packages/headless/src/features/query/query-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/query/query-insight-analytics-actions.test.ts @@ -1,20 +1,20 @@ -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {logSearchboxSubmit} from './query-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {logSearchboxSubmit} from './query-insight-analytics-actions.js'; -const mockLogSearchboxSubmit = jest.fn(); +const mockLogSearchboxSubmit = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logSearchboxSubmit: mockLogSearchboxSubmit, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/query/query-insight-analytics-actions.ts b/packages/headless/src/features/query/query-insight-analytics-actions.ts index 3751cfc3add..d877c1ff31a 100644 --- a/packages/headless/src/features/query/query-insight-analytics-actions.ts +++ b/packages/headless/src/features/query/query-insight-analytics-actions.ts @@ -1,9 +1,9 @@ import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export const logSearchboxSubmit = (): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.searchboxSubmit)( diff --git a/packages/headless/src/features/query/query-selectors.ts b/packages/headless/src/features/query/query-selectors.ts index 45d5f33556b..09e6d391476 100644 --- a/packages/headless/src/features/query/query-selectors.ts +++ b/packages/headless/src/features/query/query-selectors.ts @@ -1,5 +1,5 @@ import {createSelector} from '@reduxjs/toolkit'; -import {QueryState} from './query-state'; +import {QueryState} from './query-state.js'; export const selectQuery = createSelector( (state: {query?: QueryState}) => state.query, diff --git a/packages/headless/src/features/query/query-slice.test.ts b/packages/headless/src/features/query/query-slice.test.ts index 97ca58c5ae8..e76bbb478ff 100644 --- a/packages/headless/src/features/query/query-slice.test.ts +++ b/packages/headless/src/features/query/query-slice.test.ts @@ -1,11 +1,11 @@ -import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {updateQuery} from './query-actions'; -import {queryReducer} from './query-slice'; -import {getQueryInitialState, QueryState} from './query-state'; +import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {updateQuery} from './query-actions.js'; +import {queryReducer} from './query-slice.js'; +import {getQueryInitialState, QueryState} from './query-state.js'; describe('query slice', () => { let state: QueryState; diff --git a/packages/headless/src/features/query/query-slice.ts b/packages/headless/src/features/query/query-slice.ts index 2af6e13323b..2bf1c983f16 100644 --- a/packages/headless/src/features/query/query-slice.ts +++ b/packages/headless/src/features/query/query-slice.ts @@ -1,10 +1,10 @@ import {createReducer} from '@reduxjs/toolkit'; -import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions'; -import {change} from '../history/history-actions'; -import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {updateQuery} from './query-actions'; -import {getQueryInitialState} from './query-state'; +import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions.js'; +import {change} from '../history/history-actions.js'; +import {selectQuerySuggestion} from '../query-suggest/query-suggest-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {updateQuery} from './query-actions.js'; +import {getQueryInitialState} from './query-state.js'; export const queryReducer = createReducer(getQueryInitialState(), (builder) => builder diff --git a/packages/headless/src/features/question-answering/__snapshots__/question-answering-analytics-actions.test.ts.snap b/packages/headless/src/features/question-answering/__snapshots__/question-answering-analytics-actions.test.ts.snap index 6faab5a10e9..9eb7b91eee6 100644 --- a/packages/headless/src/features/question-answering/__snapshots__/question-answering-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/question-answering/__snapshots__/question-answering-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logCollapseSmartSnippet with the case payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logCollapseSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -13,7 +13,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logCollapseSmartSnippetSuggestion with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logCollapseSmartSnippetSuggestion with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -26,7 +26,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logDislikeSmartSnippet with the case payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logDislikeSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -39,7 +39,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logExpandSmartSnippet with the case payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logExpandSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -52,7 +52,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logExpandSmartSnippetSuggestion with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logExpandSmartSnippetSuggestion with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -65,7 +65,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logLikeSmartSnippet with the case payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logLikeSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -78,7 +78,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetInlineLink with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetInlineLink with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -94,7 +94,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetSource with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetSource with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -110,7 +110,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetSuggestionInlineLink with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetSuggestionInlineLink with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -126,7 +126,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetSuggestionSource with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetSuggestionSource with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -142,7 +142,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logSmartSnippetDetailedFeedback with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logSmartSnippetDetailedFeedback with the right payload 1`] = ` [ "Qna.SubmitSmartSnippetFeedback", { @@ -157,7 +157,7 @@ exports[`question answering analytics actions when analyticsMode is \`next\` sho ] `; -exports[`question answering analytics actions when analyticsMode is \`next\` should log #logSmartSnippetFeedback with the right payload 1`] = ` +exports[`question answering analytics actions > when analyticsMode is \`next\` > should log #logSmartSnippetFeedback with the right payload 1`] = ` [ "Qna.SubmitSmartSnippetFeedback", { diff --git a/packages/headless/src/features/question-answering/__snapshots__/question-answering-insight-analytics-actions.test.ts.snap b/packages/headless/src/features/question-answering/__snapshots__/question-answering-insight-analytics-actions.test.ts.snap index 2edda2519bb..9e1dab068a3 100644 --- a/packages/headless/src/features/question-answering/__snapshots__/question-answering-insight-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/question-answering/__snapshots__/question-answering-insight-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logCollapseSmartSnippet with the case payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logCollapseSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -13,7 +13,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logCollapseSmartSnippetSuggestion with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logCollapseSmartSnippetSuggestion with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -26,7 +26,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logDislikeSmartSnippet with the case payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logDislikeSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -39,7 +39,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logExpandSmartSnippet with the case payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logExpandSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -52,7 +52,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logExpandSmartSnippetSuggestion with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logExpandSmartSnippetSuggestion with the right payload 1`] = ` [ "Qna.AnswerAction", { @@ -65,7 +65,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logLikeSmartSnippet with the case payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logLikeSmartSnippet with the case payload 1`] = ` [ "Qna.AnswerAction", { @@ -78,7 +78,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetInlineLink with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetInlineLink with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -94,7 +94,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetSource with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetSource with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -110,7 +110,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetSuggestionInlineLink with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetSuggestionInlineLink with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -126,7 +126,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logOpenSmartSnippetSuggestionSource with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logOpenSmartSnippetSuggestionSource with the right payload 1`] = ` [ "Qna.CitationClick", { @@ -142,7 +142,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logSmartSnippetDetailedFeedback with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logSmartSnippetDetailedFeedback with the right payload 1`] = ` [ "Qna.SubmitSmartSnippetFeedback", { @@ -157,7 +157,7 @@ exports[`question answering insight analytics actions when analyticsMode is \`ne ] `; -exports[`question answering insight analytics actions when analyticsMode is \`next\` should log #logSmartSnippetFeedback with the right payload 1`] = ` +exports[`question answering insight analytics actions > when analyticsMode is \`next\` > should log #logSmartSnippetFeedback with the right payload 1`] = ` [ "Qna.SubmitSmartSnippetFeedback", { diff --git a/packages/headless/src/features/question-answering/question-answering-actions-loader.ts b/packages/headless/src/features/question-answering/question-answering-actions-loader.ts index 950ab1cd310..4eee408157c 100644 --- a/packages/headless/src/features/question-answering/question-answering-actions-loader.ts +++ b/packages/headless/src/features/question-answering/question-answering-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {questionAnsweringReducer as questionAnswering} from '../../features/question-answering/question-answering-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {questionAnsweringReducer as questionAnswering} from '../../features/question-answering/question-answering-slice.js'; import { collapseSmartSnippet, dislikeSmartSnippet, @@ -10,8 +10,8 @@ import { closeFeedbackModal, collapseSmartSnippetRelatedQuestion, expandSmartSnippetRelatedQuestion, -} from './question-answering-actions'; -import {QuestionAnsweringUniqueIdentifierActionCreatorPayload} from './question-answering-document-id'; +} from './question-answering-actions.js'; +import {QuestionAnsweringUniqueIdentifierActionCreatorPayload} from './question-answering-document-id.js'; /** * The question answering action creators. diff --git a/packages/headless/src/features/question-answering/question-answering-actions.ts b/packages/headless/src/features/question-answering/question-answering-actions.ts index feaae4b3dee..1d88e3d1385 100644 --- a/packages/headless/src/features/question-answering/question-answering-actions.ts +++ b/packages/headless/src/features/question-answering/question-answering-actions.ts @@ -2,7 +2,7 @@ import {createAction} from '@reduxjs/toolkit'; import { QuestionAnsweringUniqueIdentifierActionCreatorPayload, validateQuestionAnsweringActionCreatorPayload, -} from './question-answering-document-id'; +} from './question-answering-document-id.js'; export const expandSmartSnippet = createAction('smartSnippet/expand'); diff --git a/packages/headless/src/features/question-answering/question-answering-analytics-actions.test.ts b/packages/headless/src/features/question-answering/question-answering-analytics-actions.test.ts index 07ce763e3d9..9f8aff53e9f 100644 --- a/packages/headless/src/features/question-answering/question-answering-analytics-actions.test.ts +++ b/packages/headless/src/features/question-answering/question-answering-analytics-actions.test.ts @@ -1,16 +1,16 @@ import {createRelay} from '@coveo/relay'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {createMockState} from '../../test/mock-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {emptyQuestionAnswer} from '../search/search-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {createMockState} from '../../test/mock-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {emptyQuestionAnswer} from '../search/search-state.js'; import { logExpandSmartSnippet, logExpandSmartSnippetSuggestion, @@ -26,68 +26,68 @@ import { logCloseSmartSnippetFeedbackModal, logSmartSnippetFeedback, logSmartSnippetDetailedFeedback, -} from './question-answering-analytics-actions'; -import {getQuestionAnsweringInitialState} from './question-answering-state'; +} from './question-answering-analytics-actions.js'; +import {getQuestionAnsweringInitialState} from './question-answering-state.js'; -const mockLogFunction = jest.fn(); -const mockMakeExpandSmartSnippet = jest.fn(() => ({ +const mockLogFunction = vi.fn(); +const mockMakeExpandSmartSnippet = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeCollapseSmartSnippet = jest.fn(() => ({ +const mockMakeCollapseSmartSnippet = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeLikeSmartSnippet = jest.fn(() => ({ +const mockMakeLikeSmartSnippet = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeDislikeSmartSnippet = jest.fn(() => ({ +const mockMakeDislikeSmartSnippet = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeOpenSmartSnippetSource = jest.fn((..._args) => ({ +const mockMakeOpenSmartSnippetSource = vi.fn((..._args) => ({ log: mockLogFunction, })); -const mockMakeOpenSmartSnippetInlineLink = jest.fn((..._args) => ({ +const mockMakeOpenSmartSnippetInlineLink = vi.fn((..._args) => ({ log: mockLogFunction, })); -const mockMakeOpenSmartSnippetFeedbackModal = jest.fn(() => ({ +const mockMakeOpenSmartSnippetFeedbackModal = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeCloseSmartSnippetFeedbackModal = jest.fn(() => ({ +const mockMakeCloseSmartSnippetFeedbackModal = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeSmartSnippetFeedback = jest.fn((..._args) => ({ +const mockMakeSmartSnippetFeedback = vi.fn((..._args) => ({ log: mockLogFunction, })); -const mockMakeSmartSnippetDetailedFeedback = jest.fn(() => ({ +const mockMakeSmartSnippetDetailedFeedback = vi.fn(() => ({ log: mockLogFunction, })); -const mockMakeExpandSmartSnippetSuggestion = jest.fn((..._args) => ({ +const mockMakeExpandSmartSnippetSuggestion = vi.fn((..._args) => ({ log: mockLogFunction, })); -const mockMakeCollapseSmartSnippetSuggestion = jest.fn((..._args) => ({ +const mockMakeCollapseSmartSnippetSuggestion = vi.fn((..._args) => ({ log: mockLogFunction, })); -const mockMakeOpenSmartSnippetSuggestionSource = jest.fn((..._args) => ({ +const mockMakeOpenSmartSnippetSuggestionSource = vi.fn((..._args) => ({ log: mockLogFunction, })); -const mockMakeOpenSmartSnippetSuggestionInlineLink = jest.fn((..._args) => ({ +const mockMakeOpenSmartSnippetSuggestionInlineLink = vi.fn((..._args) => ({ log: mockLogFunction, })); -const emit = jest.fn(); +const emit = vi.fn(); -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); -jest.mock('coveo.analytics', () => { - const mockCoveoSearchPageClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCoveoSearchPageClient = vi.fn(() => ({ + disable: vi.fn(), makeExpandSmartSnippet: mockMakeExpandSmartSnippet, makeCollapseSmartSnippet: mockMakeCollapseSmartSnippet, makeLikeSmartSnippet: mockMakeLikeSmartSnippet, @@ -108,7 +108,7 @@ jest.mock('coveo.analytics', () => { return { CoveoSearchPageClient: mockCoveoSearchPageClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -209,7 +209,7 @@ describe('question answering analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/question-answering/question-answering-analytics-actions.ts b/packages/headless/src/features/question-answering/question-answering-analytics-actions.ts index 1569ddb6705..b7f678dc527 100644 --- a/packages/headless/src/features/question-answering/question-answering-analytics-actions.ts +++ b/packages/headless/src/features/question-answering/question-answering-analytics-actions.ts @@ -1,23 +1,23 @@ import {Qna} from '@coveo/relay-event-types'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; import { ClickAction, CustomAction, documentIdentifier, makeAnalyticsAction, partialDocumentInformation, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; import { inlineLinkPayloadDefinition, QuestionAnsweringInlineLinkActionCreatorPayload, QuestionAnsweringUniqueIdentifierActionCreatorPayload, uniqueIdentifierPayloadDefinition, validateQuestionAnsweringActionCreatorPayload, -} from './question-answering-document-id'; +} from './question-answering-document-id.js'; import { answerSourceSelector, relatedQuestionSelector, -} from './question-answering-selectors'; +} from './question-answering-selectors.js'; export type SmartSnippetFeedback = | 'does_not_answer' diff --git a/packages/headless/src/features/question-answering/question-answering-document-id.ts b/packages/headless/src/features/question-answering/question-answering-document-id.ts index 5c53ae6a843..6c3f3c0318a 100644 --- a/packages/headless/src/features/question-answering/question-answering-document-id.ts +++ b/packages/headless/src/features/question-answering/question-answering-document-id.ts @@ -3,7 +3,7 @@ import { requiredEmptyAllowedString, requiredNonEmptyString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export interface QuestionAnsweringUniqueIdentifierActionCreatorPayload { questionAnswerId: string; diff --git a/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.test.ts b/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.test.ts index 34d8f3f485e..9e1f19ab485 100644 --- a/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.test.ts @@ -1,16 +1,16 @@ import {createRelay} from '@coveo/relay'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { buildMockInsightEngine, MockedInsightEngine, -} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {emptyQuestionAnswer} from '../search/search-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {emptyQuestionAnswer} from '../search/search-state.js'; import { logExpandSmartSnippet, logExpandSmartSnippetSuggestion, @@ -26,39 +26,39 @@ import { logCloseSmartSnippetFeedbackModal, logSmartSnippetFeedback, logSmartSnippetDetailedFeedback, -} from './question-answering-insight-analytics-actions'; -import {getQuestionAnsweringInitialState} from './question-answering-state'; - -const mockLogExpandSmartSnippet = jest.fn(); -const mockLogCollapseSmartSnippet = jest.fn(); -const mockLogLikeSmartSnippet = jest.fn(); -const mockLogDislikeSmartSnippet = jest.fn(); -const mockLogOpenSmartSnippetSource = jest.fn(); -const mockLogOpenSmartSnippetInlineLink = jest.fn(); -const mockLogOpenSmartSnippetFeedbackModal = jest.fn(); -const mockLogCloseSmartSnippetFeedbackModal = jest.fn(); -const mockLogSmartSnippetFeedback = jest.fn(); -const mockLogSmartSnippetDetailedFeedback = jest.fn(); -const mockLogExpandSmartSnippetSuggestion = jest.fn(); -const mockLogCollapseSmartSnippetSuggestion = jest.fn(); -const mockLogOpenSmartSnippetSuggestionSource = jest.fn(); -const mockLogOpenSmartSnippetSuggestionInlineLink = jest.fn(); -const emit = jest.fn(); - -jest.mock('@coveo/relay'); - -jest.mocked(createRelay).mockReturnValue({ +} from './question-answering-insight-analytics-actions.js'; +import {getQuestionAnsweringInitialState} from './question-answering-state.js'; + +const mockLogExpandSmartSnippet = vi.fn(); +const mockLogCollapseSmartSnippet = vi.fn(); +const mockLogLikeSmartSnippet = vi.fn(); +const mockLogDislikeSmartSnippet = vi.fn(); +const mockLogOpenSmartSnippetSource = vi.fn(); +const mockLogOpenSmartSnippetInlineLink = vi.fn(); +const mockLogOpenSmartSnippetFeedbackModal = vi.fn(); +const mockLogCloseSmartSnippetFeedbackModal = vi.fn(); +const mockLogSmartSnippetFeedback = vi.fn(); +const mockLogSmartSnippetDetailedFeedback = vi.fn(); +const mockLogExpandSmartSnippetSuggestion = vi.fn(); +const mockLogCollapseSmartSnippetSuggestion = vi.fn(); +const mockLogOpenSmartSnippetSuggestionSource = vi.fn(); +const mockLogOpenSmartSnippetSuggestionInlineLink = vi.fn(); +const emit = vi.fn(); + +vi.mock('@coveo/relay'); + +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ - disable: jest.fn(), +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ + disable: vi.fn(), logExpandSmartSnippet: mockLogExpandSmartSnippet, logCollapseSmartSnippet: mockLogCollapseSmartSnippet, logLikeSmartSnippet: mockLogLikeSmartSnippet, @@ -79,7 +79,7 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); @@ -201,7 +201,7 @@ describe('question answering insight analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.ts b/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.ts index 0985ce21a87..c5acc393368 100644 --- a/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.ts +++ b/packages/headless/src/features/question-answering/question-answering-insight-analytics-actions.ts @@ -1,25 +1,25 @@ import {Qna} from '@coveo/relay-event-types'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; import { InsightAction, documentIdentifier, makeInsightAnalyticsActionFactory, partialDocumentInformation, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; -import {SmartSnippetFeedback} from './question-answering-analytics-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; +import {SmartSnippetFeedback} from './question-answering-analytics-actions.js'; import { inlineLinkPayloadDefinition, QuestionAnsweringInlineLinkActionCreatorPayload, QuestionAnsweringUniqueIdentifierActionCreatorPayload, uniqueIdentifierPayloadDefinition, validateQuestionAnsweringActionCreatorPayload, -} from './question-answering-document-id'; +} from './question-answering-document-id.js'; import { answerSourceSelector, relatedQuestionSelector, -} from './question-answering-selectors'; +} from './question-answering-selectors.js'; export const logExpandSmartSnippet = (): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.expandSmartSnippet)({ diff --git a/packages/headless/src/features/question-answering/question-answering-selectors.ts b/packages/headless/src/features/question-answering/question-answering-selectors.ts index b245c3d436f..a38c86463d4 100644 --- a/packages/headless/src/features/question-answering/question-answering-selectors.ts +++ b/packages/headless/src/features/question-answering/question-answering-selectors.ts @@ -1,9 +1,9 @@ -import {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering'; +import {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering.js'; import { QuestionAnsweringSection, SearchSection, -} from '../../state/state-sections'; -import {resultFromFieldSelector} from '../search/search-selectors'; +} from '../../state/state-sections.js'; +import {resultFromFieldSelector} from '../search/search-selectors.js'; export function answerSourceSelector( state: Partial, diff --git a/packages/headless/src/features/question-answering/question-answering-slice.test.ts b/packages/headless/src/features/question-answering/question-answering-slice.test.ts index d842902ec6c..3c0d57f8061 100644 --- a/packages/headless/src/features/question-answering/question-answering-slice.test.ts +++ b/packages/headless/src/features/question-answering/question-answering-slice.test.ts @@ -1,13 +1,13 @@ -import {SearchResponseSuccess} from '../../api/search/search/search-response'; +import {SearchResponseSuccess} from '../../api/search/search/search-response.js'; import { buildMockQuestionAnswer, buildMockQuestionsAnswers, -} from '../../test/mock-question-answer'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearch} from '../../test/mock-search'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {executeSearch} from '../search/search-actions'; +} from '../../test/mock-question-answer.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {executeSearch} from '../search/search-actions.js'; import { collapseSmartSnippet, collapseSmartSnippetRelatedQuestion, @@ -15,12 +15,12 @@ import { expandSmartSnippet, expandSmartSnippetRelatedQuestion, likeSmartSnippet, -} from './question-answering-actions'; -import {questionAnsweringReducer} from './question-answering-slice'; +} from './question-answering-actions.js'; +import {questionAnsweringReducer} from './question-answering-slice.js'; import { getQuestionAnsweringInitialState, QuestionAnsweringState, -} from './question-answering-state'; +} from './question-answering-state.js'; function buildUniqueQuestionAnswer(increment: number) { return buildMockQuestionAnswer({ diff --git a/packages/headless/src/features/question-answering/question-answering-slice.ts b/packages/headless/src/features/question-answering/question-answering-slice.ts index c8b0df465eb..62cee2d2650 100644 --- a/packages/headless/src/features/question-answering/question-answering-slice.ts +++ b/packages/headless/src/features/question-answering/question-answering-slice.ts @@ -1,7 +1,7 @@ import {createReducer} from '@reduxjs/toolkit'; -import {QuestionAnswer} from '../../api/search/search/question-answering'; -import {getObjectHash} from '../../utils/utils'; -import {executeSearch} from '../search/search-actions'; +import {QuestionAnswer} from '../../api/search/search/question-answering.js'; +import {getObjectHash} from '../../utils/utils.js'; +import {executeSearch} from '../search/search-actions.js'; import { collapseSmartSnippet, collapseSmartSnippetRelatedQuestion, @@ -11,12 +11,12 @@ import { likeSmartSnippet, openFeedbackModal, closeFeedbackModal, -} from './question-answering-actions'; -import {QuestionAnsweringUniqueIdentifierActionCreatorPayload} from './question-answering-document-id'; +} from './question-answering-actions.js'; +import {QuestionAnsweringUniqueIdentifierActionCreatorPayload} from './question-answering-document-id.js'; import { getQuestionAnsweringInitialState, QuestionAnsweringRelatedQuestionState, -} from './question-answering-state'; +} from './question-answering-state.js'; const findRelatedQuestionIdx = ( relatedQuestions: QuestionAnsweringRelatedQuestionState[], diff --git a/packages/headless/src/features/question-answering/question-answering-state.ts b/packages/headless/src/features/question-answering/question-answering-state.ts index 2bee6852b4f..86ad53be2ce 100644 --- a/packages/headless/src/features/question-answering/question-answering-state.ts +++ b/packages/headless/src/features/question-answering/question-answering-state.ts @@ -1,4 +1,4 @@ -import {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering'; +import {QuestionAnswerDocumentIdentifier} from '../../api/search/search/question-answering.js'; export interface QuestionAnsweringRelatedQuestionState extends QuestionAnswerDocumentIdentifier { diff --git a/packages/headless/src/features/recent-queries/recent-queries-actions-loader.ts b/packages/headless/src/features/recent-queries/recent-queries-actions-loader.ts index 6c850937fe7..8cf967b47e4 100644 --- a/packages/headless/src/features/recent-queries/recent-queries-actions-loader.ts +++ b/packages/headless/src/features/recent-queries/recent-queries-actions-loader.ts @@ -1,11 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {recentQueriesReducer as recentQueries} from '../../features/recent-queries/recent-queries-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {recentQueriesReducer as recentQueries} from '../../features/recent-queries/recent-queries-slice.js'; import { RegisterRecentQueriesCreatorPayload, registerRecentQueries, clearRecentQueries, -} from './recent-queries-actions'; +} from './recent-queries-actions.js'; /** * The RecentQueries action creators. diff --git a/packages/headless/src/features/recent-queries/recent-queries-actions.ts b/packages/headless/src/features/recent-queries/recent-queries-actions.ts index af5d771596c..f7ce16d2268 100644 --- a/packages/headless/src/features/recent-queries/recent-queries-actions.ts +++ b/packages/headless/src/features/recent-queries/recent-queries-actions.ts @@ -1,6 +1,6 @@ import {ArrayValue, NumberValue, StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; export interface RegisterRecentQueriesCreatorPayload { /** diff --git a/packages/headless/src/features/recent-queries/recent-queries-analytics-actions.ts b/packages/headless/src/features/recent-queries/recent-queries-analytics-actions.ts index 7c5ab96c941..896962d4193 100644 --- a/packages/headless/src/features/recent-queries/recent-queries-analytics-actions.ts +++ b/packages/headless/src/features/recent-queries/recent-queries-analytics-actions.ts @@ -2,7 +2,7 @@ import { makeAnalyticsAction, CustomAction, LegacySearchAction, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; export const logClearRecentQueries = (): CustomAction => makeAnalyticsAction('analytics/recentQueries/clear', (client) => { diff --git a/packages/headless/src/features/recent-queries/recent-queries-slice.test.ts b/packages/headless/src/features/recent-queries/recent-queries-slice.test.ts index 97aa062b394..829b2b97484 100644 --- a/packages/headless/src/features/recent-queries/recent-queries-slice.test.ts +++ b/packages/headless/src/features/recent-queries/recent-queries-slice.test.ts @@ -1,17 +1,17 @@ -import {Result} from '../../api/search/search/result'; -import {buildMockSearch} from '../../test/mock-search'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {logSearchEvent} from '../analytics/analytics-actions'; -import {executeSearch} from '../search/search-actions'; +import {Result} from '../../api/search/search/result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {logSearchEvent} from '../analytics/analytics-actions.js'; +import {executeSearch} from '../search/search-actions.js'; import { clearRecentQueries, registerRecentQueries, -} from './recent-queries-actions'; -import {recentQueriesReducer} from './recent-queries-slice'; +} from './recent-queries-actions.js'; +import {recentQueriesReducer} from './recent-queries-slice.js'; import { getRecentQueriesInitialState, RecentQueriesState, -} from './recent-queries-state'; +} from './recent-queries-state.js'; function withResult(rest = {}) { return { diff --git a/packages/headless/src/features/recent-queries/recent-queries-slice.ts b/packages/headless/src/features/recent-queries/recent-queries-slice.ts index c9be7fbd310..5e1e574efd7 100644 --- a/packages/headless/src/features/recent-queries/recent-queries-slice.ts +++ b/packages/headless/src/features/recent-queries/recent-queries-slice.ts @@ -1,14 +1,14 @@ import {AnyAction, type Draft as WritableDraft} from '@reduxjs/toolkit'; import {createReducer} from '@reduxjs/toolkit'; -import {executeSearch} from '../search/search-actions'; +import {executeSearch} from '../search/search-actions.js'; import { registerRecentQueries, clearRecentQueries, -} from './recent-queries-actions'; +} from './recent-queries-actions.js'; import { RecentQueriesState, getRecentQueriesInitialState, -} from './recent-queries-state'; +} from './recent-queries-state.js'; export const recentQueriesReducer = createReducer( getRecentQueriesInitialState(), diff --git a/packages/headless/src/features/recent-results/recent-results-actions-loader.ts b/packages/headless/src/features/recent-results/recent-results-actions-loader.ts index 0bf17fd6d7a..dfbe9287b9e 100644 --- a/packages/headless/src/features/recent-results/recent-results-actions-loader.ts +++ b/packages/headless/src/features/recent-results/recent-results-actions-loader.ts @@ -1,13 +1,13 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {Result} from '../../api/search/search/result'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {recentResultsReducer as recentResults} from '../../features/recent-results/recent-results-slice'; +import {Result} from '../../api/search/search/result.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {recentResultsReducer as recentResults} from '../../features/recent-results/recent-results-slice.js'; import { RegisterRecentResultsCreatorPayload, registerRecentResults, clearRecentResults, pushRecentResult, -} from './recent-results-actions'; +} from './recent-results-actions.js'; export type {RegisterRecentResultsCreatorPayload}; /** diff --git a/packages/headless/src/features/recent-results/recent-results-actions.ts b/packages/headless/src/features/recent-results/recent-results-actions.ts index 75c9cdaf1c0..7943cb032b4 100644 --- a/packages/headless/src/features/recent-results/recent-results-actions.ts +++ b/packages/headless/src/features/recent-results/recent-results-actions.ts @@ -1,11 +1,11 @@ import {ArrayValue, NumberValue, RecordValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {Result} from '../../api/search/search/result'; -import {validatePayload} from '../../utils/validate-payload'; +import {Result} from '../../api/search/search/result.js'; +import {validatePayload} from '../../utils/validate-payload.js'; import { resultPartialDefinition, validateResultPayload, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; export interface RegisterRecentResultsCreatorPayload { /** diff --git a/packages/headless/src/features/recent-results/recent-results-analytics-actions.ts b/packages/headless/src/features/recent-results/recent-results-analytics-actions.ts index 80a5502a711..3b0c7252468 100644 --- a/packages/headless/src/features/recent-results/recent-results-analytics-actions.ts +++ b/packages/headless/src/features/recent-results/recent-results-analytics-actions.ts @@ -1,11 +1,11 @@ -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { makeAnalyticsAction, partialDocumentInformation, documentIdentifier, validateResultPayload, CustomAction, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; export const logRecentResultClick = (result: Result): CustomAction => makeAnalyticsAction('analytics/recentResults/click', (client, state) => { diff --git a/packages/headless/src/features/recent-results/recent-results-slice.test.ts b/packages/headless/src/features/recent-results/recent-results-slice.test.ts index 345643405ef..ba0069c2513 100644 --- a/packages/headless/src/features/recent-results/recent-results-slice.test.ts +++ b/packages/headless/src/features/recent-results/recent-results-slice.test.ts @@ -1,14 +1,14 @@ -import {buildMockResult} from '../../test/mock-result'; +import {buildMockResult} from '../../test/mock-result.js'; import { clearRecentResults, pushRecentResult, registerRecentResults, -} from './recent-results-actions'; -import {recentResultsReducer} from './recent-results-slice'; +} from './recent-results-actions.js'; +import {recentResultsReducer} from './recent-results-slice.js'; import { getRecentResultsInitialState, RecentResultsState, -} from './recent-results-state'; +} from './recent-results-state.js'; describe('recent-results slice', () => { let state: RecentResultsState; diff --git a/packages/headless/src/features/recent-results/recent-results-slice.ts b/packages/headless/src/features/recent-results/recent-results-slice.ts index 839f893aa5c..5c0c5b591ad 100644 --- a/packages/headless/src/features/recent-results/recent-results-slice.ts +++ b/packages/headless/src/features/recent-results/recent-results-slice.ts @@ -3,8 +3,8 @@ import { registerRecentResults, clearRecentResults, pushRecentResult, -} from './recent-results-actions'; -import {getRecentResultsInitialState} from './recent-results-state'; +} from './recent-results-actions.js'; +import {getRecentResultsInitialState} from './recent-results-state.js'; export const recentResultsReducer = createReducer( getRecentResultsInitialState(), diff --git a/packages/headless/src/features/recent-results/recent-results-state.ts b/packages/headless/src/features/recent-results/recent-results-state.ts index 6dde4b47210..42fbbd20aba 100644 --- a/packages/headless/src/features/recent-results/recent-results-state.ts +++ b/packages/headless/src/features/recent-results/recent-results-state.ts @@ -1,4 +1,4 @@ -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; export interface RecentResultsState { results: Result[]; diff --git a/packages/headless/src/features/recommendation/__snapshots__/recommendation-analytics-actions.test.ts.snap b/packages/headless/src/features/recommendation/__snapshots__/recommendation-analytics-actions.test.ts.snap index 60c361683ce..3f089466026 100644 --- a/packages/headless/src/features/recommendation/__snapshots__/recommendation-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/recommendation/__snapshots__/recommendation-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`recommendation analytics actions #logRecommendationOpen when analyticsMode is \`legacy\` should call coveo.analytics.makeRecommendationOpen properly 1`] = ` +exports[`recommendation analytics actions > #logRecommendationOpen > when analyticsMode is \`legacy\` should call coveo.analytics.makeRecommendationOpen properly 1`] = ` [ { "collectionName": "example collectionName", @@ -21,7 +21,7 @@ exports[`recommendation analytics actions #logRecommendationOpen when analyticsM ] `; -exports[`recommendation analytics actions #logRecommendationOpen when analyticsMode is \`next\` 1`] = ` +exports[`recommendation analytics actions > #logRecommendationOpen > when analyticsMode is \`next\` 1`] = ` [ "itemClick", { @@ -33,7 +33,7 @@ exports[`recommendation analytics actions #logRecommendationOpen when analyticsM "url": "example documentUrl", }, "position": 1, - "searchUid": "", + "searchUid": "example searchUid", }, ] `; diff --git a/packages/headless/src/features/recommendation/recommendation-actions-loader.ts b/packages/headless/src/features/recommendation/recommendation-actions-loader.ts index ac2db4b57ad..5eb117e99bd 100644 --- a/packages/headless/src/features/recommendation/recommendation-actions-loader.ts +++ b/packages/headless/src/features/recommendation/recommendation-actions-loader.ts @@ -1,14 +1,14 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkSearchOptions} from '../../api/search/search-api-client'; -import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine'; -import {recommendationReducer as recommendation} from '../../features/recommendation/recommendation-slice'; +import {AsyncThunkSearchOptions} from '../../api/search/search-api-client.js'; +import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine.js'; +import {recommendationReducer as recommendation} from '../../features/recommendation/recommendation-slice.js'; import { getRecommendations, GetRecommendationsThunkReturn, StateNeededByGetRecommendations, setRecommendationId, SetRecommendationIdActionCreatorPayload, -} from './recommendation-actions'; +} from './recommendation-actions.js'; export type {SetRecommendationIdActionCreatorPayload}; diff --git a/packages/headless/src/features/recommendation/recommendation-actions.ts b/packages/headless/src/features/recommendation/recommendation-actions.ts index ddaf8dd06c9..cf9c4203af9 100644 --- a/packages/headless/src/features/recommendation/recommendation-actions.ts +++ b/packages/headless/src/features/recommendation/recommendation-actions.ts @@ -2,30 +2,30 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { getVisitorID, historyStore, -} from '../../api/analytics/coveo-analytics-utils'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {RecommendationRequest} from '../../api/search/recommendation/recommendation-request'; +} from '../../api/analytics/coveo-analytics-utils.js'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {RecommendationRequest} from '../../api/search/recommendation/recommendation-request.js'; import { AsyncThunkSearchOptions, isErrorResponse, -} from '../../api/search/search-api-client'; -import {Result} from '../../api/search/search/result'; -import {RecommendationAppState} from '../../state/recommendation-app-state'; +} from '../../api/search/search-api-client.js'; +import {Result} from '../../api/search/search/result.js'; +import {RecommendationAppState} from '../../state/recommendation-app-state.js'; import { ConfigurationSection, RecommendationSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; import { validatePayload, requiredNonEmptyString, -} from '../../utils/validate-payload'; -import {AnalyticsAsyncThunk} from '../analytics/analytics-utils'; -import {fromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params'; -import {SearchAction} from '../search/search-actions'; +} from '../../utils/validate-payload.js'; +import {AnalyticsAsyncThunk} from '../analytics/analytics-utils.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params.js'; +import {SearchAction} from '../search/search-actions.js'; import { logRecommendationUpdate, recommendationInterfaceLoad, -} from './recommendation-analytics-actions'; +} from './recommendation-analytics-actions.js'; export type StateNeededByGetRecommendations = ConfigurationSection & RecommendationSection & diff --git a/packages/headless/src/features/recommendation/recommendation-analytics-actions.test.ts b/packages/headless/src/features/recommendation/recommendation-analytics-actions.test.ts index 281fac009e3..1254bad18a8 100644 --- a/packages/headless/src/features/recommendation/recommendation-analytics-actions.test.ts +++ b/packages/headless/src/features/recommendation/recommendation-analytics-actions.test.ts @@ -4,31 +4,33 @@ import { SearchEngine, buildSearchEngine, getSampleSearchEngineConfiguration, -} from '../../app/search-engine/search-engine'; -import {buildMockNonEmptyResult} from '../../test/mock-result'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {logRecommendationOpen} from './recommendation-analytics-actions'; +} from '../../app/search-engine/search-engine.js'; +import {buildMockNonEmptyResult} from '../../test/mock-result.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {logRecommendationOpen} from './recommendation-analytics-actions.js'; -jest.mock('@coveo/relay'); -jest.mock('coveo.analytics'); +vi.mock('@coveo/relay'); +vi.mock('coveo.analytics'); describe('recommendation analytics actions', () => { describe('#logRecommendationOpen', () => { - const testResult = buildMockNonEmptyResult(); + const testResult = buildMockNonEmptyResult({ + searchUid: 'example searchUid', + }); let engine: SearchEngine; - const makeRecommendationOpen = jest.fn(); - const emit = jest.fn(); + const makeRecommendationOpen = vi.fn(); + const emit = vi.fn(); beforeEach(() => { - jest.mocked(CoveoSearchPageClient).mockReturnValue({ + vi.mocked(CoveoSearchPageClient).mockReturnValue({ makeRecommendationOpen, } as unknown as CoveoSearchPageClient); - jest.mocked(createRelay).mockReturnValue({ + vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); }); diff --git a/packages/headless/src/features/recommendation/recommendation-analytics-actions.ts b/packages/headless/src/features/recommendation/recommendation-analytics-actions.ts index 24c39c29a52..81b8e6725f0 100644 --- a/packages/headless/src/features/recommendation/recommendation-analytics-actions.ts +++ b/packages/headless/src/features/recommendation/recommendation-analytics-actions.ts @@ -1,6 +1,6 @@ import {ItemClick} from '@coveo/relay-event-types'; -import {RecommendationAnalyticsProvider} from '../../api/analytics/recommendations-analytics'; -import {Result} from '../../api/search/search/result'; +import {RecommendationAnalyticsProvider} from '../../api/analytics/recommendations-analytics.js'; +import {Result} from '../../api/search/search/result.js'; import { ClickAction, documentIdentifier, @@ -9,9 +9,9 @@ import { partialRecommendationInformation, LegacySearchAction, validateResultPayload, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; //TODO: KIT-2859 export const logRecommendationUpdate = (): LegacySearchAction => @@ -43,7 +43,7 @@ export const logRecommendationOpen = (result: Result): ClickAction => const docInfo = partialDocumentInformation(result, state); const docId = documentIdentifier(result); return { - searchUid: state.search?.response.searchUid ?? '', + searchUid: result.searchUid ?? '', position: docInfo.documentPosition, itemMetadata: { uniqueFieldName: docId.contentIDKey, diff --git a/packages/headless/src/features/recommendation/recommendation-click-analytics-actions-loader.ts b/packages/headless/src/features/recommendation/recommendation-click-analytics-actions-loader.ts index 154bbf5f463..3bb3e5e283f 100644 --- a/packages/headless/src/features/recommendation/recommendation-click-analytics-actions-loader.ts +++ b/packages/headless/src/features/recommendation/recommendation-click-analytics-actions-loader.ts @@ -1,7 +1,7 @@ -import {Result} from '../../api/search/search/result'; -import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine'; -import {ClickAction} from '../analytics/analytics-utils'; -import {logRecommendationOpen} from './recommendation-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {RecommendationEngine} from '../../app/recommendation-engine/recommendation-engine.js'; +import {ClickAction} from '../analytics/analytics-utils.js'; +import {logRecommendationOpen} from './recommendation-analytics-actions.js'; /** * The click analytics action creators. diff --git a/packages/headless/src/features/recommendation/recommendation-slice.test.ts b/packages/headless/src/features/recommendation/recommendation-slice.test.ts index 696d4ee962b..4c8bb837795 100644 --- a/packages/headless/src/features/recommendation/recommendation-slice.test.ts +++ b/packages/headless/src/features/recommendation/recommendation-slice.test.ts @@ -1,14 +1,14 @@ -import {buildMockRecommendation} from '../../test/mock-recommendation'; -import {buildMockResult} from '../../test/mock-result'; +import {buildMockRecommendation} from '../../test/mock-recommendation.js'; +import {buildMockResult} from '../../test/mock-result.js'; import { getRecommendations, setRecommendationId, -} from './recommendation-actions'; -import {recommendationReducer} from './recommendation-slice'; +} from './recommendation-actions.js'; +import {recommendationReducer} from './recommendation-slice.js'; import { getRecommendationInitialState, RecommendationState, -} from './recommendation-state'; +} from './recommendation-state.js'; describe('recommendation slice', () => { let state: RecommendationState; @@ -34,7 +34,7 @@ describe('recommendation slice', () => { }); it('when a getRecommendations fulfilled is received, it updates the state to the received payload', () => { - const result = buildMockResult(); + const result = buildMockResult({searchUid: 'some-id'}); const response = buildMockRecommendation({ recommendations: [result], duration: 123, diff --git a/packages/headless/src/features/recommendation/recommendation-slice.ts b/packages/headless/src/features/recommendation/recommendation-slice.ts index a2ea7f73462..29671fa8b75 100644 --- a/packages/headless/src/features/recommendation/recommendation-slice.ts +++ b/packages/headless/src/features/recommendation/recommendation-slice.ts @@ -2,8 +2,8 @@ import {createReducer} from '@reduxjs/toolkit'; import { getRecommendations, setRecommendationId, -} from './recommendation-actions'; -import {getRecommendationInitialState} from './recommendation-state'; +} from './recommendation-actions.js'; +import {getRecommendationInitialState} from './recommendation-state.js'; export const recommendationReducer = createReducer( getRecommendationInitialState(), @@ -19,7 +19,12 @@ export const recommendationReducer = createReducer( }) .addCase(getRecommendations.fulfilled, (state, action) => { state.error = null; - state.recommendations = action.payload.recommendations; + state.recommendations = action.payload.recommendations.map( + (recommendation) => ({ + ...recommendation, + searchUid: action.payload.searchUid, + }) + ); state.duration = action.payload.duration; state.isLoading = false; state.searchUid = action.payload.searchUid; diff --git a/packages/headless/src/features/recommendation/recommendation-state.ts b/packages/headless/src/features/recommendation/recommendation-state.ts index fd9cecb66eb..58ccea1eaea 100644 --- a/packages/headless/src/features/recommendation/recommendation-state.ts +++ b/packages/headless/src/features/recommendation/recommendation-state.ts @@ -1,5 +1,5 @@ -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {Result} from '../../api/search/search/result'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {Result} from '../../api/search/search/result.js'; export const getRecommendationInitialState = (): RecommendationState => ({ duration: 0, diff --git a/packages/headless/src/features/result-actions/__snapshots__/result-actions-insight-analytics-actions.test.ts.snap b/packages/headless/src/features/result-actions/__snapshots__/result-actions-insight-analytics-actions.test.ts.snap index aabc6285866..333beecf617 100644 --- a/packages/headless/src/features/result-actions/__snapshots__/result-actions-insight-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/result-actions/__snapshots__/result-actions-insight-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`result actions insight analytics actions when analyticsMode is \`next\` logCaseSendEmail should call relay.emit properly 1`] = ` +exports[`result actions insight analytics actions > when analyticsMode is \`next\` > logCaseSendEmail > should call relay.emit properly 1`] = ` [ "InsightPanel.ItemAction", { @@ -23,7 +23,7 @@ exports[`result actions insight analytics actions when analyticsMode is \`next\` ] `; -exports[`result actions insight analytics actions when analyticsMode is \`next\` logCopyToClipboard should call relay.emit properly 1`] = ` +exports[`result actions insight analytics actions > when analyticsMode is \`next\` > logCopyToClipboard > should call relay.emit properly 1`] = ` [ "InsightPanel.ItemAction", { @@ -46,7 +46,7 @@ exports[`result actions insight analytics actions when analyticsMode is \`next\` ] `; -exports[`result actions insight analytics actions when analyticsMode is \`next\` logFeedItemTextPost should call relay.emit properly 1`] = ` +exports[`result actions insight analytics actions > when analyticsMode is \`next\` > logFeedItemTextPost > should call relay.emit properly 1`] = ` [ "InsightPanel.ItemAction", { diff --git a/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.test.ts b/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.test.ts index d14c5dc6b3c..f5e8453edcf 100644 --- a/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.test.ts @@ -1,29 +1,29 @@ import {createRelay} from '@coveo/relay'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; import { logCaseSendEmail, logCopyToClipboard, logFeedItemTextPost, -} from './result-actions-insight-analytics-actions'; +} from './result-actions-insight-analytics-actions.js'; -const mockLogCopyToClipboard = jest.fn(); -const mockLogCaseSendEmail = jest.fn(); -const mockLogFeedItemTextPost = jest.fn(); -const emit = jest.fn(); +const mockLogCopyToClipboard = vi.fn(); +const mockLogCaseSendEmail = vi.fn(); +const mockLogFeedItemTextPost = vi.fn(); +const emit = vi.fn(); -jest.mock('@coveo/relay'); +vi.mock('@coveo/relay'); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logCopyToClipboard: mockLogCopyToClipboard, logCaseSendEmail: mockLogCaseSendEmail, @@ -32,16 +32,16 @@ jest.mock('coveo.analytics', () => { return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); @@ -87,6 +87,7 @@ const resultParams = { firstSentences: 'first-sentences', flags: 'flags', rankingModifier: 'example rankingModifier', + searchUid: 'example searchUid', raw: buildMockRaw({ author: 'example author', urihash: 'example documentUriHash', @@ -102,9 +103,7 @@ describe('result actions insight analytics actions', () => { let engine: InsightEngine; const searchState = buildMockSearchState({ results: [testResult], - response: buildMockSearchResponse({ - searchUid: 'example searchUid', - }), + response: buildMockSearchResponse(), }); const caseContextState = { caseContext: { @@ -116,7 +115,7 @@ describe('result actions insight analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.ts b/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.ts index 80cf5c42308..0772a1cdfeb 100644 --- a/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.ts +++ b/packages/headless/src/features/result-actions/result-actions-insight-analytics-actions.ts @@ -1,5 +1,5 @@ import {InsightPanel} from '@coveo/relay-event-types'; -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { analyticsEventItemMetadata, documentIdentifier, @@ -7,10 +7,10 @@ import { makeInsightAnalyticsActionFactory, partialDocumentInformation, validateResultPayload, -} from '../analytics/analytics-utils'; -import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export const logCopyToClipboard = (result: Result): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.copyToClipboard)({ @@ -32,7 +32,7 @@ export const logCopyToClipboard = (result: Result): InsightAction => return { itemMetadata: analyticsEventItemMetadata(result, state), position: information.documentPosition, - searchUid: state.search?.response.searchUid || '', + searchUid: result.searchUid || '', action: 'copyToClipboard', context: analyticsEventCaseContext(state), }; @@ -59,7 +59,7 @@ export const logCaseSendEmail = (result: Result): InsightAction => return { itemMetadata: analyticsEventItemMetadata(result, state), position: information.documentPosition, - searchUid: state.search?.response.searchUid || '', + searchUid: result.searchUid || '', action: 'sendEmail', context: analyticsEventCaseContext(state), }; @@ -86,7 +86,7 @@ export const logFeedItemTextPost = (result: Result): InsightAction => return { itemMetadata: analyticsEventItemMetadata(result, state), position: information.documentPosition, - searchUid: state.search?.response.searchUid || '', + searchUid: result.searchUid || '', action: 'postToFeed', context: analyticsEventCaseContext(state), }; diff --git a/packages/headless/src/features/result-preview/__snapshots__/result-preview-analytics-actions.test.ts.snap b/packages/headless/src/features/result-preview/__snapshots__/result-preview-analytics-actions.test.ts.snap index 92577d7f540..7fc51991fdd 100644 --- a/packages/headless/src/features/result-preview/__snapshots__/result-preview-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/result-preview/__snapshots__/result-preview-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`result preview analytics actions #logDocumentQuickview when analyticsMode is \`legacy\` should call coveo.analytics.makeRecommendationOpen properly 1`] = ` +exports[`result preview analytics actions > #logDocumentQuickview > when analyticsMode is \`legacy\` should call coveo.analytics.makeRecommendationOpen properly 1`] = ` [ { "collectionName": "example collectionName", @@ -21,7 +21,7 @@ exports[`result preview analytics actions #logDocumentQuickview when analyticsMo ] `; -exports[`result preview analytics actions #logDocumentQuickview when analyticsMode is \`next\` should call relay.emit properly 1`] = ` +exports[`result preview analytics actions > #logDocumentQuickview > when analyticsMode is \`next\` should call relay.emit properly 1`] = ` [ "itemClick", { @@ -34,7 +34,7 @@ exports[`result preview analytics actions #logDocumentQuickview when analyticsMo "url": "example documentUrl", }, "position": 1, - "searchUid": "", + "searchUid": "someid", }, ] `; diff --git a/packages/headless/src/features/result-preview/__snapshots__/result-preview-insight-analytics-actions.test.ts.snap b/packages/headless/src/features/result-preview/__snapshots__/result-preview-insight-analytics-actions.test.ts.snap index b36dfcd8376..41627067bde 100644 --- a/packages/headless/src/features/result-preview/__snapshots__/result-preview-insight-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/result-preview/__snapshots__/result-preview-insight-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`#logDocumentQuickview when analyticsMode is \`next\` should call relay.emit properly 1`] = ` +exports[`#logDocumentQuickview > when analyticsMode is \`next\` > should call relay.emit properly 1`] = ` [ "InsightPanel.ItemAction", { diff --git a/packages/headless/src/features/result-preview/result-preview-actions-loader.ts b/packages/headless/src/features/result-preview/result-preview-actions-loader.ts index fcf0b9fdc28..6a5f24c395f 100644 --- a/packages/headless/src/features/result-preview/result-preview-actions-loader.ts +++ b/packages/headless/src/features/result-preview/result-preview-actions-loader.ts @@ -1,7 +1,7 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {HtmlRequestOptions} from '../../api/search/html/html-request'; -import {CoreEngine} from '../../app/engine'; -import {resultPreviewReducer as resultPreview} from '../../features/result-preview/result-preview-slice'; +import {HtmlRequestOptions} from '../../api/search/html/html-request.js'; +import {CoreEngine} from '../../app/engine.js'; +import {resultPreviewReducer as resultPreview} from '../../features/result-preview/result-preview-slice.js'; import { AsyncThunkGlobalOptions, fetchResultContent, @@ -13,8 +13,8 @@ import { updateContentURL, UpdateContentURLOptions, PreparePreviewPaginationActionPayload, -} from './result-preview-actions'; -import {StateNeededByHtmlEndpoint} from './result-preview-request-builder'; +} from './result-preview-actions.js'; +import {StateNeededByHtmlEndpoint} from './result-preview-request-builder.js'; /** * The result preview action creators. diff --git a/packages/headless/src/features/result-preview/result-preview-actions.ts b/packages/headless/src/features/result-preview/result-preview-actions.ts index 019a855d387..ee225c45c25 100644 --- a/packages/headless/src/features/result-preview/result-preview-actions.ts +++ b/packages/headless/src/features/result-preview/result-preview-actions.ts @@ -3,21 +3,21 @@ import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; import { buildContentURL, HtmlApiClient, -} from '../../api/search/html/html-api-client'; +} from '../../api/search/html/html-api-client.js'; import { HtmlRequest, HtmlRequestOptions, -} from '../../api/search/html/html-request'; -import {isErrorResponse} from '../../api/search/search-api-client'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import type {Result} from '../../api/search/search/result'; -import {AsyncThunkOptions} from '../../app/async-thunk-options'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {validatePayload} from '../../utils/validate-payload'; +} from '../../api/search/html/html-request.js'; +import {isErrorResponse} from '../../api/search/search-api-client.js'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import type {Result} from '../../api/search/search/result.js'; +import {AsyncThunkOptions} from '../../app/async-thunk-options.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {validatePayload} from '../../utils/validate-payload.js'; import { buildResultPreviewRequest, StateNeededByHtmlEndpoint, -} from './result-preview-request-builder'; +} from './result-preview-request-builder.js'; export interface FetchResultContentThunkReturn { content: string; diff --git a/packages/headless/src/features/result-preview/result-preview-analytics-actions.test.ts b/packages/headless/src/features/result-preview/result-preview-analytics-actions.test.ts index a593a8bcbc8..9b2ec9c218d 100644 --- a/packages/headless/src/features/result-preview/result-preview-analytics-actions.test.ts +++ b/packages/headless/src/features/result-preview/result-preview-analytics-actions.test.ts @@ -4,31 +4,31 @@ import { SearchEngine, buildSearchEngine, getSampleSearchEngineConfiguration, -} from '../../app/search-engine/search-engine'; -import {buildMockNonEmptyResult} from '../../test/mock-result'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {logDocumentQuickview} from './result-preview-analytics-actions'; +} from '../../app/search-engine/search-engine.js'; +import {buildMockNonEmptyResult} from '../../test/mock-result.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {logDocumentQuickview} from './result-preview-analytics-actions.js'; -jest.mock('@coveo/relay'); -jest.mock('coveo.analytics'); +vi.mock('@coveo/relay'); +vi.mock('coveo.analytics'); describe('result preview analytics actions', () => { describe('#logDocumentQuickview', () => { - const testResult = buildMockNonEmptyResult(); + const testResult = buildMockNonEmptyResult({searchUid: 'someid'}); let engine: SearchEngine; - const makeDocumentQuickview = jest.fn(); - const emit = jest.fn(); + const makeDocumentQuickview = vi.fn(); + const emit = vi.fn(); beforeEach(() => { - jest.mocked(CoveoSearchPageClient).mockReturnValue({ + vi.mocked(CoveoSearchPageClient).mockReturnValue({ makeDocumentQuickview, } as unknown as CoveoSearchPageClient); - jest.mocked(createRelay).mockReturnValue({ + vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); }); diff --git a/packages/headless/src/features/result-preview/result-preview-analytics-actions.ts b/packages/headless/src/features/result-preview/result-preview-analytics-actions.ts index 270e6f3efcf..a304a728248 100644 --- a/packages/headless/src/features/result-preview/result-preview-analytics-actions.ts +++ b/packages/headless/src/features/result-preview/result-preview-analytics-actions.ts @@ -1,12 +1,12 @@ import {ItemClick} from '@coveo/relay-event-types'; -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { ClickAction, documentIdentifier, makeAnalyticsAction, partialDocumentInformation, validateResultPayload, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; export const logDocumentQuickview = (result: Result): ClickAction => { return makeAnalyticsAction({ @@ -22,7 +22,7 @@ export const logDocumentQuickview = (result: Result): ClickAction => { const docInfo = partialDocumentInformation(result, state); const docId = documentIdentifier(result); return { - searchUid: state.search?.response.searchUid ?? '', + searchUid: result.searchUid ?? '', position: docInfo.documentPosition, actionCause: 'preview', itemMetadata: { diff --git a/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.test.ts b/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.test.ts index ee2d41f4790..bc1e3b831dc 100644 --- a/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.test.ts @@ -1,40 +1,40 @@ import {createRelay} from '@coveo/relay'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {logDocumentQuickview} from './result-preview-insight-analytics-actions'; - -jest.mock('@coveo/relay'); -jest.mock('coveo.analytics'); - -const mockLogDocumentQuickview = jest.fn(); -const emit = jest.fn(); - -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {logDocumentQuickview} from './result-preview-insight-analytics-actions.js'; + +vi.mock('@coveo/relay'); +vi.mock('coveo.analytics'); + +const mockLogDocumentQuickview = vi.fn(); +const emit = vi.fn(); + +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logDocumentQuickview: mockLogDocumentQuickview, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); @@ -79,6 +79,7 @@ const resultParams = { firstSentences: 'first-sentences', flags: 'flags', rankingModifier: 'example rankingModifier', + searchUid: 'example searchUid', raw: buildMockRaw({ author: 'example author', urihash: 'example documentUriHash', @@ -94,13 +95,11 @@ describe('#logDocumentQuickview', () => { let engine: InsightEngine; const searchState = buildMockSearchState({ results: [testResult], - response: buildMockSearchResponse({ - searchUid: 'example searchUid', - }), + response: buildMockSearchResponse(), }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.ts b/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.ts index 48a15ca7bd8..c5c7022fa40 100644 --- a/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.ts +++ b/packages/headless/src/features/result-preview/result-preview-insight-analytics-actions.ts @@ -1,5 +1,5 @@ import {InsightPanel} from '@coveo/relay-event-types'; -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { ClickAction, analyticsEventItemMetadata, @@ -7,8 +7,8 @@ import { makeInsightAnalyticsActionFactory, partialDocumentInformation, validateResultPayload, -} from '../analytics/analytics-utils'; -import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils'; +} from '../analytics/analytics-utils.js'; +import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils.js'; export const logDocumentQuickview = (result: Result): ClickAction => { return makeInsightAnalyticsActionFactory('')({ @@ -26,7 +26,7 @@ export const logDocumentQuickview = (result: Result): ClickAction => { action: 'preview', itemMetadata: analyticsEventItemMetadata(result, state), position: information.documentPosition, - searchUid: state.search?.response.searchUid || '', + searchUid: result.searchUid || '', context: analyticsEventCaseContext(state), }; }, diff --git a/packages/headless/src/features/result-preview/result-preview-request-builder.test.ts b/packages/headless/src/features/result-preview/result-preview-request-builder.test.ts index 7def2fb2944..6dd8e079446 100644 --- a/packages/headless/src/features/result-preview/result-preview-request-builder.test.ts +++ b/packages/headless/src/features/result-preview/result-preview-request-builder.test.ts @@ -1,12 +1,12 @@ -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {HtmlRequestOptions} from '../../api/search/html/html-request'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {getQueryInitialState} from '../query/query-state'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {HtmlRequestOptions} from '../../api/search/html/html-request.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {getQueryInitialState} from '../query/query-state.js'; import { buildResultPreviewRequest, StateNeededByHtmlEndpoint, -} from '../result-preview/result-preview-request-builder'; -import {getResultPreviewInitialState} from './result-preview-state'; +} from '../result-preview/result-preview-request-builder.js'; +import {getResultPreviewInitialState} from './result-preview-state.js'; describe('ResultPreviewRequestBuilder', () => { let state: StateNeededByHtmlEndpoint; diff --git a/packages/headless/src/features/result-preview/result-preview-request-builder.ts b/packages/headless/src/features/result-preview/result-preview-request-builder.ts index 66646f7156b..e50f61173eb 100644 --- a/packages/headless/src/features/result-preview/result-preview-request-builder.ts +++ b/packages/headless/src/features/result-preview/result-preview-request-builder.ts @@ -1,14 +1,14 @@ -import {getVisitorID} from '../../api/analytics/coveo-analytics-utils'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; +import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; import { HtmlRequest, HtmlRequestOptions, -} from '../../api/search/html/html-request'; +} from '../../api/search/html/html-request.js'; import { ConfigurationSection, QuerySection, ResultPreviewSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; export type StateNeededByHtmlEndpoint = ConfigurationSection & ResultPreviewSection & diff --git a/packages/headless/src/features/result-preview/result-preview-slice.test.ts b/packages/headless/src/features/result-preview/result-preview-slice.test.ts index cf135276b8d..f26c3e22944 100644 --- a/packages/headless/src/features/result-preview/result-preview-slice.test.ts +++ b/packages/headless/src/features/result-preview/result-preview-slice.test.ts @@ -1,23 +1,26 @@ -import {buildMockResult} from '../../test/mock-result'; -import {buildMockResultPreviewRequest} from '../../test/mock-result-preview-request-builder'; -import {buildMockLegacySearch, buildMockSearch} from '../../test/mock-search'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {logInterfaceLoad} from '../analytics/analytics-actions'; -import {executeSearch} from '../insight-search/insight-search-actions'; -import {logPageNext} from '../pagination/pagination-analytics-actions'; -import {fetchMoreResults, fetchPage} from '../search/search-actions'; +import {buildMockResultPreviewRequest} from '../../test/mock-result-preview-request-builder.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import { + buildMockLegacySearch, + buildMockSearch, +} from '../../test/mock-search.js'; +import {logInterfaceLoad} from '../analytics/analytics-actions.js'; +import {executeSearch} from '../insight-search/insight-search-actions.js'; +import {logPageNext} from '../pagination/pagination-analytics-actions.js'; +import {fetchMoreResults, fetchPage} from '../search/search-actions.js'; import { fetchResultContent, nextPreview, preparePreviewPagination, previousPreview, updateContentURL, -} from './result-preview-actions'; -import {resultPreviewReducer} from './result-preview-slice'; +} from './result-preview-actions.js'; +import {resultPreviewReducer} from './result-preview-slice.js'; import { getResultPreviewInitialState, ResultPreviewState, -} from './result-preview-state'; +} from './result-preview-state.js'; describe('ResultPreview', () => { let state: ResultPreviewState; diff --git a/packages/headless/src/features/result-preview/result-preview-slice.ts b/packages/headless/src/features/result-preview/result-preview-slice.ts index c45d36dbc58..f6fd812c936 100644 --- a/packages/headless/src/features/result-preview/result-preview-slice.ts +++ b/packages/headless/src/features/result-preview/result-preview-slice.ts @@ -1,21 +1,21 @@ import {createReducer} from '@reduxjs/toolkit'; -import type {Result} from '../../api/search/search/result'; +import type {Result} from '../../api/search/search/result.js'; import { fetchMoreResults, executeSearch, fetchPage, -} from '../search/search-actions'; +} from '../search/search-actions.js'; import { fetchResultContent, nextPreview, preparePreviewPagination, previousPreview, updateContentURL, -} from './result-preview-actions'; +} from './result-preview-actions.js'; import { ResultPreviewState, getResultPreviewInitialState, -} from './result-preview-state'; +} from './result-preview-state.js'; const resetPreviewContentState = (state: ResultPreviewState) => { const {content, isLoading, uniqueId, contentURL} = diff --git a/packages/headless/src/features/result-templates/result-templates-helpers.test.ts b/packages/headless/src/features/result-templates/result-templates-helpers.test.ts index 3daa8f17945..3b90e7b72fe 100644 --- a/packages/headless/src/features/result-templates/result-templates-helpers.test.ts +++ b/packages/headless/src/features/result-templates/result-templates-helpers.test.ts @@ -1,12 +1,12 @@ -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; import { fieldMustMatch, fieldMustNotMatch, fieldsMustBeDefined, fieldsMustNotBeDefined, getResultProperty, -} from './result-templates-helpers'; +} from './result-templates-helpers.js'; describe('result template helpers', () => { function buildResult(fieldName: string, fieldValues: unknown) { diff --git a/packages/headless/src/features/result-templates/result-templates-helpers.ts b/packages/headless/src/features/result-templates/result-templates-helpers.ts index 837919c720c..bfbb2432023 100644 --- a/packages/headless/src/features/result-templates/result-templates-helpers.ts +++ b/packages/headless/src/features/result-templates/result-templates-helpers.ts @@ -1,7 +1,7 @@ import {isNullOrUndefined} from '@coveo/bueno'; -import {Result} from '../../api/search/search/result'; -import {isArray} from '../../utils/utils'; -import {ResultTemplateCondition} from './result-templates-manager'; +import {Result} from '../../api/search/search/result.js'; +import {isArray} from '../../utils/utils.js'; +import {ResultTemplateCondition} from './result-templates-manager.js'; /** * Extracts a property from a result object. diff --git a/packages/headless/src/features/result-templates/result-templates-manager.test.ts b/packages/headless/src/features/result-templates/result-templates-manager.test.ts index 44a77ae0b2f..98fed5f48c0 100644 --- a/packages/headless/src/features/result-templates/result-templates-manager.test.ts +++ b/packages/headless/src/features/result-templates/result-templates-manager.test.ts @@ -1,15 +1,15 @@ -import {fieldsReducer as fields} from '../../features/fields/fields-slice'; +import {fieldsReducer as fields} from '../../features/fields/fields-slice.js'; import { buildMockSearchEngine, MockedSearchEngine, -} from '../../test/mock-engine-v2'; -import {buildMockResult} from '../../test/mock-result'; -import {createMockState} from '../../test/mock-state'; +} from '../../test/mock-engine-v2.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {createMockState} from '../../test/mock-state.js'; import { ResultTemplatesManager, buildResultTemplatesManager, ResultTemplate, -} from './result-templates-manager'; +} from './result-templates-manager.js'; describe('result template manager', () => { let resultTemplateManager: ResultTemplatesManager; diff --git a/packages/headless/src/features/result-templates/result-templates-manager.ts b/packages/headless/src/features/result-templates/result-templates-manager.ts index ad70badd1a0..e253514e39a 100644 --- a/packages/headless/src/features/result-templates/result-templates-manager.ts +++ b/packages/headless/src/features/result-templates/result-templates-manager.ts @@ -1,14 +1,14 @@ -import {Result} from '../../api/search/search/result'; -import {CoreEngine, CoreEngineNext} from '../../app/engine'; -import {fieldsReducer as fields} from '../../features/fields/fields-slice'; -import {FieldsSection} from '../../state/state-sections'; -import {loadReducerError} from '../../utils/errors'; -import {registerFieldsToInclude} from '../fields/fields-actions'; +import {Result} from '../../api/search/search/result.js'; +import {CoreEngine, CoreEngineNext} from '../../app/engine.js'; +import {fieldsReducer as fields} from '../../features/fields/fields-slice.js'; +import {FieldsSection} from '../../state/state-sections.js'; +import {loadReducerError} from '../../utils/errors.js'; +import {registerFieldsToInclude} from '../fields/fields-actions.js'; import { buildTemplatesManager, Template, TemplateCondition, -} from '../templates/templates-manager'; +} from '../templates/templates-manager.js'; export type ResultTemplate = Template; export type ResultTemplateCondition = TemplateCondition; diff --git a/packages/headless/src/features/result/__snapshots__/result-analytics-actions.test.ts.snap b/packages/headless/src/features/result/__snapshots__/result-analytics-actions.test.ts.snap index 48e6fe4cfbd..e655131452c 100644 --- a/packages/headless/src/features/result/__snapshots__/result-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/result/__snapshots__/result-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`result analytics actions #logDocumentOpen when analyticsMode is \`legacy\` should call coveo.analytics.makeDocumentOpen properly 1`] = ` +exports[`result analytics actions > #logDocumentOpen > when analyticsMode is \`legacy\` should call coveo.analytics.makeDocumentOpen properly 1`] = ` [ { "collectionName": "example collectionName", @@ -21,7 +21,7 @@ exports[`result analytics actions #logDocumentOpen when analyticsMode is \`legac ] `; -exports[`result analytics actions #logDocumentOpen when analyticsMode is \`next\` should call relay.emit properly 1`] = ` +exports[`result analytics actions > #logDocumentOpen > when analyticsMode is \`next\` should call relay.emit properly 1`] = ` [ "itemClick", { @@ -33,7 +33,7 @@ exports[`result analytics actions #logDocumentOpen when analyticsMode is \`next\ "url": "example documentUrl", }, "position": 1, - "searchUid": "", + "searchUid": "example searchUid", }, ] `; diff --git a/packages/headless/src/features/result/__snapshots__/result-insight-analytics-actions.test.ts.snap b/packages/headless/src/features/result/__snapshots__/result-insight-analytics-actions.test.ts.snap index cc99f41426e..1a4fae07dd4 100644 --- a/packages/headless/src/features/result/__snapshots__/result-insight-analytics-actions.test.ts.snap +++ b/packages/headless/src/features/result/__snapshots__/result-insight-analytics-actions.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`result insight analytics actions when analyticsMode is \`next\` logDocumentOpen should call relay.emit properly 1`] = ` +exports[`result insight analytics actions > when analyticsMode is \`next\` > logDocumentOpen > should call relay.emit properly 1`] = ` [ "InsightPanel.ItemAction", { diff --git a/packages/headless/src/features/result/result-analytics-actions.test.ts b/packages/headless/src/features/result/result-analytics-actions.test.ts index 463465a5a86..5433ba41943 100644 --- a/packages/headless/src/features/result/result-analytics-actions.test.ts +++ b/packages/headless/src/features/result/result-analytics-actions.test.ts @@ -4,31 +4,33 @@ import { SearchEngine, buildSearchEngine, getSampleSearchEngineConfiguration, -} from '../../app/search-engine/search-engine'; -import {buildMockNonEmptyResult} from '../../test/mock-result'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {logDocumentOpen} from './result-analytics-actions'; +} from '../../app/search-engine/search-engine.js'; +import {buildMockNonEmptyResult} from '../../test/mock-result.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {logDocumentOpen} from './result-analytics-actions.js'; -jest.mock('@coveo/relay'); -jest.mock('coveo.analytics'); +vi.mock('@coveo/relay'); +vi.mock('coveo.analytics'); describe('result analytics actions', () => { describe('#logDocumentOpen', () => { - const testResult = buildMockNonEmptyResult(); + const testResult = buildMockNonEmptyResult({ + searchUid: 'example searchUid', + }); let engine: SearchEngine; - const makeDocumentOpen = jest.fn(); - const emit = jest.fn(); + const makeDocumentOpen = vi.fn(); + const emit = vi.fn(); beforeEach(() => { - jest.mocked(CoveoSearchPageClient).mockReturnValue({ + vi.mocked(CoveoSearchPageClient).mockReturnValue({ makeDocumentOpen, } as unknown as CoveoSearchPageClient); - jest.mocked(createRelay).mockReturnValue({ + vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); }); diff --git a/packages/headless/src/features/result/result-analytics-actions.ts b/packages/headless/src/features/result/result-analytics-actions.ts index 5e82de5a55b..cfcc8812abf 100644 --- a/packages/headless/src/features/result/result-analytics-actions.ts +++ b/packages/headless/src/features/result/result-analytics-actions.ts @@ -1,12 +1,12 @@ import {ItemClick} from '@coveo/relay-event-types'; -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { partialDocumentInformation, documentIdentifier, validateResultPayload, makeAnalyticsAction, ClickAction, -} from '../analytics/analytics-utils'; +} from '../analytics/analytics-utils.js'; export const logDocumentOpen = (result: Result): ClickAction => makeAnalyticsAction({ @@ -23,7 +23,7 @@ export const logDocumentOpen = (result: Result): ClickAction => const docInfo = partialDocumentInformation(result, state); const docId = documentIdentifier(result); return { - searchUid: state.search?.response.searchUid ?? '', + searchUid: result.searchUid ?? '', position: docInfo.documentPosition, itemMetadata: { uniqueFieldName: docId.contentIDKey, diff --git a/packages/headless/src/features/result/result-insight-analytics-actions.test.ts b/packages/headless/src/features/result/result-insight-analytics-actions.test.ts index 22fc008b33d..7f98f90398a 100644 --- a/packages/headless/src/features/result/result-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/result/result-insight-analytics-actions.test.ts @@ -1,39 +1,39 @@ import {createRelay} from '@coveo/relay'; -import {InsightEngine} from '../../app/insight-engine/insight-engine'; -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {buildMockRaw} from '../../test/mock-raw'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {clearMicrotaskQueue} from '../../test/unit-test-utils'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {logDocumentOpen} from './result-insight-analytics-actions'; - -const mockLogDocumentOpen = jest.fn(); -const emit = jest.fn(); - -jest.mock('@coveo/relay'); - -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +import {InsightEngine} from '../../app/insight-engine/insight-engine.js'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {buildMockRaw} from '../../test/mock-raw.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {clearMicrotaskQueue} from '../../test/unit-test-utils.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {logDocumentOpen} from './result-insight-analytics-actions.js'; + +const mockLogDocumentOpen = vi.fn(); +const emit = vi.fn(); + +vi.mock('@coveo/relay'); + +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logDocumentOpen: mockLogDocumentOpen, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); -jest.mocked(createRelay).mockReturnValue({ +vi.mocked(createRelay).mockReturnValue({ emit, - getMeta: jest.fn(), - on: jest.fn(), - off: jest.fn(), - updateConfig: jest.fn(), + getMeta: vi.fn(), + on: vi.fn(), + off: vi.fn(), + updateConfig: vi.fn(), version: 'foo', }); @@ -79,6 +79,7 @@ const resultParams = { firstSentences: 'first-sentences', flags: 'flags', rankingModifier: 'example rankingModifier', + searchUid: 'example searchUid', raw: buildMockRaw({ author: 'example author', urihash: 'example documentUriHash', @@ -94,9 +95,7 @@ describe('result insight analytics actions', () => { let engine: InsightEngine; const searchState = buildMockSearchState({ results: [testResult], - response: buildMockSearchResponse({ - searchUid: 'example searchUid', - }), + response: buildMockSearchResponse(), }); const caseContextState = { caseContext: { @@ -108,7 +107,7 @@ describe('result insight analytics actions', () => { }; afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); describe('when analyticsMode is `legacy`', () => { diff --git a/packages/headless/src/features/result/result-insight-analytics-actions.ts b/packages/headless/src/features/result/result-insight-analytics-actions.ts index d5c00d44896..92929f4cea8 100644 --- a/packages/headless/src/features/result/result-insight-analytics-actions.ts +++ b/packages/headless/src/features/result/result-insight-analytics-actions.ts @@ -1,15 +1,15 @@ import {InsightPanel} from '@coveo/relay-event-types'; -import {Result} from '../../api/search/search/result'; +import {Result} from '../../api/search/search/result.js'; import { partialDocumentInformation, documentIdentifier, validateResultPayload, makeInsightAnalyticsActionFactory, analyticsEventItemMetadata, -} from '../analytics/analytics-utils'; -import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; +} from '../analytics/analytics-utils.js'; +import {analyticsEventCaseContext} from '../analytics/insight-analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; export const logDocumentOpen = (result: Result) => makeInsightAnalyticsActionFactory(SearchPageEvents.documentOpen)({ @@ -31,7 +31,7 @@ export const logDocumentOpen = (result: Result) => return { itemMetadata: analyticsEventItemMetadata(result, state), position: information.documentPosition, - searchUid: state.search?.response.searchUid || '', + searchUid: result.searchUid || '', action: 'open', context: analyticsEventCaseContext(state), }; diff --git a/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.test.ts b/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.test.ts index 8536e36b43e..e5f0184d0f9 100644 --- a/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.test.ts +++ b/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.test.ts @@ -1,7 +1,7 @@ -import {SearchAppState} from '../../../state/search-app-state'; -import {createMockState} from '../../../test/mock-state'; -import {buildMockTabSlice} from '../../../test/mock-tab-state'; -import {buildSearchAndFoldingLoadCollectionRequest} from './search-and-folding-request'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {buildMockTabSlice} from '../../../test/mock-tab-state.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from './search-and-folding-request.js'; describe('buildSearchAndFoldingLoadCollectionRequest', () => { describe('#aq', () => { diff --git a/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.ts b/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.ts index c634c18bf9f..af50580e28a 100644 --- a/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.ts +++ b/packages/headless/src/features/search-and-folding/legacy/search-and-folding-request.ts @@ -3,12 +3,12 @@ import {EventDescription} from 'coveo.analytics'; import { getVisitorID, historyStore, -} from '../../../api/analytics/coveo-analytics-utils'; -import {getSearchApiBaseUrl} from '../../../api/platform-client'; -import {SearchRequest} from '../../../api/search/search/search-request'; -import {SearchAppState} from '../../../state/search-app-state'; -import {ConfigurationSection} from '../../../state/state-sections'; -import {fromAnalyticsStateToAnalyticsParams} from '../../configuration/legacy-analytics-params'; +} from '../../../api/analytics/coveo-analytics-utils.js'; +import {getSearchApiBaseUrl} from '../../../api/platform-client.js'; +import {SearchRequest} from '../../../api/search/search/search-request.js'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {ConfigurationSection} from '../../../state/state-sections.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../../configuration/legacy-analytics-params.js'; type StateNeededByExecuteSearchAndFolding = ConfigurationSection & Partial; diff --git a/packages/headless/src/features/search-and-folding/search-and-folding-request.test.ts b/packages/headless/src/features/search-and-folding/search-and-folding-request.test.ts index 6374718e72f..afc14e627d1 100644 --- a/packages/headless/src/features/search-and-folding/search-and-folding-request.test.ts +++ b/packages/headless/src/features/search-and-folding/search-and-folding-request.test.ts @@ -1,8 +1,8 @@ -import {SearchAppState} from '../../state/search-app-state'; -import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider'; -import {createMockState} from '../../test/mock-state'; -import {buildMockTabSlice} from '../../test/mock-tab-state'; -import {buildSearchAndFoldingLoadCollectionRequest} from './search-and-folding-request'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildMockTabSlice} from '../../test/mock-tab-state.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from './search-and-folding-request.js'; describe('buildSearchAndFoldingLoadCollectionRequest', () => { describe('#aq', () => { diff --git a/packages/headless/src/features/search-and-folding/search-and-folding-request.ts b/packages/headless/src/features/search-and-folding/search-and-folding-request.ts index 6c2c6913a90..08353ff2493 100644 --- a/packages/headless/src/features/search-and-folding/search-and-folding-request.ts +++ b/packages/headless/src/features/search-and-folding/search-and-folding-request.ts @@ -1,11 +1,11 @@ import {isNullOrUndefined} from '@coveo/bueno'; import {EventDescription} from 'coveo.analytics'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {SearchRequest} from '../../api/search/search/search-request'; -import {NavigatorContext} from '../../app/navigatorContextProvider'; -import {SearchAppState} from '../../state/search-app-state'; -import {ConfigurationSection} from '../../state/state-sections'; -import {fromAnalyticsStateToAnalyticsParams} from '../configuration/analytics-params'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {SearchRequest} from '../../api/search/search/search-request.js'; +import {NavigatorContext} from '../../app/navigatorContextProvider.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {ConfigurationSection} from '../../state/state-sections.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../configuration/analytics-params.js'; type StateNeededByExecuteSearchAndFolding = ConfigurationSection & Partial; diff --git a/packages/headless/src/features/search-hub/search-hub-actions-loader.ts b/packages/headless/src/features/search-hub/search-hub-actions-loader.ts index 74bba1e4c25..c5d77294d11 100644 --- a/packages/headless/src/features/search-hub/search-hub-actions-loader.ts +++ b/packages/headless/src/features/search-hub/search-hub-actions-loader.ts @@ -1,7 +1,7 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice'; -import {setSearchHub} from './search-hub-actions'; +import {CoreEngine} from '../../app/engine.js'; +import {searchHubReducer as searchHub} from '../../features/search-hub/search-hub-slice.js'; +import {setSearchHub} from './search-hub-actions.js'; /** * The search hub action creators. diff --git a/packages/headless/src/features/search-hub/search-hub-actions.ts b/packages/headless/src/features/search-hub/search-hub-actions.ts index 995233a9c6e..a40e2a6ec63 100644 --- a/packages/headless/src/features/search-hub/search-hub-actions.ts +++ b/packages/headless/src/features/search-hub/search-hub-actions.ts @@ -1,6 +1,6 @@ import {StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; export const setSearchHub = createAction('searchHub/set', (payload: string) => validatePayload( diff --git a/packages/headless/src/features/search-hub/search-hub-slice.test.ts b/packages/headless/src/features/search-hub/search-hub-slice.test.ts index 0e450c576c6..b58f545ef6e 100644 --- a/packages/headless/src/features/search-hub/search-hub-slice.test.ts +++ b/packages/headless/src/features/search-hub/search-hub-slice.test.ts @@ -1,9 +1,9 @@ -import {updateSearchConfiguration} from '../configuration/configuration-actions'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {setSearchHub} from './search-hub-actions'; -import {searchHubReducer} from './search-hub-slice'; -import {getSearchHubInitialState} from './search-hub-state'; +import {updateSearchConfiguration} from '../configuration/configuration-actions.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {setSearchHub} from './search-hub-actions.js'; +import {searchHubReducer} from './search-hub-slice.js'; +import {getSearchHubInitialState} from './search-hub-state.js'; describe('search hub slice', () => { it('should have initial state', () => { diff --git a/packages/headless/src/features/search-hub/search-hub-slice.ts b/packages/headless/src/features/search-hub/search-hub-slice.ts index 9cb4e8aae7f..c126da4c8a1 100644 --- a/packages/headless/src/features/search-hub/search-hub-slice.ts +++ b/packages/headless/src/features/search-hub/search-hub-slice.ts @@ -1,8 +1,8 @@ import {createReducer} from '@reduxjs/toolkit'; -import {updateSearchConfiguration} from '../configuration/configuration-actions'; -import {change} from '../history/history-actions'; -import {setSearchHub} from './search-hub-actions'; -import {getSearchHubInitialState} from './search-hub-state'; +import {updateSearchConfiguration} from '../configuration/configuration-actions.js'; +import {change} from '../history/history-actions.js'; +import {setSearchHub} from './search-hub-actions.js'; +import {getSearchHubInitialState} from './search-hub-state.js'; export const searchHubReducer = createReducer( getSearchHubInitialState(), diff --git a/packages/headless/src/features/search-parameters/search-parameter-actions.ts b/packages/headless/src/features/search-parameters/search-parameter-actions.ts index 76755dcc1d3..7db4ce2e5c8 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-actions.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-actions.ts @@ -1,8 +1,8 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; -import {DateRangeRequest} from '../facets/range-facets/date-facet-set/interfaces/request'; -import {NumericRangeRequest} from '../facets/range-facets/numeric-facet-set/interfaces/request'; -import {searchParametersDefinition} from './search-parameter-schema'; +import {validatePayload} from '../../utils/validate-payload.js'; +import {DateRangeRequest} from '../facets/range-facets/date-facet-set/interfaces/request.js'; +import {NumericRangeRequest} from '../facets/range-facets/numeric-facet-set/interfaces/request.js'; +import {searchParametersDefinition} from './search-parameter-schema.js'; /** * The parameters affecting the search response. diff --git a/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.test.ts b/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.test.ts index b1622f84d90..4ba6d7c7906 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.test.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.test.ts @@ -1,8 +1,8 @@ import { interfaceChange, logInterfaceChange, -} from '../analytics/analytics-actions'; -import {LegacySearchAction} from '../analytics/analytics-utils'; +} from '../analytics/analytics-actions.js'; +import {LegacySearchAction} from '../analytics/analytics-utils.js'; import { logFacetClearAll, logFacetDeselect, @@ -12,24 +12,24 @@ import { facetClearAll, facetExclude, logFacetUnexclude, -} from '../facets/facet-set/facet-set-analytics-actions'; +} from '../facets/facet-set/facet-set-analytics-actions.js'; import { logPageNumber, logPagerResize, -} from '../pagination/pagination-analytics-actions'; +} from '../pagination/pagination-analytics-actions.js'; import { logSearchboxSubmit, searchboxSubmit, -} from '../query/query-analytics-actions'; +} from '../query/query-analytics-actions.js'; import { logResultsSort, resultsSort, -} from '../sort-criteria/sort-criteria-analytics-actions'; +} from '../sort-criteria/sort-criteria-analytics-actions.js'; import { legacyLogParametersChange, parametersChange, -} from './search-parameter-analytics-actions'; -import {logParametersChange} from './search-parameter-insight-analytics-actions'; +} from './search-parameter-analytics-actions.js'; +import {logParametersChange} from './search-parameter-insight-analytics-actions.js'; describe('legacyLogParametersChange', () => { function expectIdenticalActionType( diff --git a/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.ts b/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.ts index 80858805ee9..4234fb670fa 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-analytics-actions.ts @@ -1,5 +1,5 @@ -import {DateRangeRequest} from '../../controllers/core/facets/range-facet/date-facet/headless-core-date-facet'; -import {NumericRangeRequest} from '../../controllers/facets/range-facet/numeric-facet/headless-numeric-facet'; +import {DateRangeRequest} from '../../controllers/core/facets/range-facet/date-facet/headless-core-date-facet.js'; +import {NumericRangeRequest} from '../../controllers/facets/range-facet/numeric-facet/headless-numeric-facet.js'; import { logFacetClearAll, logFacetDeselect, @@ -10,26 +10,26 @@ import { facetExclude, facetSelect, logFacetUnexclude, -} from '../../features/facets/facet-set/facet-set-analytics-actions'; +} from '../../features/facets/facet-set/facet-set-analytics-actions.js'; import { logSearchboxSubmit, searchboxSubmit, -} from '../../features/query/query-analytics-actions'; -import {SearchParameters} from '../../features/search-parameters/search-parameter-actions'; +} from '../../features/query/query-analytics-actions.js'; +import {SearchParameters} from '../../features/search-parameters/search-parameter-actions.js'; import { logResultsSort, resultsSort, -} from '../../features/sort-criteria/sort-criteria-analytics-actions'; +} from '../../features/sort-criteria/sort-criteria-analytics-actions.js'; import { interfaceChange, logInterfaceChange, -} from '../analytics/analytics-actions'; -import {LegacySearchAction} from '../analytics/analytics-utils'; +} from '../analytics/analytics-actions.js'; +import {LegacySearchAction} from '../analytics/analytics-utils.js'; import { logPageNumber, logPagerResize, -} from '../pagination/pagination-analytics-actions'; -import {SearchAction} from '../search/search-actions'; +} from '../pagination/pagination-analytics-actions.js'; +import {SearchAction} from '../search/search-actions.js'; //TODO: KIT-2859 export function legacyLogParametersChange( diff --git a/packages/headless/src/features/search-parameters/search-parameter-insight-analytics-actions.ts b/packages/headless/src/features/search-parameters/search-parameter-insight-analytics-actions.ts index dc3fbc6449e..322b5fabd07 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-insight-analytics-actions.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-insight-analytics-actions.ts @@ -1,16 +1,16 @@ -import {DateRangeRequest} from '../../controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet'; -import {NumericRangeRequest} from '../../controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet'; -import {InsightAction} from '../analytics/analytics-utils'; -import {logFacetUnexclude} from '../facets/facet-set/facet-set-analytics-actions'; +import {DateRangeRequest} from '../../controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.js'; +import {NumericRangeRequest} from '../../controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.js'; +import {InsightAction} from '../analytics/analytics-utils.js'; +import {logFacetUnexclude} from '../facets/facet-set/facet-set-analytics-actions.js'; import { logFacetClearAll, logFacetDeselect, logFacetSelect, -} from '../facets/facet-set/facet-set-insight-analytics-actions'; -import {logInsightInterfaceChange} from '../insight-search/insight-search-analytics-actions'; -import {logSearchboxSubmit} from '../query/query-insight-analytics-actions'; -import {logResultsSort} from '../sort-criteria/sort-criteria-insight-analytics-actions'; -import {SearchParameters} from './search-parameter-actions'; +} from '../facets/facet-set/facet-set-insight-analytics-actions.js'; +import {logInsightInterfaceChange} from '../insight-search/insight-search-analytics-actions.js'; +import {logSearchboxSubmit} from '../query/query-insight-analytics-actions.js'; +import {logResultsSort} from '../sort-criteria/sort-criteria-insight-analytics-actions.js'; +import {SearchParameters} from './search-parameter-actions.js'; export function logParametersChange( previousParameters: SearchParameters, diff --git a/packages/headless/src/features/search-parameters/search-parameter-schema.ts b/packages/headless/src/features/search-parameters/search-parameter-schema.ts index d92aa5616ba..f95b2fa635f 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-schema.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-schema.ts @@ -5,7 +5,7 @@ import { NumberValue, RecordValue, } from '@coveo/bueno'; -import {SearchParameters} from './search-parameter-actions'; +import {SearchParameters} from './search-parameter-actions.js'; export const searchParametersDefinition: SchemaDefinition< Required diff --git a/packages/headless/src/features/search-parameters/search-parameter-selectors.ts b/packages/headless/src/features/search-parameters/search-parameter-selectors.ts index 2d21049e6a3..a33fd0edc30 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-selectors.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-selectors.ts @@ -1,10 +1,10 @@ -import {SearchParametersState} from '../../state/search-app-state'; -import {getAdvancedSearchQueriesInitialState} from '../advanced-search-queries/advanced-search-queries-state'; -import {getDebugInitialState} from '../debug/debug-state'; -import {getPaginationInitialState} from '../pagination/pagination-state'; -import {getQueryInitialState} from '../query/query-state'; -import {getSortCriteriaInitialState} from '../sort-criteria/sort-criteria-state'; -import {SearchParameters} from './search-parameter-actions'; +import {SearchParametersState} from '../../state/search-app-state.js'; +import {getAdvancedSearchQueriesInitialState} from '../advanced-search-queries/advanced-search-queries-state.js'; +import {getDebugInitialState} from '../debug/debug-state.js'; +import {getPaginationInitialState} from '../pagination/pagination-state.js'; +import {getQueryInitialState} from '../query/query-state.js'; +import {getSortCriteriaInitialState} from '../sort-criteria/sort-criteria-state.js'; +import {SearchParameters} from './search-parameter-actions.js'; export function initialSearchParameterSelector( state: Partial diff --git a/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.test.ts b/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.test.ts index ed312207446..1def464f876 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.test.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.test.ts @@ -1,5 +1,5 @@ -import {SearchParameters} from './search-parameter-actions'; -import {buildSSRSearchParameterSerializer} from './search-parameter-serializer.ssr'; +import {SearchParameters} from './search-parameter-actions.js'; +import {buildSSRSearchParameterSerializer} from './search-parameter-serializer.ssr.js'; const someSpecialCharactersThatNeedsEncoding = [ '&', diff --git a/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.ts b/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.ts index 79d50275688..a291faa8402 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-serializer.ssr.ts @@ -1,12 +1,12 @@ import {isNullOrUndefined} from '@coveo/bueno'; -import {arrayEqualStrictlyDifferentOrder} from '../../utils/compare-utils'; -import type {SearchParameters} from './search-parameter-actions'; +import {arrayEqualStrictlyDifferentOrder} from '../../utils/compare-utils.js'; +import type {SearchParameters} from './search-parameter-actions.js'; import { SearchParameterKey, isValidKey, rangeDelimiterExclusive, rangeDelimiterInclusive, -} from './search-parameter-serializer'; +} from './search-parameter-serializer.js'; import { FacetValueSearchParam, RangeFacetValueSearchParam, @@ -16,7 +16,7 @@ import { isFacetPair, isRangeFacetPair, isValidSearchParam, -} from './search-parameter-utils'; +} from './search-parameter-utils.js'; export function buildSSRSearchParameterSerializer() { return {toSearchParameters, serialize}; diff --git a/packages/headless/src/features/search-parameters/search-parameter-serializer.test.ts b/packages/headless/src/features/search-parameters/search-parameter-serializer.test.ts index c41b53d8961..470a5fe0bd3 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-serializer.test.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-serializer.test.ts @@ -1,13 +1,13 @@ -import {serializeRelativeDate} from '../../api/search/date/relative-date'; -import {buildDateRange} from '../../controllers/facets/range-facet/date-facet/headless-date-facet'; -import {buildNumericRange} from '../../controllers/facets/range-facet/numeric-facet/headless-numeric-facet'; -import {buildMockSearchParameters} from '../../test/mock-search-parameters'; +import {serializeRelativeDate} from '../../api/search/date/relative-date.js'; +import {buildDateRange} from '../../controllers/facets/range-facet/date-facet/headless-date-facet.js'; +import {buildNumericRange} from '../../controllers/facets/range-facet/numeric-facet/headless-numeric-facet.js'; +import {buildMockSearchParameters} from '../../test/mock-search-parameters.js'; import { buildSearchParameterSerializer, isValidBasicKey, isValidKey, keyHasObjectValue, -} from './search-parameter-serializer'; +} from './search-parameter-serializer.js'; const someSpecialCharactersThatNeedsEncoding = [ '&', diff --git a/packages/headless/src/features/search-parameters/search-parameter-serializer.ts b/packages/headless/src/features/search-parameters/search-parameter-serializer.ts index 662eb3fe8e6..18db4e40d83 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-serializer.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-serializer.ts @@ -3,15 +3,15 @@ import { API_DATE_FORMAT, isSearchApiDate, validateAbsoluteDate, -} from '../../api/search/date/date-format'; +} from '../../api/search/date/date-format.js'; import { isRelativeDateFormat, validateRelativeDate, -} from '../../api/search/date/relative-date'; -import {buildDateRange} from '../../controllers/facets/range-facet/date-facet/headless-date-facet'; -import {buildNumericRange} from '../../controllers/facets/range-facet/numeric-facet/headless-numeric-facet'; -import {RangeValueRequest} from '../facets/range-facets/generic/interfaces/range-facet'; -import {SearchParameters} from './search-parameter-actions'; +} from '../../api/search/date/relative-date.js'; +import {buildDateRange} from '../../controllers/facets/range-facet/date-facet/headless-date-facet.js'; +import {buildNumericRange} from '../../controllers/facets/range-facet/numeric-facet/headless-numeric-facet.js'; +import {RangeValueRequest} from '../facets/range-facets/generic/interfaces/range-facet.js'; +import {SearchParameters} from './search-parameter-actions.js'; export const rangeDelimiterExclusive = '..'; export const rangeDelimiterInclusive = '...'; diff --git a/packages/headless/src/features/search-parameters/search-parameter-utils.test.ts b/packages/headless/src/features/search-parameters/search-parameter-utils.test.ts index ef6c5045099..89d2f048f2d 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-utils.test.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-utils.test.ts @@ -1,4 +1,4 @@ -import type {SearchParameterKey} from './search-parameter-serializer'; +import type {SearchParameterKey} from './search-parameter-serializer.js'; import { SearchParamValue, addFacetValuesToSearchParams, @@ -7,7 +7,7 @@ import { isRangeFacetPair, isValidSearchParam, toArray, -} from './search-parameter-utils'; +} from './search-parameter-utils.js'; describe('search-parameter-utils', () => { describe('toArray', () => { diff --git a/packages/headless/src/features/search-parameters/search-parameter-utils.ts b/packages/headless/src/features/search-parameters/search-parameter-utils.ts index 1d34afad34a..8c3a944ea33 100644 --- a/packages/headless/src/features/search-parameters/search-parameter-utils.ts +++ b/packages/headless/src/features/search-parameters/search-parameter-utils.ts @@ -1,7 +1,7 @@ import {isNullOrUndefined} from '@coveo/bueno'; -import {isEmptyString} from '../../utils/utils'; -import type {DateRangeRequest} from '../facets/range-facets/date-facet-set/interfaces/request'; -import type {NumericRangeRequest} from '../facets/range-facets/numeric-facet-set/interfaces/request'; +import {isEmptyString} from '../../utils/utils.js'; +import type {DateRangeRequest} from '../facets/range-facets/date-facet-set/interfaces/request.js'; +import type {NumericRangeRequest} from '../facets/range-facets/numeric-facet-set/interfaces/request.js'; import { SearchParameterKey, buildDateRanges, @@ -12,7 +12,7 @@ import { isRangeFacetObject, isValidBasicKey, keyHasObjectValue, -} from './search-parameter-serializer'; +} from './search-parameter-serializer.js'; export type SearchParamValue = string | string[] | undefined; export type SearchParamPair = [SearchParameterKey, T]; diff --git a/packages/headless/src/features/search/legacy/search-actions-thunk-processor.test.ts b/packages/headless/src/features/search/legacy/search-actions-thunk-processor.test.ts index 7e4edb450d7..3b09928de41 100644 --- a/packages/headless/src/features/search/legacy/search-actions-thunk-processor.test.ts +++ b/packages/headless/src/features/search/legacy/search-actions-thunk-processor.test.ts @@ -1,22 +1,23 @@ import {Relay} from '@coveo/relay'; import {Logger} from 'pino'; -import {SearchAPIClient} from '../../../api/search/search-api-client'; -import {defaultNodeJSNavigatorContextProvider} from '../../../app/navigatorContextProvider'; -import {buildMockResult} from '../../../test/mock-result'; -import {buildMockSearchRequest} from '../../../test/mock-search-request'; -import {buildMockSearchResponse} from '../../../test/mock-search-response'; -import {buildMockSearchState} from '../../../test/mock-search-state'; -import {getConfigurationInitialState} from '../../configuration/configuration-state'; -import {updateQuery} from '../../query/query-actions'; -import {logSearchboxSubmit} from '../../query/query-analytics-actions'; -import {logQueryError} from '../search-analytics-actions'; -import {ExecuteSearchThunkReturn} from './search-actions'; +import {Mock} from 'vitest'; +import {SearchAPIClient} from '../../../api/search/search-api-client.js'; +import {defaultNodeJSNavigatorContextProvider} from '../../../app/navigatorContextProvider.js'; +import {buildMockResult} from '../../../test/mock-result.js'; +import {buildMockSearchRequest} from '../../../test/mock-search-request.js'; +import {buildMockSearchResponse} from '../../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../../test/mock-search-state.js'; +import {getConfigurationInitialState} from '../../configuration/configuration-state.js'; +import {updateQuery} from '../../query/query-actions.js'; +import {logSearchboxSubmit} from '../../query/query-analytics-actions.js'; +import {logQueryError} from '../search-analytics-actions.js'; import { AsyncSearchThunkProcessor, AsyncThunkConfig, -} from './search-actions-thunk-processor'; +} from './search-actions-thunk-processor.js'; +import {ExecuteSearchThunkReturn} from './search-actions.js'; -jest.mock('../search-analytics-actions'); +vi.mock('../search-analytics-actions'); describe('AsyncSearchThunkProcessor', () => { let config: AsyncThunkConfig; @@ -24,17 +25,17 @@ describe('AsyncSearchThunkProcessor', () => { beforeEach(() => { config = { analyticsAction: logSearchboxSubmit(), - dispatch: jest.fn(), + dispatch: vi.fn(), extra: { - analyticsClientMiddleware: jest.fn(), - apiClient: {search: jest.fn()} as unknown as SearchAPIClient, - logger: jest.fn() as unknown as Logger, - validatePayload: jest.fn(), - preprocessRequest: jest.fn(), - relay: jest.fn() as unknown as Relay, + analyticsClientMiddleware: vi.fn(), + apiClient: {search: vi.fn()} as unknown as SearchAPIClient, + logger: vi.fn() as unknown as Logger, + validatePayload: vi.fn(), + preprocessRequest: vi.fn(), + relay: vi.fn() as unknown as Relay, navigatorContext: defaultNodeJSNavigatorContextProvider(), }, - getState: jest.fn().mockReturnValue({ + getState: vi.fn().mockReturnValue({ configuration: getConfigurationInitialState(), search: buildMockSearchState({ results, @@ -45,7 +46,7 @@ describe('AsyncSearchThunkProcessor', () => { automaticallyCorrectQuery: true, }, }), - rejectWithValue: jest.fn(), + rejectWithValue: vi.fn(), }; }); @@ -116,7 +117,7 @@ describe('AsyncSearchThunkProcessor', () => { results: [buildMockResult()], }); - (config.extra.apiClient.search as jest.Mock).mockReturnValue( + (config.extra.apiClient.search as Mock).mockReturnValue( Promise.resolve({success: responseAfterCorrection}) ); @@ -181,7 +182,7 @@ describe('AsyncSearchThunkProcessor', () => { it('process properly when there are no results returned, there is a did you mean correction, and automatic correction is disabled', async () => { const processor = new AsyncSearchThunkProcessor<{}>({ ...config, - getState: jest.fn().mockReturnValue({ + getState: vi.fn().mockReturnValue({ configuration: getConfigurationInitialState(), search: buildMockSearchState({ results, @@ -235,7 +236,7 @@ describe('AsyncSearchThunkProcessor', () => { results: [buildMockResult()], }); - (config.extra.apiClient.search as jest.Mock).mockReturnValue( + (config.extra.apiClient.search as Mock).mockReturnValue( Promise.resolve({success: responseAfterModification}) ); diff --git a/packages/headless/src/features/search/legacy/search-actions-thunk-processor.ts b/packages/headless/src/features/search/legacy/search-actions-thunk-processor.ts index de23f9d694b..0491853d48f 100644 --- a/packages/headless/src/features/search/legacy/search-actions-thunk-processor.ts +++ b/packages/headless/src/features/search/legacy/search-actions-thunk-processor.ts @@ -1,17 +1,17 @@ import {isNullOrUndefined} from '@coveo/bueno'; import {AnyAction} from '@reduxjs/toolkit'; import {ThunkDispatch} from 'redux-thunk'; -import {StateNeededBySearchAnalyticsProvider} from '../../../api/analytics/search-analytics'; +import {StateNeededBySearchAnalyticsProvider} from '../../../api/analytics/search-analytics.js'; import { isErrorResponse, isSuccessResponse, SearchAPIClient, -} from '../../../api/search/search-api-client'; -import {SearchAPIErrorWithStatusCode} from '../../../api/search/search-api-error-response'; -import {SearchOrigin} from '../../../api/search/search-metadata'; -import {SearchRequest} from '../../../api/search/search/search-request'; -import {SearchResponseSuccess} from '../../../api/search/search/search-response'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; +} from '../../../api/search/search-api-client.js'; +import {SearchAPIErrorWithStatusCode} from '../../../api/search/search-api-error-response.js'; +import {SearchOrigin} from '../../../api/search/search-metadata.js'; +import {SearchRequest} from '../../../api/search/search/search-request.js'; +import {SearchResponseSuccess} from '../../../api/search/search/search-response.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; import { AdvancedSearchQueriesSection, CategoryFacetSection, @@ -34,29 +34,29 @@ import { SearchSection, SortSection, TriggerSection, -} from '../../../state/state-sections'; -import {AnalyticsAsyncThunk} from '../../analytics/analytics-utils'; -import {applyDidYouMeanCorrection} from '../../did-you-mean/did-you-mean-actions'; -import {logDidYouMeanAutomatic} from '../../did-you-mean/did-you-mean-analytics-actions'; -import {snapshot} from '../../history/history-actions'; -import {extractHistory} from '../../history/history-state'; -import {updateQuery} from '../../query/query-actions'; -import {getQueryInitialState} from '../../query/query-state'; -import {logTriggerQuery} from '../../triggers/trigger-analytics-actions'; +} from '../../../state/state-sections.js'; +import {AnalyticsAsyncThunk} from '../../analytics/analytics-utils.js'; +import {applyDidYouMeanCorrection} from '../../did-you-mean/did-you-mean-actions.js'; +import {logDidYouMeanAutomatic} from '../../did-you-mean/did-you-mean-analytics-actions.js'; +import {snapshot} from '../../history/history-actions.js'; +import {extractHistory} from '../../history/history-state.js'; +import {updateQuery} from '../../query/query-actions.js'; +import {getQueryInitialState} from '../../query/query-state.js'; +import {logTriggerQuery} from '../../triggers/trigger-analytics-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from '../../triggers/triggers-actions'; -import {logQueryError} from '../search-analytics-actions'; +} from '../../triggers/triggers-actions.js'; +import {logQueryError} from '../search-analytics-actions.js'; import { ErrorResponse, MappedSearchRequest, mapSearchResponse, SuccessResponse, -} from '../search-mappings'; -import {getSearchInitialState} from '../search-state'; -import {ExecuteSearchThunkReturn} from './search-actions'; -import {buildSearchRequest} from './search-request'; +} from '../search-mappings.js'; +import {getSearchInitialState} from '../search-state.js'; +import {ExecuteSearchThunkReturn} from './search-actions.js'; +import {buildSearchRequest} from './search-request.js'; export type StateNeededByExecuteSearch = ConfigurationSection & Partial< diff --git a/packages/headless/src/features/search/legacy/search-actions.test.ts b/packages/headless/src/features/search/legacy/search-actions.test.ts index 665b49cd812..263796b57f5 100644 --- a/packages/headless/src/features/search/legacy/search-actions.test.ts +++ b/packages/headless/src/features/search/legacy/search-actions.test.ts @@ -1,18 +1,18 @@ -import {SearchAPIClient} from '../../../api/search/search-api-client'; -import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments'; +import {SearchAPIClient} from '../../../api/search/search-api-client.js'; +import {ClientThunkExtraArguments} from '../../../app/thunk-extra-arguments.js'; import { MockedSearchEngine, buildMockSearchEngine, -} from '../../../test/mock-engine-v2'; -import {createMockState} from '../../../test/mock-state'; -import {logSearchboxSubmit} from '../../query/query-analytics-actions'; +} from '../../../test/mock-engine-v2.js'; +import {createMockState} from '../../../test/mock-state.js'; +import {logSearchboxSubmit} from '../../query/query-analytics-actions.js'; import { executeSearch, fetchInstantResults, fetchFacetValues, fetchPage, fetchMoreResults, -} from './search-actions'; +} from './search-actions.js'; describe('search actions', () => { let e: MockedSearchEngine; @@ -25,9 +25,9 @@ describe('search actions', () => { }) as unknown as ClientThunkExtraArguments; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); apiClient = { - search: jest.fn(), + search: vi.fn(), } as unknown as SearchAPIClient; e = buildMockSearchEngine(createMockState()); }); diff --git a/packages/headless/src/features/search/legacy/search-actions.ts b/packages/headless/src/features/search/legacy/search-actions.ts index 1bf173061e4..93185510db7 100644 --- a/packages/headless/src/features/search/legacy/search-actions.ts +++ b/packages/headless/src/features/search/legacy/search-actions.ts @@ -1,45 +1,45 @@ import {BooleanValue, NumberValue, StringValue} from '@coveo/bueno'; import {createAsyncThunk} from '@reduxjs/toolkit'; import {EventDescription} from 'coveo.analytics'; -import {historyStore} from '../../../api/analytics/coveo-analytics-utils'; -import {AsyncThunkSearchOptions} from '../../../api/search/search-api-client'; -import {SearchResponseSuccess} from '../../../api/search/search/search-response'; -import {AsyncThunkOptions} from '../../../app/async-thunk-options'; -import {InstantResultSection} from '../../../state/state-sections'; +import {historyStore} from '../../../api/analytics/coveo-analytics-utils.js'; +import {AsyncThunkSearchOptions} from '../../../api/search/search-api-client.js'; +import {SearchResponseSuccess} from '../../../api/search/search/search-response.js'; +import {AsyncThunkOptions} from '../../../app/async-thunk-options.js'; +import {InstantResultSection} from '../../../state/state-sections.js'; import { requiredNonEmptyString, validatePayload, -} from '../../../utils/validate-payload'; +} from '../../../utils/validate-payload.js'; import { AnalyticsAsyncThunk, LegacySearchAction, -} from '../../analytics/analytics-utils'; +} from '../../analytics/analytics-utils.js'; import { deselectAllBreadcrumbs, deselectAllNonBreadcrumbs, -} from '../../breadcrumb/breadcrumb-actions'; -import {updateFacetAutoSelection} from '../../facets/generic/facet-actions'; -import {logInstantResultsSearch} from '../../instant-results/instant-result-analytics-actions'; +} from '../../breadcrumb/breadcrumb-actions.js'; +import {updateFacetAutoSelection} from '../../facets/generic/facet-actions.js'; +import {logInstantResultsSearch} from '../../instant-results/instant-result-analytics-actions.js'; import { FetchInstantResultsActionCreatorPayload, FetchInstantResultsThunkReturn, updateInstantResultsQuery, -} from '../../instant-results/instant-results-actions'; -import {updatePage} from '../../pagination/pagination-actions'; +} from '../../instant-results/instant-results-actions.js'; +import {updatePage} from '../../pagination/pagination-actions.js'; import { updateQuery, UpdateQueryActionCreatorPayload, -} from '../../query/query-actions'; -import {buildSearchAndFoldingLoadCollectionRequest} from '../../search-and-folding/legacy/search-and-folding-request'; -import {logFetchMoreResults} from '../search-analytics-actions'; -import {MappedSearchRequest, mapSearchRequest} from '../search-mappings'; +} from '../../query/query-actions.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from '../../search-and-folding/legacy/search-and-folding-request.js'; +import {logFetchMoreResults} from '../search-analytics-actions.js'; +import {MappedSearchRequest, mapSearchRequest} from '../search-mappings.js'; import { AsyncSearchThunkProcessor, StateNeededByExecuteSearch, -} from './search-actions-thunk-processor'; -import {buildSearchRequest} from './search-request'; +} from './search-actions-thunk-processor.js'; +import {buildSearchRequest} from './search-request.js'; -export type {StateNeededByExecuteSearch} from './search-actions-thunk-processor'; +export type {StateNeededByExecuteSearch} from './search-actions-thunk-processor.js'; export interface ExecuteSearchThunkReturn { /** The successful search response. */ diff --git a/packages/headless/src/features/search/legacy/search-request.ts b/packages/headless/src/features/search/legacy/search-request.ts index 58da0faf5ca..9777e5cf138 100644 --- a/packages/headless/src/features/search/legacy/search-request.ts +++ b/packages/headless/src/features/search/legacy/search-request.ts @@ -1,12 +1,12 @@ import {EventDescription} from 'coveo.analytics'; -import {SearchAppState} from '../../../state/search-app-state'; -import {ConfigurationSection} from '../../../state/state-sections'; -import {getFacets} from '../../../utils/facet-utils'; -import {AutomaticFacetRequest} from '../../facets/automatic-facet-set/interfaces/request'; -import {AutomaticFacetResponse} from '../../facets/automatic-facet-set/interfaces/response'; -import {maximumNumberOfResultsFromIndex} from '../../pagination/pagination-constants'; -import {buildSearchAndFoldingLoadCollectionRequest} from '../../search-and-folding/legacy/search-and-folding-request'; -import {mapSearchRequest} from '../search-mappings'; +import {SearchAppState} from '../../../state/search-app-state.js'; +import {ConfigurationSection} from '../../../state/state-sections.js'; +import {getFacets} from '../../../utils/facet-utils.js'; +import {AutomaticFacetRequest} from '../../facets/automatic-facet-set/interfaces/request.js'; +import {AutomaticFacetResponse} from '../../facets/automatic-facet-set/interfaces/response.js'; +import {maximumNumberOfResultsFromIndex} from '../../pagination/pagination-constants.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from '../../search-and-folding/legacy/search-and-folding-request.js'; +import {mapSearchRequest} from '../search-mappings.js'; type StateNeededBySearchRequest = ConfigurationSection & Partial; diff --git a/packages/headless/src/features/search/search-actions-loader.ts b/packages/headless/src/features/search/search-actions-loader.ts index f956639cdfc..f7747e788b7 100644 --- a/packages/headless/src/features/search/search-actions-loader.ts +++ b/packages/headless/src/features/search/search-actions-loader.ts @@ -2,17 +2,18 @@ import {AsyncThunkAction} from '@reduxjs/toolkit'; import { AsyncThunkSearchOptions, SearchAPIClient, -} from '../../api/search/search-api-client'; -import {AsyncThunkOptions} from '../../app/async-thunk-options'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {searchReducer as search} from '../../features/search/search-slice'; -import {InstantResultSection} from '../../state/state-sections'; -import {LegacySearchAction} from '../analytics/analytics-utils'; +} from '../../api/search/search-api-client.js'; +import {AsyncThunkOptions} from '../../app/async-thunk-options.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {searchReducer as search} from '../../features/search/search-slice.js'; +import {InstantResultSection} from '../../state/state-sections.js'; +import {LegacySearchAction} from '../analytics/analytics-utils.js'; import { FetchInstantResultsActionCreatorPayload, FetchInstantResultsThunkReturn, -} from '../instant-results/instant-results-actions'; +} from '../instant-results/instant-results-actions.js'; +import {StateNeededByExecuteSearch} from './legacy/search-actions-thunk-processor.js'; import { executeSearch, ExecuteSearchThunkReturn, @@ -20,8 +21,7 @@ import { fetchFacetValues, fetchPage, fetchInstantResults, -} from './legacy/search-actions'; -import {StateNeededByExecuteSearch} from './legacy/search-actions-thunk-processor'; +} from './legacy/search-actions.js'; /** * The search action creators. diff --git a/packages/headless/src/features/search/search-actions-thunk-processor.ts b/packages/headless/src/features/search/search-actions-thunk-processor.ts index bc2055b5127..eb6db3e9b2e 100644 --- a/packages/headless/src/features/search/search-actions-thunk-processor.ts +++ b/packages/headless/src/features/search/search-actions-thunk-processor.ts @@ -5,11 +5,11 @@ import { isErrorResponse, isSuccessResponse, SearchAPIClient, -} from '../../api/search/search-api-client'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {SearchOrigin} from '../../api/search/search-metadata'; -import {SearchRequest} from '../../api/search/search/search-request'; -import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments'; +} from '../../api/search/search-api-client.js'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {SearchOrigin} from '../../api/search/search-metadata.js'; +import {SearchRequest} from '../../api/search/search/search-request.js'; +import {ClientThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; import { AdvancedSearchQueriesSection, CategoryFacetSection, @@ -32,25 +32,25 @@ import { SearchSection, SortSection, TriggerSection, -} from '../../state/state-sections'; -import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions'; -import {didYouMeanAutomatic} from '../did-you-mean/did-you-mean-analytics-actions'; -import {snapshot} from '../history/history-actions'; -import {extractHistory} from '../history/history-state'; -import {updateQuery} from '../query/query-actions'; +} from '../../state/state-sections.js'; +import {applyDidYouMeanCorrection} from '../did-you-mean/did-you-mean-actions.js'; +import {didYouMeanAutomatic} from '../did-you-mean/did-you-mean-analytics-actions.js'; +import {snapshot} from '../history/history-actions.js'; +import {extractHistory} from '../history/history-state.js'; +import {updateQuery} from '../query/query-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from '../triggers/triggers-actions'; -import {ExecuteSearchThunkReturn} from './search-actions'; -import {logQueryError} from './search-analytics-actions'; +} from '../triggers/triggers-actions.js'; +import {ExecuteSearchThunkReturn} from './search-actions.js'; +import {logQueryError} from './search-analytics-actions.js'; import { ErrorResponse, MappedSearchRequest, mapSearchResponse, SuccessResponse, -} from './search-mappings'; -import {buildSearchRequest} from './search-request'; +} from './search-mappings.js'; +import {buildSearchRequest} from './search-request.js'; export interface AnalyticsAction { actionCause?: string; diff --git a/packages/headless/src/features/search/search-actions.ts b/packages/headless/src/features/search/search-actions.ts index 3146f949380..88458c38494 100644 --- a/packages/headless/src/features/search/search-actions.ts +++ b/packages/headless/src/features/search/search-actions.ts @@ -1,56 +1,56 @@ import {BooleanValue, NumberValue, StringValue} from '@coveo/bueno'; import {createAsyncThunk} from '@reduxjs/toolkit'; import {EventDescription} from 'coveo.analytics'; -import {historyStore} from '../../api/analytics/coveo-analytics-utils'; -import {AsyncThunkSearchOptions} from '../../api/search/search-api-client'; -import {SearchResponseSuccess} from '../../api/search/search/search-response'; -import {AsyncThunkOptions} from '../../app/async-thunk-options'; -import {NavigatorContext} from '../../app/navigatorContextProvider'; -import {InstantResultSection} from '../../state/state-sections'; +import {historyStore} from '../../api/analytics/coveo-analytics-utils.js'; +import {AsyncThunkSearchOptions} from '../../api/search/search-api-client.js'; +import {SearchResponseSuccess} from '../../api/search/search/search-response.js'; +import {AsyncThunkOptions} from '../../app/async-thunk-options.js'; +import {NavigatorContext} from '../../app/navigatorContextProvider.js'; +import {InstantResultSection} from '../../state/state-sections.js'; import { requiredNonEmptyString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { LegacySearchAction, makeBasicNewSearchAnalyticsAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; import { deselectAllBreadcrumbs, deselectAllNonBreadcrumbs, -} from '../breadcrumb/breadcrumb-actions'; -import {updateFacetAutoSelection} from '../facets/generic/facet-actions'; -import {searchboxAsYouType} from '../instant-results/instant-result-analytics-actions'; +} from '../breadcrumb/breadcrumb-actions.js'; +import {updateFacetAutoSelection} from '../facets/generic/facet-actions.js'; +import {searchboxAsYouType} from '../instant-results/instant-result-analytics-actions.js'; import { FetchInstantResultsActionCreatorPayload, FetchInstantResultsThunkReturn, updateInstantResultsQuery, -} from '../instant-results/instant-results-actions'; -import {updatePage} from '../pagination/pagination-actions'; +} from '../instant-results/instant-results-actions.js'; +import {updatePage} from '../pagination/pagination-actions.js'; import { updateQuery, UpdateQueryActionCreatorPayload, -} from '../query/query-actions'; -import {buildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/search-and-folding-request'; +} from '../query/query-actions.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/search-and-folding-request.js'; import { legacyExecuteSearch, legacyFetchInstantResults, legacyFetchMoreResults, legacyFetchPage, -} from './legacy/search-actions'; +} from './legacy/search-actions.js'; import { AsyncSearchThunkProcessor, StateNeededByExecuteSearch, -} from './search-actions-thunk-processor'; -import {MappedSearchRequest, mapSearchRequest} from './search-mappings'; -import {buildSearchRequest} from './search-request'; +} from './search-actions-thunk-processor.js'; +import {MappedSearchRequest, mapSearchRequest} from './search-mappings.js'; +import {buildSearchRequest} from './search-request.js'; export interface SearchAction { actionCause: string; } -export type {StateNeededByExecuteSearch} from './search-actions-thunk-processor'; +export type {StateNeededByExecuteSearch} from './search-actions-thunk-processor.js'; export interface ExecuteSearchThunkReturn { /** The successful search response. */ diff --git a/packages/headless/src/features/search/search-analytics-actions.ts b/packages/headless/src/features/search/search-analytics-actions.ts index 4271d735404..4be06706412 100644 --- a/packages/headless/src/features/search/search-analytics-actions.ts +++ b/packages/headless/src/features/search/search-analytics-actions.ts @@ -1,10 +1,10 @@ -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {getAdvancedSearchQueriesInitialState} from '../advanced-search-queries/advanced-search-queries-state'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {getAdvancedSearchQueriesInitialState} from '../advanced-search-queries/advanced-search-queries-state.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {getQueryInitialState} from '../query/query-state'; +} from '../analytics/analytics-utils.js'; +import {getQueryInitialState} from '../query/query-state.js'; export const logFetchMoreResults = (): LegacySearchAction => makeAnalyticsAction('search/logFetchMoreResults', (client) => diff --git a/packages/headless/src/features/search/search-mappings.test.ts b/packages/headless/src/features/search/search-mappings.test.ts index df5df607e95..49fea563357 100644 --- a/packages/headless/src/features/search/search-mappings.test.ts +++ b/packages/headless/src/features/search/search-mappings.test.ts @@ -1,13 +1,13 @@ import { formatRelativeDateForSearchApi, serializeRelativeDate, -} from '../../api/search/date/relative-date'; -import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request'; -import {buildMockDateFacetResponse} from '../../test/mock-date-facet-response'; -import {buildMockDateFacetValue} from '../../test/mock-date-facet-value'; -import {buildMockSearchRequest} from '../../test/mock-search-request'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {mapSearchRequest, mapSearchResponse} from './search-mappings'; +} from '../../api/search/date/relative-date.js'; +import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request.js'; +import {buildMockDateFacetResponse} from '../../test/mock-date-facet-response.js'; +import {buildMockDateFacetValue} from '../../test/mock-date-facet-value.js'; +import {buildMockSearchRequest} from '../../test/mock-search-request.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {mapSearchRequest, mapSearchResponse} from './search-mappings.js'; const facetId = 'myfacet'; const relativeStart = serializeRelativeDate({ @@ -33,12 +33,12 @@ const getExpectedMappings = () => ({ describe('#mapSearchRequest', () => { beforeAll(() => { const frozenInTime = new Date(); - jest.useFakeTimers(); - jest.setSystemTime(frozenInTime); + vi.useFakeTimers(); + vi.setSystemTime(frozenInTime); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('should return the full request along with mappings', () => { @@ -91,12 +91,12 @@ describe('#mapSearchRequest', () => { describe('#mapSearchResponse', () => { beforeAll(() => { const frozenInTime = new Date(); - jest.useFakeTimers(); - jest.setSystemTime(frozenInTime); + vi.useFakeTimers(); + vi.setSystemTime(frozenInTime); }); afterAll(() => { - jest.useRealTimers(); + vi.useRealTimers(); }); it('should return the full response', () => { diff --git a/packages/headless/src/features/search/search-mappings.ts b/packages/headless/src/features/search/search-mappings.ts index 7002dc0e52f..b00c028b7a6 100644 --- a/packages/headless/src/features/search/search-mappings.ts +++ b/packages/headless/src/features/search/search-mappings.ts @@ -1,22 +1,22 @@ import { formatRelativeDateForSearchApi, isRelativeDateFormat, -} from '../../api/search/date/relative-date'; -import {SearchAPIClientResponse} from '../../api/search/search-api-client'; -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {FacetsParam} from '../../api/search/search-api-params'; -import {SearchRequest} from '../../api/search/search/search-request'; -import {SearchResponseSuccess} from '../../api/search/search/search-response'; -import {AnyFacetRequest} from '../facets/generic/interfaces/generic-facet-request'; -import {AnyFacetResponse} from '../facets/generic/interfaces/generic-facet-response'; +} from '../../api/search/date/relative-date.js'; +import {SearchAPIClientResponse} from '../../api/search/search-api-client.js'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {FacetsParam} from '../../api/search/search-api-params.js'; +import {SearchRequest} from '../../api/search/search/search-request.js'; +import {SearchResponseSuccess} from '../../api/search/search/search-response.js'; +import {AnyFacetRequest} from '../facets/generic/interfaces/generic-facet-request.js'; +import {AnyFacetResponse} from '../facets/generic/interfaces/generic-facet-response.js'; import { DateRangeRequest, isDateFacetRequest, -} from '../facets/range-facets/date-facet-set/interfaces/request'; +} from '../facets/range-facets/date-facet-set/interfaces/request.js'; import { DateFacetResponse, DateFacetValue, -} from '../facets/range-facets/date-facet-set/interfaces/response'; +} from '../facets/range-facets/date-facet-set/interfaces/response.js'; function formatStartFacetValue(value: string) { return `start${value}`; diff --git a/packages/headless/src/features/search/search-request.test.ts b/packages/headless/src/features/search/search-request.test.ts index 62b75f413b9..09620be2785 100644 --- a/packages/headless/src/features/search/search-request.test.ts +++ b/packages/headless/src/features/search/search-request.test.ts @@ -1,26 +1,26 @@ -import {SearchAppState} from '../../state/search-app-state'; -import {buildMockAutomaticFacetRequest} from '../../test/mock-automatic-facet-request'; -import {buildMockAutomaticFacetResponse} from '../../test/mock-automatic-facet-response'; -import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice'; -import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request'; -import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice'; -import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request'; -import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice'; -import {buildMockDateFacetValue} from '../../test/mock-date-facet-value'; -import {buildMockFacetOptions} from '../../test/mock-facet-options'; -import {buildFacetOptionsSlice} from '../../test/mock-facet-options-slice'; -import {buildMockFacetRequest} from '../../test/mock-facet-request'; -import {buildMockFacetSlice} from '../../test/mock-facet-slice'; -import {buildMockFacetValue} from '../../test/mock-facet-value'; -import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider'; -import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request'; -import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice'; -import {createMockState} from '../../test/mock-state'; -import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value'; -import {buildMockTabSlice} from '../../test/mock-tab-state'; -import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants'; -import {buildSearchRequest} from './search-request'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {buildMockAutomaticFacetRequest} from '../../test/mock-automatic-facet-request.js'; +import {buildMockAutomaticFacetResponse} from '../../test/mock-automatic-facet-response.js'; +import {buildMockAutomaticFacetSlice} from '../../test/mock-automatic-facet-slice.js'; +import {buildMockCategoryFacetRequest} from '../../test/mock-category-facet-request.js'; +import {buildMockCategoryFacetSlice} from '../../test/mock-category-facet-slice.js'; +import {buildMockDateFacetRequest} from '../../test/mock-date-facet-request.js'; +import {buildMockDateFacetSlice} from '../../test/mock-date-facet-slice.js'; +import {buildMockDateFacetValue} from '../../test/mock-date-facet-value.js'; +import {buildFacetOptionsSlice} from '../../test/mock-facet-options-slice.js'; +import {buildMockFacetOptions} from '../../test/mock-facet-options.js'; +import {buildMockFacetRequest} from '../../test/mock-facet-request.js'; +import {buildMockFacetSlice} from '../../test/mock-facet-slice.js'; +import {buildMockFacetValue} from '../../test/mock-facet-value.js'; +import {buildMockNavigatorContextProvider} from '../../test/mock-navigator-context-provider.js'; +import {buildMockNumericFacetRequest} from '../../test/mock-numeric-facet-request.js'; +import {buildMockNumericFacetSlice} from '../../test/mock-numeric-facet-slice.js'; +import {createMockState} from '../../test/mock-state.js'; +import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value.js'; +import {buildMockTabSlice} from '../../test/mock-tab-state.js'; +import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants.js'; +import {buildSearchRequest} from './search-request.js'; describe('search request', () => { let state: SearchAppState; diff --git a/packages/headless/src/features/search/search-request.ts b/packages/headless/src/features/search/search-request.ts index afa5e436823..5aab6993014 100644 --- a/packages/headless/src/features/search/search-request.ts +++ b/packages/headless/src/features/search/search-request.ts @@ -1,18 +1,18 @@ import {EventDescription} from 'coveo.analytics'; -import {NavigatorContext} from '../../app/navigatorContextProvider'; -import {SearchAppState} from '../../state/search-app-state'; -import {ConfigurationSection} from '../../state/state-sections'; -import {sortFacets} from '../../utils/facet-utils'; -import {AutomaticFacetRequest} from '../facets/automatic-facet-set/interfaces/request'; -import {AutomaticFacetResponse} from '../facets/automatic-facet-set/interfaces/response'; -import {FacetSetState} from '../facets/facet-set/facet-set-state'; -import {getFacetRequests} from '../facets/generic/interfaces/generic-facet-request'; -import {AnyFacetValue} from '../facets/generic/interfaces/generic-facet-response'; -import {RangeFacetSetState} from '../facets/range-facets/generic/interfaces/range-facet'; -import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants'; -import {buildSearchAndFoldingLoadCollectionRequest as legacyBuildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/legacy/search-and-folding-request'; -import {buildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/search-and-folding-request'; -import {mapSearchRequest} from './search-mappings'; +import {NavigatorContext} from '../../app/navigatorContextProvider.js'; +import {SearchAppState} from '../../state/search-app-state.js'; +import {ConfigurationSection} from '../../state/state-sections.js'; +import {sortFacets} from '../../utils/facet-utils.js'; +import {AutomaticFacetRequest} from '../facets/automatic-facet-set/interfaces/request.js'; +import {AutomaticFacetResponse} from '../facets/automatic-facet-set/interfaces/response.js'; +import {FacetSetState} from '../facets/facet-set/facet-set-state.js'; +import {getFacetRequests} from '../facets/generic/interfaces/generic-facet-request.js'; +import {AnyFacetValue} from '../facets/generic/interfaces/generic-facet-response.js'; +import {RangeFacetSetState} from '../facets/range-facets/generic/interfaces/range-facet.js'; +import {maximumNumberOfResultsFromIndex} from '../pagination/pagination-constants.js'; +import {buildSearchAndFoldingLoadCollectionRequest as legacyBuildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/legacy/search-and-folding-request.js'; +import {buildSearchAndFoldingLoadCollectionRequest} from '../search-and-folding/search-and-folding-request.js'; +import {mapSearchRequest} from './search-mappings.js'; type StateNeededBySearchRequest = ConfigurationSection & Partial; diff --git a/packages/headless/src/features/search/search-selectors.test.ts b/packages/headless/src/features/search/search-selectors.test.ts index 6a50e28f8bc..a1e0592f1a1 100644 --- a/packages/headless/src/features/search/search-selectors.test.ts +++ b/packages/headless/src/features/search/search-selectors.test.ts @@ -1,5 +1,5 @@ -import {createMockState} from '../../test/mock-state'; -import {firstSearchExecutedSelector} from './search-selectors'; +import {createMockState} from '../../test/mock-state.js'; +import {firstSearchExecutedSelector} from './search-selectors.js'; describe('search selectors', () => { it(`when the response searchUid is truthy, diff --git a/packages/headless/src/features/search/search-selectors.ts b/packages/headless/src/features/search/search-selectors.ts index 7ea41358f46..339e7918d28 100644 --- a/packages/headless/src/features/search/search-selectors.ts +++ b/packages/headless/src/features/search/search-selectors.ts @@ -1,5 +1,5 @@ -import {SearchSection} from '../../state/state-sections'; -import {getResultProperty} from '../result-templates/result-templates-helpers'; +import {SearchSection} from '../../state/state-sections.js'; +import {getResultProperty} from '../result-templates/result-templates-helpers.js'; export function firstSearchExecutedSelector(state: SearchSection) { return state.search.response.searchUid !== ''; diff --git a/packages/headless/src/features/search/search-slice.test.ts b/packages/headless/src/features/search/search-slice.test.ts index a6835e83983..9e881e94b8d 100644 --- a/packages/headless/src/features/search/search-slice.test.ts +++ b/packages/headless/src/features/search/search-slice.test.ts @@ -1,26 +1,26 @@ -import {Result} from '../../api/search/search/result'; -import {buildMockFacetResponse} from '../../test/mock-facet-response'; -import {buildMockQuestionsAnswers} from '../../test/mock-question-answer'; -import {buildMockResult} from '../../test/mock-result'; -import {buildMockSearch} from '../../test/mock-search'; -import {buildMockSearchResponse} from '../../test/mock-search-response'; -import {buildMockSearchState} from '../../test/mock-search-state'; -import {logFacetShowMore} from '../facets/facet-set/facet-set-analytics-actions'; -import {logPageNext} from '../pagination/pagination-analytics-actions'; -import {logSearchboxSubmit} from '../query/query-analytics-actions'; +import {Result} from '../../api/search/search/result.js'; +import {buildMockFacetResponse} from '../../test/mock-facet-response.js'; +import {buildMockQuestionsAnswers} from '../../test/mock-question-answer.js'; +import {buildMockResult} from '../../test/mock-result.js'; +import {buildMockSearchResponse} from '../../test/mock-search-response.js'; +import {buildMockSearchState} from '../../test/mock-search-state.js'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {logFacetShowMore} from '../facets/facet-set/facet-set-analytics-actions.js'; +import {logPageNext} from '../pagination/pagination-analytics-actions.js'; +import {logSearchboxSubmit} from '../query/query-analytics-actions.js'; import { executeSearch, ExecuteSearchThunkReturn, fetchFacetValues, fetchMoreResults, fetchPage, -} from './search-actions'; -import {searchReducer} from './search-slice'; +} from './search-actions.js'; +import {searchReducer} from './search-slice.js'; import { emptyQuestionAnswer, getSearchInitialState, SearchState, -} from './search-state'; +} from './search-state.js'; describe('search-slice', () => { let state: SearchState; @@ -148,6 +148,22 @@ describe('search-slice', () => { expect(finalState.searchResponseId).toBe('a_new_id'); }); + it('when a executeSearch fulfilled is received, results should contain last #searchUid', () => { + state.searchResponseId = 'an_initial_id'; + const response = buildMockSearchResponse({results: [newResult]}); + response.searchUid = 'a_new_id'; + const search = buildMockSearch({ + response, + }); + + const finalState = searchReducer( + state, + executeSearch.fulfilled(search, '', {legacy: logSearchboxSubmit()}) + ); + + expect(finalState.results[0].searchUid).toBe('a_new_id'); + }); + it('when a executeSearch fulfilled is received, it overwrites the #questionAnswer', () => { state.questionAnswer = buildMockQuestionsAnswers({ question: 'When?', @@ -200,6 +216,26 @@ describe('search-slice', () => { expect(finalState.searchResponseId).toBe('an_initial_id'); }); + it('when a fetchMoreResults fulfilled is received, previous results keep their #searchUiD', () => { + state.results = state.results.map((result) => ({ + ...result, + searchUid: 'an_initial_id', + })); + const response = buildMockSearchResponse({results: [newResult]}); + response.searchUid = 'a_new_id'; + const search = buildMockSearch({ + response, + }); + + const finalState = searchReducer( + state, + fetchMoreResults.fulfilled(search, '') + ); + + expect(finalState.results[0].searchUid).toBe('an_initial_id'); + expect(finalState.results[1].searchUid).toBe('a_new_id'); + }); + it('when a fetchMoreResults fulfilled is received, keeps the previous #questionAnswer', () => { const originalQuestionAnswers = buildMockQuestionsAnswers({ question: 'Why?', diff --git a/packages/headless/src/features/search/search-slice.ts b/packages/headless/src/features/search/search-slice.ts index 7281201000d..2bc1b51ea30 100644 --- a/packages/headless/src/features/search/search-slice.ts +++ b/packages/headless/src/features/search/search-slice.ts @@ -4,12 +4,12 @@ import { fetchFacetValues, fetchMoreResults, fetchPage, -} from './legacy/search-actions'; +} from './legacy/search-actions.js'; import { emptyQuestionAnswer, getSearchInitialState, SearchState, -} from './search-state'; +} from './search-state.js'; type SearchAction = typeof executeSearch | typeof fetchMoreResults; @@ -44,7 +44,10 @@ function handleFulfilledNewSearch( action: ReturnType ) { handleFulfilledSearch(state, action); - state.results = action.payload.response.results; + state.results = action.payload.response.results.map((result) => ({ + ...result, + searchUid: action.payload.response.searchUid, + })); state.searchResponseId = action.payload.response.searchUid; state.questionAnswer = action.payload.response.questionAnswer; state.extendedResults = action.payload.response.extendedResults; @@ -81,7 +84,13 @@ export const searchReducer = createReducer( }); builder.addCase(fetchMoreResults.fulfilled, (state, action) => { handleFulfilledSearch(state, action); - state.results = [...state.results, ...action.payload.response.results]; + state.results = [ + ...state.results, + ...action.payload.response.results.map((result) => ({ + ...result, + searchUid: action.payload.response.searchUid, + })), + ]; }); builder.addCase(fetchPage.fulfilled, (state, action) => { handleFulfilledSearch(state, action); diff --git a/packages/headless/src/features/search/search-state.ts b/packages/headless/src/features/search/search-state.ts index 78502056b9d..c6f2b0b9927 100644 --- a/packages/headless/src/features/search/search-state.ts +++ b/packages/headless/src/features/search/search-state.ts @@ -1,8 +1,8 @@ -import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response'; -import {ExtendedResults} from '../../api/search/search/extended-results'; -import {QuestionsAnswers} from '../../api/search/search/question-answering'; -import {Result} from '../../api/search/search/result'; -import {SearchResponseSuccess} from '../../api/search/search/search-response'; +import {SearchAPIErrorWithStatusCode} from '../../api/search/search-api-error-response.js'; +import {ExtendedResults} from '../../api/search/search/extended-results.js'; +import {QuestionsAnswers} from '../../api/search/search/question-answering.js'; +import {Result} from '../../api/search/search/result.js'; +import {SearchResponseSuccess} from '../../api/search/search/search-response.js'; export interface SearchState { /** The search response. For a full description, refer to {@link https://docs.coveo.com/en/13/cloud-v2-api-reference/search-api#operation/searchUsingPost}*/ diff --git a/packages/headless/src/features/sort-criteria/criteria-parser.test.ts b/packages/headless/src/features/sort-criteria/criteria-parser.test.ts index 9fcace50073..e44f0e2de54 100644 --- a/packages/headless/src/features/sort-criteria/criteria-parser.test.ts +++ b/packages/headless/src/features/sort-criteria/criteria-parser.test.ts @@ -1,3 +1,4 @@ +import {parseCriterionExpression} from './criteria-parser.js'; import { buildRelevanceSortCriterion, buildQueryRankingExpressionSortCriterion, @@ -6,8 +7,7 @@ import { buildFieldSortCriterion, SortOrder, SortBy, -} from './criteria'; -import {parseCriterionExpression} from './criteria-parser'; +} from './criteria.js'; describe('#parseCriterionExpression', () => { it('when criterion expression is empty, throws an error', () => { diff --git a/packages/headless/src/features/sort-criteria/criteria-parser.ts b/packages/headless/src/features/sort-criteria/criteria-parser.ts index 28aea4c2f59..6505b4d4026 100644 --- a/packages/headless/src/features/sort-criteria/criteria-parser.ts +++ b/packages/headless/src/features/sort-criteria/criteria-parser.ts @@ -7,7 +7,7 @@ import { SortCriterion, SortOrder, SortBy, -} from './criteria'; +} from './criteria.js'; function parseCriterion(criterion: { by: string; diff --git a/packages/headless/src/features/sort-criteria/criteria.test.ts b/packages/headless/src/features/sort-criteria/criteria.test.ts index acb363694e1..19c80f599e8 100644 --- a/packages/headless/src/features/sort-criteria/criteria.test.ts +++ b/packages/headless/src/features/sort-criteria/criteria.test.ts @@ -6,7 +6,7 @@ import { buildFieldSortCriterion, buildCriterionExpression, SortOrder, -} from './criteria'; +} from './criteria.js'; describe('sort-criterion functions', () => { it('#buildRelevanceSortCriterion returns the correct value', () => { diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-actions-loader.ts b/packages/headless/src/features/sort-criteria/sort-criteria-actions-loader.ts index d8ac8d586aa..69c09c34e12 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-actions-loader.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-actions-loader.ts @@ -1,11 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {sortCriteriaReducer as sortCriteria} from '../../features/sort-criteria/sort-criteria-slice'; -import {SortCriterion} from './criteria'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {sortCriteriaReducer as sortCriteria} from '../../features/sort-criteria/sort-criteria-slice.js'; +import {SortCriterion} from './criteria.js'; import { registerSortCriterion, updateSortCriterion, -} from './sort-criteria-actions'; +} from './sort-criteria-actions.js'; /** * The sort criteria action creators. diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-actions.ts b/packages/headless/src/features/sort-criteria/sort-criteria-actions.ts index 886bb7bfd3a..687d8efeab5 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-actions.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-actions.ts @@ -1,7 +1,7 @@ import {EnumValue, isArray, SchemaDefinition} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; -import {SortBy, SortCriterion} from './criteria'; +import {validatePayload} from '../../utils/validate-payload.js'; +import {SortBy, SortCriterion} from './criteria.js'; const criterionDefinition = { by: new EnumValue({enum: SortBy, required: true}), diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-analytics-actions.ts b/packages/headless/src/features/sort-criteria/sort-criteria-analytics-actions.ts index 1ed471d6c11..d1389ce75f6 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-analytics-actions.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-analytics-actions.ts @@ -1,10 +1,10 @@ import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; -import {getSortCriteriaInitialState} from './sort-criteria-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; +import {getSortCriteriaInitialState} from './sort-criteria-state.js'; //TODO: KIT-2859 export const logResultsSort = (): LegacySearchAction => diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.test.ts b/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.test.ts index 172a3e0930c..333790fc1a5 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.test.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.test.ts @@ -1,20 +1,20 @@ -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {logResultsSort} from './sort-criteria-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {logResultsSort} from './sort-criteria-insight-analytics-actions.js'; -const mockLogResultsSort = jest.fn(); +const mockLogResultsSort = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logResultsSort: mockLogResultsSort, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.ts b/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.ts index 636a0a4ab10..9ac61c84d56 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-insight-analytics-actions.ts @@ -1,10 +1,10 @@ import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; -import {getSortCriteriaInitialState} from './sort-criteria-state'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; +import {getSortCriteriaInitialState} from './sort-criteria-state.js'; export const logResultsSort = (): InsightAction => makeInsightAnalyticsActionFactory(SearchPageEvents.resultsSort)( diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-slice.test.ts b/packages/headless/src/features/sort-criteria/sort-criteria-slice.test.ts index e9a203d88ab..9e6d56b6f0d 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-slice.test.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-slice.test.ts @@ -1,19 +1,19 @@ -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; import { buildCriterionExpression, buildFieldSortCriterion, buildRelevanceSortCriterion, SortOrder, -} from './criteria'; +} from './criteria.js'; import { registerSortCriterion, updateSortCriterion, -} from './sort-criteria-actions'; -import {sortCriteriaReducer} from './sort-criteria-slice'; +} from './sort-criteria-actions.js'; +import {sortCriteriaReducer} from './sort-criteria-slice.js'; import { getSortCriteriaInitialState, SortCriteriaState, -} from './sort-criteria-state'; +} from './sort-criteria-state.js'; describe('sortCriteria', () => { let state: SortCriteriaState; diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-slice.ts b/packages/headless/src/features/sort-criteria/sort-criteria-slice.ts index 62b9eea0009..a3ab7d1e3f8 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-slice.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-slice.ts @@ -1,12 +1,12 @@ import {createReducer} from '@reduxjs/toolkit'; -import {change} from '../history/history-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {buildCriterionExpression} from './criteria'; +import {change} from '../history/history-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {buildCriterionExpression} from './criteria.js'; import { registerSortCriterion, updateSortCriterion, -} from './sort-criteria-actions'; -import {getSortCriteriaInitialState} from './sort-criteria-state'; +} from './sort-criteria-actions.js'; +import {getSortCriteriaInitialState} from './sort-criteria-state.js'; export const sortCriteriaReducer = createReducer( getSortCriteriaInitialState(), diff --git a/packages/headless/src/features/sort-criteria/sort-criteria-state.ts b/packages/headless/src/features/sort-criteria/sort-criteria-state.ts index 3386b36306e..942430de1d2 100644 --- a/packages/headless/src/features/sort-criteria/sort-criteria-state.ts +++ b/packages/headless/src/features/sort-criteria/sort-criteria-state.ts @@ -1,7 +1,7 @@ import { buildCriterionExpression, buildRelevanceSortCriterion, -} from './criteria'; +} from './criteria.js'; export type SortCriteriaState = string; diff --git a/packages/headless/src/features/sort/sort-actions-loader.ts b/packages/headless/src/features/sort/sort-actions-loader.ts index a60735dc652..77c556471cf 100644 --- a/packages/headless/src/features/sort/sort-actions-loader.ts +++ b/packages/headless/src/features/sort/sort-actions-loader.ts @@ -1,8 +1,8 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {CoreEngine} from '../../app/engine'; -import {sortReducer as sort} from '../../features/sort/sort-slice'; -import {SortCriterion} from './sort'; -import {registerSortCriterion, updateSortCriterion} from './sort-actions'; +import {CoreEngine} from '../../app/engine.js'; +import {sortReducer as sort} from '../../features/sort/sort-slice.js'; +import {registerSortCriterion, updateSortCriterion} from './sort-actions.js'; +import {SortCriterion} from './sort.js'; /** * The sort action creators. diff --git a/packages/headless/src/features/sort/sort-actions.ts b/packages/headless/src/features/sort/sort-actions.ts index 5e1ac207985..78d0e0a95b7 100644 --- a/packages/headless/src/features/sort/sort-actions.ts +++ b/packages/headless/src/features/sort/sort-actions.ts @@ -1,7 +1,7 @@ import {EnumValue, SchemaDefinition} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; -import {SortCriterion, SortBy} from './sort'; +import {validatePayload} from '../../utils/validate-payload.js'; +import {SortCriterion, SortBy} from './sort.js'; const criterionDefinition = { by: new EnumValue({ diff --git a/packages/headless/src/features/sort/sort-slice.ts b/packages/headless/src/features/sort/sort-slice.ts index 773bf041176..aa0ed579c42 100644 --- a/packages/headless/src/features/sort/sort-slice.ts +++ b/packages/headless/src/features/sort/sort-slice.ts @@ -1,6 +1,6 @@ import {createReducer} from '@reduxjs/toolkit'; -import {registerSortCriterion, updateSortCriterion} from './sort-actions'; -import {getSortInitialState} from './sort-state'; +import {registerSortCriterion, updateSortCriterion} from './sort-actions.js'; +import {getSortInitialState} from './sort-state.js'; export const sortReducer = createReducer(getSortInitialState(), (builder) => { builder diff --git a/packages/headless/src/features/sort/sort-state.ts b/packages/headless/src/features/sort/sort-state.ts index fb3abaf5941..4d2baf1f449 100644 --- a/packages/headless/src/features/sort/sort-state.ts +++ b/packages/headless/src/features/sort/sort-state.ts @@ -1,4 +1,4 @@ -import {buildRelevanceSortCriterion, SortCriterion} from './sort'; +import {buildRelevanceSortCriterion, SortCriterion} from './sort.js'; export type SortState = SortCriterion; diff --git a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions-loader.ts b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions-loader.ts index c0aa83be778..85f521fa3f0 100644 --- a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions-loader.ts +++ b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions-loader.ts @@ -1,7 +1,7 @@ import {AsyncThunkAction, PayloadAction} from '@reduxjs/toolkit'; -import {AsyncThunkSearchOptions} from '../../api/search/search-api-client'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../features/standalone-search-box-set/standalone-search-box-set-slice'; +import {AsyncThunkSearchOptions} from '../../api/search/search-api-client.js'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {standaloneSearchBoxSetReducer as standaloneSearchBoxSet} from '../../features/standalone-search-box-set/standalone-search-box-set-slice.js'; import { registerStandaloneSearchBox, RegisterStandaloneSearchBoxActionCreatorPayload, @@ -15,7 +15,7 @@ import { resetStandaloneSearchBox, ResetStandaloneSearchBoxActionCreatorPayload, updateStandaloneSearchBoxRedirectionUrl, -} from './standalone-search-box-set-actions'; +} from './standalone-search-box-set-actions.js'; export type { RegisterStandaloneSearchBoxActionCreatorPayload, diff --git a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions.ts b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions.ts index f61420fb528..a3210c29584 100644 --- a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions.ts +++ b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-actions.ts @@ -1,29 +1,32 @@ import {BooleanValue, StringValue} from '@coveo/bueno'; import {createAction, createAsyncThunk} from '@reduxjs/toolkit'; -import {getVisitorID} from '../../api/analytics/coveo-analytics-utils'; -import {getSearchApiBaseUrl} from '../../api/platform-client'; -import {ExecutionPlan} from '../../api/search/plan/plan-endpoint'; -import {PlanRequest} from '../../api/search/plan/plan-request'; +import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js'; +import {getSearchApiBaseUrl} from '../../api/platform-client.js'; +import {ExecutionPlan} from '../../api/search/plan/plan-endpoint.js'; +import {PlanRequest} from '../../api/search/plan/plan-request.js'; import { AsyncThunkSearchOptions, isErrorResponse, -} from '../../api/search/search-api-client'; -import {NavigatorContext} from '../../app/navigatorContextProvider'; +} from '../../api/search/search-api-client.js'; +import {NavigatorContext} from '../../app/navigatorContextProvider.js'; import { ConfigurationSection, ContextSection, PipelineSection, QuerySection, SearchHubSection, -} from '../../state/state-sections'; +} from '../../state/state-sections.js'; import { requiredNonEmptyString, validatePayload, -} from '../../utils/validate-payload'; -import {CustomAction, makeAnalyticsAction} from '../analytics/analytics-utils'; -import {fromAnalyticsStateToAnalyticsParams} from '../configuration/analytics-params'; -import {fromAnalyticsStateToAnalyticsParams as legacyFromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params'; -import {OmniboxSuggestionMetadata} from '../query-suggest/query-suggest-analytics-actions'; +} from '../../utils/validate-payload.js'; +import { + CustomAction, + makeAnalyticsAction, +} from '../analytics/analytics-utils.js'; +import {fromAnalyticsStateToAnalyticsParams} from '../configuration/analytics-params.js'; +import {fromAnalyticsStateToAnalyticsParams as legacyFromAnalyticsStateToAnalyticsParams} from '../configuration/legacy-analytics-params.js'; +import {OmniboxSuggestionMetadata} from '../query-suggest/query-suggest-analytics-actions.js'; export interface RegisterStandaloneSearchBoxActionCreatorPayload { /** diff --git a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.test.ts b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.test.ts index f673afa32ba..62449182d00 100644 --- a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.test.ts +++ b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.test.ts @@ -1,5 +1,5 @@ -import {buildMockOmniboxSuggestionMetadata} from '../../test/mock-omnibox-suggestion-metadata'; -import {buildMockStandaloneSearchBoxEntry} from '../../test/mock-standalone-search-box-entry'; +import {buildMockOmniboxSuggestionMetadata} from '../../test/mock-omnibox-suggestion-metadata.js'; +import {buildMockStandaloneSearchBoxEntry} from '../../test/mock-standalone-search-box-entry.js'; import { fetchRedirectUrl, registerStandaloneSearchBox, @@ -7,9 +7,9 @@ import { updateAnalyticsToSearchFromLink, resetStandaloneSearchBox, updateStandaloneSearchBoxRedirectionUrl, -} from './standalone-search-box-set-actions'; -import {standaloneSearchBoxSetReducer} from './standalone-search-box-set-slice'; -import {StandaloneSearchBoxSetState} from './standalone-search-box-set-state'; +} from './standalone-search-box-set-actions.js'; +import {standaloneSearchBoxSetReducer} from './standalone-search-box-set-slice.js'; +import {StandaloneSearchBoxSetState} from './standalone-search-box-set-state.js'; describe('standalone search box slice', () => { const id = '1'; diff --git a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.ts b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.ts index 9b05de9eeaa..2effa131c03 100644 --- a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.ts +++ b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-slice.ts @@ -6,11 +6,11 @@ import { updateAnalyticsToOmniboxFromLink, updateAnalyticsToSearchFromLink, updateStandaloneSearchBoxRedirectionUrl, -} from './standalone-search-box-set-actions'; +} from './standalone-search-box-set-actions.js'; import { getStandaloneSearchBoxSetInitialState, StandaloneSearchBoxEntry, -} from './standalone-search-box-set-state'; +} from './standalone-search-box-set-state.js'; export const standaloneSearchBoxSetReducer = createReducer( getStandaloneSearchBoxSetInitialState(), diff --git a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-state.ts b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-state.ts index 20f6c51d4f0..77072b47deb 100644 --- a/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-state.ts +++ b/packages/headless/src/features/standalone-search-box-set/standalone-search-box-set-state.ts @@ -1,4 +1,4 @@ -import {OmniboxSuggestionMetadata} from '../query-suggest/query-suggest-analytics-actions'; +import {OmniboxSuggestionMetadata} from '../query-suggest/query-suggest-analytics-actions.js'; export type StandaloneSearchBoxSetState = Record< string, diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-actions-loader.ts b/packages/headless/src/features/static-filter-set/static-filter-set-actions-loader.ts index 0b26e9a6b8e..4e8e5399edb 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-actions-loader.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-actions-loader.ts @@ -1,6 +1,6 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {staticFilterSetReducer as staticFilterSet} from '../../features/static-filter-set/static-filter-set-slice.js'; import { registerStaticFilter, RegisterStaticFilterActionCreatorPayload, @@ -8,7 +8,7 @@ import { ToggleSelectStaticFilterValueActionCreatorPayload, deselectAllStaticFilterValues, toggleExcludeStaticFilterValue, -} from './static-filter-set-actions'; +} from './static-filter-set-actions.js'; export type { RegisterStaticFilterActionCreatorPayload, diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-actions.test.ts b/packages/headless/src/features/static-filter-set/static-filter-set-actions.test.ts index 322ea4e12ad..61d8cf69e9c 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-actions.test.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-actions.test.ts @@ -1,20 +1,20 @@ -import {ThunkExtraArguments} from '../../app/thunk-extra-arguments'; -import {buildMockInsightEngine} from '../../test/mock-engine-v2'; -import {buildMockInsightState} from '../../test/mock-insight-state'; -import {getConfigurationInitialState} from '../configuration/configuration-state'; -import {logInsightStaticFilterDeselect} from './static-filter-set-insight-analytics-actions'; +import {ThunkExtraArguments} from '../../app/thunk-extra-arguments.js'; +import {buildMockInsightEngine} from '../../test/mock-engine-v2.js'; +import {buildMockInsightState} from '../../test/mock-insight-state.js'; +import {getConfigurationInitialState} from '../configuration/configuration-state.js'; +import {logInsightStaticFilterDeselect} from './static-filter-set-insight-analytics-actions.js'; -const mockOriginalStaticFilterDeselect = jest.fn(); +const mockOriginalStaticFilterDeselect = vi.fn(); -jest.mock('coveo.analytics', () => { - const mockCoveoInsightClient = jest.fn(() => ({ +vi.mock('coveo.analytics', () => { + const mockCoveoInsightClient = vi.fn(() => ({ disable: () => {}, logStaticFilterDeselect: mockOriginalStaticFilterDeselect, })); return { CoveoInsightClient: mockCoveoInsightClient, - history: {HistoryStore: jest.fn()}, + history: {HistoryStore: vi.fn()}, }; }); diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-actions.ts b/packages/headless/src/features/static-filter-set/static-filter-set-actions.ts index 30436a74ba6..5c881eaac95 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-actions.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-actions.ts @@ -1,17 +1,17 @@ import {createAction} from '@reduxjs/toolkit'; -import {validatePayload} from '../../utils/validate-payload'; +import {validatePayload} from '../../utils/validate-payload.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; import { staticFilterIdSchema, staticFilterValueSchema, staticFilterValuesSchema, -} from './static-filter-set-schema'; -import {StaticFilterValue} from './static-filter-set-state'; +} from './static-filter-set-schema.js'; +import {StaticFilterValue} from './static-filter-set-state.js'; export interface RegisterStaticFilterActionCreatorPayload { /** diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-insight-analytics-actions.ts b/packages/headless/src/features/static-filter-set/static-filter-set-insight-analytics-actions.ts index 8674731f192..9d4b02e17c3 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-insight-analytics-actions.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-insight-analytics-actions.ts @@ -1,10 +1,10 @@ import { InsightAction, makeInsightAnalyticsActionFactory, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state'; -import {LogStaticFilterToggleValueActionCreatorPayload} from './static-filter-set-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {getCaseContextAnalyticsMetadata} from '../case-context/case-context-state.js'; +import {LogStaticFilterToggleValueActionCreatorPayload} from './static-filter-set-actions.js'; export const logInsightStaticFilterDeselect = ( metadata: LogStaticFilterToggleValueActionCreatorPayload diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-schema.ts b/packages/headless/src/features/static-filter-set/static-filter-set-schema.ts index 3beecf92e2e..48a38de8e7a 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-schema.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-schema.ts @@ -2,8 +2,8 @@ import {ArrayValue, RecordValue, StringValue} from '@coveo/bueno'; import { requiredEmptyAllowedString, requiredNonEmptyString, -} from '../../utils/validate-payload'; -import {StaticFilterValueState} from './static-filter-set-state'; +} from '../../utils/validate-payload.js'; +import {StaticFilterValueState} from './static-filter-set-state.js'; export const staticFilterIdSchema = requiredNonEmptyString; diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-slice.test.ts b/packages/headless/src/features/static-filter-set/static-filter-set-slice.test.ts index 84e71cefcb5..ef6b6b10677 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-slice.test.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-slice.test.ts @@ -1,17 +1,17 @@ -import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice'; -import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value'; -import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; +import {buildMockStaticFilterSlice} from '../../test/mock-static-filter-slice.js'; +import {buildMockStaticFilterValue} from '../../test/mock-static-filter-value.js'; +import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; import { deselectAllStaticFilterValues, registerStaticFilter, toggleSelectStaticFilterValue, -} from './static-filter-set-actions'; -import {staticFilterSetReducer} from './static-filter-set-slice'; +} from './static-filter-set-actions.js'; +import {staticFilterSetReducer} from './static-filter-set-slice.js'; import { StaticFilterValue, StaticFilterValueState, -} from './static-filter-set-state'; +} from './static-filter-set-state.js'; describe('static-filter-set slice', () => { it('initializes correctly', () => { diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-slice.ts b/packages/headless/src/features/static-filter-set/static-filter-set-slice.ts index 2d938942eda..77a6c5a2dac 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-slice.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-slice.ts @@ -1,13 +1,13 @@ import {createReducer} from '@reduxjs/toolkit'; -import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; +import {deselectAllBreadcrumbs} from '../breadcrumb/breadcrumb-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; import { deselectAllStaticFilterValues, registerStaticFilter, toggleExcludeStaticFilterValue, toggleSelectStaticFilterValue, -} from './static-filter-set-actions'; -import {getStaticFilterSetInitialState} from './static-filter-set-state'; +} from './static-filter-set-actions.js'; +import {getStaticFilterSetInitialState} from './static-filter-set-state.js'; export const staticFilterSetReducer = createReducer( getStaticFilterSetInitialState(), diff --git a/packages/headless/src/features/static-filter-set/static-filter-set-state.ts b/packages/headless/src/features/static-filter-set/static-filter-set-state.ts index f31b0d724cd..c582633d225 100644 --- a/packages/headless/src/features/static-filter-set/static-filter-set-state.ts +++ b/packages/headless/src/features/static-filter-set/static-filter-set-state.ts @@ -1,4 +1,4 @@ -import {FacetValueState} from '../facets/facet-api/value'; +import {FacetValueState} from '../facets/facet-api/value.js'; export type StaticFilterSetState = Record; diff --git a/packages/headless/src/features/tab-set/tab-set-actions-loader.ts b/packages/headless/src/features/tab-set/tab-set-actions-loader.ts index 095971582d1..1ec0adab11d 100644 --- a/packages/headless/src/features/tab-set/tab-set-actions-loader.ts +++ b/packages/headless/src/features/tab-set/tab-set-actions-loader.ts @@ -1,11 +1,11 @@ import {PayloadAction} from '@reduxjs/toolkit'; -import {SearchEngine} from '../../app/search-engine/search-engine'; -import {tabSetReducer as tabSet} from '../../features/tab-set/tab-set-slice'; +import {SearchEngine} from '../../app/search-engine/search-engine.js'; +import {tabSetReducer as tabSet} from '../../features/tab-set/tab-set-slice.js'; import { registerTab, RegisterTabActionCreatorPayload, updateActiveTab, -} from './tab-set-actions'; +} from './tab-set-actions.js'; export type {RegisterTabActionCreatorPayload}; diff --git a/packages/headless/src/features/tab-set/tab-set-actions.ts b/packages/headless/src/features/tab-set/tab-set-actions.ts index 38ee536800e..78c60d95644 100644 --- a/packages/headless/src/features/tab-set/tab-set-actions.ts +++ b/packages/headless/src/features/tab-set/tab-set-actions.ts @@ -4,7 +4,7 @@ import { requiredEmptyAllowedString, requiredNonEmptyString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; export interface RegisterTabActionCreatorPayload { /** diff --git a/packages/headless/src/features/tab-set/tab-set-selectors.ts b/packages/headless/src/features/tab-set/tab-set-selectors.ts index 2329eb59b85..fde0a9ac6eb 100644 --- a/packages/headless/src/features/tab-set/tab-set-selectors.ts +++ b/packages/headless/src/features/tab-set/tab-set-selectors.ts @@ -1,5 +1,5 @@ import {createSelector} from '@reduxjs/toolkit'; -import {TabSetState} from './tab-set-state'; +import {TabSetState} from './tab-set-state.js'; export const selectActiveTab = createSelector( (state?: TabSetState) => state, diff --git a/packages/headless/src/features/tab-set/tab-set-slice.test.ts b/packages/headless/src/features/tab-set/tab-set-slice.test.ts index 4e2d11a72ff..8d344b6e7af 100644 --- a/packages/headless/src/features/tab-set/tab-set-slice.test.ts +++ b/packages/headless/src/features/tab-set/tab-set-slice.test.ts @@ -1,9 +1,9 @@ -import {buildMockTabSlice} from '../../test/mock-tab-state'; -import {change} from '../history/history-actions'; -import {getHistoryInitialState} from '../history/history-state'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {registerTab, updateActiveTab} from './tab-set-actions'; -import {tabSetReducer} from './tab-set-slice'; +import {buildMockTabSlice} from '../../test/mock-tab-state.js'; +import {change} from '../history/history-actions.js'; +import {getHistoryInitialState} from '../history/history-state.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {registerTab, updateActiveTab} from './tab-set-actions.js'; +import {tabSetReducer} from './tab-set-slice.js'; describe('tab set slice', () => { it('initializes state correctly', () => { diff --git a/packages/headless/src/features/tab-set/tab-set-slice.ts b/packages/headless/src/features/tab-set/tab-set-slice.ts index f2ecae6a00a..c2b2cfad06c 100644 --- a/packages/headless/src/features/tab-set/tab-set-slice.ts +++ b/packages/headless/src/features/tab-set/tab-set-slice.ts @@ -1,8 +1,8 @@ import {createReducer} from '@reduxjs/toolkit'; -import {change} from '../history/history-actions'; -import {restoreSearchParameters} from '../search-parameters/search-parameter-actions'; -import {registerTab, updateActiveTab} from './tab-set-actions'; -import {getTabSetInitialState, TabSetState} from './tab-set-state'; +import {change} from '../history/history-actions.js'; +import {restoreSearchParameters} from '../search-parameters/search-parameter-actions.js'; +import {registerTab, updateActiveTab} from './tab-set-actions.js'; +import {getTabSetInitialState, TabSetState} from './tab-set-state.js'; export const tabSetReducer = createReducer( getTabSetInitialState(), diff --git a/packages/headless/src/features/templates/templates-manager.ts b/packages/headless/src/features/templates/templates-manager.ts index 781045021ce..0c1f81902ab 100644 --- a/packages/headless/src/features/templates/templates-manager.ts +++ b/packages/headless/src/features/templates/templates-manager.ts @@ -5,7 +5,7 @@ import { SchemaValidationError, Value, } from '@coveo/bueno'; -import {requiredNonEmptyString} from '../../utils/validate-payload'; +import {requiredNonEmptyString} from '../../utils/validate-payload.js'; export type TemplateCondition = (item: ItemType) => boolean; diff --git a/packages/headless/src/features/triggers/trigger-analytics-actions.ts b/packages/headless/src/features/triggers/trigger-analytics-actions.ts index b802c586b7a..ec0edc578b1 100644 --- a/packages/headless/src/features/triggers/trigger-analytics-actions.ts +++ b/packages/headless/src/features/triggers/trigger-analytics-actions.ts @@ -2,13 +2,13 @@ import {RecordValue} from '@coveo/bueno'; import { requiredEmptyAllowedString, validatePayload, -} from '../../utils/validate-payload'; +} from '../../utils/validate-payload.js'; import { makeAnalyticsAction, LegacySearchAction, -} from '../analytics/analytics-utils'; -import {SearchPageEvents} from '../analytics/search-action-cause'; -import {SearchAction} from '../search/search-actions'; +} from '../analytics/analytics-utils.js'; +import {SearchPageEvents} from '../analytics/search-action-cause.js'; +import {SearchAction} from '../search/search-actions.js'; export interface LogUndoTriggerQueryActionCreatorPayload { /** diff --git a/packages/headless/src/features/triggers/triggers-actions.ts b/packages/headless/src/features/triggers/triggers-actions.ts index e793a68a90b..bf0f7220164 100644 --- a/packages/headless/src/features/triggers/triggers-actions.ts +++ b/packages/headless/src/features/triggers/triggers-actions.ts @@ -1,6 +1,6 @@ import {RecordValue, StringValue} from '@coveo/bueno'; import {createAction} from '@reduxjs/toolkit'; -import {nonEmptyString, validatePayload} from '../../utils/validate-payload'; +import {nonEmptyString, validatePayload} from '../../utils/validate-payload.js'; export interface ApplyQueryTriggerModificationPayload { originalQuery: string; diff --git a/packages/headless/src/features/triggers/triggers-slice-functions.test.ts b/packages/headless/src/features/triggers/triggers-slice-functions.test.ts index 54c2e66e883..7d61d106718 100644 --- a/packages/headless/src/features/triggers/triggers-slice-functions.test.ts +++ b/packages/headless/src/features/triggers/triggers-slice-functions.test.ts @@ -1,15 +1,15 @@ -import {Trigger} from '../../api/common/trigger'; -import {buildMockExecuteTrigger} from '../../test/mock-trigger-execute'; -import {buildMockNotifyTrigger} from '../../test/mock-trigger-notify'; -import {buildMockQueryTrigger} from '../../test/mock-trigger-query'; -import {buildMockRedirectTrigger} from '../../test/mock-trigger-redirect'; +import {Trigger} from '../../api/common/trigger.js'; +import {buildMockExecuteTrigger} from '../../test/mock-trigger-execute.js'; +import {buildMockNotifyTrigger} from '../../test/mock-trigger-notify.js'; +import {buildMockQueryTrigger} from '../../test/mock-trigger-query.js'; +import {buildMockRedirectTrigger} from '../../test/mock-trigger-redirect.js'; import { handleApplyQueryTriggerModification, handleFetchItemsFulfilled, handleFetchItemsPending, handleUpdateIgnoreQueryTrigger, -} from './triggers-slice-functions'; -import {TriggerState, getTriggerInitialState} from './triggers-state'; +} from './triggers-slice-functions.js'; +import {TriggerState, getTriggerInitialState} from './triggers-state.js'; describe('triggers slice functions', () => { let state: TriggerState; diff --git a/packages/headless/src/features/triggers/triggers-slice-functions.ts b/packages/headless/src/features/triggers/triggers-slice-functions.ts index f2911c6f626..0a521a38f3d 100644 --- a/packages/headless/src/features/triggers/triggers-slice-functions.ts +++ b/packages/headless/src/features/triggers/triggers-slice-functions.ts @@ -1,6 +1,6 @@ -import {Trigger} from '../../api/common/trigger'; -import {ApplyQueryTriggerModificationPayload} from './triggers-actions'; -import {FunctionExecutionTrigger, TriggerState} from './triggers-state'; +import {Trigger} from '../../api/common/trigger.js'; +import {ApplyQueryTriggerModificationPayload} from './triggers-actions.js'; +import {FunctionExecutionTrigger, TriggerState} from './triggers-state.js'; export function handleFetchItemsPending(state: TriggerState) { state.query = ''; diff --git a/packages/headless/src/features/triggers/triggers-slice.test.ts b/packages/headless/src/features/triggers/triggers-slice.test.ts index 0c6b3be1111..b50c5dd09e0 100644 --- a/packages/headless/src/features/triggers/triggers-slice.test.ts +++ b/packages/headless/src/features/triggers/triggers-slice.test.ts @@ -1,21 +1,24 @@ -import {buildMockSearch} from '../../test/mock-search'; -import {buildMockExecuteTrigger} from '../../test/mock-trigger-execute'; -import {buildMockNotifyTrigger} from '../../test/mock-trigger-notify'; -import {buildMockQueryTrigger} from '../../test/mock-trigger-query'; -import {buildMockRedirectTrigger} from '../../test/mock-trigger-redirect'; -import {TransitiveSearchAction, executeSearch} from '../search/search-actions'; +import {buildMockSearch} from '../../test/mock-search.js'; +import {buildMockExecuteTrigger} from '../../test/mock-trigger-execute.js'; +import {buildMockNotifyTrigger} from '../../test/mock-trigger-notify.js'; +import {buildMockQueryTrigger} from '../../test/mock-trigger-query.js'; +import {buildMockRedirectTrigger} from '../../test/mock-trigger-redirect.js'; +import { + TransitiveSearchAction, + executeSearch, +} from '../search/search-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from './triggers-actions'; -import {triggerReducer} from './triggers-slice'; +} from './triggers-actions.js'; import { handleApplyQueryTriggerModification, handleFetchItemsFulfilled, handleFetchItemsPending, handleUpdateIgnoreQueryTrigger, -} from './triggers-slice-functions'; -import {TriggerState, getTriggerInitialState} from './triggers-state'; +} from './triggers-slice-functions.js'; +import {triggerReducer} from './triggers-slice.js'; +import {TriggerState, getTriggerInitialState} from './triggers-state.js'; describe('triggers slice', () => { let initialState: TriggerState; diff --git a/packages/headless/src/features/triggers/triggers-slice.ts b/packages/headless/src/features/triggers/triggers-slice.ts index c3c9290e0a0..a2c0ed1d16e 100644 --- a/packages/headless/src/features/triggers/triggers-slice.ts +++ b/packages/headless/src/features/triggers/triggers-slice.ts @@ -1,16 +1,16 @@ import {createReducer} from '@reduxjs/toolkit'; -import {executeSearch} from '../search/search-actions'; +import {executeSearch} from '../search/search-actions.js'; import { applyQueryTriggerModification, updateIgnoreQueryTrigger, -} from './triggers-actions'; +} from './triggers-actions.js'; import { handleApplyQueryTriggerModification, handleFetchItemsFulfilled, handleFetchItemsPending, handleUpdateIgnoreQueryTrigger, -} from './triggers-slice-functions'; -import {getTriggerInitialState} from './triggers-state'; +} from './triggers-slice-functions.js'; +import {getTriggerInitialState} from './triggers-state.js'; export const triggerReducer = createReducer( getTriggerInitialState(), diff --git a/packages/headless/src/features/triggers/triggers-state.ts b/packages/headless/src/features/triggers/triggers-state.ts index 52f6e79689a..0ded404818a 100644 --- a/packages/headless/src/features/triggers/triggers-state.ts +++ b/packages/headless/src/features/triggers/triggers-state.ts @@ -1,4 +1,4 @@ -import {ExecuteTriggerParams} from '../../api/common/trigger'; +import {ExecuteTriggerParams} from '../../api/common/trigger.js'; /** * The name of a function to execute and its parameters. diff --git a/packages/headless/src/index.ts b/packages/headless/src/index.ts index 1702000bad5..3f58359a33e 100644 --- a/packages/headless/src/index.ts +++ b/packages/headless/src/index.ts @@ -1,4 +1,4 @@ -import * as HighlightUtils from './utils/highlight'; +import * as HighlightUtils from './utils/highlight.js'; // 3rd Party Libraries export type {Unsubscribe, Middleware} from '@reduxjs/toolkit'; @@ -11,35 +11,35 @@ export type { SearchEngineOptions, SearchEngineConfiguration, SearchConfigurationOptions, -} from './app/search-engine/search-engine'; +} from './app/search-engine/search-engine.js'; export { buildSearchEngine, getSampleSearchEngineConfiguration, -} from './app/search-engine/search-engine'; +} from './app/search-engine/search-engine.js'; -export type {CoreEngine, ExternalEngineOptions} from './app/engine'; +export type {CoreEngine, ExternalEngineOptions} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; -export type {LoggerOptions} from './app/logger'; +} from './app/engine-configuration.js'; +export type {LoggerOptions} from './app/logger.js'; -export type {LogLevel} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +export type {LogLevel} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; // State export type { SearchParametersState, SearchAppState, -} from './state/search-app-state'; +} from './state/search-app-state.js'; //#region Controllers export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; -export {buildController} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; +export {buildController} from './controllers/controller/headless-controller.js'; export type { RelevanceInspectorInitialState, @@ -56,8 +56,8 @@ export type { RankingInformation, TermWeightReport, SecurityIdentity, -} from './controllers/relevance-inspector/headless-relevance-inspector'; -export {buildRelevanceInspector} from './controllers/relevance-inspector/headless-relevance-inspector'; +} from './controllers/relevance-inspector/headless-relevance-inspector.js'; +export {buildRelevanceInspector} from './controllers/relevance-inspector/headless-relevance-inspector.js'; export type { Context, @@ -66,15 +66,15 @@ export type { ContextState, ContextValue, ContextPayload, -} from './controllers/context/headless-context'; -export {buildContext} from './controllers/context/headless-context'; +} from './controllers/context/headless-context.js'; +export {buildContext} from './controllers/context/headless-context.js'; export type { DictionaryFieldContext, DictionaryFieldContextState, DictionaryFieldContextPayload, -} from './controllers/dictionary-field-context/headless-dictionary-field-context'; -export {buildDictionaryFieldContext} from './controllers/dictionary-field-context/headless-dictionary-field-context'; +} from './controllers/dictionary-field-context/headless-dictionary-field-context.js'; +export {buildDictionaryFieldContext} from './controllers/dictionary-field-context/headless-dictionary-field-context.js'; export type { DidYouMean, @@ -83,8 +83,8 @@ export type { WordCorrection, DidYouMeanProps, DidYouMeanOptions, -} from './controllers/did-you-mean/headless-did-you-mean'; -export {buildDidYouMean} from './controllers/did-you-mean/headless-did-you-mean'; +} from './controllers/did-you-mean/headless-did-you-mean.js'; +export {buildDidYouMean} from './controllers/did-you-mean/headless-did-you-mean.js'; export type { CategoryFacetOptions, @@ -97,8 +97,8 @@ export type { CategoryFacetSearchResult, CoreCategoryFacet, CoreCategoryFacetState, -} from './controllers/facets/category-facet/headless-category-facet'; -export {buildCategoryFacet} from './controllers/facets/category-facet/headless-category-facet'; +} from './controllers/facets/category-facet/headless-category-facet.js'; +export {buildCategoryFacet} from './controllers/facets/category-facet/headless-category-facet.js'; export type { FacetOptions, @@ -113,8 +113,8 @@ export type { SpecificFacetSearchResult, CoreFacet, CoreFacetState, -} from './controllers/facets/facet/headless-facet'; -export {buildFacet} from './controllers/facets/facet/headless-facet'; +} from './controllers/facets/facet/headless-facet.js'; +export {buildFacet} from './controllers/facets/facet/headless-facet.js'; export type { DateRangeOptions, @@ -123,11 +123,11 @@ export type { DateFacetProps, DateFacetState, DateFacet, -} from './controllers/facets/range-facet/date-facet/headless-date-facet'; +} from './controllers/facets/range-facet/date-facet/headless-date-facet.js'; export { buildDateRange, buildDateFacet, -} from './controllers/facets/range-facet/date-facet/headless-date-facet'; +} from './controllers/facets/range-facet/date-facet/headless-date-facet.js'; export type { NumericRangeOptions, @@ -135,11 +135,11 @@ export type { NumericFacetProps, NumericFacetState, NumericFacet, -} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet'; +} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.js'; export { buildNumericRange, buildNumericFacet, -} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet'; +} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.js'; export type { NumericFilter, @@ -148,8 +148,8 @@ export type { NumericFilterRange, NumericFilterState, NumericFilterInitialState, -} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter'; -export {buildNumericFilter} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter'; +} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.js'; +export {buildNumericFilter} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.js'; export type { DateFilter, @@ -158,14 +158,14 @@ export type { DateFilterRange, DateFilterState, DateFilterInitialState, -} from './controllers/facets/range-facet/date-facet/headless-date-filter'; -export {buildDateFilter} from './controllers/facets/range-facet/date-facet/headless-date-filter'; +} from './controllers/facets/range-facet/date-facet/headless-date-filter.js'; +export {buildDateFilter} from './controllers/facets/range-facet/date-facet/headless-date-filter.js'; export type { HistoryManager, HistoryManagerState, -} from './controllers/history-manager/headless-history-manager'; -export {buildHistoryManager} from './controllers/history-manager/headless-history-manager'; +} from './controllers/history-manager/headless-history-manager.js'; +export {buildHistoryManager} from './controllers/history-manager/headless-history-manager.js'; export type { PagerInitialState, @@ -173,50 +173,50 @@ export type { PagerProps, PagerState, Pager, -} from './controllers/pager/headless-pager'; -export {buildPager} from './controllers/pager/headless-pager'; +} from './controllers/pager/headless-pager.js'; +export {buildPager} from './controllers/pager/headless-pager.js'; export type { QueryError, QueryErrorState, -} from './controllers/query-error/headless-query-error'; -export {buildQueryError} from './controllers/query-error/headless-query-error'; +} from './controllers/query-error/headless-query-error.js'; +export {buildQueryError} from './controllers/query-error/headless-query-error.js'; export type { QuerySummaryState, QuerySummary, -} from './controllers/query-summary/headless-query-summary'; -export {buildQuerySummary} from './controllers/query-summary/headless-query-summary'; +} from './controllers/query-summary/headless-query-summary.js'; +export {buildQuerySummary} from './controllers/query-summary/headless-query-summary.js'; export type { ResultListProps, ResultListOptions, ResultListState, ResultList, -} from './controllers/result-list/headless-result-list'; -export {buildResultList} from './controllers/result-list/headless-result-list'; +} from './controllers/result-list/headless-result-list.js'; +export {buildResultList} from './controllers/result-list/headless-result-list.js'; export type { InteractiveResultOptions, InteractiveResultProps, InteractiveResult, -} from './controllers/result-list/headless-interactive-result'; -export {buildInteractiveResult} from './controllers/result-list/headless-interactive-result'; +} from './controllers/result-list/headless-interactive-result.js'; +export {buildInteractiveResult} from './controllers/result-list/headless-interactive-result.js'; export type { InteractiveInstantResultOptions, InteractiveInstantResultProps, InteractiveInstantResult, -} from './controllers/instant-results/headless-interactive-instant-result'; -export {buildInteractiveInstantResult} from './controllers/instant-results/headless-interactive-instant-result'; +} from './controllers/instant-results/headless-interactive-instant-result.js'; +export {buildInteractiveInstantResult} from './controllers/instant-results/headless-interactive-instant-result.js'; export type { ResultsPerPageInitialState, ResultsPerPageProps, ResultsPerPageState, ResultsPerPage, -} from './controllers/results-per-page/headless-results-per-page'; -export {buildResultsPerPage} from './controllers/results-per-page/headless-results-per-page'; +} from './controllers/results-per-page/headless-results-per-page.js'; +export {buildResultsPerPage} from './controllers/results-per-page/headless-results-per-page.js'; export type { SearchBoxOptions, @@ -226,24 +226,24 @@ export type { Suggestion, SuggestionHighlightingOptions, Delimiters, -} from './controllers/search-box/headless-search-box'; -export {buildSearchBox} from './controllers/search-box/headless-search-box'; +} from './controllers/search-box/headless-search-box.js'; +export {buildSearchBox} from './controllers/search-box/headless-search-box.js'; export type { InstantResults, InstantResultsState, InstantResultProps, InstantResultOptions, -} from './controllers/instant-results/instant-results'; -export {buildInstantResults} from './controllers/instant-results/instant-results'; +} from './controllers/instant-results/instant-results.js'; +export {buildInstantResults} from './controllers/instant-results/instant-results.js'; export type { SortInitialState, SortProps, SortState, Sort, -} from './controllers/sort/headless-sort'; -export {buildSort} from './controllers/sort/headless-sort'; +} from './controllers/sort/headless-sort.js'; +export {buildSort} from './controllers/sort/headless-sort.js'; export type { StaticFilterValueOptions, @@ -253,11 +253,11 @@ export type { StaticFilterState, StaticFilterValue, StaticFilterValueState, -} from './controllers/static-filter/headless-static-filter'; +} from './controllers/static-filter/headless-static-filter.js'; export { buildStaticFilterValue, buildStaticFilter, -} from './controllers/static-filter/headless-static-filter'; +} from './controllers/static-filter/headless-static-filter.js'; export type { TabInitialState, @@ -265,21 +265,21 @@ export type { TabProps, TabState, Tab, -} from './controllers/tab/headless-tab'; -export {buildTab} from './controllers/tab/headless-tab'; +} from './controllers/tab/headless-tab.js'; +export {buildTab} from './controllers/tab/headless-tab.js'; export type { TabManagerState, TabManager, -} from './controllers/tab-manager/headless-tab-manager'; -export {buildTabManager} from './controllers/tab-manager/headless-tab-manager'; +} from './controllers/tab-manager/headless-tab-manager.js'; +export {buildTabManager} from './controllers/tab-manager/headless-tab-manager.js'; export type { FacetManagerPayload, FacetManagerState, FacetManager, -} from './controllers/facet-manager/headless-facet-manager'; -export {buildFacetManager} from './controllers/facet-manager/headless-facet-manager'; +} from './controllers/facet-manager/headless-facet-manager.js'; +export {buildFacetManager} from './controllers/facet-manager/headless-facet-manager.js'; export type { NumericFacetBreadcrumb, @@ -295,8 +295,8 @@ export type { AutomaticFacetBreadcrumb, CoreBreadcrumbManager, CoreBreadcrumbManagerState, -} from './controllers/breadcrumb-manager/headless-breadcrumb-manager'; -export {buildBreadcrumbManager} from './controllers/breadcrumb-manager/headless-breadcrumb-manager'; +} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.js'; +export {buildBreadcrumbManager} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.js'; export type { StandaloneSearchBoxOptions, @@ -304,8 +304,8 @@ export type { StandaloneSearchBoxProps, StandaloneSearchBoxState, StandaloneSearchBox, -} from './controllers/standalone-search-box/headless-standalone-search-box'; -export {buildStandaloneSearchBox} from './controllers/standalone-search-box/headless-standalone-search-box'; +} from './controllers/standalone-search-box/headless-standalone-search-box.js'; +export {buildStandaloneSearchBox} from './controllers/standalone-search-box/headless-standalone-search-box.js'; export type { SearchParameterManagerProps, @@ -313,24 +313,24 @@ export type { SearchParameterManagerState, SearchParameterManager, SearchParameters, -} from './controllers/search-parameter-manager/headless-search-parameter-manager'; -export {buildSearchParameterManager} from './controllers/search-parameter-manager/headless-search-parameter-manager'; +} from './controllers/search-parameter-manager/headless-search-parameter-manager.js'; +export {buildSearchParameterManager} from './controllers/search-parameter-manager/headless-search-parameter-manager.js'; export type { UrlManagerProps, UrlManagerInitialState, UrlManagerState, UrlManager, -} from './controllers/url-manager/headless-url-manager'; -export {buildUrlManager} from './controllers/url-manager/headless-url-manager'; +} from './controllers/url-manager/headless-url-manager.js'; +export {buildUrlManager} from './controllers/url-manager/headless-url-manager.js'; export type { SearchStatus, SearchStatusState, -} from './controllers/search-status/headless-search-status'; -export {buildSearchStatus} from './controllers/search-status/headless-search-status'; +} from './controllers/search-status/headless-search-status.js'; +export {buildSearchStatus} from './controllers/search-status/headless-search-status.js'; -export type {ErrorPayload} from './controllers/controller/error-payload'; +export type {ErrorPayload} from './controllers/controller/error-payload.js'; export type { Quickview, @@ -339,8 +339,8 @@ export type { QuickviewState, CoreQuickviewState, CoreQuickview, -} from './controllers/quickview/headless-quickview'; -export {buildQuickview} from './controllers/quickview/headless-quickview'; +} from './controllers/quickview/headless-quickview.js'; +export {buildQuickview} from './controllers/quickview/headless-quickview.js'; export type { FoldingOptions, @@ -350,34 +350,34 @@ export type { FoldedResultListProps, FoldedResultList, FoldedResultListState, -} from './controllers/folded-result-list/headless-folded-result-list'; -export {buildFoldedResultList} from './controllers/folded-result-list/headless-folded-result-list'; +} from './controllers/folded-result-list/headless-folded-result-list.js'; +export {buildFoldedResultList} from './controllers/folded-result-list/headless-folded-result-list.js'; export type { RedirectionTrigger, RedirectionTriggerState, -} from './controllers/core/triggers/headless-core-redirection-trigger'; -export {buildRedirectionTrigger} from './controllers/triggers/headless-redirection-trigger'; +} from './controllers/core/triggers/headless-core-redirection-trigger.js'; +export {buildRedirectionTrigger} from './controllers/triggers/headless-redirection-trigger.js'; export type { QueryTrigger, QueryTriggerState, -} from './controllers/core/triggers/headless-core-query-trigger'; -export {buildQueryTrigger} from './controllers/triggers/headless-query-trigger'; +} from './controllers/core/triggers/headless-core-query-trigger.js'; +export {buildQueryTrigger} from './controllers/triggers/headless-query-trigger.js'; export type { ExecuteTrigger, ExecuteTriggerState, -} from './controllers/triggers/headless-execute-trigger'; -export {buildExecuteTrigger} from './controllers/triggers/headless-execute-trigger'; +} from './controllers/triggers/headless-execute-trigger.js'; +export {buildExecuteTrigger} from './controllers/triggers/headless-execute-trigger.js'; -export type {ExecuteTriggerParams} from './api/common/trigger'; +export type {ExecuteTriggerParams} from './api/common/trigger.js'; export type { NotifyTrigger, NotifyTriggerState, -} from './controllers/core/triggers/headless-core-notify-trigger'; -export {buildNotifyTrigger} from './controllers/triggers/headless-notify-trigger'; +} from './controllers/core/triggers/headless-core-notify-trigger.js'; +export {buildNotifyTrigger} from './controllers/triggers/headless-notify-trigger.js'; export type { SmartSnippet, @@ -386,10 +386,10 @@ export type { SmartSnippetState, QuestionAnswerDocumentIdentifier, SmartSnippetCore, -} from './controllers/smart-snippet/headless-smart-snippet'; -export {buildSmartSnippet} from './controllers/smart-snippet/headless-smart-snippet'; +} from './controllers/smart-snippet/headless-smart-snippet.js'; +export {buildSmartSnippet} from './controllers/smart-snippet/headless-smart-snippet.js'; -export type {InlineLink} from './controllers/smart-snippet/headless-smart-snippet-interactive-inline-links'; +export type {InlineLink} from './controllers/smart-snippet/headless-smart-snippet-interactive-inline-links.js'; export type { SmartSnippetQuestionsList, @@ -399,8 +399,8 @@ export type { SmartSnippetRelatedQuestion, CoreSmartSnippetQuestionsList, CoreSmartSnippetQuestionsListState, -} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list'; -export {buildSmartSnippetQuestionsList} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list'; +} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.js'; +export {buildSmartSnippetQuestionsList} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.js'; export type { RecentQueriesListInitialState, @@ -408,8 +408,8 @@ export type { RecentQueriesState, RecentQueriesListProps, RecentQueriesListOptions, -} from './controllers/recent-queries-list/headless-recent-queries-list'; -export {buildRecentQueriesList} from './controllers/recent-queries-list/headless-recent-queries-list'; +} from './controllers/recent-queries-list/headless-recent-queries-list.js'; +export {buildRecentQueriesList} from './controllers/recent-queries-list/headless-recent-queries-list.js'; export type { RecentResultsListInitialState, @@ -417,27 +417,27 @@ export type { RecentResultsState, RecentResultsListProps, RecentResultsListOptions, -} from './controllers/recent-results-list/headless-recent-results-list'; -export {buildRecentResultsList} from './controllers/recent-results-list/headless-recent-results-list'; +} from './controllers/recent-results-list/headless-recent-results-list.js'; +export {buildRecentResultsList} from './controllers/recent-results-list/headless-recent-results-list.js'; export type { InteractiveRecentResult, InteractiveRecentResultProps, InteractiveRecentResultOptions, -} from './controllers/recent-results-list/headless-interactive-recent-result'; -export {buildInteractiveRecentResult} from './controllers/recent-results-list/headless-interactive-recent-result'; +} from './controllers/recent-results-list/headless-interactive-recent-result.js'; +export {buildInteractiveRecentResult} from './controllers/recent-results-list/headless-interactive-recent-result.js'; export type { InteractiveResultCore, InteractiveResultCoreOptions, InteractiveResultCoreProps, -} from './controllers/core/interactive-result/headless-core-interactive-result'; +} from './controllers/core/interactive-result/headless-core-interactive-result.js'; export type { FacetConditionsManager, AnyFacetValuesCondition, -} from './controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager'; -export {buildCoreFacetConditionsManager as buildFacetConditionsManager} from './controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager'; +} from './controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.js'; +export {buildCoreFacetConditionsManager as buildFacetConditionsManager} from './controllers/core/facets/facet-conditions-manager/headless-facet-conditions-manager.js'; export type { FieldSuggestionsValue, @@ -445,8 +445,8 @@ export type { FieldSuggestions, FieldSuggestionsOptions, FieldSuggestionsProps, -} from './controllers/field-suggestions/facet/headless-field-suggestions'; -export {buildFieldSuggestions} from './controllers/field-suggestions/facet/headless-field-suggestions'; +} from './controllers/field-suggestions/facet/headless-field-suggestions.js'; +export {buildFieldSuggestions} from './controllers/field-suggestions/facet/headless-field-suggestions.js'; export type { CategoryFieldSuggestionsValue, @@ -454,9 +454,9 @@ export type { CategoryFieldSuggestions, CategoryFieldSuggestionsOptions, CategoryFieldSuggestionsProps, -} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions'; +} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.js'; -export {buildCategoryFieldSuggestions} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions'; +export {buildCategoryFieldSuggestions} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.js'; export type { AutomaticFacet, @@ -465,8 +465,8 @@ export type { AutomaticFacetGeneratorProps, AutomaticFacetGeneratorState, AutomaticFacetGeneratorOptions, -} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator'; -export {buildAutomaticFacetGenerator} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator'; +} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.js'; +export {buildAutomaticFacetGenerator} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.js'; export type { GeneratedAnswer, @@ -475,15 +475,15 @@ export type { GeneratedAnswerCitation, GeneratedResponseFormat, GeneratedAnswerPropsInitialState, -} from './controllers/generated-answer/headless-generated-answer'; -export {buildGeneratedAnswer} from './controllers/generated-answer/headless-generated-answer'; +} from './controllers/generated-answer/headless-generated-answer.js'; +export {buildGeneratedAnswer} from './controllers/generated-answer/headless-generated-answer.js'; export type { InteractiveCitationOptions, InteractiveCitationProps, InteractiveCitation, -} from './controllers/generated-answer/headless-interactive-citation'; -export {buildInteractiveCitation} from './controllers/generated-answer/headless-interactive-citation'; +} from './controllers/generated-answer/headless-interactive-citation.js'; +export {buildInteractiveCitation} from './controllers/generated-answer/headless-interactive-citation.js'; //#endregion //#endregion @@ -494,73 +494,73 @@ export { facetRequestSelector, facetResponseSelector, facetResponseSelectedValuesSelector, -} from './features/facets/facet-set/facet-set-selectors'; +} from './features/facets/facet-set/facet-set-selectors.js'; export { currentPageSelector, maxPageSelector, currentPagesSelector, -} from './features/pagination/pagination-selectors'; +} from './features/pagination/pagination-selectors.js'; //#region Grouped actions -export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers'; -export * from './features/advanced-search-queries/advanced-search-queries-actions-loader'; -export * from './features/facets/category-facet-set/category-facet-set-actions-loader'; -export * from './features/facets/facet-set/facet-set-actions-loader'; -export * from './features/configuration/configuration-actions-loader'; -export * from './features/configuration/search-configuration-actions-loader'; -export * from './features/context/context-actions-loader'; -export * from './features/dictionary-field-context/dictionary-field-context-actions-loader'; -export * from './features/debug/debug-actions-loader'; -export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader'; -export * from './features/facet-options/facet-options-actions-loader'; -export * from './features/did-you-mean/did-you-mean-actions-loader'; -export * from './features/fields/fields-actions-loader'; -export * from './features/history/history-actions-loader'; -export * from './features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader'; -export * from './features/folding/folding-actions-loader'; -export * from './features/pagination/pagination-actions-loader'; -export * from './features/pipeline/pipeline-actions-loader'; -export * from './features/query/query-actions-loader'; -export * from './features/query-set/query-set-actions-loader'; -export * from './features/instant-results/instant-results-actions-loader'; -export * from './features/query-suggest/query-suggest-actions-loader'; -export * from './features/search/search-actions-loader'; -export * from './features/search-hub/search-hub-actions-loader'; -export * from './features/sort-criteria/sort-criteria-actions-loader'; -export * from './features/standalone-search-box-set/standalone-search-box-set-actions-loader'; -export * from './features/static-filter-set/static-filter-set-actions-loader'; -export * from './features/tab-set/tab-set-actions-loader'; -export * from './features/question-answering/question-answering-actions-loader'; -export * from './features/breadcrumb/breadcrumb-actions-loader'; -export * from './features/recent-queries/recent-queries-actions-loader'; -export * from './features/recent-results/recent-results-actions-loader'; -export * from './features/excerpt-length/excerpt-length-actions-loader'; -export * from './features/result-preview/result-preview-actions-loader'; -export * from './features/generated-answer/generated-answer-actions-loader'; -export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager'; +export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers.js'; +export * from './features/advanced-search-queries/advanced-search-queries-actions-loader.js'; +export * from './features/facets/category-facet-set/category-facet-set-actions-loader.js'; +export * from './features/facets/facet-set/facet-set-actions-loader.js'; +export * from './features/configuration/configuration-actions-loader.js'; +export * from './features/configuration/search-configuration-actions-loader.js'; +export * from './features/context/context-actions-loader.js'; +export * from './features/dictionary-field-context/dictionary-field-context-actions-loader.js'; +export * from './features/debug/debug-actions-loader.js'; +export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader.js'; +export * from './features/facet-options/facet-options-actions-loader.js'; +export * from './features/did-you-mean/did-you-mean-actions-loader.js'; +export * from './features/fields/fields-actions-loader.js'; +export * from './features/history/history-actions-loader.js'; +export * from './features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.js'; +export * from './features/folding/folding-actions-loader.js'; +export * from './features/pagination/pagination-actions-loader.js'; +export * from './features/pipeline/pipeline-actions-loader.js'; +export * from './features/query/query-actions-loader.js'; +export * from './features/query-set/query-set-actions-loader.js'; +export * from './features/instant-results/instant-results-actions-loader.js'; +export * from './features/query-suggest/query-suggest-actions-loader.js'; +export * from './features/search/search-actions-loader.js'; +export * from './features/search-hub/search-hub-actions-loader.js'; +export * from './features/sort-criteria/sort-criteria-actions-loader.js'; +export * from './features/standalone-search-box-set/standalone-search-box-set-actions-loader.js'; +export * from './features/static-filter-set/static-filter-set-actions-loader.js'; +export * from './features/tab-set/tab-set-actions-loader.js'; +export * from './features/question-answering/question-answering-actions-loader.js'; +export * from './features/breadcrumb/breadcrumb-actions-loader.js'; +export * from './features/recent-queries/recent-queries-actions-loader.js'; +export * from './features/recent-results/recent-results-actions-loader.js'; +export * from './features/excerpt-length/excerpt-length-actions-loader.js'; +export * from './features/result-preview/result-preview-actions-loader.js'; +export * from './features/generated-answer/generated-answer-actions-loader.js'; +export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager.js'; //#endregion // Analytics Actions -export * from './features/analytics/search-analytics-actions-loader'; -export * from './features/analytics/click-analytics-actions-loader'; -export * from './features/analytics/generic-analytics-actions-loader'; -export * from './features/actions-history/ipx-actions-history-actions-loader'; +export * from './features/analytics/search-analytics-actions-loader.js'; +export * from './features/analytics/click-analytics-actions-loader.js'; +export * from './features/analytics/generic-analytics-actions-loader.js'; +export * from './features/actions-history/ipx-actions-history-actions-loader.js'; // Types & Helpers export { getOrganizationEndpoint, getSearchApiBaseUrl, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; -export {API_DATE_FORMAT} from './api/search/date/date-format'; +} from './api/platform-client.js'; +export {API_DATE_FORMAT} from './api/search/date/date-format.js'; export {HighlightUtils}; -export type {Result} from './api/search/search/result'; -export type {FieldDescription} from './api/search/fields/fields-response'; -export type {Raw} from './api/search/search/raw'; +export type {Result} from './api/search/search/result.js'; +export type {FieldDescription} from './api/search/fields/fields-response.js'; +export type {Raw} from './api/search/search/raw.js'; export type { TermsToHighlight, PhrasesToHighlight, -} from './api/search/search/stemming'; +} from './api/search/search/stemming.js'; export type { SortCriterion, SortByDate, @@ -568,7 +568,7 @@ export type { SortByNoSort, SortByQRE, SortByRelevancy, -} from './features/sort-criteria/criteria'; +} from './features/sort-criteria/criteria.js'; export { SortBy, SortOrder, @@ -578,63 +578,63 @@ export { buildNoSortCriterion, buildQueryRankingExpressionSortCriterion, buildRelevanceSortCriterion, -} from './features/sort-criteria/criteria'; -export {parseCriterionExpression} from './features/sort-criteria/criteria-parser'; +} from './features/sort-criteria/criteria.js'; +export {parseCriterionExpression} from './features/sort-criteria/criteria-parser.js'; export type { ResultTemplatesManager, ResultTemplate, ResultTemplateCondition, -} from './features/result-templates/result-templates-manager'; +} from './features/result-templates/result-templates-manager.js'; export type { TemplatesManager, Template, -} from './features/templates/templates-manager'; -export type {PlatformEnvironment} from './utils/url-utils'; +} from './features/templates/templates-manager.js'; +export type {PlatformEnvironment} from './utils/url-utils.js'; export type { CategoryFacetValueRequest, CategoryFacetSortCriterion, -} from './features/facets/category-facet-set/interfaces/request'; -export type {DateRangeRequest} from './features/facets/range-facets/date-facet-set/interfaces/request'; +} from './features/facets/category-facet-set/interfaces/request.js'; +export type {DateRangeRequest} from './features/facets/range-facets/date-facet-set/interfaces/request.js'; export type { CategoryFacetValue, CategoryFacetValueCommon, -} from './features/facets/category-facet-set/interfaces/response'; -export type {DateFacetValue} from './features/facets/range-facets/date-facet-set/interfaces/response'; +} from './features/facets/category-facet-set/interfaces/response.js'; +export type {DateFacetValue} from './features/facets/range-facets/date-facet-set/interfaces/response.js'; export type { FacetValueRequest, FacetSortCriterion, -} from './features/facets/facet-set/interfaces/request'; -export type {FacetResultsMustMatch} from './features/facets/facet-api/request'; -export type {NumericRangeRequest} from './features/facets/range-facets/numeric-facet-set/interfaces/request'; -export type {NumericFacetValue} from './features/facets/range-facets/numeric-facet-set/interfaces/response'; -export type {AnyFacetValueRequest} from './features/facets/generic/interfaces/generic-facet-request'; +} from './features/facets/facet-set/interfaces/request.js'; +export type {FacetResultsMustMatch} from './features/facets/facet-api/request.js'; +export type {NumericRangeRequest} from './features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +export type {NumericFacetValue} from './features/facets/range-facets/numeric-facet-set/interfaces/response.js'; +export type {AnyFacetValueRequest} from './features/facets/generic/interfaces/generic-facet-request.js'; export type { RangeFacetSortCriterion, RangeFacetRangeAlgorithm, -} from './features/facets/range-facets/generic/interfaces/request'; +} from './features/facets/range-facets/generic/interfaces/request.js'; export { MinimumFieldsToInclude, DefaultFieldsToInclude, EcommerceDefaultFieldsToInclude, -} from './features/fields/fields-state'; -export {buildSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer'; -export type {FunctionExecutionTrigger} from './features/triggers/triggers-state'; -export type {HighlightKeyword} from './utils/highlight'; -export {VERSION} from './utils/version'; +} from './features/fields/fields-state.js'; +export {buildSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer.js'; +export type {FunctionExecutionTrigger} from './features/triggers/triggers-state.js'; +export type {HighlightKeyword} from './utils/highlight.js'; +export {VERSION} from './utils/version.js'; export type { RelativeDate, RelativeDatePeriod, RelativeDateUnit, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; export { deserializeRelativeDate, validateRelativeDate, -} from './api/search/date/relative-date'; -export type {GeneratedContentFormat} from './features/generated-answer/generated-response-format'; +} from './api/search/date/relative-date.js'; +export type {GeneratedContentFormat} from './features/generated-answer/generated-response-format.js'; -export * from './utils/query-expression/query-expression'; +export * from './utils/query-expression/query-expression.js'; export type { GeneratedAnswerFeedback, GeneratedAnswerFeedbackOption, -} from './features/generated-answer/generated-answer-analytics-actions'; +} from './features/generated-answer/generated-answer-analytics-actions.js'; diff --git a/packages/headless/src/insight.index.ts b/packages/headless/src/insight.index.ts index 5df79931354..826ffb852c4 100644 --- a/packages/headless/src/insight.index.ts +++ b/packages/headless/src/insight.index.ts @@ -1,4 +1,4 @@ -import * as HighlightUtils from './utils/highlight'; +import * as HighlightUtils from './utils/highlight.js'; // 3rd Party Libraries export type {Unsubscribe, Middleware} from '@reduxjs/toolkit'; @@ -10,58 +10,59 @@ export type { InsightEngineOptions, InsightEngineConfiguration, InsightEngineSearchConfigurationOptions, -} from './app/insight-engine/insight-engine'; +} from './app/insight-engine/insight-engine.js'; export { buildInsightEngine, getSampleInsightEngineConfiguration, -} from './app/insight-engine/insight-engine'; +} from './app/insight-engine/insight-engine.js'; -export type {CoreEngine, ExternalEngineOptions} from './app/engine'; +export type {CoreEngine, ExternalEngineOptions} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; -export type {LoggerOptions} from './app/logger'; +} from './app/engine-configuration.js'; +export type {LoggerOptions} from './app/logger.js'; -export type {LogLevel} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +export type {LogLevel} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; // Action loaders -export * from './features/insight-interface/insight-interface-actions-loader'; -export * from './features/insight-search/insight-search-actions-loader'; -export * from './features/insight-search/insight-query-set-actions-loader'; -export * from './features/analytics/insight-analytics-actions-loader'; -export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader'; -export * from './features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader'; -export * from './features/recent-results/recent-results-actions-loader'; -export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader'; -export * from './features/case-context/case-context-actions-loader'; -export * from './features/context/context-actions-loader'; -export * from './features/insight-search/insight-search-analytics-actions-loader'; -export * from './features/fields/fields-actions-loader'; -export * from './features/attached-results/attached-results-actions-loader'; -export * from './features/analytics/generic-analytics-actions-loader'; -export * from './features/question-answering/question-answering-actions-loader'; -export * from './features/folding/folding-actions-loader'; -export * from './features/insight-user-actions/insight-user-actions-loader'; +export * from './features/insight-interface/insight-interface-actions-loader.js'; +export * from './features/insight-search/insight-search-actions-loader.js'; +export * from './features/insight-search/insight-query-set-actions-loader.js'; +export * from './features/analytics/insight-analytics-actions-loader.js'; +export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader.js'; +export * from './features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.js'; +export * from './features/recent-results/recent-results-actions-loader.js'; +export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader.js'; +export * from './features/case-context/case-context-actions-loader.js'; +export * from './features/context/context-actions-loader.js'; +export * from './features/insight-search/insight-search-analytics-actions-loader.js'; +export * from './features/fields/fields-actions-loader.js'; +export * from './features/attached-results/attached-results-actions-loader.js'; +export * from './features/analytics/generic-analytics-actions-loader.js'; +export * from './features/question-answering/question-answering-actions-loader.js'; +export * from './features/folding/folding-actions-loader.js'; +export * from './features/insight-user-actions/insight-user-actions-loader.js'; +export * from './features/query-suggest/query-suggest-actions-loader.js'; // Controllers export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; -export {buildController} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; +export {buildController} from './controllers/controller/headless-controller.js'; -export type {HighlightKeyword} from './utils/highlight'; +export type {HighlightKeyword} from './utils/highlight.js'; export type { DidYouMean, DidYouMeanState, QueryCorrection, WordCorrection, -} from './controllers/insight/did-you-mean/headless-insight-did-you-mean'; -export {buildDidYouMean} from './controllers/insight/did-you-mean/headless-insight-did-you-mean'; +} from './controllers/insight/did-you-mean/headless-insight-did-you-mean.js'; +export {buildDidYouMean} from './controllers/insight/did-you-mean/headless-insight-did-you-mean.js'; export type { NumericFacetBreadcrumb, @@ -74,8 +75,8 @@ export type { BreadcrumbManagerState, BreadcrumbManager, DeselectableValue, -} from './controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager'; -export {buildBreadcrumbManager} from './controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager'; +} from './controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.js'; +export {buildBreadcrumbManager} from './controllers/insight/breadcrumb-manager/headless-insight-breadcrumb-manager.js'; export type { SearchParameterManagerProps, @@ -83,20 +84,20 @@ export type { SearchParameterManagerState, SearchParameterManager, SearchParameters, -} from './controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager'; -export {buildSearchParameterManager} from './controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager'; +} from './controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.js'; +export {buildSearchParameterManager} from './controllers/insight/search-parameter-manager/headless-insight-search-parameter-manager.js'; export type { FacetManagerPayload, FacetManagerState, FacetManager, -} from './controllers/insight/facet-manager/headless-insight-facet-manager'; -export {buildFacetManager} from './controllers/insight/facet-manager/headless-insight-facet-manager'; +} from './controllers/insight/facet-manager/headless-insight-facet-manager.js'; +export {buildFacetManager} from './controllers/insight/facet-manager/headless-insight-facet-manager.js'; export type { CategoryFacetValueRequest, CategoryFacetSortCriterion, -} from './features/facets/category-facet-set/interfaces/request'; +} from './features/facets/category-facet-set/interfaces/request.js'; export type { CategoryFacetOptions, @@ -111,8 +112,8 @@ export type { CategoryFacetSearchResult, CoreCategoryFacet, CoreCategoryFacetState, -} from './controllers/insight/facets/category-facet/headless-insight-category-facet'; -export {buildCategoryFacet} from './controllers/insight/facets/category-facet/headless-insight-category-facet'; +} from './controllers/insight/facets/category-facet/headless-insight-category-facet.js'; +export {buildCategoryFacet} from './controllers/insight/facets/category-facet/headless-insight-category-facet.js'; export type { FacetOptions, @@ -128,8 +129,8 @@ export type { CoreFacet, CoreFacetState, CoreFacetOptions, -} from './controllers/insight/facets/facet/headless-insight-facet'; -export {buildFacet} from './controllers/insight/facets/facet/headless-insight-facet'; +} from './controllers/insight/facets/facet/headless-insight-facet.js'; +export {buildFacet} from './controllers/insight/facets/facet/headless-insight-facet.js'; export type { DateRangeOptions, @@ -139,11 +140,11 @@ export type { DateFacetProps, DateFacetState, DateFacet, -} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet'; +} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.js'; export { buildDateRange, buildDateFacet, -} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet'; +} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-facet.js'; export type { NumericRangeOptions, @@ -152,11 +153,11 @@ export type { NumericFacetProps, NumericFacetState, NumericFacet, -} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet'; +} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.js'; export { buildNumericRange, buildNumericFacet, -} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet'; +} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-facet.js'; export type { NumericFilter, @@ -165,8 +166,8 @@ export type { NumericFilterRange, NumericFilterState, NumericFilterInitialState, -} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter'; -export {buildNumericFilter} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter'; +} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.js'; +export {buildNumericFilter} from './controllers/insight/facets/range-facet/numeric-facet/headless-insight-numeric-filter.js'; export type { DateFilter, @@ -175,8 +176,8 @@ export type { DateFilterRange, DateFilterState, DateFilterInitialState, -} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter'; -export {buildDateFilter} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter'; +} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.js'; +export {buildDateFilter} from './controllers/insight/facets/range-facet/date-facet/headless-insight-date-filter.js'; export type { PagerInitialState, @@ -184,37 +185,37 @@ export type { PagerProps, PagerState, Pager, -} from './controllers/insight/pager/headless-insight-pager'; -export {buildPager} from './controllers/insight/pager/headless-insight-pager'; +} from './controllers/insight/pager/headless-insight-pager.js'; +export {buildPager} from './controllers/insight/pager/headless-insight-pager.js'; export type { AttachToCaseProps, AttachToCaseOptions, AttachToCase, -} from './controllers/insight/attach-to-case/headless-attach-to-case'; -export {buildAttachToCase} from './controllers/insight/attach-to-case/headless-attach-to-case'; +} from './controllers/insight/attach-to-case/headless-attach-to-case.js'; +export {buildAttachToCase} from './controllers/insight/attach-to-case/headless-attach-to-case.js'; export type { QuerySummaryState, QuerySummary, -} from './controllers/insight/query-summary/headless-insight-query-summary'; -export {buildQuerySummary} from './controllers/insight/query-summary/headless-insight-query-summary'; +} from './controllers/insight/query-summary/headless-insight-query-summary.js'; +export {buildQuerySummary} from './controllers/insight/query-summary/headless-insight-query-summary.js'; export type { QuickviewProps, QuickviewOptions, QuickviewState, Quickview, -} from './controllers/insight/quickview/headless-insight-quickview'; -export {buildQuickview} from './controllers/insight/quickview/headless-insight-quickview'; +} from './controllers/insight/quickview/headless-insight-quickview.js'; +export {buildQuickview} from './controllers/insight/quickview/headless-insight-quickview.js'; export type { ResultListProps, ResultListOptions, ResultListState, ResultList, -} from './controllers/insight/result-list/headless-insight-result-list'; -export {buildResultList} from './controllers/insight/result-list/headless-insight-result-list'; +} from './controllers/insight/result-list/headless-insight-result-list.js'; +export {buildResultList} from './controllers/insight/result-list/headless-insight-result-list.js'; export type { FoldingOptions, @@ -224,8 +225,8 @@ export type { InsightFoldedResultListProps, FoldedResultList, FoldedResultListState, -} from './controllers/insight/folded-result-list/headless-insight-folded-result-list'; -export {buildFoldedResultList} from './controllers/insight/folded-result-list/headless-insight-folded-result-list'; +} from './controllers/insight/folded-result-list/headless-insight-folded-result-list.js'; +export {buildFoldedResultList} from './controllers/insight/folded-result-list/headless-insight-folded-result-list.js'; export type { InteractiveResultCoreOptions, @@ -234,16 +235,16 @@ export type { InsightInteractiveResultOptions, InsightInteractiveResultProps, InteractiveResult, -} from './controllers/insight/result-list/headless-insight-interactive-result'; -export {buildInteractiveResult} from './controllers/insight/result-list/headless-insight-interactive-result'; +} from './controllers/insight/result-list/headless-insight-interactive-result.js'; +export {buildInteractiveResult} from './controllers/insight/result-list/headless-insight-interactive-result.js'; export type { ResultsPerPageInitialState, ResultsPerPageProps, ResultsPerPageState, ResultsPerPage, -} from './controllers/insight/results-per-page/headless-insight-results-per-page'; -export {buildResultsPerPage} from './controllers/insight/results-per-page/headless-insight-results-per-page'; +} from './controllers/insight/results-per-page/headless-insight-results-per-page.js'; +export {buildResultsPerPage} from './controllers/insight/results-per-page/headless-insight-results-per-page.js'; export type { SearchBoxOptions, @@ -253,22 +254,22 @@ export type { Suggestion, SuggestionHighlightingOptions, Delimiters, -} from './controllers/insight/search-box/headless-insight-search-box'; -export {buildSearchBox} from './controllers/insight/search-box/headless-insight-search-box'; +} from './controllers/insight/search-box/headless-insight-search-box.js'; +export {buildSearchBox} from './controllers/insight/search-box/headless-insight-search-box.js'; export type { SearchStatus, SearchStatusState, -} from './controllers/insight/status/headless-insight-status'; -export {buildSearchStatus} from './controllers/insight/status/headless-insight-status'; +} from './controllers/insight/status/headless-insight-status.js'; +export {buildSearchStatus} from './controllers/insight/status/headless-insight-status.js'; export type { SortInitialState, SortProps, SortState, Sort, -} from './controllers/insight/sort/headless-insight-sort'; -export {buildSort} from './controllers/insight/sort/headless-insight-sort'; +} from './controllers/insight/sort/headless-insight-sort.js'; +export {buildSort} from './controllers/insight/sort/headless-insight-sort.js'; export type { TabInitialState, @@ -276,20 +277,20 @@ export type { TabProps, TabState, Tab, -} from './controllers/insight/tab/headless-insight-tab'; -export {buildTab} from './controllers/insight/tab/headless-insight-tab'; +} from './controllers/insight/tab/headless-insight-tab.js'; +export {buildTab} from './controllers/insight/tab/headless-insight-tab.js'; export type { FacetConditionsManager, FacetConditionsManagerProps, AnyFacetValuesCondition, -} from './controllers/insight/facet-conditions-manager/headless-facet-conditions-manager'; -export {buildFacetConditionsManager} from './controllers/insight/facet-conditions-manager/headless-facet-conditions-manager'; +} from './controllers/insight/facet-conditions-manager/headless-facet-conditions-manager.js'; +export {buildFacetConditionsManager} from './controllers/insight/facet-conditions-manager/headless-facet-conditions-manager.js'; -export type {InsightInterfaceState} from './features/insight-interface/insight-interface-state'; +export type {InsightInterfaceState} from './features/insight-interface/insight-interface-state.js'; -export type {InsightInterface} from './controllers/insight-interface/insight-interface'; -export {buildInsightInterface} from './controllers/insight-interface/insight-interface'; +export type {InsightInterface} from './controllers/insight-interface/insight-interface.js'; +export {buildInsightInterface} from './controllers/insight-interface/insight-interface.js'; export type { InlineLink, @@ -299,8 +300,8 @@ export type { SmartSnippetState, QuestionAnswerDocumentIdentifier, SmartSnippetCore, -} from './controllers/insight/smart-snippet/headless-insight-smart-snippet'; -export {buildSmartSnippet} from './controllers/insight/smart-snippet/headless-insight-smart-snippet'; +} from './controllers/insight/smart-snippet/headless-insight-smart-snippet.js'; +export {buildSmartSnippet} from './controllers/insight/smart-snippet/headless-insight-smart-snippet.js'; export type { SmartSnippetQuestionsListOptions, @@ -310,22 +311,22 @@ export type { SmartSnippetRelatedQuestion, CoreSmartSnippetQuestionsList, CoreSmartSnippetQuestionsListState, -} from './controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list'; -export {buildSmartSnippetQuestionsList} from './controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list'; +} from './controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list.js'; +export {buildSmartSnippetQuestionsList} from './controllers/insight/smart-snippet-questions-list/headless-insight-smart-snippet-questions-list.js'; export type { GeneratedAnswer, GeneratedAnswerState, GeneratedAnswerProps, -} from './controllers/insight/generated-answer/headless-insight-generated-answer'; -export {buildGeneratedAnswer} from './controllers/insight/generated-answer/headless-insight-generated-answer'; +} from './controllers/insight/generated-answer/headless-insight-generated-answer.js'; +export {buildGeneratedAnswer} from './controllers/insight/generated-answer/headless-insight-generated-answer.js'; export type { InteractiveCitation, InteractiveCitationProps, InteractiveCitationOptions, -} from './controllers/insight/generated-answer/headless-insight-interactive-citation'; -export {buildInteractiveCitation} from './controllers/insight/generated-answer/headless-insight-interactive-citation'; +} from './controllers/insight/generated-answer/headless-insight-interactive-citation.js'; +export {buildInteractiveCitation} from './controllers/insight/generated-answer/headless-insight-interactive-citation.js'; export type { UserActionsState, @@ -334,42 +335,42 @@ export type { UserActions, UserAction, UserSession, -} from './controllers/insight/user-actions/headless-user-actions'; -export {buildUserActions} from './controllers/insight/user-actions/headless-user-actions'; +} from './controllers/insight/user-actions/headless-user-actions.js'; +export {buildUserActions} from './controllers/insight/user-actions/headless-user-actions.js'; // Features export type { ResultTemplate, ResultTemplateCondition, -} from './features/result-templates/result-templates-manager'; -export type {ResultTemplatesManager} from './features/result-templates/result-templates-manager'; -export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager'; -export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers'; +} from './features/result-templates/result-templates-manager.js'; +export type {ResultTemplatesManager} from './features/result-templates/result-templates-manager.js'; +export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager.js'; +export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers.js'; -export type {NumericFacetValue} from './features/facets/range-facets/numeric-facet-set/interfaces/response'; +export type {NumericFacetValue} from './features/facets/range-facets/numeric-facet-set/interfaces/response.js'; -export type {DateFacetValue} from './features/facets/range-facets/date-facet-set/interfaces/response'; +export type {DateFacetValue} from './features/facets/range-facets/date-facet-set/interfaces/response.js'; export type { QueryError, QueryErrorState, -} from './controllers/insight/query-error/headless-insight-query-error'; -export {buildQueryError} from './controllers/insight/query-error/headless-insight-query-error'; +} from './controllers/insight/query-error/headless-insight-query-error.js'; +export {buildQueryError} from './controllers/insight/query-error/headless-insight-query-error.js'; export type { FacetValueRequest, FacetSortCriterion, -} from './features/facets/facet-set/interfaces/request'; +} from './features/facets/facet-set/interfaces/request.js'; export type { RangeFacetSortCriterion, RangeFacetRangeAlgorithm, -} from './features/facets/range-facets/generic/interfaces/request'; +} from './features/facets/range-facets/generic/interfaces/request.js'; // Types & Helpers -export type {Raw} from './api/search/search/raw'; -export type {InsightAPIErrorStatusResponse} from './api/service/insight/insight-api-client'; -export type {Result} from './api/search/search/result'; +export type {Raw} from './api/search/search/raw.js'; +export type {InsightAPIErrorStatusResponse} from './api/service/insight/insight-api-client.js'; +export type {Result} from './api/search/search/result.js'; export {HighlightUtils}; export { @@ -377,19 +378,19 @@ export { buildDateSortCriterion, buildCriterionExpression, buildRelevanceSortCriterion, -} from './features/sort-criteria/criteria'; +} from './features/sort-criteria/criteria.js'; export type { RelativeDate, RelativeDatePeriod, RelativeDateUnit, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; -export {deserializeRelativeDate} from './api/search/date/relative-date'; +export {deserializeRelativeDate} from './api/search/date/relative-date.js'; export { getOrganizationEndpoint, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; +} from './api/platform-client.js'; -export type {PlatformEnvironment} from './utils/url-utils'; +export type {PlatformEnvironment} from './utils/url-utils.js'; diff --git a/packages/headless/src/integration-tests/analytics-migration.test.ts b/packages/headless/src/integration-tests/analytics-migration.test.ts index 958335e42da..8afa5e84965 100644 --- a/packages/headless/src/integration-tests/analytics-migration.test.ts +++ b/packages/headless/src/integration-tests/analytics-migration.test.ts @@ -1,13 +1,17 @@ -import {PlatformClient, PlatformClientCallError} from '../api/platform-client'; +import {MockInstance} from 'vitest'; +import { + PlatformClient, + PlatformClientCallError, +} from '../api/platform-client.js'; import { buildSearchEngine, getSampleSearchEngineConfiguration, -} from '../app/search-engine/search-engine'; +} from '../app/search-engine/search-engine.js'; import { SearchBoxOptions, SearchBoxProps, buildCoreSearchBox, -} from '../controllers/core/search-box/headless-core-search-box'; +} from '../controllers/core/search-box/headless-core-search-box.js'; import { interfaceChange, interfaceLoad, @@ -17,20 +21,20 @@ import { logSearchFromLink, omniboxFromLink, searchFromLink, -} from '../features/analytics/analytics-actions'; -import {LegacySearchAction} from '../features/analytics/analytics-utils'; +} from '../features/analytics/analytics-actions.js'; +import {LegacySearchAction} from '../features/analytics/analytics-utils.js'; import { didYouMeanAutomatic, didYouMeanClick, logDidYouMeanAutomatic, logDidYouMeanClick, -} from '../features/did-you-mean/did-you-mean-analytics-actions'; -import {registerCategoryFacet} from '../features/facets/category-facet-set/category-facet-set-actions'; +} from '../features/did-you-mean/did-you-mean-analytics-actions.js'; +import {registerCategoryFacet} from '../features/facets/category-facet-set/category-facet-set-actions.js'; import { categoryBreadcrumbFacet, logCategoryFacetBreadcrumb, -} from '../features/facets/category-facet-set/category-facet-set-analytics-actions'; -import {categoryFacetSetReducer} from '../features/facets/category-facet-set/category-facet-set-slice'; +} from '../features/facets/category-facet-set/category-facet-set-analytics-actions.js'; +import {categoryFacetSetReducer} from '../features/facets/category-facet-set/category-facet-set-slice.js'; import { breadcrumbFacet, facetClearAll, @@ -46,23 +50,23 @@ import { logFacetShowLess, logFacetShowMore, logFacetUpdateSort, -} from '../features/facets/facet-set/facet-set-analytics-actions'; -import {FacetSortCriterion} from '../features/facets/facet-set/interfaces/request'; -import {logClearBreadcrumbs} from '../features/facets/generic/facet-generic-analytics-actions'; -import {registerDateFacet} from '../features/facets/range-facets/date-facet-set/date-facet-actions'; +} from '../features/facets/facet-set/facet-set-analytics-actions.js'; +import {FacetSortCriterion} from '../features/facets/facet-set/interfaces/request.js'; +import {logClearBreadcrumbs} from '../features/facets/generic/facet-generic-analytics-actions.js'; +import {registerDateFacet} from '../features/facets/range-facets/date-facet-set/date-facet-actions.js'; import { dateBreadcrumbFacet, logDateFacetBreadcrumb, -} from '../features/facets/range-facets/date-facet-set/date-facet-analytics-actions'; -import {dateFacetSetReducer} from '../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../features/facets/range-facets/date-facet-set/interfaces/response'; -import {NumericFacetValue} from '../features/facets/range-facets/numeric-facet-set/interfaces/response'; -import {registerNumericFacet} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; +} from '../features/facets/range-facets/date-facet-set/date-facet-analytics-actions.js'; +import {dateFacetSetReducer} from '../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {NumericFacetValue} from '../features/facets/range-facets/numeric-facet-set/interfaces/response.js'; +import {registerNumericFacet} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; import { logNumericFacetBreadcrumb, numericBreadcrumbFacet, -} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions'; -import {numericFacetSetReducer} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; +} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.js'; +import {numericFacetSetReducer} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; import { logNavigateBackward, logNavigateForward, @@ -70,30 +74,30 @@ import { historyBackward, historyForward, noResultsBack, -} from '../features/history/history-analytics-actions'; +} from '../features/history/history-analytics-actions.js'; import { logInstantResultsSearch, searchboxAsYouType, -} from '../features/instant-results/instant-result-analytics-actions'; -import {fetchQuerySuggestions} from '../features/query-suggest/query-suggest-actions'; -import {OmniboxSuggestionMetadata} from '../features/query-suggest/query-suggest-analytics-actions'; +} from '../features/instant-results/instant-result-analytics-actions.js'; +import {fetchQuerySuggestions} from '../features/query-suggest/query-suggest-actions.js'; +import {OmniboxSuggestionMetadata} from '../features/query-suggest/query-suggest-analytics-actions.js'; import { logSearchboxSubmit, searchboxSubmit, -} from '../features/query/query-analytics-actions'; -import {logRecentQueryClick} from '../features/recent-queries/recent-queries-analytics-actions'; +} from '../features/query/query-analytics-actions.js'; +import {logRecentQueryClick} from '../features/recent-queries/recent-queries-analytics-actions.js'; import { logRecommendationUpdate, recommendationInterfaceLoad, -} from '../features/recommendation/recommendation-analytics-actions'; +} from '../features/recommendation/recommendation-analytics-actions.js'; import { executeSearch, fetchFacetValues, -} from '../features/search/search-actions'; +} from '../features/search/search-actions.js'; import { logResultsSort, resultsSort, -} from '../features/sort-criteria/sort-criteria-analytics-actions'; +} from '../features/sort-criteria/sort-criteria-analytics-actions.js'; import { StaticFilterValueMetadata, logStaticFilterClearAll, @@ -102,12 +106,12 @@ import { staticFilterClearAll, staticFilterDeselect, staticFilterSelect, -} from '../features/static-filter-set/static-filter-set-actions'; +} from '../features/static-filter-set/static-filter-set-actions.js'; import { logUndoTriggerQuery, undoTriggerQuery, -} from '../features/triggers/trigger-analytics-actions'; -import {clearMicrotaskQueue} from '../test/unit-test-utils'; +} from '../features/triggers/trigger-analytics-actions.js'; +import {clearMicrotaskQueue} from '../test/unit-test-utils.js'; const nextSearchEngine = buildSearchEngine({ configuration: { @@ -126,7 +130,7 @@ const legacySearchEngine = buildSearchEngine({ }); export function assertNextEqualsLegacy( - call: jest.SpyInstance, + call: MockInstance, excludedProperties: string[] = excludedBaseProperties ) { expect(extractAndExcludeProperties(call, 0, excludedProperties)).toEqual( @@ -135,7 +139,7 @@ export function assertNextEqualsLegacy( } export function assertActionCause( - call: jest.SpyInstance, + call: MockInstance, callIndex: number, expectedActionCause: string ) { @@ -150,7 +154,7 @@ export function assertActionCause( } export function extractAndExcludeProperties( - call: jest.SpyInstance, + call: MockInstance, callIndex: number, excludedProperties: string[] ): Record { @@ -203,10 +207,14 @@ const ANY_QUERY = 'any query'; const ANY_CATEGORY_FACET_PATH = ['any category facet path']; describe('Analytics Search Migration', () => { - let callSpy: jest.SpyInstance>; + type Procedure = ( + ...args: unknown[] + ) => Promise; + + let callSpy: MockInstance; beforeEach(() => { - callSpy = jest.spyOn(PlatformClient, 'call'); + callSpy = vi.spyOn(PlatformClient, 'call'); callSpy.mockImplementation(() => Promise.resolve(new Response())); }); diff --git a/packages/headless/src/integration-tests/category-field-suggestions.test.ts b/packages/headless/src/integration-tests/category-field-suggestions.test.ts index e83cc472da1..7feebc191cc 100644 --- a/packages/headless/src/integration-tests/category-field-suggestions.test.ts +++ b/packages/headless/src/integration-tests/category-field-suggestions.test.ts @@ -1,13 +1,13 @@ -import {SearchEngine} from '../app/search-engine/search-engine'; -import {getSampleSearchEngineConfiguration} from '../app/search-engine/search-engine'; -import {buildSearchEngine} from '../app/search-engine/search-engine'; -import {CategoryFacet} from '../controllers/facets/category-facet/headless-category-facet'; -import {buildCategoryFacet} from '../controllers/facets/category-facet/headless-category-facet'; -import {buildFacet} from '../controllers/facets/facet/headless-facet'; -import {Facet} from '../controllers/facets/facet/headless-facet'; -import {CategoryFieldSuggestions} from '../controllers/field-suggestions/category-facet/headless-category-field-suggestions'; -import {buildCategoryFieldSuggestions} from '../controllers/field-suggestions/category-facet/headless-category-field-suggestions'; -import {waitForNextStateChange} from '../test/functional-test-utils'; +import {SearchEngine} from '../app/search-engine/search-engine.js'; +import {getSampleSearchEngineConfiguration} from '../app/search-engine/search-engine.js'; +import {buildSearchEngine} from '../app/search-engine/search-engine.js'; +import {CategoryFacet} from '../controllers/facets/category-facet/headless-category-facet.js'; +import {buildCategoryFacet} from '../controllers/facets/category-facet/headless-category-facet.js'; +import {buildFacet} from '../controllers/facets/facet/headless-facet.js'; +import {Facet} from '../controllers/facets/facet/headless-facet.js'; +import {CategoryFieldSuggestions} from '../controllers/field-suggestions/category-facet/headless-category-field-suggestions.js'; +import {buildCategoryFieldSuggestions} from '../controllers/field-suggestions/category-facet/headless-category-field-suggestions.js'; +import {waitForNextStateChange} from '../test/functional-test-utils.js'; describe('category field suggestions', () => { let engine: SearchEngine; @@ -106,7 +106,7 @@ describe('category field suggestions', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('has more values', () => { diff --git a/packages/headless/src/integration-tests/commerce.test.ts b/packages/headless/src/integration-tests/commerce.test.ts index 9cf5b318fdf..56028ed462e 100644 --- a/packages/headless/src/integration-tests/commerce.test.ts +++ b/packages/headless/src/integration-tests/commerce.test.ts @@ -1,20 +1,20 @@ +import {getSampleCommerceEngineConfiguration} from '../app/commerce-engine/commerce-engine-configuration.js'; import { CommerceEngine, buildCommerceEngine, CommerceEngineConfiguration, -} from '../app/commerce-engine/commerce-engine'; -import {getSampleCommerceEngineConfiguration} from '../app/commerce-engine/commerce-engine-configuration'; -import {CategoryFieldSuggestions} from '../controllers/commerce/field-suggestions/headless-category-field-suggestions'; -import {buildFieldSuggestionsGenerator} from '../controllers/commerce/field-suggestions/headless-field-suggestions-generator'; -import {ProductListing} from '../controllers/commerce/product-listing/headless-product-listing'; -import {buildProductListing} from '../controllers/commerce/product-listing/headless-product-listing'; -import {buildRecommendations} from '../controllers/commerce/recommendations/headless-recommendations'; +} from '../app/commerce-engine/commerce-engine.js'; +import {CategoryFieldSuggestions} from '../controllers/commerce/field-suggestions/headless-category-field-suggestions.js'; +import {buildFieldSuggestionsGenerator} from '../controllers/commerce/field-suggestions/headless-field-suggestions-generator.js'; +import {ProductListing} from '../controllers/commerce/product-listing/headless-product-listing.js'; +import {buildProductListing} from '../controllers/commerce/product-listing/headless-product-listing.js'; +import {buildRecommendations} from '../controllers/commerce/recommendations/headless-recommendations.js'; import { buildSearchBox, SearchBox, -} from '../controllers/commerce/search-box/headless-search-box'; -import {buildSearch} from '../controllers/commerce/search/headless-search'; -import {waitForNextStateChange} from '../test/functional-test-utils'; +} from '../controllers/commerce/search-box/headless-search-box.js'; +import {buildSearch} from '../controllers/commerce/search/headless-search.js'; +import {waitForNextStateChange} from '../test/functional-test-utils.js'; describe.skip('commerce', () => { let configuration: CommerceEngineConfiguration; diff --git a/packages/headless/src/integration-tests/field-suggestions.test.ts b/packages/headless/src/integration-tests/field-suggestions.test.ts index 9251bcdd15d..c4148184b43 100644 --- a/packages/headless/src/integration-tests/field-suggestions.test.ts +++ b/packages/headless/src/integration-tests/field-suggestions.test.ts @@ -1,12 +1,12 @@ -import {SearchEngine} from '../app/search-engine/search-engine'; -import {getSampleSearchEngineConfiguration} from '../app/search-engine/search-engine'; -import {buildSearchEngine} from '../app/search-engine/search-engine'; -import {Facet} from '../controllers/facets/facet/headless-facet'; -import {buildFacet} from '../controllers/facets/facet/headless-facet'; -import {FieldSuggestionsValue} from '../controllers/field-suggestions/facet/headless-field-suggestions'; -import {FieldSuggestions} from '../controllers/field-suggestions/facet/headless-field-suggestions'; -import {buildFieldSuggestions} from '../controllers/field-suggestions/facet/headless-field-suggestions'; -import {waitForNextStateChange} from '../test/functional-test-utils'; +import {SearchEngine} from '../app/search-engine/search-engine.js'; +import {getSampleSearchEngineConfiguration} from '../app/search-engine/search-engine.js'; +import {buildSearchEngine} from '../app/search-engine/search-engine.js'; +import {Facet} from '../controllers/facets/facet/headless-facet.js'; +import {buildFacet} from '../controllers/facets/facet/headless-facet.js'; +import {FieldSuggestionsValue} from '../controllers/field-suggestions/facet/headless-field-suggestions.js'; +import {FieldSuggestions} from '../controllers/field-suggestions/facet/headless-field-suggestions.js'; +import {buildFieldSuggestions} from '../controllers/field-suggestions/facet/headless-field-suggestions.js'; +import {waitForNextStateChange} from '../test/functional-test-utils.js'; describe('field suggestions', () => { let engine: SearchEngine; @@ -125,7 +125,7 @@ describe('field suggestions', () => { }); afterEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it('has more values', () => { diff --git a/packages/headless/src/integration-tests/insight-analytics-migration.test.ts b/packages/headless/src/integration-tests/insight-analytics-migration.test.ts index c144737bfd4..980326163ee 100644 --- a/packages/headless/src/integration-tests/insight-analytics-migration.test.ts +++ b/packages/headless/src/integration-tests/insight-analytics-migration.test.ts @@ -1,27 +1,31 @@ -import {PlatformClient, PlatformClientCallError} from '../api/platform-client'; -import {getSampleEngineConfiguration} from '../app/engine-configuration'; +import {MockInstance} from 'vitest'; +import { + PlatformClient, + PlatformClientCallError, +} from '../api/platform-client.js'; +import {getSampleEngineConfiguration} from '../app/engine-configuration.js'; import { InsightEngineConfiguration, buildInsightEngine, -} from '../app/insight-engine/insight-engine'; -import {NumericFacetValue} from '../controllers/facets/range-facet/numeric-facet/headless-numeric-facet'; +} from '../app/insight-engine/insight-engine.js'; +import {NumericFacetValue} from '../controllers/facets/range-facet/numeric-facet/headless-numeric-facet.js'; import { interfaceChange, interfaceLoad, -} from '../features/analytics/analytics-actions'; -import {didYouMeanClick} from '../features/did-you-mean/did-you-mean-analytics-actions'; -import {logDidYouMeanClick} from '../features/did-you-mean/did-you-mean-insight-analytics-actions'; -import {registerCategoryFacet} from '../features/facets/category-facet-set/category-facet-set-actions'; -import {categoryBreadcrumbFacet} from '../features/facets/category-facet-set/category-facet-set-analytics-actions'; -import {logCategoryFacetBreadcrumb} from '../features/facets/category-facet-set/category-facet-set-insight-analytics-actions'; -import {categoryFacetSetReducer} from '../features/facets/category-facet-set/category-facet-set-slice'; +} from '../features/analytics/analytics-actions.js'; +import {didYouMeanClick} from '../features/did-you-mean/did-you-mean-analytics-actions.js'; +import {logDidYouMeanClick} from '../features/did-you-mean/did-you-mean-insight-analytics-actions.js'; +import {registerCategoryFacet} from '../features/facets/category-facet-set/category-facet-set-actions.js'; +import {categoryBreadcrumbFacet} from '../features/facets/category-facet-set/category-facet-set-analytics-actions.js'; +import {logCategoryFacetBreadcrumb} from '../features/facets/category-facet-set/category-facet-set-insight-analytics-actions.js'; +import {categoryFacetSetReducer} from '../features/facets/category-facet-set/category-facet-set-slice.js'; import { breadcrumbFacet, facetClearAll, facetDeselect, facetSelect, facetUpdateSort, -} from '../features/facets/facet-set/facet-set-analytics-actions'; +} from '../features/facets/facet-set/facet-set-analytics-actions.js'; import { logFacetBreadcrumb, logFacetClearAll, @@ -30,50 +34,50 @@ import { logFacetShowLess, logFacetShowMore, logFacetUpdateSort, -} from '../features/facets/facet-set/facet-set-insight-analytics-actions'; -import {FacetSortCriterion} from '../features/facets/facet-set/interfaces/request'; -import {logClearBreadcrumbs} from '../features/facets/generic/facet-generic-insight-analytics-actions'; -import {registerDateFacet} from '../features/facets/range-facets/date-facet-set/date-facet-actions'; -import {dateBreadcrumbFacet} from '../features/facets/range-facets/date-facet-set/date-facet-analytics-actions'; -import {logDateFacetBreadcrumb} from '../features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions'; -import {dateFacetSetReducer} from '../features/facets/range-facets/date-facet-set/date-facet-set-slice'; -import {DateFacetValue} from '../features/facets/range-facets/date-facet-set/interfaces/response'; -import {registerNumericFacet} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-actions'; -import {numericBreadcrumbFacet} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions'; -import {logNumericFacetBreadcrumb} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions'; -import {numericFacetSetReducer} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice'; -import {retryGeneratedAnswer} from '../features/generated-answer/generated-answer-analytics-actions'; -import {logRetryGeneratedAnswer} from '../features/generated-answer/generated-answer-insight-analytics-actions'; +} from '../features/facets/facet-set/facet-set-insight-analytics-actions.js'; +import {FacetSortCriterion} from '../features/facets/facet-set/interfaces/request.js'; +import {logClearBreadcrumbs} from '../features/facets/generic/facet-generic-insight-analytics-actions.js'; +import {registerDateFacet} from '../features/facets/range-facets/date-facet-set/date-facet-actions.js'; +import {dateBreadcrumbFacet} from '../features/facets/range-facets/date-facet-set/date-facet-analytics-actions.js'; +import {logDateFacetBreadcrumb} from '../features/facets/range-facets/date-facet-set/date-facet-insight-analytics-actions.js'; +import {dateFacetSetReducer} from '../features/facets/range-facets/date-facet-set/date-facet-set-slice.js'; +import {DateFacetValue} from '../features/facets/range-facets/date-facet-set/interfaces/response.js'; +import {registerNumericFacet} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-actions.js'; +import {numericBreadcrumbFacet} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-analytics-actions.js'; +import {logNumericFacetBreadcrumb} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-insight-analytics-actions.js'; +import {numericFacetSetReducer} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-set-slice.js'; +import {retryGeneratedAnswer} from '../features/generated-answer/generated-answer-analytics-actions.js'; +import {logRetryGeneratedAnswer} from '../features/generated-answer/generated-answer-insight-analytics-actions.js'; import { executeSearch, fetchFacetValues, fetchPage, -} from '../features/insight-search/insight-search-actions'; +} from '../features/insight-search/insight-search-actions.js'; import { logInsightInterfaceChange, logInsightInterfaceLoad, -} from '../features/insight-search/insight-search-analytics-actions'; -import {browseResults} from '../features/pagination/pagination-analytics-actions'; +} from '../features/insight-search/insight-search-analytics-actions.js'; +import {browseResults} from '../features/pagination/pagination-analytics-actions.js'; import { logPageNext, logPagePrevious, logPageNumber, -} from '../features/pagination/pagination-insight-analytics-actions'; -import {searchboxSubmit} from '../features/query/query-analytics-actions'; -import {logSearchboxSubmit} from '../features/query/query-insight-analytics-actions'; -import {resultsSort} from '../features/sort-criteria/sort-criteria-analytics-actions'; -import {logResultsSort} from '../features/sort-criteria/sort-criteria-insight-analytics-actions'; +} from '../features/pagination/pagination-insight-analytics-actions.js'; +import {searchboxSubmit} from '../features/query/query-analytics-actions.js'; +import {logSearchboxSubmit} from '../features/query/query-insight-analytics-actions.js'; +import {resultsSort} from '../features/sort-criteria/sort-criteria-analytics-actions.js'; +import {logResultsSort} from '../features/sort-criteria/sort-criteria-insight-analytics-actions.js'; import { StaticFilterValueMetadata, staticFilterDeselect, -} from '../features/static-filter-set/static-filter-set-actions'; -import {logInsightStaticFilterDeselect} from '../features/static-filter-set/static-filter-set-insight-analytics-actions'; -import {clearMicrotaskQueue} from '../test/unit-test-utils'; +} from '../features/static-filter-set/static-filter-set-actions.js'; +import {logInsightStaticFilterDeselect} from '../features/static-filter-set/static-filter-set-insight-analytics-actions.js'; +import {clearMicrotaskQueue} from '../test/unit-test-utils.js'; import { assertActionCause, assertNextEqualsLegacy, excludedBaseProperties, -} from './analytics-migration.test'; +} from './analytics-migration.test.js'; function getSampleInsightEngineConfiguration(): InsightEngineConfiguration { return { @@ -118,10 +122,14 @@ const ANY_STATIC_FILTER_VALUE: StaticFilterValueMetadata = { const ANY_CATEGORY_FACET_PATH = ['any category facet path']; describe('Analytics Search Migration', () => { - let callSpy: jest.SpyInstance>; + type Procedure = ( + ...args: unknown[] + ) => Promise; + + let callSpy: MockInstance; beforeEach(() => { - callSpy = jest.spyOn(PlatformClient, 'call'); + callSpy = vi.spyOn(PlatformClient, 'call'); callSpy.mockImplementation(() => Promise.resolve(new Response())); }); diff --git a/packages/headless/src/integration-tests/search-app.test.ts b/packages/headless/src/integration-tests/search-app.test.ts index e68223f450e..5523a5c8648 100644 --- a/packages/headless/src/integration-tests/search-app.test.ts +++ b/packages/headless/src/integration-tests/search-app.test.ts @@ -1,33 +1,33 @@ -import {Result} from '../api/search/search/result'; -import { - SearchEngine, - buildSearchEngine, -} from '../app/search-engine/search-engine'; +import {Result} from '../api/search/search/result.js'; import { getSampleSearchEngineConfiguration, SearchEngineConfiguration, -} from '../app/search-engine/search-engine-configuration'; +} from '../app/search-engine/search-engine-configuration.js'; +import { + SearchEngine, + buildSearchEngine, +} from '../app/search-engine/search-engine.js'; import { CategoryFacet, buildCategoryFacet, -} from '../controllers/facets/category-facet/headless-category-facet'; -import {Facet, FacetValue} from '../controllers/facets/facet/headless-facet'; -import {buildFacet} from '../controllers/facets/facet/headless-facet'; +} from '../controllers/facets/category-facet/headless-category-facet.js'; +import {Facet, FacetValue} from '../controllers/facets/facet/headless-facet.js'; +import {buildFacet} from '../controllers/facets/facet/headless-facet.js'; import { ResultList, buildResultList, -} from '../controllers/result-list/headless-result-list'; +} from '../controllers/result-list/headless-result-list.js'; import { SearchBox, buildSearchBox, -} from '../controllers/search-box/headless-search-box'; -import {Sort, buildSort} from '../controllers/sort/headless-sort'; +} from '../controllers/search-box/headless-search-box.js'; +import {Sort, buildSort} from '../controllers/sort/headless-sort.js'; import { buildDateSortCriterion, buildRelevanceSortCriterion, SortOrder, -} from '../features/sort-criteria/criteria'; -import {waitForNextStateChange} from '../test/functional-test-utils'; +} from '../features/sort-criteria/criteria.js'; +import {waitForNextStateChange} from '../test/functional-test-utils.js'; let configuration: SearchEngineConfiguration; let engine: SearchEngine; diff --git a/packages/headless/src/recommendation.index.ts b/packages/headless/src/recommendation.index.ts index a8fc60f4b25..887678d9f12 100644 --- a/packages/headless/src/recommendation.index.ts +++ b/packages/headless/src/recommendation.index.ts @@ -1,4 +1,4 @@ -import * as HighlightUtils from './utils/highlight'; +import * as HighlightUtils from './utils/highlight.js'; export {HighlightUtils}; @@ -9,50 +9,50 @@ export type { RecommendationEngine, RecommendationEngineOptions, RecommendationEngineConfiguration, -} from './app/recommendation-engine/recommendation-engine'; +} from './app/recommendation-engine/recommendation-engine.js'; export { buildRecommendationEngine, getSampleRecommendationEngineConfiguration, -} from './app/recommendation-engine/recommendation-engine'; +} from './app/recommendation-engine/recommendation-engine.js'; -export type {CoreEngine, ExternalEngineOptions} from './app/engine'; +export type {CoreEngine, ExternalEngineOptions} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; -export type {LoggerOptions} from './app/logger'; -export type {LogLevel} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +} from './app/engine-configuration.js'; +export type {LoggerOptions} from './app/logger.js'; +export type {LogLevel} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; // Actions -export * from './features/configuration/configuration-actions-loader'; -export * from './features/configuration/search-configuration-actions-loader'; -export * from './features/advanced-search-queries/advanced-search-queries-actions-loader'; -export * from './features/context/context-actions-loader'; -export * from './features/dictionary-field-context/dictionary-field-context-actions-loader'; -export * from './features/fields/fields-actions-loader'; -export * from './features/pipeline/pipeline-actions-loader'; -export * from './features/search-hub/search-hub-actions-loader'; -export * from './features/debug/debug-actions-loader'; -export * from './features/recommendation/recommendation-actions-loader'; -export * from './features/recommendation/recommendation-click-analytics-actions-loader'; -export * from './features/pagination/pagination-actions-loader'; +export * from './features/configuration/configuration-actions-loader.js'; +export * from './features/configuration/search-configuration-actions-loader.js'; +export * from './features/advanced-search-queries/advanced-search-queries-actions-loader.js'; +export * from './features/context/context-actions-loader.js'; +export * from './features/dictionary-field-context/dictionary-field-context-actions-loader.js'; +export * from './features/fields/fields-actions-loader.js'; +export * from './features/pipeline/pipeline-actions-loader.js'; +export * from './features/search-hub/search-hub-actions-loader.js'; +export * from './features/debug/debug-actions-loader.js'; +export * from './features/recommendation/recommendation-actions-loader.js'; +export * from './features/recommendation/recommendation-click-analytics-actions-loader.js'; +export * from './features/pagination/pagination-actions-loader.js'; // Controllers export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; -export {buildController} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; +export {buildController} from './controllers/controller/headless-controller.js'; export type { RecommendationListOptions, RecommendationListProps, RecommendationListState, RecommendationList, -} from './controllers/recommendation/headless-recommendation'; -export {buildRecommendationList} from './controllers/recommendation/headless-recommendation'; +} from './controllers/recommendation/headless-recommendation.js'; +export {buildRecommendationList} from './controllers/recommendation/headless-recommendation.js'; export type { RecommendationInteractiveResultOptions, @@ -61,8 +61,8 @@ export type { InteractiveResultCoreOptions, InteractiveResultCoreProps, InteractiveResultCore, -} from './controllers/recommendation/result-list/headless-recommendation-interactive-result'; -export {buildInteractiveResult} from './controllers/recommendation/result-list/headless-recommendation-interactive-result'; +} from './controllers/recommendation/result-list/headless-recommendation-interactive-result.js'; +export {buildInteractiveResult} from './controllers/recommendation/result-list/headless-recommendation-interactive-result.js'; export type { Context, @@ -71,40 +71,40 @@ export type { ContextState, ContextValue, ContextPayload, -} from './controllers/context/headless-context'; -export {buildContext} from './controllers/context/headless-context'; +} from './controllers/context/headless-context.js'; +export {buildContext} from './controllers/context/headless-context.js'; export type { DictionaryFieldContext, DictionaryFieldContextState, DictionaryFieldContextPayload, -} from './controllers/dictionary-field-context/headless-dictionary-field-context'; -export {buildDictionaryFieldContext} from './controllers/dictionary-field-context/headless-dictionary-field-context'; +} from './controllers/dictionary-field-context/headless-dictionary-field-context.js'; +export {buildDictionaryFieldContext} from './controllers/dictionary-field-context/headless-dictionary-field-context.js'; // Miscellaneous -export type {Result} from './api/search/search/result'; -export type {HighlightKeyword} from './utils/highlight'; -export type {Raw} from './api/search/search/raw'; +export type {Result} from './api/search/search/result.js'; +export type {HighlightKeyword} from './utils/highlight.js'; +export type {Raw} from './api/search/search/raw.js'; export { getOrganizationEndpoint, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; +} from './api/platform-client.js'; // Features export type { ResultTemplatesManager, ResultTemplate, ResultTemplateCondition, -} from './features/result-templates/result-templates-manager'; -export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager'; +} from './features/result-templates/result-templates-manager.js'; +export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager.js'; -export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers'; +export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers.js'; export { MinimumFieldsToInclude, DefaultFieldsToInclude, EcommerceDefaultFieldsToInclude, -} from './features/fields/fields-state'; +} from './features/fields/fields-state.js'; -export type {PlatformEnvironment} from './utils/url-utils'; +export type {PlatformEnvironment} from './utils/url-utils.js'; diff --git a/packages/headless/src/selectors/commerce-selectors.index.ts b/packages/headless/src/selectors/commerce-selectors.index.ts index 6d6d79fb364..88c9f1c8ebc 100644 --- a/packages/headless/src/selectors/commerce-selectors.index.ts +++ b/packages/headless/src/selectors/commerce-selectors.index.ts @@ -1,7 +1,7 @@ -import {CommerceEngine} from '../app/commerce-engine/commerce-engine'; -import {stateKey} from '../app/state-key'; -import * as PLSelectors from '../features/commerce/product-listing/product-listing-selectors'; -import * as SearchSelectors from '../features/commerce/search/search-selectors'; +import {CommerceEngine} from '../app/commerce-engine/commerce-engine.js'; +import {stateKey} from '../app/state-key.js'; +import * as PLSelectors from '../features/commerce/product-listing/product-listing-selectors.js'; +import * as SearchSelectors from '../features/commerce/search/search-selectors.js'; export namespace Search { export const responseIdSelector = wrapWithAccessFromEngine( diff --git a/packages/headless/src/ssr-commerce.index.ts b/packages/headless/src/ssr-commerce.index.ts index f6d62bcda7a..cc10e3af4a4 100644 --- a/packages/headless/src/ssr-commerce.index.ts +++ b/packages/headless/src/ssr-commerce.index.ts @@ -2,23 +2,23 @@ export type {Unsubscribe, Middleware} from '@reduxjs/toolkit'; export type {Relay} from '@coveo/relay'; // Main App -export type {CommerceEngineOptions} from './app/commerce-engine/commerce-engine'; -export type {CommerceEngineConfiguration} from './app/commerce-engine/commerce-engine-configuration'; +export type {CommerceEngineOptions} from './app/commerce-engine/commerce-engine.js'; +export type {CommerceEngineConfiguration} from './app/commerce-engine/commerce-engine-configuration.js'; export type { SSRCommerceEngine as CommerceEngine, CommerceEngineDefinition, CommerceEngineDefinitionOptions, -} from './app/commerce-engine/commerce-engine.ssr'; -export {defineCommerceEngine} from './app/commerce-engine/commerce-engine.ssr'; -export {getSampleCommerceEngineConfiguration} from './app/commerce-engine/commerce-engine-configuration'; +} from './app/commerce-engine/commerce-engine.ssr.js'; +export {defineCommerceEngine} from './app/commerce-engine/commerce-engine.ssr.js'; +export {getSampleCommerceEngineConfiguration} from './app/commerce-engine/commerce-engine-configuration.js'; // export type -export type {CoreEngineNext, ExternalEngineOptions} from './app/engine'; +export type {CoreEngineNext, ExternalEngineOptions} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; +} from './app/engine-configuration.js'; export type { ControllerDefinitionsMap, InferControllerFromDefinition, @@ -26,37 +26,37 @@ export type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, InferControllerStaticStateMapFromDefinitionsWithSolutionType, -} from './app/commerce-ssr-engine/types/common'; -export type {Build} from './app/ssr-engine/types/build'; +} from './app/commerce-ssr-engine/types/common.js'; +export type {Build} from './app/ssr-engine/types/build.js'; export type { EngineDefinition, InferStaticState, InferHydratedState, InferBuildResult, -} from './app/commerce-ssr-engine/types/core-engine'; -export type {LoggerOptions} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +} from './app/commerce-ssr-engine/types/core-engine.js'; +export type {LoggerOptions} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; -export type {LogLevel} from './app/logger'; +export type {LogLevel} from './app/logger.js'; // State export type { CommerceSearchParametersState, CommerceProductListingParametersState, CommerceAppState, -} from './state/commerce-app-state'; +} from './state/commerce-app-state.js'; //#region Controllers export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; export type { DidYouMean, DidYouMeanState, -} from './controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr'; -export {defineDidYouMean} from './controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr'; +} from './controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.js'; +export {defineDidYouMean} from './controllers/commerce/search/did-you-mean/headless-did-you-mean.ssr.js'; export type { BaseFacetSearchResult, @@ -73,15 +73,15 @@ export type { RegularFacet, RegularFacetState, RegularFacetValue, -} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr'; -export {defineFacetGenerator} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr'; +} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.js'; +export {defineFacetGenerator} from './controllers/commerce/core/facets/generator/headless-commerce-facet-generator.ssr.js'; export type { Pagination, PaginationProps, PaginationState, -} from './controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr'; -export {definePagination} from './controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr'; +} from './controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.js'; +export {definePagination} from './controllers/commerce/core/pagination/headless-core-commerce-pagination.ssr.js'; export type { ParameterManager, @@ -90,23 +90,23 @@ export type { Parameters, ProductListingParameters, CommerceSearchParameters, -} from './controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr'; -export {defineParameterManager} from './controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr'; +} from './controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.js'; +export {defineParameterManager} from './controllers/commerce/core/parameter-manager/headless-core-parameter-manager.ssr.js'; export type { ProductList, ProductListState, -} from './controllers/commerce/product-listing/headless-product-listing.ssr'; -export {defineProductList} from './controllers/commerce/product-listing/headless-product-listing.ssr'; +} from './controllers/commerce/product-listing/headless-product-listing.ssr.js'; +export {defineProductList} from './controllers/commerce/product-listing/headless-product-listing.ssr.js'; -export type {ProductView} from './controllers/commerce/product-view/headless-product-view.ssr'; -export {defineProductView} from './controllers/commerce/product-view/headless-product-view.ssr'; +export type {ProductView} from './controllers/commerce/product-view/headless-product-view.ssr.js'; +export {defineProductView} from './controllers/commerce/product-view/headless-product-view.ssr.js'; export type { RecommendationsState, Recommendations, -} from './controllers/commerce/recommendations/headless-recommendations.ssr'; -export {defineRecommendations} from './controllers/commerce/recommendations/headless-recommendations.ssr'; +} from './controllers/commerce/recommendations/headless-recommendations.ssr.js'; +export {defineRecommendations} from './controllers/commerce/recommendations/headless-recommendations.ssr.js'; export type { Cart, @@ -115,8 +115,8 @@ export type { CartProps, CartState, CartDefinition, -} from './controllers/commerce/context/cart/headless-cart.ssr'; -export {defineCart} from './controllers/commerce/context/cart/headless-cart.ssr'; +} from './controllers/commerce/context/cart/headless-cart.ssr.js'; +export {defineCart} from './controllers/commerce/context/cart/headless-cart.ssr.js'; export type { Context, @@ -125,8 +125,8 @@ export type { ContextState, View, ContextDefinition, -} from './controllers/commerce/context/headless-context.ssr'; -export {defineContext} from './controllers/commerce/context/headless-context.ssr'; +} from './controllers/commerce/context/headless-context.ssr.js'; +export {defineContext} from './controllers/commerce/context/headless-context.ssr.js'; export type { SearchBox, @@ -135,15 +135,15 @@ export type { SearchBoxState, Suggestion, SearchBoxDefinition, -} from './controllers/commerce/search-box/headless-search-box.ssr'; -export {defineSearchBox} from './controllers/commerce/search-box/headless-search-box.ssr'; +} from './controllers/commerce/search-box/headless-search-box.ssr.js'; +export {defineSearchBox} from './controllers/commerce/search-box/headless-search-box.ssr.js'; export type { Sort, SortProps, SortState, -} from './controllers/commerce/core/sort/headless-core-commerce-sort.ssr'; -export {defineSort} from './controllers/commerce/core/sort/headless-core-commerce-sort.ssr'; +} from './controllers/commerce/core/sort/headless-core-commerce-sort.ssr.js'; +export {defineSort} from './controllers/commerce/core/sort/headless-core-commerce-sort.ssr.js'; export type { Summary, @@ -151,8 +151,8 @@ export type { RecommendationsSummaryState, SearchSummaryState, SummaryState, -} from './controllers/commerce/core/summary/headless-core-summary.ssr'; -export {defineSummary} from './controllers/commerce/core/summary/headless-core-summary.ssr'; +} from './controllers/commerce/core/summary/headless-core-summary.ssr.js'; +export {defineSummary} from './controllers/commerce/core/summary/headless-core-summary.ssr.js'; export type { RecentQueriesList, @@ -161,8 +161,8 @@ export type { RecentQueriesListInitialState, RecentQueriesState, RecentQueriesListDefinition, -} from './controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr'; -export {defineRecentQueriesList} from './controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr'; +} from './controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.js'; +export {defineRecentQueriesList} from './controllers/commerce/recent-queries-list/headless-recent-queries-list.ssr.js'; export type { FieldSuggestions, @@ -173,37 +173,37 @@ export type { GeneratedFieldSuggestionsControllers, FieldSuggestionsGenerator, FieldSuggestionsGeneratorDefinition, -} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr'; -export {defineFieldSuggestionsGenerator} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr'; +} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.js'; +export {defineFieldSuggestionsGenerator} from './controllers/commerce/field-suggestions/headless-field-suggestions-generator.ssr.js'; export type { NotifyTrigger, NotifyTriggerState, NotifyTriggerDefinition, -} from './controllers/commerce/triggers/headless-notify-trigger.ssr'; -export {defineNotifyTrigger} from './controllers/commerce/triggers/headless-notify-trigger.ssr'; +} from './controllers/commerce/triggers/headless-notify-trigger.ssr.js'; +export {defineNotifyTrigger} from './controllers/commerce/triggers/headless-notify-trigger.ssr.js'; export type { QueryTrigger, QueryTriggerState, QueryTriggerDefinition, -} from './controllers/commerce/triggers/headless-query-trigger.ssr'; -export {defineQueryTrigger} from './controllers/commerce/triggers/headless-query-trigger.ssr'; +} from './controllers/commerce/triggers/headless-query-trigger.ssr.js'; +export {defineQueryTrigger} from './controllers/commerce/triggers/headless-query-trigger.ssr.js'; export type { RedirectionTrigger, RedirectionTriggerState, RedirectionTriggerDefinition, -} from './controllers/commerce/triggers/headless-redirection-trigger.ssr'; -export {defineRedirectionTrigger} from './controllers/commerce/triggers/headless-redirection-trigger.ssr'; +} from './controllers/commerce/triggers/headless-redirection-trigger.ssr.js'; +export {defineRedirectionTrigger} from './controllers/commerce/triggers/headless-redirection-trigger.ssr.js'; export type { StandaloneSearchBox, StandaloneSearchBoxProps, StandaloneSearchBoxState, StandaloneSearchBoxDefinition, -} from './controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr'; -export {defineStandaloneSearchBox} from './controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr'; +} from './controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.js'; +export {defineStandaloneSearchBox} from './controllers/commerce/standalone-search-box/headless-standalone-search-box.ssr.js'; export type { InstantProducts, @@ -211,37 +211,37 @@ export type { InstantProductsState, InstantProductsProps, InstantProductsDefinition, -} from './controllers/commerce/instant-products/headless-instant-products.ssr'; -export {defineInstantProducts} from './controllers/commerce/instant-products/headless-instant-products.ssr'; +} from './controllers/commerce/instant-products/headless-instant-products.ssr.js'; +export {defineInstantProducts} from './controllers/commerce/instant-products/headless-instant-products.ssr.js'; // TODO: KIT-3391 - export other SSR commerce controllers //#endregion //#region Grouped actions -export * from './features/commerce/context/context-actions-loader'; -export * from './features/commerce/search/search-actions-loader'; -export * from './features/commerce/product-listing/product-listing-actions-loader'; -export * from './features/commerce/recommendations/recommendations-actions-loader'; -export * from './features/commerce/pagination/pagination-actions-loader'; -export * from './features/commerce/product/product-actions-loaders'; -export * from './features/commerce/context/cart/cart-actions-loader'; -export * from './features/commerce/sort/sort-actions-loader'; -export * from './features/commerce/facets/core-facet/core-facet-actions-loader'; -export * from './features/commerce/facets/category-facet/category-facet-actions-loader'; -export * from './features/commerce/facets/regular-facet/regular-facet-actions-loader'; -export * from './features/commerce/facets/date-facet/date-facet-actions-loader'; -export * from './features/commerce/facets/numeric-facet/numeric-facet-actions-loader'; -export * from './features/commerce/query-set/query-set-actions-loader'; -export * from './features/commerce/query-suggest/query-suggest-actions-loader'; -export * from './features/commerce/configuration/configuration-actions-loader'; -export * from './features/commerce/query/query-actions-loader'; -export * from './features/commerce/search-parameters/search-parameters-actions-loader'; -export * from './features/commerce/product-listing-parameters/product-listing-parameters-actions-loader'; -export * from './features/commerce/triggers/triggers-actions-loader'; -export * from './features/commerce/instant-products/instant-products-actions-loader'; -export * from './features/commerce/recent-queries/recent-queries-actions-loader'; -export * from './features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader'; -export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager'; +export * from './features/commerce/context/context-actions-loader.js'; +export * from './features/commerce/search/search-actions-loader.js'; +export * from './features/commerce/product-listing/product-listing-actions-loader.js'; +export * from './features/commerce/recommendations/recommendations-actions-loader.js'; +export * from './features/commerce/pagination/pagination-actions-loader.js'; +export * from './features/commerce/product/product-actions-loaders.js'; +export * from './features/commerce/context/cart/cart-actions-loader.js'; +export * from './features/commerce/sort/sort-actions-loader.js'; +export * from './features/commerce/facets/core-facet/core-facet-actions-loader.js'; +export * from './features/commerce/facets/category-facet/category-facet-actions-loader.js'; +export * from './features/commerce/facets/regular-facet/regular-facet-actions-loader.js'; +export * from './features/commerce/facets/date-facet/date-facet-actions-loader.js'; +export * from './features/commerce/facets/numeric-facet/numeric-facet-actions-loader.js'; +export * from './features/commerce/query-set/query-set-actions-loader.js'; +export * from './features/commerce/query-suggest/query-suggest-actions-loader.js'; +export * from './features/commerce/configuration/configuration-actions-loader.js'; +export * from './features/commerce/query/query-actions-loader.js'; +export * from './features/commerce/search-parameters/search-parameters-actions-loader.js'; +export * from './features/commerce/product-listing-parameters/product-listing-parameters-actions-loader.js'; +export * from './features/commerce/triggers/triggers-actions-loader.js'; +export * from './features/commerce/instant-products/instant-products-actions-loader.js'; +export * from './features/commerce/recent-queries/recent-queries-actions-loader.js'; +export * from './features/commerce/standalone-search-box-set/standalone-search-box-set-actions-loader.js'; +export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager.js'; //#endregion // Types & Helpers @@ -250,7 +250,7 @@ export type { BaseProduct, Product, ChildProduct, -} from './api/commerce/common/product'; +} from './api/commerce/common/product.js'; export type { SortCriterion, SortByDate, @@ -258,7 +258,7 @@ export type { SortByNoSort, SortByQRE, SortByRelevancy, -} from './features/sort-criteria/criteria'; +} from './features/sort-criteria/criteria.js'; export { SortBy, SortOrder, @@ -268,36 +268,36 @@ export { buildNoSortCriterion, buildQueryRankingExpressionSortCriterion, buildRelevanceSortCriterion, -} from './features/sort-criteria/criteria'; -export {parseCriterionExpression} from './features/sort-criteria/criteria-parser'; -export type {Template} from './features/templates/templates-manager'; +} from './features/sort-criteria/criteria.js'; +export {parseCriterionExpression} from './features/sort-criteria/criteria-parser.js'; +export type {Template} from './features/templates/templates-manager.js'; export type { ProductTemplate, ProductTemplateCondition, ProductTemplatesManager, -} from './features/commerce/product-templates/product-templates-manager'; -export {ProductTemplatesHelpers} from './features/commerce/product-templates/product-templates-helpers'; +} from './features/commerce/product-templates/product-templates-manager.js'; +export {ProductTemplatesHelpers} from './features/commerce/product-templates/product-templates-helpers.js'; -export type {PlatformEnvironment} from './utils/url-utils'; +export type {PlatformEnvironment} from './utils/url-utils.js'; -export {buildSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer'; -export type {HighlightKeyword} from './utils/highlight'; -export {VERSION} from './utils/version'; +export {buildSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer.js'; +export type {HighlightKeyword} from './utils/highlight.js'; +export {VERSION} from './utils/version.js'; export type { RelativeDate, RelativeDatePeriod, RelativeDateUnit, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; export { deserializeRelativeDate, validateRelativeDate, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; export { getOrganizationEndpoint, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; +} from './api/platform-client.js'; -export {getCommerceApiBaseUrl} from './api/commerce/commerce-api-client'; +export {getCommerceApiBaseUrl} from './api/commerce/commerce-api-client.js'; -export * from './utils/query-expression/query-expression'; +export * from './utils/query-expression/query-expression.js'; diff --git a/packages/headless/src/ssr.index.ts b/packages/headless/src/ssr.index.ts index 6cd602c957d..1c099066c8e 100644 --- a/packages/headless/src/ssr.index.ts +++ b/packages/headless/src/ssr.index.ts @@ -8,63 +8,64 @@ export type { SearchEngineOptions, SearchEngineConfiguration, SearchConfigurationOptions, -} from './app/search-engine/search-engine'; +} from './app/search-engine/search-engine.js'; export type { SSRSearchEngine as SearchEngine, SearchEngineDefinition, SearchEngineDefinitionOptions, SearchCompletedAction, -} from './app/search-engine/search-engine.ssr'; -export {defineSearchEngine} from './app/search-engine/search-engine.ssr'; -export {getSampleSearchEngineConfiguration} from './app/search-engine/search-engine'; - -export type {InstantResultsDefinition} from './controllers/instant-results/instant-results.ssr'; -export type {AutomaticFacetGeneratorDefinition} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr'; -export type {BreadcrumbManagerDefinition} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr'; -export type {CategoryFacetDefinition} from './controllers/facets/category-facet/headless-category-facet.ssr'; -export type {CategoryFieldSuggestionsDefinition} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr'; -export type {ContextDefinition} from './controllers/context/headless-context.ssr'; -export type {DateFacetDefinition} from './controllers/facets/range-facet/date-facet/headless-date-facet.ssr'; -export type {DateFilterDefinition} from './controllers/facets/range-facet/date-facet/headless-date-filter.ssr'; -export type {DictionaryFieldContextDefinition} from './controllers/dictionary-field-context/headless-dictionary-field-context.ssr'; -export type {DidYouMeanDefinition} from './controllers/did-you-mean/headless-did-you-mean.ssr'; -export type {ExecuteTriggerDefinition} from './controllers/triggers/headless-execute-trigger.ssr'; -export type {FacetDefinition} from './controllers/facets/facet/headless-facet.ssr'; -export type {FacetManagerDefinition} from './controllers/facet-manager/headless-facet-manager.ssr'; -export type {FieldSuggestionsDefinition} from './controllers/field-suggestions/facet/headless-field-suggestions.ssr'; -export type {FoldedResultListDefinition} from './controllers/folded-result-list/headless-folded-result-list.ssr'; -export type {HistoryManagerDefinition} from './controllers/history-manager/headless-history-manager.ssr'; -export type {NotifyTriggerDefinition} from './controllers/triggers/headless-notify-trigger.ssr'; -export type {NumericFacetDefinition} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr'; -export type {NumericFilterDefinition} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr'; -export type {PagerDefinition} from './controllers/pager/headless-pager.ssr'; -export type {QueryErrorDefinition} from './controllers/query-error/headless-query-error.ssr'; -export type {QuerySummaryDefinition} from './controllers/query-summary/headless-query-summary.ssr'; -export type {QueryTriggerDefinition} from './controllers/triggers/headless-query-trigger.ssr'; -export type {QuickviewDefinition} from './controllers/quickview/headless-quickview.ssr'; -export type {RecentQueriesListDefinition} from './controllers/recent-queries-list/headless-recent-queries-list.ssr'; -export type {RecentResultsListDefinition} from './controllers/recent-results-list/headless-recent-results-list.ssr'; -export type {RedirectionTriggerDefinition} from './controllers/triggers/headless-redirection-trigger.ssr'; -export type {RelevanceInspectorDefinition} from './controllers/relevance-inspector/headless-relevance-inspector.ssr'; -export type {ResultListDefinition} from './controllers/result-list/headless-result-list.ssr'; -export type {ResultsPerPageDefinition} from './controllers/results-per-page/headless-results-per-page.ssr'; -export type {SearchBoxDefinition} from './controllers/search-box/headless-search-box.ssr'; -export type {SearchParameterManagerDefinition} from './controllers/search-parameter-manager/headless-search-parameter-manager.ssr'; -export type {SearchStatusDefinition} from './controllers/search-status/headless-search-status.ssr'; -export type {SmartSnippetDefinition} from './controllers/smart-snippet/headless-smart-snippet.ssr'; -export type {SmartSnippetQuestionsListDefinition} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr'; -export type {SortDefinition} from './controllers/sort/headless-sort.ssr'; -export type {StandaloneSearchBoxDefinition} from './controllers/standalone-search-box/headless-standalone-search-box.ssr'; -export type {StaticFilterDefinition} from './controllers/static-filter/headless-static-filter.ssr'; -export type {TabDefinition} from './controllers/tab/headless-tab.ssr'; +} from './app/search-engine/search-engine.ssr.js'; +export {defineSearchEngine} from './app/search-engine/search-engine.ssr.js'; +export {getSampleSearchEngineConfiguration} from './app/search-engine/search-engine.js'; + +export type {InstantResultsDefinition} from './controllers/instant-results/instant-results.ssr.js'; +export type {AutomaticFacetGeneratorDefinition} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.js'; +export type {BreadcrumbManagerDefinition} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.js'; +export type {CategoryFacetDefinition} from './controllers/facets/category-facet/headless-category-facet.ssr.js'; +export type {CategoryFieldSuggestionsDefinition} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.js'; +export type {ContextDefinition} from './controllers/context/headless-context.ssr.js'; +export type {DateFacetDefinition} from './controllers/facets/range-facet/date-facet/headless-date-facet.ssr.js'; +export type {DateFilterDefinition} from './controllers/facets/range-facet/date-facet/headless-date-filter.ssr.js'; +export type {DictionaryFieldContextDefinition} from './controllers/dictionary-field-context/headless-dictionary-field-context.ssr.js'; +export type {DidYouMeanDefinition} from './controllers/did-you-mean/headless-did-you-mean.ssr.js'; +export type {ExecuteTriggerDefinition} from './controllers/triggers/headless-execute-trigger.ssr.js'; +export type {FacetDefinition} from './controllers/facets/facet/headless-facet.ssr.js'; +export type {FacetManagerDefinition} from './controllers/facet-manager/headless-facet-manager.ssr.js'; +export type {FieldSuggestionsDefinition} from './controllers/field-suggestions/facet/headless-field-suggestions.ssr.js'; +export type {FoldedResultListDefinition} from './controllers/folded-result-list/headless-folded-result-list.ssr.js'; +export type {HistoryManagerDefinition} from './controllers/history-manager/headless-history-manager.ssr.js'; +export type {NotifyTriggerDefinition} from './controllers/triggers/headless-notify-trigger.ssr.js'; +export type {NumericFacetDefinition} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.js'; +export type {NumericFilterDefinition} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.js'; +export type {PagerDefinition} from './controllers/pager/headless-pager.ssr.js'; +export type {QueryErrorDefinition} from './controllers/query-error/headless-query-error.ssr.js'; +export type {QuerySummaryDefinition} from './controllers/query-summary/headless-query-summary.ssr.js'; +export type {QueryTriggerDefinition} from './controllers/triggers/headless-query-trigger.ssr.js'; +export type {QuickviewDefinition} from './controllers/quickview/headless-quickview.ssr.js'; +export type {RecentQueriesListDefinition} from './controllers/recent-queries-list/headless-recent-queries-list.ssr.js'; +export type {RecentResultsListDefinition} from './controllers/recent-results-list/headless-recent-results-list.ssr.js'; +export type {RedirectionTriggerDefinition} from './controllers/triggers/headless-redirection-trigger.ssr.js'; +export type {RelevanceInspectorDefinition} from './controllers/relevance-inspector/headless-relevance-inspector.ssr.js'; +export type {ResultListDefinition} from './controllers/result-list/headless-result-list.ssr.js'; +export type {ResultsPerPageDefinition} from './controllers/results-per-page/headless-results-per-page.ssr.js'; +export type {SearchBoxDefinition} from './controllers/search-box/headless-search-box.ssr.js'; +export type {SearchParameterManagerDefinition} from './controllers/search-parameter-manager/headless-search-parameter-manager.ssr.js'; +export type {SearchStatusDefinition} from './controllers/search-status/headless-search-status.ssr.js'; +export type {SmartSnippetDefinition} from './controllers/smart-snippet/headless-smart-snippet.ssr.js'; +export type {SmartSnippetQuestionsListDefinition} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.js'; +export type {SortDefinition} from './controllers/sort/headless-sort.ssr.js'; +export type {StandaloneSearchBoxDefinition} from './controllers/standalone-search-box/headless-standalone-search-box.ssr.js'; +export type {StaticFilterDefinition} from './controllers/static-filter/headless-static-filter.ssr.js'; +export type {TabDefinition} from './controllers/tab/headless-tab.ssr.js'; +export type {NavigatorContextProvider} from './app/navigatorContextProvider.js'; // export type -export type {CoreEngine, ExternalEngineOptions} from './app/engine'; +export type {CoreEngine, ExternalEngineOptions} from './app/engine.js'; export type { EngineConfiguration, AnalyticsConfiguration, AnalyticsRuntimeEnvironment, -} from './app/engine-configuration'; +} from './app/engine-configuration.js'; export type { ControllerDefinitionWithoutProps, ControllerDefinitionWithProps, @@ -74,30 +75,30 @@ export type { InferControllerStaticStateFromController, InferControllerStaticStateMapFromControllers, InferControllerStaticStateMapFromDefinitions, -} from './app/ssr-engine/types/common'; -export type {Build} from './app/ssr-engine/types/build'; +} from './app/ssr-engine/types/common.js'; +export type {Build} from './app/ssr-engine/types/build.js'; export type { EngineDefinition, InferStaticState, InferHydratedState, InferBuildResult, -} from './app/ssr-engine/types/core-engine'; -export type {LoggerOptions} from './app/logger'; -export type {NavigatorContext} from './app/navigatorContextProvider'; +} from './app/ssr-engine/types/core-engine.js'; +export type {LoggerOptions} from './app/logger.js'; +export type {NavigatorContext} from './app/navigatorContextProvider.js'; -export type {LogLevel} from './app/logger'; +export type {LogLevel} from './app/logger.js'; // State export type { SearchParametersState, SearchAppState, -} from './state/search-app-state'; +} from './state/search-app-state.js'; //#region Controllers export type { Controller, Subscribable, -} from './controllers/controller/headless-controller'; +} from './controllers/controller/headless-controller.js'; export type { RelevanceInspectorInitialState, RelevanceInspectorProps, @@ -113,8 +114,8 @@ export type { RankingInformation, TermWeightReport, SecurityIdentity, -} from './controllers/relevance-inspector/headless-relevance-inspector.ssr'; -export {defineRelevanceInspector} from './controllers/relevance-inspector/headless-relevance-inspector.ssr'; +} from './controllers/relevance-inspector/headless-relevance-inspector.ssr.js'; +export {defineRelevanceInspector} from './controllers/relevance-inspector/headless-relevance-inspector.ssr.js'; export type { Context, @@ -123,23 +124,23 @@ export type { ContextPayload, ContextProps, ContextInitialState, -} from './controllers/context/headless-context.ssr'; -export {defineContext} from './controllers/context/headless-context.ssr'; +} from './controllers/context/headless-context.ssr.js'; +export {defineContext} from './controllers/context/headless-context.ssr.js'; export type { DictionaryFieldContext, DictionaryFieldContextState, DictionaryFieldContextPayload, -} from './controllers/dictionary-field-context/headless-dictionary-field-context.ssr'; -export {defineDictionaryFieldContext} from './controllers/dictionary-field-context/headless-dictionary-field-context.ssr'; +} from './controllers/dictionary-field-context/headless-dictionary-field-context.ssr.js'; +export {defineDictionaryFieldContext} from './controllers/dictionary-field-context/headless-dictionary-field-context.ssr.js'; export type { DidYouMean, DidYouMeanState, QueryCorrection, WordCorrection, -} from './controllers/did-you-mean/headless-did-you-mean.ssr'; -export {defineDidYouMean} from './controllers/did-you-mean/headless-did-you-mean.ssr'; +} from './controllers/did-you-mean/headless-did-you-mean.ssr.js'; +export {defineDidYouMean} from './controllers/did-you-mean/headless-did-you-mean.ssr.js'; export type { CategoryFacetOptions, @@ -152,8 +153,8 @@ export type { CategoryFacetSearchResult, CoreCategoryFacet, CoreCategoryFacetState, -} from './controllers/facets/category-facet/headless-category-facet.ssr'; -export {defineCategoryFacet} from './controllers/facets/category-facet/headless-category-facet.ssr'; +} from './controllers/facets/category-facet/headless-category-facet.ssr.js'; +export {defineCategoryFacet} from './controllers/facets/category-facet/headless-category-facet.ssr.js'; export type { FacetOptions, @@ -168,8 +169,8 @@ export type { SpecificFacetSearchResult, CoreFacet, CoreFacetState, -} from './controllers/facets/facet/headless-facet.ssr'; -export {defineFacet} from './controllers/facets/facet/headless-facet.ssr'; +} from './controllers/facets/facet/headless-facet.ssr.js'; +export {defineFacet} from './controllers/facets/facet/headless-facet.ssr.js'; export type { DateRangeOptions, @@ -178,11 +179,11 @@ export type { DateFacetProps, DateFacetState, DateFacet, -} from './controllers/facets/range-facet/date-facet/headless-date-facet.ssr'; +} from './controllers/facets/range-facet/date-facet/headless-date-facet.ssr.js'; export { buildDateRange, defineDateFacet, -} from './controllers/facets/range-facet/date-facet/headless-date-facet.ssr'; +} from './controllers/facets/range-facet/date-facet/headless-date-facet.ssr.js'; export type { NumericRangeOptions, @@ -190,11 +191,11 @@ export type { NumericFacetProps, NumericFacetState, NumericFacet, -} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr'; +} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.js'; export { buildNumericRange, defineNumericFacet, -} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr'; +} from './controllers/facets/range-facet/numeric-facet/headless-numeric-facet.ssr.js'; export type { NumericFilter, @@ -203,8 +204,8 @@ export type { NumericFilterRange, NumericFilterState, NumericFilterInitialState, -} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr'; -export {defineNumericFilter} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr'; +} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.js'; +export {defineNumericFilter} from './controllers/facets/range-facet/numeric-facet/headless-numeric-filter.ssr.js'; export type { DateFilter, @@ -213,14 +214,14 @@ export type { DateFilterRange, DateFilterState, DateFilterInitialState, -} from './controllers/facets/range-facet/date-facet/headless-date-filter.ssr'; -export {defineDateFilter} from './controllers/facets/range-facet/date-facet/headless-date-filter.ssr'; +} from './controllers/facets/range-facet/date-facet/headless-date-filter.ssr.js'; +export {defineDateFilter} from './controllers/facets/range-facet/date-facet/headless-date-filter.ssr.js'; export type { HistoryManager, HistoryManagerState, -} from './controllers/history-manager/headless-history-manager.ssr'; -export {defineHistoryManager} from './controllers/history-manager/headless-history-manager.ssr'; +} from './controllers/history-manager/headless-history-manager.ssr.js'; +export {defineHistoryManager} from './controllers/history-manager/headless-history-manager.ssr.js'; export type { PagerInitialState, @@ -228,36 +229,36 @@ export type { PagerProps, PagerState, Pager, -} from './controllers/pager/headless-pager.ssr'; -export {definePager} from './controllers/pager/headless-pager.ssr'; +} from './controllers/pager/headless-pager.ssr.js'; +export {definePager} from './controllers/pager/headless-pager.ssr.js'; export type { QueryError, QueryErrorState, -} from './controllers/query-error/headless-query-error.ssr'; -export {defineQueryError} from './controllers/query-error/headless-query-error.ssr'; +} from './controllers/query-error/headless-query-error.ssr.js'; +export {defineQueryError} from './controllers/query-error/headless-query-error.ssr.js'; export type { QuerySummaryState, QuerySummary, -} from './controllers/query-summary/headless-query-summary.ssr'; -export {defineQuerySummary} from './controllers/query-summary/headless-query-summary.ssr'; +} from './controllers/query-summary/headless-query-summary.ssr.js'; +export {defineQuerySummary} from './controllers/query-summary/headless-query-summary.ssr.js'; export type { ResultListProps, ResultListOptions, ResultListState, ResultList, -} from './controllers/result-list/headless-result-list.ssr'; -export {defineResultList} from './controllers/result-list/headless-result-list.ssr'; +} from './controllers/result-list/headless-result-list.ssr.js'; +export {defineResultList} from './controllers/result-list/headless-result-list.ssr.js'; export type { ResultsPerPageInitialState, ResultsPerPageProps, ResultsPerPageState, ResultsPerPage, -} from './controllers/results-per-page/headless-results-per-page.ssr'; -export {defineResultsPerPage} from './controllers/results-per-page/headless-results-per-page.ssr'; +} from './controllers/results-per-page/headless-results-per-page.ssr.js'; +export {defineResultsPerPage} from './controllers/results-per-page/headless-results-per-page.ssr.js'; export type { SearchBoxOptions, @@ -267,24 +268,24 @@ export type { Suggestion, SuggestionHighlightingOptions, Delimiters, -} from './controllers/search-box/headless-search-box.ssr'; -export {defineSearchBox} from './controllers/search-box/headless-search-box.ssr'; +} from './controllers/search-box/headless-search-box.ssr.js'; +export {defineSearchBox} from './controllers/search-box/headless-search-box.ssr.js'; export type { InstantResults, InstantResultsState, InstantResultProps, InstantResultOptions, -} from './controllers/instant-results/instant-results.ssr'; -export {defineInstantResults} from './controllers/instant-results/instant-results.ssr'; +} from './controllers/instant-results/instant-results.ssr.js'; +export {defineInstantResults} from './controllers/instant-results/instant-results.ssr.js'; export type { SortInitialState, SortProps, SortState, Sort, -} from './controllers/sort/headless-sort.ssr'; -export {defineSort} from './controllers/sort/headless-sort.ssr'; +} from './controllers/sort/headless-sort.ssr.js'; +export {defineSort} from './controllers/sort/headless-sort.ssr.js'; export type { StaticFilterValueOptions, @@ -294,11 +295,11 @@ export type { StaticFilterState, StaticFilterValue, StaticFilterValueState, -} from './controllers/static-filter/headless-static-filter.ssr'; +} from './controllers/static-filter/headless-static-filter.ssr.js'; export { buildStaticFilterValue, defineStaticFilter, -} from './controllers/static-filter/headless-static-filter.ssr'; +} from './controllers/static-filter/headless-static-filter.ssr.js'; export type { TabInitialState, @@ -306,21 +307,21 @@ export type { TabProps, TabState, Tab, -} from './controllers/tab/headless-tab.ssr'; -export {defineTab} from './controllers/tab/headless-tab.ssr'; +} from './controllers/tab/headless-tab.ssr.js'; +export {defineTab} from './controllers/tab/headless-tab.ssr.js'; export type { TabManagerState, TabManager, -} from './controllers/tab-manager/headless-tab-manager.ssr'; -export {defineTabManager} from './controllers/tab-manager/headless-tab-manager.ssr'; +} from './controllers/tab-manager/headless-tab-manager.ssr.js'; +export {defineTabManager} from './controllers/tab-manager/headless-tab-manager.ssr.js'; export type { FacetManagerPayload, FacetManagerState, FacetManager, -} from './controllers/facet-manager/headless-facet-manager.ssr'; -export {defineFacetManager} from './controllers/facet-manager/headless-facet-manager.ssr'; +} from './controllers/facet-manager/headless-facet-manager.ssr.js'; +export {defineFacetManager} from './controllers/facet-manager/headless-facet-manager.ssr.js'; export type { NumericFacetBreadcrumb, @@ -336,8 +337,8 @@ export type { AutomaticFacetBreadcrumb, CoreBreadcrumbManager, CoreBreadcrumbManagerState, -} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr'; -export {defineBreadcrumbManager} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr'; +} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.js'; +export {defineBreadcrumbManager} from './controllers/breadcrumb-manager/headless-breadcrumb-manager.ssr.js'; export type { StandaloneSearchBoxOptions, @@ -345,8 +346,8 @@ export type { StandaloneSearchBoxProps, StandaloneSearchBoxState, StandaloneSearchBox, -} from './controllers/standalone-search-box/headless-standalone-search-box.ssr'; -export {defineStandaloneSearchBox} from './controllers/standalone-search-box/headless-standalone-search-box.ssr'; +} from './controllers/standalone-search-box/headless-standalone-search-box.ssr.js'; +export {defineStandaloneSearchBox} from './controllers/standalone-search-box/headless-standalone-search-box.ssr.js'; export type { SearchParameterManagerBuildProps, @@ -354,8 +355,8 @@ export type { SearchParameterManagerState, SearchParameterManager, SearchParameters, -} from './controllers/search-parameter-manager/headless-search-parameter-manager.ssr'; -export {defineSearchParameterManager} from './controllers/search-parameter-manager/headless-search-parameter-manager.ssr'; +} from './controllers/search-parameter-manager/headless-search-parameter-manager.ssr.js'; +export {defineSearchParameterManager} from './controllers/search-parameter-manager/headless-search-parameter-manager.ssr.js'; export type { UrlManager, @@ -363,16 +364,16 @@ export type { UrlManagerInitialState, UrlManagerProps, UrlManagerState, -} from './controllers/url-manager/headless-url-manager.ssr'; -export {defineUrlManager} from './controllers/url-manager/headless-url-manager.ssr'; +} from './controllers/url-manager/headless-url-manager.ssr.js'; +export {defineUrlManager} from './controllers/url-manager/headless-url-manager.ssr.js'; export type { SearchStatus, SearchStatusState, -} from './controllers/search-status/headless-search-status.ssr'; -export {defineSearchStatus} from './controllers/search-status/headless-search-status.ssr'; +} from './controllers/search-status/headless-search-status.ssr.js'; +export {defineSearchStatus} from './controllers/search-status/headless-search-status.ssr.js'; -export type {ErrorPayload} from './controllers/controller/error-payload'; +export type {ErrorPayload} from './controllers/controller/error-payload.js'; export type { Quickview, @@ -381,8 +382,8 @@ export type { QuickviewState, CoreQuickviewState, CoreQuickview, -} from './controllers/quickview/headless-quickview.ssr'; -export {defineQuickview} from './controllers/quickview/headless-quickview.ssr'; +} from './controllers/quickview/headless-quickview.ssr.js'; +export {defineQuickview} from './controllers/quickview/headless-quickview.ssr.js'; export type { FoldingOptions, @@ -392,34 +393,34 @@ export type { FoldedResultListProps, FoldedResultList, FoldedResultListState, -} from './controllers/folded-result-list/headless-folded-result-list.ssr'; -export {defineFoldedResultList} from './controllers/folded-result-list/headless-folded-result-list.ssr'; +} from './controllers/folded-result-list/headless-folded-result-list.ssr.js'; +export {defineFoldedResultList} from './controllers/folded-result-list/headless-folded-result-list.ssr.js'; export type { RedirectionTrigger, RedirectionTriggerState, -} from './controllers/triggers/headless-redirection-trigger.ssr'; -export {defineRedirectionTrigger} from './controllers/triggers/headless-redirection-trigger.ssr'; +} from './controllers/triggers/headless-redirection-trigger.ssr.js'; +export {defineRedirectionTrigger} from './controllers/triggers/headless-redirection-trigger.ssr.js'; export type { QueryTrigger, QueryTriggerState, -} from './controllers/triggers/headless-query-trigger.ssr'; -export {defineQueryTrigger} from './controllers/triggers/headless-query-trigger.ssr'; +} from './controllers/triggers/headless-query-trigger.ssr.js'; +export {defineQueryTrigger} from './controllers/triggers/headless-query-trigger.ssr.js'; export type { ExecuteTrigger, ExecuteTriggerState, -} from './controllers/triggers/headless-execute-trigger.ssr'; -export {defineExecuteTrigger} from './controllers/triggers/headless-execute-trigger.ssr'; +} from './controllers/triggers/headless-execute-trigger.ssr.js'; +export {defineExecuteTrigger} from './controllers/triggers/headless-execute-trigger.ssr.js'; -export type {ExecuteTriggerParams} from './api/common/trigger'; +export type {ExecuteTriggerParams} from './api/common/trigger.js'; export type { NotifyTrigger, NotifyTriggerState, -} from './controllers/triggers/headless-notify-trigger.ssr'; -export {defineNotifyTrigger} from './controllers/triggers/headless-notify-trigger.ssr'; +} from './controllers/triggers/headless-notify-trigger.ssr.js'; +export {defineNotifyTrigger} from './controllers/triggers/headless-notify-trigger.ssr.js'; export type { SmartSnippet, @@ -428,10 +429,10 @@ export type { SmartSnippetState, QuestionAnswerDocumentIdentifier, SmartSnippetCore, -} from './controllers/smart-snippet/headless-smart-snippet.ssr'; -export {defineSmartSnippet} from './controllers/smart-snippet/headless-smart-snippet.ssr'; +} from './controllers/smart-snippet/headless-smart-snippet.ssr.js'; +export {defineSmartSnippet} from './controllers/smart-snippet/headless-smart-snippet.ssr.js'; -export type {InlineLink} from './controllers/smart-snippet/headless-smart-snippet-interactive-inline-links'; +export type {InlineLink} from './controllers/smart-snippet/headless-smart-snippet-interactive-inline-links.js'; export type { SmartSnippetQuestionsList, @@ -441,8 +442,8 @@ export type { SmartSnippetRelatedQuestion, CoreSmartSnippetQuestionsList, CoreSmartSnippetQuestionsListState, -} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr'; -export {defineSmartSnippetQuestionsList} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr'; +} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.js'; +export {defineSmartSnippetQuestionsList} from './controllers/smart-snippet-questions-list/headless-smart-snippet-questions-list.ssr.js'; export type { RecentQueriesListInitialState, @@ -450,8 +451,8 @@ export type { RecentQueriesState, RecentQueriesListProps, RecentQueriesListOptions, -} from './controllers/recent-queries-list/headless-recent-queries-list.ssr'; -export {defineRecentQueriesList} from './controllers/recent-queries-list/headless-recent-queries-list.ssr'; +} from './controllers/recent-queries-list/headless-recent-queries-list.ssr.js'; +export {defineRecentQueriesList} from './controllers/recent-queries-list/headless-recent-queries-list.ssr.js'; export type { RecentResultsListInitialState, @@ -459,8 +460,8 @@ export type { RecentResultsState, RecentResultsListProps, RecentResultsListOptions, -} from './controllers/recent-results-list/headless-recent-results-list.ssr'; -export {defineRecentResultsList} from './controllers/recent-results-list/headless-recent-results-list.ssr'; +} from './controllers/recent-results-list/headless-recent-results-list.ssr.js'; +export {defineRecentResultsList} from './controllers/recent-results-list/headless-recent-results-list.ssr.js'; export type { FieldSuggestionsValue, @@ -468,8 +469,8 @@ export type { FieldSuggestions, FieldSuggestionsOptions, FieldSuggestionsProps, -} from './controllers/field-suggestions/facet/headless-field-suggestions.ssr'; -export {defineFieldSuggestions} from './controllers/field-suggestions/facet/headless-field-suggestions.ssr'; +} from './controllers/field-suggestions/facet/headless-field-suggestions.ssr.js'; +export {defineFieldSuggestions} from './controllers/field-suggestions/facet/headless-field-suggestions.ssr.js'; export type { CategoryFieldSuggestionsValue, @@ -477,8 +478,8 @@ export type { CategoryFieldSuggestions, CategoryFieldSuggestionsOptions, CategoryFieldSuggestionsProps, -} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr'; -export {defineCategoryFieldSuggestions} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr'; +} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.js'; +export {defineCategoryFieldSuggestions} from './controllers/field-suggestions/category-facet/headless-category-field-suggestions.ssr.js'; export type { AutomaticFacet, @@ -487,8 +488,8 @@ export type { AutomaticFacetGeneratorProps, AutomaticFacetGeneratorState, AutomaticFacetGeneratorOptions, -} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr'; -export {defineAutomaticFacetGenerator} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr'; +} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.js'; +export {defineAutomaticFacetGenerator} from './controllers/facets/automatic-facet-generator/headless-automatic-facet-generator.ssr.js'; //#endregion // Selectors @@ -497,66 +498,66 @@ export { facetRequestSelector, facetResponseSelector, facetResponseSelectedValuesSelector, -} from './features/facets/facet-set/facet-set-selectors'; +} from './features/facets/facet-set/facet-set-selectors.js'; export { currentPageSelector, maxPageSelector, currentPagesSelector, -} from './features/pagination/pagination-selectors'; +} from './features/pagination/pagination-selectors.js'; //#region Grouped actions -export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers'; -export * from './features/advanced-search-queries/advanced-search-queries-actions-loader'; -export * from './features/facets/category-facet-set/category-facet-set-actions-loader'; -export * from './features/facets/facet-set/facet-set-actions-loader'; -export * from './features/configuration/configuration-actions-loader'; -export * from './features/configuration/search-configuration-actions-loader'; -export * from './features/context/context-actions-loader'; -export * from './features/dictionary-field-context/dictionary-field-context-actions-loader'; -export * from './features/debug/debug-actions-loader'; -export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader'; -export * from './features/facet-options/facet-options-actions-loader'; -export * from './features/did-you-mean/did-you-mean-actions-loader'; -export * from './features/fields/fields-actions-loader'; -export * from './features/history/history-actions-loader'; -export * from './features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader'; -export * from './features/folding/folding-actions-loader'; -export * from './features/pagination/pagination-actions-loader'; -export * from './features/pipeline/pipeline-actions-loader'; -export * from './features/query/query-actions-loader'; -export * from './features/query-set/query-set-actions-loader'; -export * from './features/instant-results/instant-results-actions-loader'; -export * from './features/query-suggest/query-suggest-actions-loader'; -export * from './features/search/search-actions-loader'; -export * from './features/search-hub/search-hub-actions-loader'; -export * from './features/sort-criteria/sort-criteria-actions-loader'; -export * from './features/standalone-search-box-set/standalone-search-box-set-actions-loader'; -export * from './features/static-filter-set/static-filter-set-actions-loader'; -export * from './features/tab-set/tab-set-actions-loader'; -export * from './features/question-answering/question-answering-actions-loader'; -export * from './features/breadcrumb/breadcrumb-actions-loader'; -export * from './features/recent-queries/recent-queries-actions-loader'; -export * from './features/recent-results/recent-results-actions-loader'; -export * from './features/excerpt-length/excerpt-length-actions-loader'; -export * from './features/result-preview/result-preview-actions-loader'; -export * from './features/generated-answer/generated-answer-actions-loader'; -export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager'; +export {ResultTemplatesHelpers} from './features/result-templates/result-templates-helpers.js'; +export * from './features/advanced-search-queries/advanced-search-queries-actions-loader.js'; +export * from './features/facets/category-facet-set/category-facet-set-actions-loader.js'; +export * from './features/facets/facet-set/facet-set-actions-loader.js'; +export * from './features/configuration/configuration-actions-loader.js'; +export * from './features/configuration/search-configuration-actions-loader.js'; +export * from './features/context/context-actions-loader.js'; +export * from './features/dictionary-field-context/dictionary-field-context-actions-loader.js'; +export * from './features/debug/debug-actions-loader.js'; +export * from './features/facets/range-facets/date-facet-set/date-facet-actions-loader.js'; +export * from './features/facet-options/facet-options-actions-loader.js'; +export * from './features/did-you-mean/did-you-mean-actions-loader.js'; +export * from './features/fields/fields-actions-loader.js'; +export * from './features/history/history-actions-loader.js'; +export * from './features/facets/range-facets/numeric-facet-set/numeric-facet-actions-loader.js'; +export * from './features/folding/folding-actions-loader.js'; +export * from './features/pagination/pagination-actions-loader.js'; +export * from './features/pipeline/pipeline-actions-loader.js'; +export * from './features/query/query-actions-loader.js'; +export * from './features/query-set/query-set-actions-loader.js'; +export * from './features/instant-results/instant-results-actions-loader.js'; +export * from './features/query-suggest/query-suggest-actions-loader.js'; +export * from './features/search/search-actions-loader.js'; +export * from './features/search-hub/search-hub-actions-loader.js'; +export * from './features/sort-criteria/sort-criteria-actions-loader.js'; +export * from './features/standalone-search-box-set/standalone-search-box-set-actions-loader.js'; +export * from './features/static-filter-set/static-filter-set-actions-loader.js'; +export * from './features/tab-set/tab-set-actions-loader.js'; +export * from './features/question-answering/question-answering-actions-loader.js'; +export * from './features/breadcrumb/breadcrumb-actions-loader.js'; +export * from './features/recent-queries/recent-queries-actions-loader.js'; +export * from './features/recent-results/recent-results-actions-loader.js'; +export * from './features/excerpt-length/excerpt-length-actions-loader.js'; +export * from './features/result-preview/result-preview-actions-loader.js'; +export * from './features/generated-answer/generated-answer-actions-loader.js'; +export {buildResultTemplatesManager} from './features/result-templates/result-templates-manager.js'; //#endregion // Analytics Actions -export * from './features/analytics/search-analytics-actions-loader'; -export * from './features/analytics/click-analytics-actions-loader'; -export * from './features/analytics/generic-analytics-actions-loader'; +export * from './features/analytics/search-analytics-actions-loader.js'; +export * from './features/analytics/click-analytics-actions-loader.js'; +export * from './features/analytics/generic-analytics-actions-loader.js'; // Types & Helpers -export {buildSSRSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer.ssr'; -export type {Result} from './api/search/search/result'; -export type {FieldDescription} from './api/search/fields/fields-response'; -export type {Raw} from './api/search/search/raw'; +export {buildSSRSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer.ssr.js'; +export type {Result} from './api/search/search/result.js'; +export type {FieldDescription} from './api/search/fields/fields-response.js'; +export type {Raw} from './api/search/search/raw.js'; export type { TermsToHighlight, PhrasesToHighlight, -} from './api/search/search/stemming'; +} from './api/search/search/stemming.js'; export type { SortCriterion, SortByDate, @@ -564,7 +565,7 @@ export type { SortByNoSort, SortByQRE, SortByRelevancy, -} from './features/sort-criteria/criteria'; +} from './features/sort-criteria/criteria.js'; export { SortBy, SortOrder, @@ -574,58 +575,58 @@ export { buildNoSortCriterion, buildQueryRankingExpressionSortCriterion, buildRelevanceSortCriterion, -} from './features/sort-criteria/criteria'; -export {parseCriterionExpression} from './features/sort-criteria/criteria-parser'; +} from './features/sort-criteria/criteria.js'; +export {parseCriterionExpression} from './features/sort-criteria/criteria-parser.js'; export type { ResultTemplatesManager, ResultTemplate, ResultTemplateCondition, -} from './features/result-templates/result-templates-manager'; -export type {PlatformEnvironment} from './utils/url-utils'; +} from './features/result-templates/result-templates-manager.js'; +export type {PlatformEnvironment} from './utils/url-utils.js'; export type { CategoryFacetValueRequest, CategoryFacetSortCriterion, -} from './features/facets/category-facet-set/interfaces/request'; -export type {DateRangeRequest} from './features/facets/range-facets/date-facet-set/interfaces/request'; +} from './features/facets/category-facet-set/interfaces/request.js'; +export type {DateRangeRequest} from './features/facets/range-facets/date-facet-set/interfaces/request.js'; export type { CategoryFacetValue, CategoryFacetValueCommon, -} from './features/facets/category-facet-set/interfaces/response'; -export type {DateFacetValue} from './features/facets/range-facets/date-facet-set/interfaces/response'; +} from './features/facets/category-facet-set/interfaces/response.js'; +export type {DateFacetValue} from './features/facets/range-facets/date-facet-set/interfaces/response.js'; export type { FacetValueRequest, FacetSortCriterion, -} from './features/facets/facet-set/interfaces/request'; -export type {FacetResultsMustMatch} from './features/facets/facet-api/request'; -export type {NumericRangeRequest} from './features/facets/range-facets/numeric-facet-set/interfaces/request'; -export type {NumericFacetValue} from './features/facets/range-facets/numeric-facet-set/interfaces/response'; -export type {AnyFacetValueRequest} from './features/facets/generic/interfaces/generic-facet-request'; +} from './features/facets/facet-set/interfaces/request.js'; +export type {FacetResultsMustMatch} from './features/facets/facet-api/request.js'; +export type {NumericRangeRequest} from './features/facets/range-facets/numeric-facet-set/interfaces/request.js'; +export type {NumericFacetValue} from './features/facets/range-facets/numeric-facet-set/interfaces/response.js'; +export type {AnyFacetValueRequest} from './features/facets/generic/interfaces/generic-facet-request.js'; export type { RangeFacetSortCriterion, RangeFacetRangeAlgorithm, -} from './features/facets/range-facets/generic/interfaces/request'; +} from './features/facets/range-facets/generic/interfaces/request.js'; export { MinimumFieldsToInclude, DefaultFieldsToInclude, EcommerceDefaultFieldsToInclude, -} from './features/fields/fields-state'; -export {buildSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer'; -export type {FunctionExecutionTrigger} from './features/triggers/triggers-state'; -export type {HighlightKeyword} from './utils/highlight'; -export {VERSION} from './utils/version'; +} from './features/fields/fields-state.js'; +export {buildSearchParameterSerializer} from './features/search-parameters/search-parameter-serializer.js'; +export type {FunctionExecutionTrigger} from './features/triggers/triggers-state.js'; +export type {HighlightKeyword} from './utils/highlight.js'; +export {VERSION} from './utils/version.js'; export type { RelativeDate, RelativeDatePeriod, RelativeDateUnit, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; export { deserializeRelativeDate, validateRelativeDate, -} from './api/search/date/relative-date'; +} from './api/search/date/relative-date.js'; export { getOrganizationEndpoint, getAnalyticsNextApiBaseUrl, -} from './api/platform-client'; +} from './api/platform-client.js'; -export * from './utils/query-expression/query-expression'; +export * from './utils/query-expression/query-expression.js'; diff --git a/packages/headless/src/state/case-assist-app-state.ts b/packages/headless/src/state/case-assist-app-state.ts index 5db203a39a8..fa96990cccb 100644 --- a/packages/headless/src/state/case-assist-app-state.ts +++ b/packages/headless/src/state/case-assist-app-state.ts @@ -8,7 +8,7 @@ import { VersionSection, ResultPreviewSection, SearchHubSection, -} from './state-sections'; +} from './state-sections.js'; export type CaseAssistAppState = ConfigurationSection & CaseAssistConfigurationSection & diff --git a/packages/headless/src/state/commerce-app-state.ts b/packages/headless/src/state/commerce-app-state.ts index 81892776baf..ee31a2abb81 100644 --- a/packages/headless/src/state/commerce-app-state.ts +++ b/packages/headless/src/state/commerce-app-state.ts @@ -22,7 +22,7 @@ import { TriggerSection, ManualRangeSection, CommerceConfigurationSection, -} from './state-sections'; +} from './state-sections.js'; export type CommerceProductListingParametersState = CommerceFacetSetSection & CommerceSortSection & diff --git a/packages/headless/src/state/insight-app-state.ts b/packages/headless/src/state/insight-app-state.ts index 8a8f9712657..a38108137d4 100644 --- a/packages/headless/src/state/insight-app-state.ts +++ b/packages/headless/src/state/insight-app-state.ts @@ -28,7 +28,7 @@ import { GeneratedAnswerSection, ContextSection, InsightUserActionsSection, -} from './state-sections'; +} from './state-sections.js'; export type InsightSearchParametersState = FacetSection & DateFacetSection & diff --git a/packages/headless/src/state/recommendation-app-state.ts b/packages/headless/src/state/recommendation-app-state.ts index b5704032571..d05508c4ff2 100644 --- a/packages/headless/src/state/recommendation-app-state.ts +++ b/packages/headless/src/state/recommendation-app-state.ts @@ -10,7 +10,7 @@ import { SearchHubSection, VersionSection, PaginationSection, -} from './state-sections'; +} from './state-sections.js'; export type RecommendationAppState = ConfigurationSection & FieldsSection & diff --git a/packages/headless/src/state/search-app-state.ts b/packages/headless/src/state/search-app-state.ts index 79df49623cf..2ea0ad8b828 100644 --- a/packages/headless/src/state/search-app-state.ts +++ b/packages/headless/src/state/search-app-state.ts @@ -37,7 +37,7 @@ import { ExcerptLengthSection, AutomaticFacetSection, GeneratedAnswerSection, -} from './state-sections'; +} from './state-sections.js'; export type SearchParametersState = FacetSection & DateFacetSection & diff --git a/packages/headless/src/state/state-sections.ts b/packages/headless/src/state/state-sections.ts index 3d86defa5f7..4037db6c629 100644 --- a/packages/headless/src/state/state-sections.ts +++ b/packages/headless/src/state/state-sections.ts @@ -1,64 +1,64 @@ -import {StateWithHistory} from '../app/undoable'; -import {AdvancedSearchQueriesState} from '../features/advanced-search-queries/advanced-search-queries-state'; -import {AttachedResultsState} from '../features/attached-results/attached-results-state'; -import {CaseAssistConfigurationState} from '../features/case-assist-configuration/case-assist-configuration-state'; -import {CaseContextState} from '../features/case-context/case-context-state'; -import {CaseFieldState} from '../features/case-field/case-field-state'; -import {CaseInputState} from '../features/case-input/case-input-state'; -import {ConfigurationState as CommerceConfigurationState} from '../features/commerce/configuration/configuration-state'; -import {CartState} from '../features/commerce/context/cart/cart-state'; -import {CommerceContextState} from '../features/commerce/context/context-state'; -import {DidYouMeanState as CommerceDidYouMeanState} from '../features/commerce/did-you-mean/did-you-mean-state'; -import {CommerceFacetSetState} from '../features/commerce/facets/facet-set/facet-set-state'; -import {FieldSuggestionsOrderState} from '../features/commerce/facets/field-suggestions-order/field-suggestions-order-state'; -import {ManualNumericFacetSetState} from '../features/commerce/facets/numeric-facet/manual-numeric-facet-state'; -import {InstantProductsState} from '../features/commerce/instant-products/instant-products-state'; -import {CommercePaginationState} from '../features/commerce/pagination/pagination-state'; -import {ProductListingState} from '../features/commerce/product-listing/product-listing-state'; -import {CommerceQueryState} from '../features/commerce/query/query-state'; -import {RecommendationsState as CommerceRecommendationsState} from '../features/commerce/recommendations/recommendations-state'; -import {CommerceSearchState} from '../features/commerce/search/search-state'; -import {CommerceSortState} from '../features/commerce/sort/sort-state'; -import {CommerceStandaloneSearchBoxSetState} from '../features/commerce/standalone-search-box-set/standalone-search-box-set-state'; -import {ConfigurationState} from '../features/configuration/configuration-state'; -import {ContextState} from '../features/context/context-state'; -import {DictionaryFieldContextState} from '../features/dictionary-field-context/dictionary-field-context-state'; -import {DidYouMeanState} from '../features/did-you-mean/did-you-mean-state'; -import {DocumentSuggestionState} from '../features/document-suggestion/document-suggestion-state'; -import {ExcerptLengthState} from '../features/excerpt-length/excerpt-length-state'; -import {FacetOptionsState} from '../features/facet-options/facet-options-state'; -import {AutomaticFacetSetState} from '../features/facets/automatic-facet-set/automatic-facet-set-state'; -import {CategoryFacetSetState} from '../features/facets/category-facet-set/category-facet-set-state'; -import {FacetOrderState} from '../features/facets/facet-order/facet-order-state'; -import {CategoryFacetSearchSetState} from '../features/facets/facet-search-set/category/category-facet-search-set-state'; -import {SpecificFacetSearchSetState} from '../features/facets/facet-search-set/specific/specific-facet-search-set-state'; -import {FacetSetState} from '../features/facets/facet-set/facet-set-state'; -import {DateFacetSetState} from '../features/facets/range-facets/date-facet-set/date-facet-set-state'; -import {NumericFacetSetState} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-set-state'; -import {FieldsState} from '../features/fields/fields-state'; -import {FoldingState} from '../features/folding/folding-state'; -import {GeneratedAnswerState} from '../features/generated-answer/generated-answer-state'; -import {HistoryState} from '../features/history/history-state'; -import {InsightConfigurationState} from '../features/insight-configuration/insight-configuration-state'; -import {InsightInterfaceState} from '../features/insight-interface/insight-interface-state'; -import {UserActionsState} from '../features/insight-user-actions/insight-user-actions-state'; -import {InstantResultsState} from '../features/instant-results/instant-results-state'; -import {PaginationState} from '../features/pagination/pagination-state'; -import {QuerySetState} from '../features/query-set/query-set-state'; -import {QuerySuggestSet} from '../features/query-suggest/query-suggest-state'; -import {QueryState} from '../features/query/query-state'; -import {QuestionAnsweringState} from '../features/question-answering/question-answering-state'; -import {RecentQueriesState} from '../features/recent-queries/recent-queries-state'; -import {RecentResultsState} from '../features/recent-results/recent-results-state'; -import {RecommendationState} from '../features/recommendation/recommendation-state'; -import {ResultPreviewState} from '../features/result-preview/result-preview-state'; -import {SearchState} from '../features/search/search-state'; -import {SortCriteriaState} from '../features/sort-criteria/sort-criteria-state'; -import {SortState} from '../features/sort/sort-state'; -import {StandaloneSearchBoxSetState} from '../features/standalone-search-box-set/standalone-search-box-set-state'; -import {StaticFilterSetState} from '../features/static-filter-set/static-filter-set-state'; -import {TabSetState} from '../features/tab-set/tab-set-state'; -import {TriggerState} from '../features/triggers/triggers-state'; +import {StateWithHistory} from '../app/undoable.js'; +import {AdvancedSearchQueriesState} from '../features/advanced-search-queries/advanced-search-queries-state.js'; +import {AttachedResultsState} from '../features/attached-results/attached-results-state.js'; +import {CaseAssistConfigurationState} from '../features/case-assist-configuration/case-assist-configuration-state.js'; +import {CaseContextState} from '../features/case-context/case-context-state.js'; +import {CaseFieldState} from '../features/case-field/case-field-state.js'; +import {CaseInputState} from '../features/case-input/case-input-state.js'; +import {ConfigurationState as CommerceConfigurationState} from '../features/commerce/configuration/configuration-state.js'; +import {CartState} from '../features/commerce/context/cart/cart-state.js'; +import {CommerceContextState} from '../features/commerce/context/context-state.js'; +import {DidYouMeanState as CommerceDidYouMeanState} from '../features/commerce/did-you-mean/did-you-mean-state.js'; +import {CommerceFacetSetState} from '../features/commerce/facets/facet-set/facet-set-state.js'; +import {FieldSuggestionsOrderState} from '../features/commerce/facets/field-suggestions-order/field-suggestions-order-state.js'; +import {ManualNumericFacetSetState} from '../features/commerce/facets/numeric-facet/manual-numeric-facet-state.js'; +import {InstantProductsState} from '../features/commerce/instant-products/instant-products-state.js'; +import {CommercePaginationState} from '../features/commerce/pagination/pagination-state.js'; +import {ProductListingState} from '../features/commerce/product-listing/product-listing-state.js'; +import {CommerceQueryState} from '../features/commerce/query/query-state.js'; +import {RecommendationsState as CommerceRecommendationsState} from '../features/commerce/recommendations/recommendations-state.js'; +import {CommerceSearchState} from '../features/commerce/search/search-state.js'; +import {CommerceSortState} from '../features/commerce/sort/sort-state.js'; +import {CommerceStandaloneSearchBoxSetState} from '../features/commerce/standalone-search-box-set/standalone-search-box-set-state.js'; +import {ConfigurationState} from '../features/configuration/configuration-state.js'; +import {ContextState} from '../features/context/context-state.js'; +import {DictionaryFieldContextState} from '../features/dictionary-field-context/dictionary-field-context-state.js'; +import {DidYouMeanState} from '../features/did-you-mean/did-you-mean-state.js'; +import {DocumentSuggestionState} from '../features/document-suggestion/document-suggestion-state.js'; +import {ExcerptLengthState} from '../features/excerpt-length/excerpt-length-state.js'; +import {FacetOptionsState} from '../features/facet-options/facet-options-state.js'; +import {AutomaticFacetSetState} from '../features/facets/automatic-facet-set/automatic-facet-set-state.js'; +import {CategoryFacetSetState} from '../features/facets/category-facet-set/category-facet-set-state.js'; +import {FacetOrderState} from '../features/facets/facet-order/facet-order-state.js'; +import {CategoryFacetSearchSetState} from '../features/facets/facet-search-set/category/category-facet-search-set-state.js'; +import {SpecificFacetSearchSetState} from '../features/facets/facet-search-set/specific/specific-facet-search-set-state.js'; +import {FacetSetState} from '../features/facets/facet-set/facet-set-state.js'; +import {DateFacetSetState} from '../features/facets/range-facets/date-facet-set/date-facet-set-state.js'; +import {NumericFacetSetState} from '../features/facets/range-facets/numeric-facet-set/numeric-facet-set-state.js'; +import {FieldsState} from '../features/fields/fields-state.js'; +import {FoldingState} from '../features/folding/folding-state.js'; +import {GeneratedAnswerState} from '../features/generated-answer/generated-answer-state.js'; +import {HistoryState} from '../features/history/history-state.js'; +import {InsightConfigurationState} from '../features/insight-configuration/insight-configuration-state.js'; +import {InsightInterfaceState} from '../features/insight-interface/insight-interface-state.js'; +import {UserActionsState} from '../features/insight-user-actions/insight-user-actions-state.js'; +import {InstantResultsState} from '../features/instant-results/instant-results-state.js'; +import {PaginationState} from '../features/pagination/pagination-state.js'; +import {QuerySetState} from '../features/query-set/query-set-state.js'; +import {QuerySuggestSet} from '../features/query-suggest/query-suggest-state.js'; +import {QueryState} from '../features/query/query-state.js'; +import {QuestionAnsweringState} from '../features/question-answering/question-answering-state.js'; +import {RecentQueriesState} from '../features/recent-queries/recent-queries-state.js'; +import {RecentResultsState} from '../features/recent-results/recent-results-state.js'; +import {RecommendationState} from '../features/recommendation/recommendation-state.js'; +import {ResultPreviewState} from '../features/result-preview/result-preview-state.js'; +import {SearchState} from '../features/search/search-state.js'; +import {SortCriteriaState} from '../features/sort-criteria/sort-criteria-state.js'; +import {SortState} from '../features/sort/sort-state.js'; +import {StandaloneSearchBoxSetState} from '../features/standalone-search-box-set/standalone-search-box-set-state.js'; +import {StaticFilterSetState} from '../features/static-filter-set/static-filter-set-state.js'; +import {TabSetState} from '../features/tab-set/tab-set-state.js'; +import {TriggerState} from '../features/triggers/triggers-state.js'; export interface QuerySection { /** diff --git a/packages/headless/src/test/functional-test-utils.ts b/packages/headless/src/test/functional-test-utils.ts index ea5a6c6ea78..584001f6448 100644 --- a/packages/headless/src/test/functional-test-utils.ts +++ b/packages/headless/src/test/functional-test-utils.ts @@ -1,5 +1,5 @@ -import type {CoreEngine, CoreEngineNext} from '../app/engine'; -import {Controller} from '../controllers/controller/headless-controller'; +import type {CoreEngine, CoreEngineNext} from '../app/engine.js'; +import {Controller} from '../controllers/controller/headless-controller.js'; function isEngine(obj: object): obj is CoreEngine { return 'dispatch' in obj; diff --git a/packages/headless/src/test/mock-advanced-search-queries-state.ts b/packages/headless/src/test/mock-advanced-search-queries-state.ts index 52f9a3b366f..53065d52234 100644 --- a/packages/headless/src/test/mock-advanced-search-queries-state.ts +++ b/packages/headless/src/test/mock-advanced-search-queries-state.ts @@ -1,4 +1,4 @@ -import {AdvancedSearchQueriesState} from '../features/advanced-search-queries/advanced-search-queries-state'; +import {AdvancedSearchQueriesState} from '../features/advanced-search-queries/advanced-search-queries-state.js'; export function buildMockAdvancedSearchQueriesState( config: Partial = {} diff --git a/packages/headless/src/test/mock-analytics-state.ts b/packages/headless/src/test/mock-analytics-state.ts index 96c7df4936c..412c69c8d90 100644 --- a/packages/headless/src/test/mock-analytics-state.ts +++ b/packages/headless/src/test/mock-analytics-state.ts @@ -1,4 +1,4 @@ -import {AnalyticsState} from '../features/configuration/configuration-state'; +import {AnalyticsState} from '../features/configuration/configuration-state.js'; export function buildMockAnalyticsState( config: Partial = {} diff --git a/packages/headless/src/test/mock-attached-results.ts b/packages/headless/src/test/mock-attached-results.ts index 43d51122923..0a6b556e938 100644 --- a/packages/headless/src/test/mock-attached-results.ts +++ b/packages/headless/src/test/mock-attached-results.ts @@ -1,4 +1,4 @@ -import {AttachedResult} from '../features/attached-results/attached-results-state'; +import {AttachedResult} from '../features/attached-results/attached-results-state.js'; export function createMockAttachedResult( config: Partial = {} diff --git a/packages/headless/src/test/mock-automatic-facet-request.ts b/packages/headless/src/test/mock-automatic-facet-request.ts index b2b7f1277c3..27d7abcf8ff 100644 --- a/packages/headless/src/test/mock-automatic-facet-request.ts +++ b/packages/headless/src/test/mock-automatic-facet-request.ts @@ -1,4 +1,4 @@ -import {AutomaticFacetRequest} from '../features/facets/automatic-facet-set/interfaces/request'; +import {AutomaticFacetRequest} from '../features/facets/automatic-facet-set/interfaces/request.js'; export function buildMockAutomaticFacetRequest( config: Partial = {} diff --git a/packages/headless/src/test/mock-automatic-facet-response.ts b/packages/headless/src/test/mock-automatic-facet-response.ts index d046a11dc8b..31094c53737 100644 --- a/packages/headless/src/test/mock-automatic-facet-response.ts +++ b/packages/headless/src/test/mock-automatic-facet-response.ts @@ -1,4 +1,4 @@ -import {AutomaticFacetResponse} from '../features/facets/automatic-facet-set/interfaces/response'; +import {AutomaticFacetResponse} from '../features/facets/automatic-facet-set/interfaces/response.js'; export function buildMockAutomaticFacetResponse( config: Partial = {} diff --git a/packages/headless/src/test/mock-automatic-facet-slice.ts b/packages/headless/src/test/mock-automatic-facet-slice.ts index c22849077ec..94cfd2c51cf 100644 --- a/packages/headless/src/test/mock-automatic-facet-slice.ts +++ b/packages/headless/src/test/mock-automatic-facet-slice.ts @@ -1,5 +1,5 @@ -import {AutomaticFacetSlice} from '../features/facets/automatic-facet-set/automatic-facet-set-state'; -import {buildMockAutomaticFacetResponse} from './mock-automatic-facet-response'; +import {AutomaticFacetSlice} from '../features/facets/automatic-facet-set/automatic-facet-set-state.js'; +import {buildMockAutomaticFacetResponse} from './mock-automatic-facet-response.js'; export function buildMockAutomaticFacetSlice( config: Partial = {} diff --git a/packages/headless/src/test/mock-case-assist-api-client.ts b/packages/headless/src/test/mock-case-assist-api-client.ts index e8dabcbbdbd..fea680be4eb 100644 --- a/packages/headless/src/test/mock-case-assist-api-client.ts +++ b/packages/headless/src/test/mock-case-assist-api-client.ts @@ -1,9 +1,9 @@ -import pino from 'pino'; -import {NoopPreprocessRequest} from '../api/preprocess-request'; +import {pino} from 'pino'; +import {NoopPreprocessRequest} from '../api/preprocess-request.js'; import { CaseAssistAPIClient, CaseAssistAPIClientOptions, -} from '../api/service/case-assist/case-assist-api-client'; +} from '../api/service/case-assist/case-assist-api-client.js'; export function buildMockCaseAssistAPIClient( options?: Partial diff --git a/packages/headless/src/test/mock-case-assist-document-suggestion.ts b/packages/headless/src/test/mock-case-assist-document-suggestion.ts index ba800ff0218..2e108216ce0 100644 --- a/packages/headless/src/test/mock-case-assist-document-suggestion.ts +++ b/packages/headless/src/test/mock-case-assist-document-suggestion.ts @@ -1,4 +1,4 @@ -import {DocumentSuggestionResponse} from '../api/service/case-assist/get-document-suggestions/get-document-suggestions-response'; +import {DocumentSuggestionResponse} from '../api/service/case-assist/get-document-suggestions/get-document-suggestions-response.js'; export const buildMockDocumentSuggestion = ( partialDocSuggestion?: Partial diff --git a/packages/headless/src/test/mock-case-assist-state.ts b/packages/headless/src/test/mock-case-assist-state.ts index 488e96b4c93..0174b45c417 100644 --- a/packages/headless/src/test/mock-case-assist-state.ts +++ b/packages/headless/src/test/mock-case-assist-state.ts @@ -1,12 +1,12 @@ -import {getCaseAssistConfigurationInitialState} from '../features/case-assist-configuration/case-assist-configuration-state'; -import {getCaseFieldInitialState} from '../features/case-field/case-field-state'; -import {getCaseInputInitialState} from '../features/case-input/case-input-state'; -import {getConfigurationInitialState} from '../features/configuration/configuration-state'; -import {getDebugInitialState} from '../features/debug/debug-state'; -import {getDocumentSuggestionInitialState} from '../features/document-suggestion/document-suggestion-state'; -import {getResultPreviewInitialState} from '../features/result-preview/result-preview-state'; -import {getSearchHubInitialState} from '../features/search-hub/search-hub-state'; -import {CaseAssistAppState} from '../state/case-assist-app-state'; +import {getCaseAssistConfigurationInitialState} from '../features/case-assist-configuration/case-assist-configuration-state.js'; +import {getCaseFieldInitialState} from '../features/case-field/case-field-state.js'; +import {getCaseInputInitialState} from '../features/case-input/case-input-state.js'; +import {getConfigurationInitialState} from '../features/configuration/configuration-state.js'; +import {getDebugInitialState} from '../features/debug/debug-state.js'; +import {getDocumentSuggestionInitialState} from '../features/document-suggestion/document-suggestion-state.js'; +import {getResultPreviewInitialState} from '../features/result-preview/result-preview-state.js'; +import {getSearchHubInitialState} from '../features/search-hub/search-hub-state.js'; +import {CaseAssistAppState} from '../state/case-assist-app-state.js'; export function buildMockCaseAssistState( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-request.ts b/packages/headless/src/test/mock-category-facet-request.ts index 4dd0c885feb..b24ec73109d 100644 --- a/packages/headless/src/test/mock-category-facet-request.ts +++ b/packages/headless/src/test/mock-category-facet-request.ts @@ -1,4 +1,4 @@ -import {CategoryFacetRequest} from '../features/facets/category-facet-set/interfaces/request'; +import {CategoryFacetRequest} from '../features/facets/category-facet-set/interfaces/request.js'; export function buildMockCategoryFacetRequest( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-response.ts b/packages/headless/src/test/mock-category-facet-response.ts index cff2f75fc1d..8d92ab5a0ff 100644 --- a/packages/headless/src/test/mock-category-facet-response.ts +++ b/packages/headless/src/test/mock-category-facet-response.ts @@ -1,4 +1,4 @@ -import {CategoryFacetResponse} from '../features/facets/category-facet-set/interfaces/response'; +import {CategoryFacetResponse} from '../features/facets/category-facet-set/interfaces/response.js'; export function buildMockCategoryFacetResponse( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-search-response.ts b/packages/headless/src/test/mock-category-facet-search-response.ts index 013f7d980fb..4fa79b7db9b 100644 --- a/packages/headless/src/test/mock-category-facet-search-response.ts +++ b/packages/headless/src/test/mock-category-facet-search-response.ts @@ -1,4 +1,4 @@ -import {CategoryFacetSearchResponse} from '../api/search/facet-search/category-facet-search/category-facet-search-response'; +import {CategoryFacetSearchResponse} from '../api/search/facet-search/category-facet-search/category-facet-search-response.js'; export function buildMockCategoryFacetSearchResponse( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-search-result.ts b/packages/headless/src/test/mock-category-facet-search-result.ts index 3c1152b5c41..aedb26f0e74 100644 --- a/packages/headless/src/test/mock-category-facet-search-result.ts +++ b/packages/headless/src/test/mock-category-facet-search-result.ts @@ -1,4 +1,4 @@ -import {CategoryFacetSearchResult} from '../api/search/facet-search/category-facet-search/category-facet-search-response'; +import {CategoryFacetSearchResult} from '../api/search/facet-search/category-facet-search/category-facet-search-response.js'; export function buildMockCategoryFacetSearchResult( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-search.ts b/packages/headless/src/test/mock-category-facet-search.ts index 97581c73d6c..b371172dc89 100644 --- a/packages/headless/src/test/mock-category-facet-search.ts +++ b/packages/headless/src/test/mock-category-facet-search.ts @@ -1,6 +1,6 @@ -import {CategoryFacetSearchState} from '../features/facets/facet-search-set/category/category-facet-search-set-state'; -import {buildMockCategoryFacetSearchResponse} from './mock-category-facet-search-response'; -import {buildMockFacetSearchRequestOptions} from './mock-facet-search-request-options'; +import {CategoryFacetSearchState} from '../features/facets/facet-search-set/category/category-facet-search-set-state.js'; +import {buildMockCategoryFacetSearchResponse} from './mock-category-facet-search-response.js'; +import {buildMockFacetSearchRequestOptions} from './mock-facet-search-request-options.js'; export function buildMockCategoryFacetSearch( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-slice.ts b/packages/headless/src/test/mock-category-facet-slice.ts index 14342c6fa73..44546967658 100644 --- a/packages/headless/src/test/mock-category-facet-slice.ts +++ b/packages/headless/src/test/mock-category-facet-slice.ts @@ -1,5 +1,5 @@ -import {CategoryFacetSlice} from '../features/facets/category-facet-set/category-facet-set-state'; -import {buildMockCategoryFacetRequest} from './mock-category-facet-request'; +import {CategoryFacetSlice} from '../features/facets/category-facet-set/category-facet-set-state.js'; +import {buildMockCategoryFacetRequest} from './mock-category-facet-request.js'; export function buildMockCategoryFacetSlice( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-value-request.ts b/packages/headless/src/test/mock-category-facet-value-request.ts index c475cc6242f..13509862ddc 100644 --- a/packages/headless/src/test/mock-category-facet-value-request.ts +++ b/packages/headless/src/test/mock-category-facet-value-request.ts @@ -1,4 +1,4 @@ -import {CategoryFacetValueRequest} from '../features/facets/category-facet-set/interfaces/request'; +import {CategoryFacetValueRequest} from '../features/facets/category-facet-set/interfaces/request.js'; export function buildMockCategoryFacetValueRequest( config: Partial = {} diff --git a/packages/headless/src/test/mock-category-facet-value.ts b/packages/headless/src/test/mock-category-facet-value.ts index 374a3e36ad7..94863501a4a 100644 --- a/packages/headless/src/test/mock-category-facet-value.ts +++ b/packages/headless/src/test/mock-category-facet-value.ts @@ -1,4 +1,4 @@ -import {CategoryFacetValue} from '../features/facets/category-facet-set/interfaces/response'; +import {CategoryFacetValue} from '../features/facets/category-facet-set/interfaces/response.js'; export function buildMockCategoryFacetValue( config: Partial = {} diff --git a/packages/headless/src/test/mock-citation.ts b/packages/headless/src/test/mock-citation.ts index bcc5f84ac9d..89592f87d07 100644 --- a/packages/headless/src/test/mock-citation.ts +++ b/packages/headless/src/test/mock-citation.ts @@ -1,4 +1,4 @@ -import {GeneratedAnswerCitation} from '../api/generated-answer/generated-answer-event-payload'; +import {GeneratedAnswerCitation} from '../api/generated-answer/generated-answer-event-payload.js'; /** * For internal use only. diff --git a/packages/headless/src/test/mock-commerce-api-client.ts b/packages/headless/src/test/mock-commerce-api-client.ts index 2db4138957a..42dc41188c0 100644 --- a/packages/headless/src/test/mock-commerce-api-client.ts +++ b/packages/headless/src/test/mock-commerce-api-client.ts @@ -1,9 +1,9 @@ -import pino from 'pino'; +import {pino} from 'pino'; import { CommerceAPIClient, CommerceAPIClientOptions, -} from '../api/commerce/commerce-api-client'; -import {NoopPreprocessRequest} from '../api/preprocess-request'; +} from '../api/commerce/commerce-api-client.js'; +import {NoopPreprocessRequest} from '../api/preprocess-request.js'; export function buildMockCommerceAPIClient( options?: Partial diff --git a/packages/headless/src/test/mock-commerce-facet-request.ts b/packages/headless/src/test/mock-commerce-facet-request.ts index eb96ac43b45..786b1dca442 100644 --- a/packages/headless/src/test/mock-commerce-facet-request.ts +++ b/packages/headless/src/test/mock-commerce-facet-request.ts @@ -1,4 +1,4 @@ -import {AnyFacetRequest} from '../features/commerce/facets/facet-set/interfaces/request'; +import {AnyFacetRequest} from '../features/commerce/facets/facet-set/interfaces/request.js'; export function buildMockCommerceFacetRequest( config: Partial = {} diff --git a/packages/headless/src/test/mock-commerce-facet-response.ts b/packages/headless/src/test/mock-commerce-facet-response.ts index 5640d3c442d..0fb0d568de9 100644 --- a/packages/headless/src/test/mock-commerce-facet-response.ts +++ b/packages/headless/src/test/mock-commerce-facet-response.ts @@ -4,7 +4,7 @@ import { DateFacetResponse, AnyFacetResponse, CategoryFacetResponse, -} from '../features/commerce/facets/facet-set/interfaces/response'; +} from '../features/commerce/facets/facet-set/interfaces/response.js'; function getMockBaseCommerceFacetResponse(): Omit< AnyFacetResponse, diff --git a/packages/headless/src/test/mock-commerce-facet-slice.ts b/packages/headless/src/test/mock-commerce-facet-slice.ts index 8409ff68a69..49a87b298ba 100644 --- a/packages/headless/src/test/mock-commerce-facet-slice.ts +++ b/packages/headless/src/test/mock-commerce-facet-slice.ts @@ -1,5 +1,5 @@ -import {CommerceFacetSlice} from '../features/commerce/facets/facet-set/facet-set-state'; -import {buildMockCommerceFacetRequest} from './mock-commerce-facet-request'; +import {CommerceFacetSlice} from '../features/commerce/facets/facet-set/facet-set-state.js'; +import {buildMockCommerceFacetRequest} from './mock-commerce-facet-request.js'; export function buildMockCommerceFacetSlice( config: Partial = {} diff --git a/packages/headless/src/test/mock-commerce-facet-value.ts b/packages/headless/src/test/mock-commerce-facet-value.ts index d29cdf35387..dffd169cd16 100644 --- a/packages/headless/src/test/mock-commerce-facet-value.ts +++ b/packages/headless/src/test/mock-commerce-facet-value.ts @@ -3,7 +3,7 @@ import { NumericFacetValue, DateFacetValue, CategoryFacetValue, -} from '../features/commerce/facets/facet-set/interfaces/response'; +} from '../features/commerce/facets/facet-set/interfaces/response.js'; export function buildMockCommerceRegularFacetValue( config: Partial = {} diff --git a/packages/headless/src/test/mock-commerce-search.ts b/packages/headless/src/test/mock-commerce-search.ts index fb704a4a0ed..cf65e53d5fc 100644 --- a/packages/headless/src/test/mock-commerce-search.ts +++ b/packages/headless/src/test/mock-commerce-search.ts @@ -1,6 +1,6 @@ -import {SearchCommerceSuccessResponse} from '../api/commerce/search/response'; -import {QuerySearchCommerceAPIThunkReturn} from '../features/commerce/search/search-actions'; -import {buildFetchProductListingResponse as buildFetchProductsCoreResponse} from './mock-product-listing'; +import {SearchCommerceSuccessResponse} from '../api/commerce/search/response.js'; +import {QuerySearchCommerceAPIThunkReturn} from '../features/commerce/search/search-actions.js'; +import {buildFetchProductListingResponse as buildFetchProductsCoreResponse} from './mock-product-listing.js'; export function buildSearchResponse( response: Partial = {}, diff --git a/packages/headless/src/test/mock-commerce-standalone-search-box-entry.ts b/packages/headless/src/test/mock-commerce-standalone-search-box-entry.ts index 76cdd07fcc7..2e167da064e 100644 --- a/packages/headless/src/test/mock-commerce-standalone-search-box-entry.ts +++ b/packages/headless/src/test/mock-commerce-standalone-search-box-entry.ts @@ -1,4 +1,4 @@ -import {StandaloneSearchBoxEntry} from '../features/commerce/standalone-search-box-set/standalone-search-box-set-state'; +import {StandaloneSearchBoxEntry} from '../features/commerce/standalone-search-box-set/standalone-search-box-set-state.js'; export function buildMockCommerceStandaloneSearchBoxEntry( config: Partial = {} diff --git a/packages/headless/src/test/mock-commerce-state.ts b/packages/headless/src/test/mock-commerce-state.ts index 2ea14549686..1ada557ff39 100644 --- a/packages/headless/src/test/mock-commerce-state.ts +++ b/packages/headless/src/test/mock-commerce-state.ts @@ -1,26 +1,26 @@ -import {getConfigurationInitialState} from '../features/commerce/configuration/configuration-state'; -import {getCartInitialState} from '../features/commerce/context/cart/cart-state'; -import {getContextInitialState} from '../features/commerce/context/context-state'; -import {getCommerceFacetSetInitialState} from '../features/commerce/facets/facet-set/facet-set-state'; -import {getFieldSuggestionsOrderInitialState} from '../features/commerce/facets/field-suggestions-order/field-suggestions-order-state'; -import {getManualNumericFacetInitialState} from '../features/commerce/facets/numeric-facet/manual-numeric-facet-state'; -import {getInstantProductsInitialState} from '../features/commerce/instant-products/instant-products-state'; -import {getCommercePaginationInitialState} from '../features/commerce/pagination/pagination-state'; -import {getProductListingInitialState} from '../features/commerce/product-listing/product-listing-state'; -import {getCommerceQueryInitialState} from '../features/commerce/query/query-state'; -import {getRecommendationsInitialState} from '../features/commerce/recommendations/recommendations-state'; -import {getCommerceSearchInitialState} from '../features/commerce/search/search-state'; -import {getCommerceSortInitialState} from '../features/commerce/sort/sort-state'; -import {getCommerceStandaloneSearchBoxSetInitialState} from '../features/commerce/standalone-search-box-set/standalone-search-box-set-state'; -import {getDidYouMeanInitialState} from '../features/did-you-mean/did-you-mean-state'; -import {getFacetOrderInitialState} from '../features/facets/facet-order/facet-order-state'; -import {getCategoryFacetSearchSetInitialState} from '../features/facets/facet-search-set/category/category-facet-search-set-state'; -import {getFacetSearchSetInitialState} from '../features/facets/facet-search-set/specific/specific-facet-search-set-state'; -import {getQuerySetInitialState} from '../features/query-set/query-set-state'; -import {getQuerySuggestSetInitialState} from '../features/query-suggest/query-suggest-state'; -import {getRecentQueriesInitialState} from '../features/recent-queries/recent-queries-state'; -import {getTriggerInitialState} from '../features/triggers/triggers-state'; -import {CommerceAppState} from '../state/commerce-app-state'; +import {getConfigurationInitialState} from '../features/commerce/configuration/configuration-state.js'; +import {getCartInitialState} from '../features/commerce/context/cart/cart-state.js'; +import {getContextInitialState} from '../features/commerce/context/context-state.js'; +import {getCommerceFacetSetInitialState} from '../features/commerce/facets/facet-set/facet-set-state.js'; +import {getFieldSuggestionsOrderInitialState} from '../features/commerce/facets/field-suggestions-order/field-suggestions-order-state.js'; +import {getManualNumericFacetInitialState} from '../features/commerce/facets/numeric-facet/manual-numeric-facet-state.js'; +import {getInstantProductsInitialState} from '../features/commerce/instant-products/instant-products-state.js'; +import {getCommercePaginationInitialState} from '../features/commerce/pagination/pagination-state.js'; +import {getProductListingInitialState} from '../features/commerce/product-listing/product-listing-state.js'; +import {getCommerceQueryInitialState} from '../features/commerce/query/query-state.js'; +import {getRecommendationsInitialState} from '../features/commerce/recommendations/recommendations-state.js'; +import {getCommerceSearchInitialState} from '../features/commerce/search/search-state.js'; +import {getCommerceSortInitialState} from '../features/commerce/sort/sort-state.js'; +import {getCommerceStandaloneSearchBoxSetInitialState} from '../features/commerce/standalone-search-box-set/standalone-search-box-set-state.js'; +import {getDidYouMeanInitialState} from '../features/did-you-mean/did-you-mean-state.js'; +import {getFacetOrderInitialState} from '../features/facets/facet-order/facet-order-state.js'; +import {getCategoryFacetSearchSetInitialState} from '../features/facets/facet-search-set/category/category-facet-search-set-state.js'; +import {getFacetSearchSetInitialState} from '../features/facets/facet-search-set/specific/specific-facet-search-set-state.js'; +import {getQuerySetInitialState} from '../features/query-set/query-set-state.js'; +import {getQuerySuggestSetInitialState} from '../features/query-suggest/query-suggest-state.js'; +import {getRecentQueriesInitialState} from '../features/recent-queries/recent-queries-state.js'; +import {getTriggerInitialState} from '../features/triggers/triggers-state.js'; +import {CommerceAppState} from '../state/commerce-app-state.js'; export function buildMockCommerceState( config: Partial = {} diff --git a/packages/headless/src/test/mock-date-facet-request.ts b/packages/headless/src/test/mock-date-facet-request.ts index 20deabc0bad..c3b47a7991e 100644 --- a/packages/headless/src/test/mock-date-facet-request.ts +++ b/packages/headless/src/test/mock-date-facet-request.ts @@ -1,4 +1,4 @@ -import {DateFacetRequest} from '../features/facets/range-facets/date-facet-set/interfaces/request'; +import {DateFacetRequest} from '../features/facets/range-facets/date-facet-set/interfaces/request.js'; export function buildMockDateFacetRequest( config: Partial