Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Code scanning - action / CodeQL-Build (push) Failing after 2s
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
120 lines
4.8 KiB
TypeScript
120 lines
4.8 KiB
TypeScript
import type { Page } from '@playwright/test';
|
|
|
|
import { IS_EE } from './config/constants';
|
|
import { createAuxContext } from './fixtures/createAuxContext';
|
|
import type { IUserState } from './fixtures/userStates';
|
|
import { Users } from './fixtures/userStates';
|
|
import { HomeChannel } from './page-objects';
|
|
import { createTargetChannel, deleteChannel, setSettingValueById } from './utils';
|
|
import { expect, test } from './utils/test';
|
|
import type { ITestUser } from './utils/user-helpers';
|
|
import { createTestUser, loginTestUser } from './utils/user-helpers';
|
|
|
|
test.use({ storageState: Users.admin.state });
|
|
|
|
test.describe.serial('read-receipts-deactivated-users', () => {
|
|
let poHomeChannel: HomeChannel;
|
|
let targetChannel: string;
|
|
let user1Context: { page: Page; poHomeChannel: HomeChannel } | undefined;
|
|
let user2Context: { page: Page; poHomeChannel: HomeChannel } | undefined;
|
|
let testUser1: ITestUser;
|
|
let testUser2: ITestUser;
|
|
let testUser1State: IUserState;
|
|
let testUser2State: IUserState;
|
|
|
|
test.skip(!IS_EE, 'Enterprise Only');
|
|
|
|
test.beforeAll(async ({ api }) => {
|
|
[testUser1, testUser2] = await Promise.all([createTestUser(api), createTestUser(api)]);
|
|
|
|
[testUser1State, testUser2State] = await Promise.all([loginTestUser(api, testUser1), loginTestUser(api, testUser2)]);
|
|
|
|
targetChannel = await createTargetChannel(api, { members: [testUser1.data.username, testUser2.data.username] });
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Message_Read_Receipt_Enabled', true),
|
|
setSettingValueById(api, 'Message_Read_Receipt_Store_Users', true),
|
|
]);
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Message_Read_Receipt_Enabled', false),
|
|
setSettingValueById(api, 'Message_Read_Receipt_Store_Users', false),
|
|
]);
|
|
|
|
await deleteChannel(api, targetChannel);
|
|
await Promise.all([testUser1?.delete(), testUser2?.delete()]);
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
poHomeChannel = new HomeChannel(page);
|
|
await poHomeChannel.goto();
|
|
});
|
|
|
|
test.afterEach(async () => {
|
|
await Promise.all([user1Context?.page.close(), user2Context?.page.close()]);
|
|
user1Context = undefined;
|
|
user2Context = undefined;
|
|
});
|
|
|
|
test('should correctly handle read receipts as users are deactivated', async ({ browser, api, page }) => {
|
|
const { page: page1 } = await createAuxContext(browser, testUser1State);
|
|
const user1Ctx = { page: page1, poHomeChannel: new HomeChannel(page1) };
|
|
user1Context = user1Ctx;
|
|
|
|
const { page: page2 } = await createAuxContext(browser, testUser2State);
|
|
const user2Ctx = { page: page2, poHomeChannel: new HomeChannel(page2) };
|
|
user2Context = user2Ctx;
|
|
|
|
await Promise.all([
|
|
poHomeChannel.navbar.openChat(targetChannel),
|
|
user1Ctx.poHomeChannel.navbar.openChat(targetChannel),
|
|
user2Ctx.poHomeChannel.navbar.openChat(targetChannel),
|
|
]);
|
|
|
|
await test.step('when all users are active', async () => {
|
|
await poHomeChannel.content.sendMessage('Message 1: All three users active');
|
|
|
|
await Promise.all([
|
|
expect(user1Ctx.poHomeChannel.content.lastUserMessage).toBeVisible(),
|
|
expect(user2Ctx.poHomeChannel.content.lastUserMessage).toBeVisible(),
|
|
]);
|
|
|
|
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
|
|
|
|
await poHomeChannel.content.openLastMessageMenu();
|
|
await page.locator('role=menuitem[name="Read receipts"]').click();
|
|
await expect(page.getByRole('dialog').getByRole('listitem')).toHaveCount(3);
|
|
await page.getByRole('button', { name: 'Close' }).click();
|
|
});
|
|
|
|
await test.step('when some users are deactivated', async () => {
|
|
await api.post('/users.setActiveStatus', { userId: testUser1.data._id, activeStatus: false });
|
|
|
|
await poHomeChannel.content.sendMessage('Message 2: User1 deactivated, two active users');
|
|
|
|
await expect(user2Ctx.poHomeChannel.content.lastUserMessage).toBeVisible();
|
|
|
|
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
|
|
|
|
await poHomeChannel.content.openLastMessageMenu();
|
|
await page.locator('role=menuitem[name="Read receipts"]').click();
|
|
await expect(page.getByRole('dialog').getByRole('listitem')).toHaveCount(2);
|
|
await page.getByRole('button', { name: 'Close' }).click();
|
|
});
|
|
|
|
await test.step('when only one user remains active (user alone in room)', async () => {
|
|
await api.post('/users.setActiveStatus', { userId: testUser2.data._id, activeStatus: false });
|
|
|
|
await poHomeChannel.content.sendMessage('Message 3: Only admin active');
|
|
|
|
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
|
|
|
|
await poHomeChannel.content.openLastMessageMenu();
|
|
await page.locator('role=menuitem[name="Read receipts"]').click();
|
|
await expect(page.getByRole('dialog').getByRole('listitem')).toHaveCount(1);
|
|
await page.getByRole('button', { name: 'Close' }).click();
|
|
});
|
|
});
|
|
});
|