From b5962ad5916c223d78a6c3c3f07137cca77f036c Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 25 May 2024 06:42:31 +0530 Subject: [PATCH] Nc test/form view validations (#8548) * fix(nc-gui): bulk update field header issue * test: add custom validation test cases * test: add custom validation test cases * test: custom validation all type test cases * test: add email, phone number validation test cases * test: fix form fill textarea issue * test: add form validation shared view test cases * test: add survey form custom validation test cases * test: add limit to range survery form test cases * test: add attachment validation survey form test cases * chore(nc-gui): lint --- .../nc-gui/components/cell/DatePicker.vue | 5 + .../nc-gui/components/cell/DateTimePicker.vue | 6 + .../nc-gui/components/cell/TimePicker.vue | 6 + .../nc-gui/components/cell/YearPicker.vue | 6 + .../nc-gui/components/smartsheet/Form.vue | 4 +- .../components/smartsheet/header/Cell.vue | 27 +- .../smartsheet/header/VirtualCell.vue | 23 +- .../smartsheet/toolbar/ColumnFilterMenu.vue | 2 +- packages/nc-gui/context/index.ts | 1 + .../playwright/pages/Dashboard/Form/index.ts | 694 ++++++++++++- .../pages/Dashboard/SurveyForm/index.ts | 58 +- .../Dashboard/common/Cell/AttachmentCell.ts | 16 + .../pages/Dashboard/common/Cell/index.ts | 17 +- tests/playwright/pages/SharedForm/index.ts | 32 + .../tests/db/views/viewForm.spec.ts | 926 +++++++++++++++++- 15 files changed, 1776 insertions(+), 47 deletions(-) diff --git a/packages/nc-gui/components/cell/DatePicker.vue b/packages/nc-gui/components/cell/DatePicker.vue index a21fab44e8..878ab83887 100644 --- a/packages/nc-gui/components/cell/DatePicker.vue +++ b/packages/nc-gui/components/cell/DatePicker.vue @@ -29,6 +29,8 @@ const isGrid = inject(IsGridInj, ref(false)) const isForm = inject(IsFormInj, ref(false)) +const isSurveyForm = inject(IsSurveyFormInj, ref(false)) + const isExpandedForm = inject(IsExpandedFormOpenInj, ref(false)) const isDateInvalid = ref(false) @@ -193,6 +195,9 @@ const handleKeydown = (e: KeyboardEvent, _open?: boolean) => { switch (e.key) { case 'Enter': e.preventDefault() + if (isSurveyForm.value) { + e.stopPropagation() + } localState.value = tempDate.value open.value = !_open diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index 45fb5fb082..78cd8e3c1b 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -25,6 +25,8 @@ const isGrid = inject(IsGridInj, ref(false)) const isForm = inject(IsFormInj, ref(false)) +const isSurveyForm = inject(IsSurveyFormInj, ref(false)) + const { t } = useI18n() const isEditColumn = inject(EditColumnInj, ref(false)) @@ -225,6 +227,10 @@ const handleKeydown = (e: KeyboardEvent, _open?: boolean, _isDatePicker: boolean switch (e.key) { case 'Enter': e.preventDefault() + if (isSurveyForm.value) { + e.stopPropagation() + } + localState.value = tempDate.value if (!_isDatePicker) { e.stopPropagation() diff --git a/packages/nc-gui/components/cell/TimePicker.vue b/packages/nc-gui/components/cell/TimePicker.vue index 662303a163..96627b52c2 100644 --- a/packages/nc-gui/components/cell/TimePicker.vue +++ b/packages/nc-gui/components/cell/TimePicker.vue @@ -27,6 +27,8 @@ const isGrid = inject(IsGridInj, ref(false)) const isForm = inject(IsFormInj, ref(false)) +const isSurveyForm = inject(IsSurveyFormInj, ref(false)) + const isExpandedForm = inject(IsExpandedFormOpenInj, ref(false)) const column = inject(ColumnInj)! @@ -171,6 +173,10 @@ const handleKeydown = (e: KeyboardEvent, _open?: boolean) => { switch (e.key) { case 'Enter': e.preventDefault() + if (isSurveyForm.value) { + e.stopPropagation() + } + localState.value = tempDate.value open.value = !_open if (!open.value) { diff --git a/packages/nc-gui/components/cell/YearPicker.vue b/packages/nc-gui/components/cell/YearPicker.vue index 9c3dd5e7d3..e4ae1b5c21 100644 --- a/packages/nc-gui/components/cell/YearPicker.vue +++ b/packages/nc-gui/components/cell/YearPicker.vue @@ -27,6 +27,8 @@ const isGrid = inject(IsGridInj, ref(false)) const isForm = inject(IsFormInj, ref(false)) +const isSurveyForm = inject(IsSurveyFormInj, ref(false)) + const isExpandedForm = inject(IsExpandedFormOpenInj, ref(false)) const isYearInvalid = ref(false) @@ -157,6 +159,10 @@ const handleKeydown = (e: KeyboardEvent, _open?: boolean) => { switch (e.key) { case 'Enter': e.preventDefault() + if (isSurveyForm.value) { + e.stopPropagation() + } + localState.value = tempDate.value open.value = !_open if (!open.value) { diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue index b35e9324ca..847dc1aea2 100644 --- a/packages/nc-gui/components/smartsheet/Form.vue +++ b/packages/nc-gui/components/smartsheet/Form.vue @@ -1196,7 +1196,7 @@ useEventListener( }" > -
+
@@ -1297,7 +1297,7 @@ useEventListener(