From 20b9f1ab5a4b95890b21366f97fe32c90ffe3249 Mon Sep 17 00:00:00 2001 From: Diego Sampaio <chinello@gmail.com> Date: Fri, 31 May 2024 17:08:38 -0300 Subject: [PATCH] fix: User status when setting "Use REST instead of websocket for Meteor calls" is disabled (#32500) --- .changeset/serious-bottles-tie.md | 5 ++ .../meteor/client/sidebar/header/UserMenu.tsx | 2 + apps/meteor/ee/server/startup/presence.ts | 2 +- apps/meteor/tests/e2e/presence.spec.ts | 48 +++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .changeset/serious-bottles-tie.md create mode 100644 apps/meteor/tests/e2e/presence.spec.ts diff --git a/.changeset/serious-bottles-tie.md b/.changeset/serious-bottles-tie.md new file mode 100644 index 00000000000..e12bb94a531 --- /dev/null +++ b/.changeset/serious-bottles-tie.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fix user not being set as online when setting "Use REST instead of websocket for Meteor calls" is disabled diff --git a/apps/meteor/client/sidebar/header/UserMenu.tsx b/apps/meteor/client/sidebar/header/UserMenu.tsx index a53836eda31..592fc19656e 100644 --- a/apps/meteor/client/sidebar/header/UserMenu.tsx +++ b/apps/meteor/client/sidebar/header/UserMenu.tsx @@ -28,6 +28,7 @@ const UserMenu = ({ user }: { user: IUser }) => { selectionMode='multiple' sections={sections} title={t('User_menu')} + aria-label={t('User_menu')} onAction={handleAction} isOpen={isOpen} onOpenChange={setIsOpen} @@ -41,6 +42,7 @@ const UserMenu = ({ user }: { user: IUser }) => { selectionMode='multiple' sections={sections} title={t('User_menu')} + aria-label={t('User_menu')} onAction={handleAction} isOpen={isOpen} onOpenChange={setIsOpen} diff --git a/apps/meteor/ee/server/startup/presence.ts b/apps/meteor/ee/server/startup/presence.ts index 3e8daad4b25..0e7ba8a2b95 100644 --- a/apps/meteor/ee/server/startup/presence.ts +++ b/apps/meteor/ee/server/startup/presence.ts @@ -30,7 +30,7 @@ Meteor.startup(() => { }); Accounts.onLogin((login: any): void => { - if (login.type !== 'resume' || !login.connection.id) { + if (!login.connection.id) { return; } diff --git a/apps/meteor/tests/e2e/presence.spec.ts b/apps/meteor/tests/e2e/presence.spec.ts new file mode 100644 index 00000000000..ad96c3cee4b --- /dev/null +++ b/apps/meteor/tests/e2e/presence.spec.ts @@ -0,0 +1,48 @@ +import { DEFAULT_USER_CREDENTIALS, IS_EE } from './config/constants'; +import { Registration } from './page-objects'; +import { setSettingValueById } from './utils/setSettingValueById'; +import { test, expect } from './utils/test'; + +test.describe.serial('Presence', () => { + let poRegistration: Registration; + + test.beforeEach(async ({ page }) => { + poRegistration = new Registration(page); + + await page.goto('/home'); + }); + + test.beforeAll(async ({ api }) => { + await expect((await setSettingValueById(api, 'API_Use_REST_For_DDP_Calls', true)).status()).toBe(200); + }); + + test.afterAll(async ({ api }) => { + await expect((await setSettingValueById(api, 'API_Use_REST_For_DDP_Calls', true)).status()).toBe(200); + }); + + test.describe('Login using default settings', () => { + test('expect user to be online after log in', async ({ page }) => { + await poRegistration.username.type('user1'); + await poRegistration.inputPassword.type(DEFAULT_USER_CREDENTIALS.password); + await poRegistration.btnLogin.click(); + + await expect(page.getByRole('button', { name: 'User menu' }).locator('.rcx-status-bullet--online')).toBeVisible(); + }); + }); + + test.describe('Login using with "Methods by REST" disabled', () => { + test.skip(IS_EE, `Micro services don't support turning this setting off`); + + test.beforeAll(async ({ api }) => { + await expect((await setSettingValueById(api, 'API_Use_REST_For_DDP_Calls', false)).status()).toBe(200); + }); + + test('expect user to be online after log in', async ({ page }) => { + await poRegistration.username.type('user1'); + await poRegistration.inputPassword.type(DEFAULT_USER_CREDENTIALS.password); + await poRegistration.btnLogin.click(); + + await expect(page.getByRole('button', { name: 'User menu' }).locator('.rcx-status-bullet--online')).toBeVisible(); + }); + }); +}); -- GitLab