Skip to content

Commit

Permalink
fix: User status when setting "Use REST instead of websocket for Mete…
Browse files Browse the repository at this point in the history
…or calls" is disabled (#32500)
  • Loading branch information
sampaiodiego committed May 31, 2024
1 parent 70dbbd1 commit 20b9f1a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/serious-bottles-tie.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions apps/meteor/client/sidebar/header/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/startup/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Meteor.startup(() => {
});

Accounts.onLogin((login: any): void => {
if (login.type !== 'resume' || !login.connection.id) {
if (!login.connection.id) {
return;
}

Expand Down
48 changes: 48 additions & 0 deletions apps/meteor/tests/e2e/presence.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
});

0 comments on commit 20b9f1a

Please sign in to comment.