Skip to content
5 changes: 5 additions & 0 deletions .changeset/rude-avocados-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed discussion names displaying as IDs in sidebar search results
1 change: 1 addition & 0 deletions apps/meteor/server/lib/spotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Spotlight {
joinCodeRequired: 1,
lastMessage: 1,
federated: true,
prid: 1,
},
sort: {
name: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class HomeSidenav {
return this.page.locator('role=button[name="Create"]');
}

get inputSearch(): Locator {
return this.page.locator('[placeholder="Search (Ctrl+K)"]').first();
}

getSidebarItemByName(name: string): Locator {
return this.page.locator(`[data-qa="sidebar-item"][aria-label="${name}"]`);
}
Expand All @@ -59,6 +63,10 @@ export class HomeSidenav {
await this.page.locator(`role=menuitem[name="${text}"]`).click();
}

async openSearch(): Promise<void> {
await this.page.locator('role=button[name="Search"]').click();
}

async logout(): Promise<void> {
await this.page.locator('[data-qa="sidebar-avatar-button"]').click();
await this.page.locator('//*[contains(@class, "rcx-option__content") and contains(text(), "Logout")]').click();
Expand Down
47 changes: 47 additions & 0 deletions apps/meteor/tests/e2e/search-discussion.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Page } from '@playwright/test';

import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetDiscussion } from './utils';
import { getSettingValueById } from './utils/getSettingValueById';
import { setSettingValueById } from './utils/setSettingValueById';
import { test, expect } from './utils/test';

test.use({ storageState: Users.user1.state });

test.describe.serial('search-discussion', () => {
let settingDefaultValue: unknown;
let poHomeChannel: HomeChannel;
let discussionName: string;

test.beforeAll(async ({ api }) => {
settingDefaultValue = await getSettingValueById(api, 'UI_Allow_room_names_with_special_chars');
});

test.beforeEach(async ({ page, api }) => {
discussionName = await createTargetDiscussion(api);
poHomeChannel = new HomeChannel(page);
await page.goto('/home');
});

test.afterAll(async ({ api }) => {
await setSettingValueById(api, 'UI_Allow_room_names_with_special_chars', settingDefaultValue);
});

const testDiscussionSearch = async (page: Page) => {
await poHomeChannel.sidenav.openSearch();
await poHomeChannel.sidenav.inputSearch.type(discussionName);
const targetSearchItem = page.locator('role=listbox').getByText(discussionName).first();
await expect(targetSearchItem).toBeVisible();
}

test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=true', async ({ page, api }) => {
await setSettingValueById(api, 'UI_Allow_room_names_with_special_chars', true);
await testDiscussionSearch(page);
});

test('expect search discussion to show fname when UI_Allow_room_names_with_special_chars=false', async ({ page, api }) => {
await setSettingValueById(api, 'UI_Allow_room_names_with_special_chars', false);
await testDiscussionSearch(page);
});
});
11 changes: 11 additions & 0 deletions apps/meteor/tests/e2e/utils/create-target-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ export async function createDirectMessage(api: BaseTest['api']): Promise<void> {
usernames: 'user1,user2',
});
}

export async function createTargetDiscussion(api: BaseTest['api']): Promise<string> {
const channelName = faker.string.uuid();
const discussionName = faker.string.uuid();

const response = await api.post('/channels.create', { name: channelName });
const { channel } = await response.json();
await api.post('/rooms.createDiscussion', { t_name: discussionName, prid: channel._id});

return discussionName;
}
7 changes: 7 additions & 0 deletions apps/meteor/tests/e2e/utils/getSettingValueById.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { BaseTest } from './test';

export const getSettingValueById = async (api: BaseTest['api'], settingId: string): Promise<unknown> => {
const response = await api.get(`/settings/${settingId}`);
const { value } = await response.json();
return value;
};