Files
upstream-rocketchat/apps/meteor/tests/e2e/presence.spec.ts
upstream-mirror 30810eecd7
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
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

253 lines
9.1 KiB
TypeScript

import { faker } from '@faker-js/faker';
import { DEFAULT_USER_CREDENTIALS } from './config/constants';
import { Users } from './fixtures/userStates';
import { AccountProfile, HomeChannel, Login } from './page-objects';
import { test, expect } from './utils/test';
test.describe.serial('Presence', () => {
let poLogin: Login;
let poHomeChannel: HomeChannel;
let poAccountProfile: AccountProfile;
test.beforeEach(async ({ page }) => {
poLogin = new Login(page);
poHomeChannel = new HomeChannel(page);
poAccountProfile = new AccountProfile(page);
});
test.describe('Login using default settings', () => {
test('should user be online after log in', async () => {
await poLogin.goto();
await poLogin.login('user1', DEFAULT_USER_CREDENTIALS.password);
await expect(poHomeChannel.navbar.btnUserMenu).toBeVisible();
});
});
test.describe('Custom status', () => {
const customStatus = faker.string.alpha(10);
test.use({ storageState: Users.admin.state });
test.beforeEach(async () => {
await poHomeChannel.goto();
});
test('should user custom status be reactive', async ({ browser }) => {
await test.step('user1 custom status should be empty', async () => {
await poHomeChannel.navbar.openChat('user1');
await expect(poHomeChannel.content.channelHeader).not.toContainText(customStatus);
});
await test.step('update user1 custom status', async () => {
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Channel.goto();
await user1Channel.navbar.changeUserCustomStatus(customStatus);
await user1Page.close();
});
await test.step('should user1 custom status be updated', async () => {
await poHomeChannel.navbar.openChat('user1');
await expect(poHomeChannel.content.channelHeader).toContainText(customStatus);
});
});
test('should be able to erase custom status', async ({ page }) => {
await poHomeChannel.navbar.changeUserCustomStatus(customStatus);
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.userMenu).toContainText(customStatus);
await page.keyboard.press('Escape');
await poHomeChannel.navbar.changeUserCustomStatus('');
await poHomeChannel.navbar.btnUserMenu.click();
await expect(async () => expect(poHomeChannel.navbar.userMenu).not.toContainText(customStatus)).toPass();
});
test('should not save custom status as `undefined` if nothing changes', async ({ page }) => {
await poHomeChannel.navbar.openEditStatusModal();
const { editStatusModal } = poHomeChannel.navbar;
await test.step('Save stays disabled while the form is untouched', async () => {
await expect(editStatusModal.btnSubmit).toBeDisabled();
});
await test.step('closing without changes leaves stored status untouched', async () => {
await editStatusModal.close();
expect(await page.evaluate(() => localStorage.getItem('fuselage-localStorage-Local_Custom_Status'))).not.toBe('undefined');
});
});
test('should show both Custom Status action and active status row when a custom status is set', async ({ page }) => {
const text = faker.string.alpha(8);
await test.step('Custom Status entry visible while no status is set', async () => {
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.btnCustomStatus).toBeVisible();
await page.keyboard.press('Escape');
});
await test.step('after setting a status, Custom Status entry stays visible alongside the active row', async () => {
await poHomeChannel.navbar.changeUserCustomStatus(text);
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.btnCustomStatus).toBeVisible();
await expect(poHomeChannel.navbar.userMenu).toContainText(text);
await page.keyboard.press('Escape');
});
await test.step('cleanup', async () => {
await poHomeChannel.navbar.changeUserCustomStatus('');
});
});
});
test.describe('Status expiration', () => {
test.use({ storageState: Users.admin.state });
test.beforeEach(async () => {
await poHomeChannel.goto();
});
test('should toggle custom date/time inputs when selecting duration', async () => {
await poHomeChannel.navbar.openEditStatusModal();
const { editStatusModal } = poHomeChannel.navbar;
await editStatusModal.setStatusMessage('available');
await editStatusModal.selectDuration('Choose date and time');
await expect(editStatusModal.customDateInput).toBeVisible();
await expect(editStatusModal.customTimeInput).toBeVisible();
await editStatusModal.selectDuration("Don't clear");
await expect(editStatusModal.customDateInput).not.toBeVisible();
await expect(editStatusModal.customTimeInput).not.toBeVisible();
await editStatusModal.close();
});
test('should reject custom expiration in the past', async () => {
await poHomeChannel.navbar.openEditStatusModal();
const { editStatusModal } = poHomeChannel.navbar;
await editStatusModal.setStatusMessage('available');
await editStatusModal.selectDuration('Choose date and time');
const today = new Date().toLocaleDateString('en-CA');
await editStatusModal.customDateInput.fill(today);
await editStatusModal.customTimeInput.fill('00:00');
await editStatusModal.btnSubmit.click();
await expect(editStatusModal.durationError).toBeVisible();
await editStatusModal.close();
});
test('should reject custom expiration when date/time is missing', async () => {
await poHomeChannel.navbar.openEditStatusModal();
const { editStatusModal } = poHomeChannel.navbar;
await editStatusModal.setStatusMessage('available');
await editStatusModal.selectDuration('Choose date and time');
await editStatusModal.customDateInput.fill('');
await editStatusModal.btnSubmit.click();
await expect(editStatusModal.durationMissingError).toBeVisible();
await editStatusModal.close();
});
test('should set status with custom date/time expiration', async ({ page }) => {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
const dateStr = tomorrow.toLocaleDateString('en-CA');
const timeStr = '12:00';
await test.step('set status with custom expiration', async () => {
await poHomeChannel.navbar.changeUserCustomStatusWithExpiration({
message: 'custom deadline',
duration: 'Choose date and time',
customDate: dateStr,
customTime: timeStr,
});
});
await test.step('verify expiration is displayed in user menu', async () => {
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.userMenu).toContainText('custom deadline');
await expect(poHomeChannel.navbar.userMenu).toContainText('Until');
await page.keyboard.press('Escape');
});
await test.step('clear status', async () => {
await poHomeChannel.navbar.changeUserStatus('online');
});
});
test('should set status with expiration, show it, and clear it', async ({ page }) => {
await test.step('set busy status with 30-minute expiration', async () => {
await poHomeChannel.navbar.changeUserCustomStatusWithExpiration({
message: 'focus time',
statusType: 'Busy',
duration: '30 minutes',
});
});
await test.step('verify expiration is displayed in user menu', async () => {
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.userMenu).toContainText('focus time');
await expect(poHomeChannel.navbar.userMenu).toContainText('Until');
await page.keyboard.press('Escape');
});
await test.step('clear status and verify expiration is removed', async () => {
await poHomeChannel.navbar.changeUserStatus('online');
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.userMenu).not.toContainText('Until');
await expect(poHomeChannel.navbar.userMenu).not.toContainText('focus time');
});
});
});
test.describe('Status set from account profile', () => {
test.use({ storageState: Users.admin.state });
test('should save status with expiration from the profile form and surface it in the user menu', async ({ page }) => {
const text = faker.string.alpha(10);
await test.step('fill Status field + Clear-after on /account/profile and save', async () => {
await poAccountProfile.goto();
await poAccountProfile.inputStatusText.fill(text);
await poAccountProfile.chooseClearStatusAfter('30 minutes');
await Promise.all([
page.waitForResponse((r) => r.url().endsWith('/v1/users.setStatus') && r.ok()),
page.waitForResponse((r) => r.url().endsWith('/v1/users.updateOwnBasicInfo') && r.ok()),
poAccountProfile.btnSaveChanges.click(),
]);
await expect(page.getByText('Profile saved successfully')).toBeVisible();
});
await test.step('status with expiration appears in user menu', async () => {
await poHomeChannel.goto();
await poHomeChannel.navbar.btnUserMenu.click();
await expect(poHomeChannel.navbar.userMenu).toContainText(text);
await expect(poHomeChannel.navbar.userMenu).toContainText('Until');
await page.keyboard.press('Escape');
});
await test.step('cleanup', async () => {
await poHomeChannel.navbar.changeUserCustomStatus('');
});
});
});
});