diff --git a/.changeset/real-grapes-itch.md b/.changeset/real-grapes-itch.md new file mode 100644 index 0000000000000..e4eda2815fa45 --- /dev/null +++ b/.changeset/real-grapes-itch.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes an issue where it‘s not being possible to configure department's `chatClosingTags` without enabling `requestTagBeforeClosingTag` diff --git a/apps/meteor/client/views/omnichannel/departments/DepartmentTags.tsx b/apps/meteor/client/views/omnichannel/departments/DepartmentTags.tsx index 7af5ddd9a1cc1..273b3cd3b6c5e 100644 --- a/apps/meteor/client/views/omnichannel/departments/DepartmentTags.tsx +++ b/apps/meteor/client/views/omnichannel/departments/DepartmentTags.tsx @@ -48,7 +48,7 @@ const DepartmentTags = ({ error, value: tags, onChange, ...props }: DepartmentTa {tags?.length > 0 && ( - + {tags.map((tag, i) => ( {tag} diff --git a/apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx b/apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx index c658e6630668b..c856f3299a7ef 100644 --- a/apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx +++ b/apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx @@ -69,12 +69,9 @@ function EditDepartment({ data, id, title, allowedToForwardData }: EditDepartmen register, control, handleSubmit, - watch, formState: { errors, isValid, isDirty, isSubmitting }, } = useForm({ mode: 'onChange', defaultValues: initialValues }); - const requestTagBeforeClosingChat = watch('requestTagBeforeClosingChat'); - const [fallbackFilter, setFallbackFilter] = useState(''); const [isUnitRequired, setUnitRequired] = useState(false); @@ -414,33 +411,28 @@ function EditDepartment({ data, id, title, allowedToForwardData }: EditDepartmen - {requestTagBeforeClosingChat && ( - - - {t('Conversation_closing_tags')} - - ( - - )} - /> - {t('Conversation_closing_tags_description')} - {errors.chatClosingTags && ( - - {errors.chatClosingTags?.message} - + + {t('Conversation_closing_tags')} + ( + )} - - )} + /> + {t('Conversation_closing_tags_description')} + {errors.chatClosingTags && ( + + {errors.chatClosingTags?.message} + + )} + diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts index 280a436b1a43d..e555c4da7f6a9 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts @@ -202,78 +202,43 @@ test.describe('OC - Manage Departments', () => { }); test('Request tag(s) before closing conversation', async () => { - await test.step('expect create new department', async () => { + await test.step('should create new department', async () => { await poOmnichannelDepartments.search(department.name); await expect(poOmnichannelDepartments.firstRowInTable).toBeVisible(); }); - await test.step('expect save form button be disabled', async () => { - await poOmnichannelDepartments.search(department.name); - await poOmnichannelDepartments.firstRowInTableMenu.click(); - await poOmnichannelDepartments.menuEditOption.click(); + const tagName = faker.string.sample(5); + await poOmnichannelDepartments.firstRowInTableMenu.click(); + await poOmnichannelDepartments.menuEditOption.click(); + + await test.step('should form save button be disabled', async () => { await expect(poOmnichannelDepartments.btnSave).toBeDisabled(); - await poOmnichannelDepartments.btnBack.click(); }); - await test.step('Disabled tags state', async () => { - await poOmnichannelDepartments.search(department.name); - await poOmnichannelDepartments.firstRowInTableMenu.click(); - await poOmnichannelDepartments.menuEditOption.click(); + await test.step('should be able to add a tag properly', async () => { + await poOmnichannelDepartments.inputTags.fill(tagName); + await poOmnichannelDepartments.btnTagsAdd.click(); - await test.step('expect to have department tags toggle button', async () => { - await expect(poOmnichannelDepartments.toggleRequestTags).toBeVisible(); - }); - - await test.step('expect have no add tag to department', async () => { - await expect(poOmnichannelDepartments.inputTags).not.toBeVisible(); - await expect(poOmnichannelDepartments.btnTagsAdd).not.toBeVisible(); - await poOmnichannelDepartments.btnBack.click(); - }); + await expect(poOmnichannelDepartments.btnTag(tagName)).toBeVisible(); + await expect(poOmnichannelDepartments.btnSave).toBeEnabled(); }); - await test.step('Enabled tags state', async () => { - const tagName = faker.string.sample(5); - - await poOmnichannelDepartments.search(department.name); - await poOmnichannelDepartments.firstRowInTableMenu.click(); - await poOmnichannelDepartments.menuEditOption.click(); - - await test.step('expect to have form save option disabled', async () => { - await expect(poOmnichannelDepartments.btnSave).toBeDisabled(); - }); - - await test.step('expect clicking on toggle button to enable tags', async () => { - await poOmnichannelDepartments.toggleRequestTags.click(); - await expect(poOmnichannelDepartments.inputTags).toBeVisible(); - await expect(poOmnichannelDepartments.btnTagsAdd).toBeVisible(); - }); - - await test.step('expect to have add and remove one tag properly tags', async () => { - await poOmnichannelDepartments.inputTags.fill(tagName); - await poOmnichannelDepartments.btnTagsAdd.click(); - - await expect(poOmnichannelDepartments.btnTag(tagName)).toBeVisible(); - await expect(poOmnichannelDepartments.btnSave).toBeEnabled(); - }); - - await test.step('expect to be invalid if there is no tag added', async () => { - await poOmnichannelDepartments.btnTag(tagName).click(); - await expect(poOmnichannelDepartments.invalidInputTags).toBeVisible(); - await expect(poOmnichannelDepartments.btnSave).toBeDisabled(); - }); + await test.step('should be able to remove a tag properly', async () => { + await poOmnichannelDepartments.btnTag(tagName).click(); + await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled(); + }); - await test.step('expect to be not possible adding empty tags', async () => { - await poOmnichannelDepartments.inputTags.fill(''); - await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled(); - }); + await test.step('should not be possible to add empty tags', async () => { + await poOmnichannelDepartments.inputTags.fill(''); + await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled(); + }); - await test.step('expect to not be possible adding same tag twice', async () => { - const tagName = faker.string.sample(5); - await poOmnichannelDepartments.inputTags.fill(tagName); - await poOmnichannelDepartments.btnTagsAdd.click(); - await poOmnichannelDepartments.inputTags.fill(tagName); - await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled(); - }); + await test.step('should not be possible to add same tag twice', async () => { + const tagName = faker.string.sample(5); + await poOmnichannelDepartments.inputTags.fill(tagName); + await poOmnichannelDepartments.btnTagsAdd.click(); + await poOmnichannelDepartments.inputTags.fill(tagName); + await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled(); }); }); diff --git a/apps/meteor/tests/e2e/page-objects/omnichannel-departments.ts b/apps/meteor/tests/e2e/page-objects/omnichannel-departments.ts index 0cf92012387eb..315377de91f29 100644 --- a/apps/meteor/tests/e2e/page-objects/omnichannel-departments.ts +++ b/apps/meteor/tests/e2e/page-objects/omnichannel-departments.ts @@ -49,10 +49,6 @@ export class OmnichannelDepartments { return this.page.locator('[data-qa="DepartmentEditTextInput-ConversationClosingTags"]'); } - get invalidInputTags() { - return this.page.locator('[data-qa="DepartmentEditTextInput-ConversationClosingTags"]:invalid'); - } - get invalidInputName() { return this.page.locator('[data-qa="DepartmentEditTextInput-Name"]:invalid'); }