Skip to content

Commit 23e047c

Browse files
fix: Remove requestTagBeforeClosing dependency from chatClosingTags (#37822)
Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com>
1 parent 532604e commit 23e047c

File tree

5 files changed

+52
-94
lines changed

5 files changed

+52
-94
lines changed

.changeset/real-grapes-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rocket.chat/meteor": patch
3+
---
4+
5+
Fixes an issue where it‘s not being possible to configure department's `chatClosingTags` without enabling `requestTagBeforeClosingTag`

apps/meteor/client/views/omnichannel/departments/DepartmentTags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const DepartmentTags = ({ error, value: tags, onChange, ...props }: DepartmentTa
4848
</Button>
4949
</FieldRow>
5050
{tags?.length > 0 && (
51-
<FieldRow>
51+
<FieldRow justifyContent='flex-start'>
5252
{tags.map((tag, i) => (
5353
<Chip key={i} onClick={handleTagChipClick(tag)} mie={8}>
5454
{tag}

apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ function EditDepartment({ data, id, title, allowedToForwardData }: EditDepartmen
6969
register,
7070
control,
7171
handleSubmit,
72-
watch,
7372
formState: { errors, isValid, isDirty, isSubmitting },
7473
} = useForm<EditDepartmentFormData>({ mode: 'onChange', defaultValues: initialValues });
7574

76-
const requestTagBeforeClosingChat = watch('requestTagBeforeClosingChat');
77-
7875
const [fallbackFilter, setFallbackFilter] = useState<string>('');
7976
const [isUnitRequired, setUnitRequired] = useState(false);
8077

@@ -414,33 +411,28 @@ function EditDepartment({ data, id, title, allowedToForwardData }: EditDepartmen
414411
</FieldRow>
415412
</Field>
416413

417-
{requestTagBeforeClosingChat && (
418-
<Field>
419-
<FieldLabel htmlFor={chatClosingTagsField} required>
420-
{t('Conversation_closing_tags')}
421-
</FieldLabel>
422-
<Controller
423-
control={control}
424-
name='chatClosingTags'
425-
rules={{ required: t('Required_field', 'tags') }}
426-
render={({ field: { value, onChange } }) => (
427-
<DepartmentTags
428-
id={chatClosingTagsField}
429-
value={value}
430-
onChange={onChange}
431-
error={errors.chatClosingTags?.message as string}
432-
aria-describedby={`${chatClosingTagsField}-hint ${chatClosingTagsField}-error`}
433-
/>
434-
)}
435-
/>
436-
<FieldHint id={`${chatClosingTagsField}-hint`}>{t('Conversation_closing_tags_description')}</FieldHint>
437-
{errors.chatClosingTags && (
438-
<FieldError aria-live='assertive' id={`${chatClosingTagsField}-error`}>
439-
{errors.chatClosingTags?.message}
440-
</FieldError>
414+
<Field>
415+
<FieldLabel htmlFor={chatClosingTagsField}>{t('Conversation_closing_tags')}</FieldLabel>
416+
<Controller
417+
control={control}
418+
name='chatClosingTags'
419+
render={({ field: { value, onChange } }) => (
420+
<DepartmentTags
421+
id={chatClosingTagsField}
422+
value={value}
423+
onChange={onChange}
424+
error={errors.chatClosingTags?.message as string}
425+
aria-describedby={`${chatClosingTagsField}-hint ${chatClosingTagsField}-error`}
426+
/>
441427
)}
442-
</Field>
443-
)}
428+
/>
429+
<FieldHint id={`${chatClosingTagsField}-hint`}>{t('Conversation_closing_tags_description')}</FieldHint>
430+
{errors.chatClosingTags && (
431+
<FieldError aria-live='assertive' id={`${chatClosingTagsField}-error`}>
432+
{errors.chatClosingTags?.message}
433+
</FieldError>
434+
)}
435+
</Field>
444436

445437
<Field>
446438
<FieldRow>

apps/meteor/tests/e2e/omnichannel/omnichannel-departaments.spec.ts

Lines changed: 25 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -202,78 +202,43 @@ test.describe('OC - Manage Departments', () => {
202202
});
203203

204204
test('Request tag(s) before closing conversation', async () => {
205-
await test.step('expect create new department', async () => {
205+
await test.step('should create new department', async () => {
206206
await poOmnichannelDepartments.search(department.name);
207207
await expect(poOmnichannelDepartments.firstRowInTable).toBeVisible();
208208
});
209209

210-
await test.step('expect save form button be disabled', async () => {
211-
await poOmnichannelDepartments.search(department.name);
212-
await poOmnichannelDepartments.firstRowInTableMenu.click();
213-
await poOmnichannelDepartments.menuEditOption.click();
210+
const tagName = faker.string.sample(5);
211+
await poOmnichannelDepartments.firstRowInTableMenu.click();
212+
await poOmnichannelDepartments.menuEditOption.click();
213+
214+
await test.step('should form save button be disabled', async () => {
214215
await expect(poOmnichannelDepartments.btnSave).toBeDisabled();
215-
await poOmnichannelDepartments.btnBack.click();
216216
});
217217

218-
await test.step('Disabled tags state', async () => {
219-
await poOmnichannelDepartments.search(department.name);
220-
await poOmnichannelDepartments.firstRowInTableMenu.click();
221-
await poOmnichannelDepartments.menuEditOption.click();
218+
await test.step('should be able to add a tag properly', async () => {
219+
await poOmnichannelDepartments.inputTags.fill(tagName);
220+
await poOmnichannelDepartments.btnTagsAdd.click();
222221

223-
await test.step('expect to have department tags toggle button', async () => {
224-
await expect(poOmnichannelDepartments.toggleRequestTags).toBeVisible();
225-
});
226-
227-
await test.step('expect have no add tag to department', async () => {
228-
await expect(poOmnichannelDepartments.inputTags).not.toBeVisible();
229-
await expect(poOmnichannelDepartments.btnTagsAdd).not.toBeVisible();
230-
await poOmnichannelDepartments.btnBack.click();
231-
});
222+
await expect(poOmnichannelDepartments.btnTag(tagName)).toBeVisible();
223+
await expect(poOmnichannelDepartments.btnSave).toBeEnabled();
232224
});
233225

234-
await test.step('Enabled tags state', async () => {
235-
const tagName = faker.string.sample(5);
236-
237-
await poOmnichannelDepartments.search(department.name);
238-
await poOmnichannelDepartments.firstRowInTableMenu.click();
239-
await poOmnichannelDepartments.menuEditOption.click();
240-
241-
await test.step('expect to have form save option disabled', async () => {
242-
await expect(poOmnichannelDepartments.btnSave).toBeDisabled();
243-
});
244-
245-
await test.step('expect clicking on toggle button to enable tags', async () => {
246-
await poOmnichannelDepartments.toggleRequestTags.click();
247-
await expect(poOmnichannelDepartments.inputTags).toBeVisible();
248-
await expect(poOmnichannelDepartments.btnTagsAdd).toBeVisible();
249-
});
250-
251-
await test.step('expect to have add and remove one tag properly tags', async () => {
252-
await poOmnichannelDepartments.inputTags.fill(tagName);
253-
await poOmnichannelDepartments.btnTagsAdd.click();
254-
255-
await expect(poOmnichannelDepartments.btnTag(tagName)).toBeVisible();
256-
await expect(poOmnichannelDepartments.btnSave).toBeEnabled();
257-
});
258-
259-
await test.step('expect to be invalid if there is no tag added', async () => {
260-
await poOmnichannelDepartments.btnTag(tagName).click();
261-
await expect(poOmnichannelDepartments.invalidInputTags).toBeVisible();
262-
await expect(poOmnichannelDepartments.btnSave).toBeDisabled();
263-
});
226+
await test.step('should be able to remove a tag properly', async () => {
227+
await poOmnichannelDepartments.btnTag(tagName).click();
228+
await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled();
229+
});
264230

265-
await test.step('expect to be not possible adding empty tags', async () => {
266-
await poOmnichannelDepartments.inputTags.fill('');
267-
await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled();
268-
});
231+
await test.step('should not be possible to add empty tags', async () => {
232+
await poOmnichannelDepartments.inputTags.fill('');
233+
await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled();
234+
});
269235

270-
await test.step('expect to not be possible adding same tag twice', async () => {
271-
const tagName = faker.string.sample(5);
272-
await poOmnichannelDepartments.inputTags.fill(tagName);
273-
await poOmnichannelDepartments.btnTagsAdd.click();
274-
await poOmnichannelDepartments.inputTags.fill(tagName);
275-
await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled();
276-
});
236+
await test.step('should not be possible to add same tag twice', async () => {
237+
const tagName = faker.string.sample(5);
238+
await poOmnichannelDepartments.inputTags.fill(tagName);
239+
await poOmnichannelDepartments.btnTagsAdd.click();
240+
await poOmnichannelDepartments.inputTags.fill(tagName);
241+
await expect(poOmnichannelDepartments.btnTagsAdd).toBeDisabled();
277242
});
278243
});
279244

apps/meteor/tests/e2e/page-objects/omnichannel-departments.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export class OmnichannelDepartments {
4949
return this.page.locator('[data-qa="DepartmentEditTextInput-ConversationClosingTags"]');
5050
}
5151

52-
get invalidInputTags() {
53-
return this.page.locator('[data-qa="DepartmentEditTextInput-ConversationClosingTags"]:invalid');
54-
}
55-
5652
get invalidInputName() {
5753
return this.page.locator('[data-qa="DepartmentEditTextInput-Name"]:invalid');
5854
}

0 commit comments

Comments
 (0)