diff --git a/.changeset/polite-cars-love.md b/.changeset/polite-cars-love.md new file mode 100644 index 0000000000000..08c5bd235efa6 --- /dev/null +++ b/.changeset/polite-cars-love.md @@ -0,0 +1,6 @@ +--- +"@rocket.chat/meteor": patch +"@rocket.chat/livechat": patch +--- + +Fixes issue where the livechat offline form would render even when disabled diff --git a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts index df4ab8db944ee..39bc606b1382f 100644 --- a/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts +++ b/apps/meteor/tests/e2e/omnichannel/omnichannel-livechat.spec.ts @@ -146,3 +146,31 @@ test.describe.serial('OC - Livechat - Resub after close room', () => { }); }); }); + +test.describe('OC - Livechat - Livechat_Display_Offline_Form', () => { + let poLiveChat: OmnichannelLiveChat; + const message = 'This form is not available'; + + test.beforeAll(async ({ api }) => { + await api.post('/settings/Livechat_display_offline_form', { value: false }); + await api.post('/settings/Livechat_offline_form_unavailable', { value: message }); + }); + + test.beforeEach(async ({ page, api }) => { + poLiveChat = new OmnichannelLiveChat(page, api); + await poLiveChat.page.goto('/livechat'); + }); + + test.afterAll(async ({ api }) => { + await api.post('/settings/Livechat_display_offline_form', { value: true }); + await api.post('/settings/Livechat_offline_form_unavailable', { value: '' }); + }); + + test('OC - Livechat - Livechat_Display_Offline_Form false', async () => { + await test.step('expect offline form to not be visible', async () => { + await poLiveChat.openAnyLiveChat(); + await expect (poLiveChat.page.locator(`div >> text=${message}`)).toBeVisible(); + await expect(poLiveChat.textAreaMessage).not.toBeVisible(); + }); + }); +}); diff --git a/packages/livechat/src/i18n/en.json b/packages/livechat/src/i18n/en.json index 620f53be45e74..dd852048222bd 100644 --- a/packages/livechat/src/i18n/en.json +++ b/packages/livechat/src/i18n/en.json @@ -65,6 +65,7 @@ "new_chat": "New Chat", "no": "No", "no_available_agents_to_transfer": "No available agents to transfer", + "offline_form_not_available": "Offline form not available", "ok": "OK", "options": "Options", "please_tell_us_some_information_to_start_the_chat": "Please, tell us some information to start the chat", diff --git a/packages/livechat/src/i18n/pt-BR.json b/packages/livechat/src/i18n/pt-BR.json index d47eb054e79b4..b6570ca1f72bc 100644 --- a/packages/livechat/src/i18n/pt-BR.json +++ b/packages/livechat/src/i18n/pt-BR.json @@ -53,6 +53,7 @@ "new_chat": "Novo Chat", "no": "Não", "no_available_agents_to_transfer": "Não há agentes disponíveis para transferência", + "offline_form_not_available": "Formulário offline não disponível", "options": "Opções", "please_tell_us_some_information_to_start_the_chat": "Por favor, nos passe algumas informações antes de iniciar o chat", "please_wait_for_the_next_available_agent": "Por favor, aguarde o próximo agente disponível..", diff --git a/packages/livechat/src/routes/LeaveMessage/index.tsx b/packages/livechat/src/routes/LeaveMessage/index.tsx index 4487ad23661a2..91b3e8f57d9cd 100644 --- a/packages/livechat/src/routes/LeaveMessage/index.tsx +++ b/packages/livechat/src/routes/LeaveMessage/index.tsx @@ -82,87 +82,97 @@ const LeaveMessage: FunctionalComponent<{ path: string }> = () => { const defaultTitle = t('leave_a_message'); const defaultMessage = t('we_are_not_online_right_now_please_leave_a_message'); - const defaultUnavailableMessage = ''; // TODO + const defaultUnavailableMessage = t('offline_form_not_available'); return ( - - -
+ {displayOfflineForm ? ( + + +
+ +
+ +
+ +
) as unknown as JSXInternal.GenericEventHandler} + id='leaveMessage' + > + + ( + + )} + /> + -
- -
+ + validateEmail(value, { style: 'rfc' }) || t('invalid_email') }, + }} + render={({ field }) => ( + + )} + /> + - ) as unknown as JSXInternal.GenericEventHandler} - id='leaveMessage' - > - - ( - - )} - /> - - - - validateEmail(value, { style: 'rfc' }) || t('invalid_email') }, - }} - render={({ field }) => ( - - )} - /> - - - {departments?.some((dept) => dept.showOnOfflineForm) ? ( - + {departments?.some((dept) => dept.showOnOfflineForm) ? ( + + ( + ({ + value: _id, + label: name, + }))} + placeholder={t('choose_an_option')} + disabled={loading} + {...field} + /> + )} + /> + + ) : null} + ( - ({ - value: _id, - label: name, - }))} - placeholder={t('choose_an_option')} - disabled={loading} - {...field} - /> + )} /> - ) : null} - - } - /> - - -
+ +
+ + + ) : ( + +
+ +
- + )} - + {displayOfflineForm ? ( + + ) : null} );