The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/tests/e2e/mark-unread.spec.ts

75 lines
2.8 KiB

import type { IRoom } from '@rocket.chat/core-typings';
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetChannelAndReturnFullRoom } from './utils';
import { test, expect } from './utils/test';
test.use({ storageState: Users.admin.state });
test.describe.serial('mark-unread', () => {
let poHomeChannel: HomeChannel;
let targetChannel: Required<IRoom>;
test.beforeEach(async ({ page, api }) => {
poHomeChannel = new HomeChannel(page);
const result = await createTargetChannelAndReturnFullRoom(api, { members: ['user2'] });
targetChannel = result.channel as Required<IRoom>;
await page.emulateMedia({ reducedMotion: 'reduce' });
await page.goto('/home');
});
test.afterEach(async ({ api }) => {
await api.post('/channels.delete', { roomName: targetChannel.name });
});
test.describe('Mark Unread - Sidebar Action', () => {
test('should not mark empty room as unread', async () => {
const item = poHomeChannel.sidebar.getSidebarItemByName(targetChannel.name);
await poHomeChannel.sidebar.markItemAsUnread(item);
await expect(poHomeChannel.sidebar.getItemUnreadBadge(item)).not.toBeVisible();
});
test('should mark a populated room as unread', async () => {
await poHomeChannel.navbar.openChat(targetChannel.name);
await poHomeChannel.content.sendMessage('this is a message for reply');
const item = poHomeChannel.sidebar.getSidebarItemByName(targetChannel.name);
await poHomeChannel.sidebar.markItemAsUnread(item);
await expect(poHomeChannel.sidebar.getItemUnreadBadge(item)).toBeVisible();
});
test('should mark a populated room as unread - search', async () => {
await poHomeChannel.navbar.openChat(targetChannel.name);
await poHomeChannel.content.sendMessage('this is a message for reply');
const item = poHomeChannel.sidebar.getSidebarItemByName(targetChannel.name);
await poHomeChannel.sidebar.markItemAsUnread(item);
await poHomeChannel.navbar.typeSearch(targetChannel.name);
await expect(poHomeChannel.navbar.getSearchItemBadge(targetChannel.name)).toBeVisible();
});
});
test.describe('Mark Unread - Message Action', () => {
test.use({ storageState: Users.user2.state });
test('should mark a populated room as unread', async ({ api }) => {
await api.post('/chat.sendMessage', {
message: {
rid: targetChannel._id,
msg: 'this is a message for reply',
},
});
await expect(async () => {
await poHomeChannel.navbar.openChat(targetChannel.name);
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.markUnread.click();
const item = poHomeChannel.sidebar.getSidebarItemByName(targetChannel.name);
await expect(poHomeChannel.sidebar.getItemUnreadBadge(item)).toBeVisible();
}).toPass();
});
});
});