From 8e2cc9f8938db001970c1700b13031d6fa05f2ab Mon Sep 17 00:00:00 2001 From: jasonchung1871 <101672465+jasonchung1871@users.noreply.github.com> Date: Tue, 25 Jun 2024 22:54:18 -0700 Subject: [PATCH] refactor: Forms 1121 composition api forms manage (#1386) * AddTeamMember updated AddTeamMember has been updated to the composition API. An issue with debounce has been fixes as it wasn't actually working. Tests now cover 100% of the script. * ApiKey updated ApiKey updated to the composition API with tests for full coverage * DocumentTemplate updated DocumentTemplate has been updated to the composition API. Some functions were moved to a composable. Tests were added for the composable, and tests are updated for DocumentTemplate. * Update EmailManagement.vue EmailManagement updated to the composition API * EmailTemplate updated EmailTemplate has been updated to the composition API and tests have been created for it * Update ManageForm ManageForm has been updated to the composition API and tests have been added. * Update ManageFormActions ManageFormActions is updated to the composition API and has added test coverage * Update ManageLayout ManageLayout updated to the composition API with added coverage * Update ManageVersions ManageVersions has been upgraded to the composition API and coverage has been added completely for it except for the template. * Update ShareForm ShareForm has been updated to the composition API and tests have been created for full coverage. Added the package vitest-canvas-mock so that we can mock the canvas required for the qr code generation. * Update Subscription Subscription.vue has been updated to the composition API and tests have been created for full coverage. * Update TeamManagement TeamManagement has been updated to the composition API and has full test coverage * fixed Design.spec.js removed console.log from identityProviders store added BaseSecure stub to Design.spec.js * Update ShareForm The shared URL did not have the full URL. --- app/frontend/package-lock.json | 40 +- app/frontend/package.json | 3 +- .../src/components/designer/FloatButton.vue | 2 +- .../components/forms/manage/AddTeamMember.vue | 305 ++-- .../src/components/forms/manage/ApiKey.vue | 174 +- .../forms/manage/DocumentTemplate.vue | 404 +++-- .../forms/manage/EmailManagement.vue | 41 +- .../components/forms/manage/EmailTemplate.vue | 112 +- .../components/forms/manage/ManageForm.vue | 237 ++- .../forms/manage/ManageFormActions.vue | 99 +- .../components/forms/manage/ManageLayout.vue | 57 +- .../forms/manage/ManageVersions.vue | 456 +++--- .../src/components/forms/manage/ShareForm.vue | 83 +- .../components/forms/manage/Subscription.vue | 131 +- .../forms/manage/TeamManagement.vue | 713 ++++---- .../src/composables/documentTemplate.js | 67 + app/frontend/src/composables/form.js | 22 + app/frontend/src/router.js | 11 +- .../forms/manage/AddTeamMember.spec.js | 925 +++++++++-- .../components/forms/manage/ApiKey.spec.js | 196 +++ .../forms/manage/DocumentTemplate.spec.js | 648 +++++++- .../forms/manage/EmailTemplate.spec.js | 102 ++ .../forms/manage/ManageForm.spec.js | 448 ++++- .../forms/manage/ManageFormActions.spec.js | 300 ++++ .../forms/manage/ManageLayout.spec.js | 39 +- .../forms/manage/ManageVersions.spec.js | 836 +++++++++- .../components/forms/manage/ShareForm.spec.js | 124 ++ .../forms/manage/Subscription.spec.js | 57 + .../forms/manage/TeamManagement.spec.js | 1440 ++++++++++++++++- .../unit/composables/documentTemplate.spec.js | 127 ++ .../tests/unit/composables/form.spec.js | 26 + .../tests/unit/fixtures/idir_user.json | 62 + app/frontend/tests/unit/fixtures/roles.json | 504 ++++++ app/frontend/tests/unit/setup.js | 2 + .../tests/unit/views/form/Create.spec.js | 16 + .../tests/unit/views/form/Design.spec.js | 5 +- app/frontend/vite.config.mjs | 6 +- 37 files changed, 7042 insertions(+), 1778 deletions(-) create mode 100644 app/frontend/src/composables/documentTemplate.js create mode 100644 app/frontend/src/composables/form.js create mode 100644 app/frontend/tests/unit/components/forms/manage/ApiKey.spec.js create mode 100644 app/frontend/tests/unit/components/forms/manage/EmailTemplate.spec.js create mode 100644 app/frontend/tests/unit/components/forms/manage/ManageFormActions.spec.js create mode 100644 app/frontend/tests/unit/components/forms/manage/ShareForm.spec.js create mode 100644 app/frontend/tests/unit/components/forms/manage/Subscription.spec.js create mode 100644 app/frontend/tests/unit/composables/documentTemplate.spec.js create mode 100644 app/frontend/tests/unit/composables/form.spec.js create mode 100644 app/frontend/tests/unit/fixtures/idir_user.json create mode 100644 app/frontend/tests/unit/fixtures/roles.json diff --git a/app/frontend/package-lock.json b/app/frontend/package-lock.json index ed5230553..5b89bcac0 100644 --- a/app/frontend/package-lock.json +++ b/app/frontend/package-lock.json @@ -55,7 +55,8 @@ "vite": "^5.2.6", "vite-plugin-eslint": "^1.8.1", "vite-plugin-vuetify": "^2.0.3", - "vitest": "^0.32.2" + "vitest": "^0.32.2", + "vitest-canvas-mock": "^0.3.3" } }, "node_modules/@ampproject/remapping": { @@ -1919,6 +1920,12 @@ "node": ">=4" } }, + "node_modules/cssfontparser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/cssfontparser/-/cssfontparser-1.2.1.tgz", + "integrity": "sha512-6tun4LoZnj7VN6YeegOVb67KBX/7JJsqvj+pv3ZA7F878/eN33AbGa5b/S/wXxS/tcp8nc40xRUrsPlxIyNUPg==", + "dev": true + }, "node_modules/cssstyle": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-3.0.0.tgz", @@ -3509,6 +3516,16 @@ "node": ">=8" } }, + "node_modules/jest-canvas-mock": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jest-canvas-mock/-/jest-canvas-mock-2.5.2.tgz", + "integrity": "sha512-vgnpPupjOL6+L5oJXzxTxFrlGEIbHdZqFU+LFNdtLxZ3lRDCl17FlTMM7IatoRQkrcyOTMlDinjUguqmQ6bR2A==", + "dev": true, + "dependencies": { + "cssfontparser": "^1.2.1", + "moo-color": "^1.0.2" + } + }, "node_modules/js-beautify": { "version": "1.14.6", "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.14.6.tgz", @@ -3857,6 +3874,15 @@ "node": "*" } }, + "node_modules/moo-color": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/moo-color/-/moo-color-1.0.3.tgz", + "integrity": "sha512-i/+ZKXMDf6aqYtBhuOcej71YSlbjT3wCO/4H1j8rPvxDJEifdwgg5MaFyu6iYAT8GBZJg2z0dkgK4YMzvURALQ==", + "dev": true, + "dependencies": { + "color-name": "^1.1.4" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5765,6 +5791,18 @@ } } }, + "node_modules/vitest-canvas-mock": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/vitest-canvas-mock/-/vitest-canvas-mock-0.3.3.tgz", + "integrity": "sha512-3P968tYBpqYyzzOaVtqnmYjqbe13576/fkjbDEJSfQAkHtC5/UjuRHOhFEN/ZV5HVZIkaROBUWgazDKJ+Ibw+Q==", + "dev": true, + "dependencies": { + "jest-canvas-mock": "~2.5.2" + }, + "peerDependencies": { + "vitest": "*" + } + }, "node_modules/vitest/node_modules/@esbuild/android-arm": { "version": "0.18.20", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.20.tgz", diff --git a/app/frontend/package.json b/app/frontend/package.json index 42fdb9f7c..76a987ddd 100644 --- a/app/frontend/package.json +++ b/app/frontend/package.json @@ -76,6 +76,7 @@ "vite": "^5.2.6", "vite-plugin-eslint": "^1.8.1", "vite-plugin-vuetify": "^2.0.3", - "vitest": "^0.32.2" + "vitest": "^0.32.2", + "vitest-canvas-mock": "^0.3.3" } } diff --git a/app/frontend/src/components/designer/FloatButton.vue b/app/frontend/src/components/designer/FloatButton.vue index 6478547b7..58ef2ac5d 100644 --- a/app/frontend/src/components/designer/FloatButton.vue +++ b/app/frontend/src/components/designer/FloatButton.vue @@ -393,7 +393,7 @@ export default { -import _ from 'lodash'; -import { mapState, mapActions } from 'pinia'; + +/* c8 ignore start */ +/* c8 ignore end */ diff --git a/app/frontend/src/components/forms/manage/DocumentTemplate.vue b/app/frontend/src/components/forms/manage/DocumentTemplate.vue index 3d3ea87ca..146904ff4 100644 --- a/app/frontend/src/components/forms/manage/DocumentTemplate.vue +++ b/app/frontend/src/components/forms/manage/DocumentTemplate.vue @@ -1,231 +1,203 @@ -