Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/meteor/client/startup/incomingMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { IMessage } from '@rocket.chat/core-typings';
import { sdk } from '../../app/utils/client/lib/SDKClient';
import { onLoggedIn } from '../lib/loggedIn';
import { getUserId } from '../lib/user';
import { upsertThreadMessageInCache } from '../lib/utils/threadMessageUtils';
import { Messages } from '../stores';

onLoggedIn(() => {
Expand All @@ -12,6 +13,10 @@ onLoggedIn(() => {
msg.u = msg.u || { username: 'rocket.cat' };
msg.private = true;

if (msg.tmid) {
upsertThreadMessageInCache(msg, msg.rid, msg.tmid);
}
Comment thread
gabriellsh marked this conversation as resolved.

return Messages.state.store(msg);
}).stop;
});
Expand Down
61 changes: 42 additions & 19 deletions apps/meteor/tests/e2e/message-mentions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,25 @@ test.describe.serial('message-mentions', () => {
});

await test.step('show "Do nothing" action', async () => {
await expect(adminPage.content.lastUserMessage.locator('button >> text="Do nothing"')).toBeVisible();
await expect(adminPage.content.getLastMessageActionButton('Do nothing')).toBeVisible();
});
await test.step('show "Add them" action', async () => {
await expect(adminPage.content.lastUserMessage.locator('button >> text="Add them"')).toBeVisible();
await expect(adminPage.content.getLastMessageActionButton('Add them')).toBeVisible();
});
await test.step('show "Let them know" action', async () => {
await expect(adminPage.content.lastUserMessage.locator('button >> text="Let them know"')).toBeVisible();
await expect(adminPage.content.getLastMessageActionButton('Let them know')).toBeVisible();
});

await test.step('dismiss', async () => {
await adminPage.content.lastUserMessage.locator('button >> text="Do nothing"').click();
await adminPage.content.getLastMessageActionButton('Do nothing').click();
});

await test.step('receive second bot message', async () => {
await adminPage.content.sendMessage(getMentionText(Users.user1.data.username));
await expect(adminPage.content.lastUserMessage.locator('.rcx-message-block')).toContainText(mentionText);
});
await test.step('send message to users', async () => {
await adminPage.content.lastUserMessage.locator('button >> text="Let them know"').click();
await adminPage.content.getLastMessageActionButton('Let them know').click();
await expect(adminPage.content.lastUserMessageBody).toContainText(getMentionText(Users.user1.data.username, 3));
});

Expand All @@ -164,11 +164,34 @@ test.describe.serial('message-mentions', () => {
await expect(adminPage.content.lastUserMessage.locator('.rcx-message-block')).toContainText(mentionText);
});
await test.step('add users to room', async () => {
await adminPage.content.lastUserMessage.locator('button >> text="Add them"').click();
await adminPage.content.getLastMessageActionButton('Add them').click();
await expect(adminPage.content.lastSystemMessageBody).toContainText('added');
});
});

test('should show non-member mention warning inside threads', async ({ page }) => {
const adminPage = new HomeChannel(page);
const mentionText = getMentionText(Users.user2.data.username, 1);

await test.step('open thread', async () => {
await adminPage.navbar.openChat(targetChannel);
await adminPage.content.sendMessage('thread parent for non-member mention warning');
await adminPage.content.openReplyInThread();
await adminPage.content.waitForThread();
});

await test.step('receive bot message inside thread', async () => {
await adminPage.content.sendMessageInThread(getMentionText(Users.user2.data.username));
await expect(adminPage.content.lastUserThreadMessage).toContainText(mentionText);
});

await test.step('show actions inside thread', async () => {
await expect(adminPage.content.getLastThreadMessageActionButton('Do nothing')).toBeVisible();
await expect(adminPage.content.getLastThreadMessageActionButton('Add them')).toBeVisible();
await expect(adminPage.content.getLastThreadMessageActionButton('Let them know')).toBeVisible();
});
});

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

Expand All @@ -183,17 +206,17 @@ test.describe.serial('message-mentions', () => {
});

await test.step('show "Do nothing" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Do nothing"')).toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Do nothing')).toBeVisible();
});
await test.step('show "Let them know" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Let them know"')).toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Let them know')).toBeVisible();
});
await test.step('not show "Add them action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Add them"')).not.toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Add them')).not.toBeVisible();
});

await test.step('dismiss', async () => {
await userPage.content.lastUserMessage.locator('button >> text="Do nothing"').click();
await userPage.content.getLastMessageActionButton('Do nothing').click();
});

await test.step('receive second bot message', async () => {
Expand All @@ -202,7 +225,7 @@ test.describe.serial('message-mentions', () => {
await expect(userPage.content.lastUserMessage.locator('.rcx-message-block')).toContainText(mentionText);
});
await test.step('send message to users', async () => {
await userPage.content.lastUserMessage.locator('button >> text="Let them know"').click();
await userPage.content.getLastMessageActionButton('Let them know').click();
await expect(userPage.content.lastUserMessageBody).toContainText(getMentionText(Users.user2.data.username, 3));
});
});
Expand Down Expand Up @@ -237,17 +260,17 @@ test.describe.serial('message-mentions', () => {
await expect(userPage.content.lastUserMessage.locator('.rcx-message-block')).toContainText(mentionText);
});
await test.step('show "Do nothing" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Do nothing"')).toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Do nothing')).toBeVisible();
});
await test.step('show "Add them" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Add them"')).toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Add them')).toBeVisible();
});
await test.step('not show "Let them know" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Let them know"')).not.toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Let them know')).not.toBeVisible();
});

await test.step('dismiss', async () => {
await userPage.content.lastUserMessage.locator('button >> text="Do nothing"').click();
await userPage.content.getLastMessageActionButton('Do nothing').click();
});

await test.step('receive second bot message', async () => {
Expand All @@ -256,7 +279,7 @@ test.describe.serial('message-mentions', () => {
await expect(userPage.content.lastUserMessage.locator('.rcx-message-block')).toContainText(mentionText);
});
await test.step('add users to room', async () => {
await userPage.content.lastUserMessage.locator('button >> text="Add them"').click();
await userPage.content.getLastMessageActionButton('Add them').click();
await expect(userPage.content.lastSystemMessageBody).toContainText('added');
});
});
Expand Down Expand Up @@ -285,13 +308,13 @@ test.describe.serial('message-mentions', () => {
});

await test.step('not show "Do nothing" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Do nothing"')).not.toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Do nothing')).not.toBeVisible();
});
await test.step('not show "Add them" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Add them"')).not.toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Add them')).not.toBeVisible();
});
await test.step('not show "Let them know" action', async () => {
await expect(userPage.content.lastUserMessage.locator('button >> text="Let them know"')).not.toBeVisible();
await expect(userPage.content.getLastMessageActionButton('Let them know')).not.toBeVisible();
});
});
});
Expand Down
8 changes: 8 additions & 0 deletions apps/meteor/tests/e2e/page-objects/fragments/home-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,14 @@ export class HomeContent {
return this.page.locator('[role="listitem"][aria-roledescription="message"]', { hasText: text });
}

getLastMessageActionButton(name: string): Locator {
return this.lastUserMessage.getByRole('button', { name, exact: true });
}

getLastThreadMessageActionButton(name: string): Locator {
return this.lastUserThreadMessage.getByRole('button', { name, exact: true });
}

getMessageById(id: string): Locator {
return this.page.locator(`[role="listitem"][aria-roledescription="message"][id="${id}"]`);
}
Expand Down
Loading