Files
upstream-rocketchat/apps/meteor/tests/e2e/homepage.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 1s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

218 lines
9.0 KiB
TypeScript

import type { Page } from '@playwright/test';
import { IS_EE } from './config/constants';
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { expect, test } from './utils/test';
const CardNames = {
Users: 'Add users',
Chan: 'Create channels',
Rooms: 'Join rooms',
Mobile: 'Mobile apps',
Desktop: 'Desktop apps',
Docs: 'Documentation',
Custom: 'Custom content',
};
test.use({ storageState: Users.admin.state });
test.describe.serial('homepage', () => {
let regularUserPage: Page;
let adminPage: Page;
test.describe('for admins', () => {
test.beforeAll(async ({ browser }) => {
adminPage = await browser.newPage({ storageState: Users.admin.state });
await new HomeChannel(adminPage).goto();
});
test.afterAll(async ({ api }) => {
expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: false })).status()).toBe(200);
expect((await api.post('/settings/Layout_Custom_Body_Only', { value: false })).status()).toBe(200);
await adminPage.close();
});
test('expect customize button and all cards to be visible', async () => {
await test.step('expect show customize button', async () => {
await expect(adminPage.locator('role=button[name="Customize"]')).toBeVisible();
});
await test.step('expect all cards to be visible', async () => {
await Promise.all(Object.values(CardNames).map((name) => expect(adminPage.getByRole('region', { name })).toBeVisible()));
});
});
test.describe('custom body with empty custom content', async () => {
test.beforeAll(async ({ api }) => {
await expect((await api.post('/settings/Layout_Home_Body', { value: '' })).status()).toBe(200);
});
test('visibility and button functionality in custom body with empty custom content', async () => {
await test.step('expect default value in custom body', async () => {
await expect(adminPage.locator('div >> text="Admins may insert content html to be rendered in this white space."')).toBeVisible();
});
await test.step('expect both change visibility and show only custom content buttons to be disabled', async () => {
await expect(adminPage.locator('role=button[name="Show to workspace"]')).toBeDisabled();
await expect(adminPage.locator('role=button[name="Show only this content"]')).toBeDisabled();
});
await test.step('expect visibility tag to show "not visible"', async () => {
await expect(adminPage.locator('span >> text="Not visible to workspace"')).toBeVisible();
});
});
});
test.describe('custom body with custom content', () => {
test.beforeAll(async ({ api }) => {
await expect((await api.post('/settings/Layout_Home_Body', { value: 'Hello admin' })).status()).toBe(200);
});
test('visibility and button functionality in custom body with custom content', async () => {
await test.step('expect custom body to be visible', async () => {
await expect(adminPage.locator('div >> text="Hello admin"')).toBeVisible();
});
await test.step('expect correct state for card buttons', async () => {
await expect(adminPage.locator('role=button[name="Show to workspace"]')).not.toBeDisabled();
await expect(adminPage.locator('role=button[name="Show only this content"]')).toBeDisabled();
});
});
test.describe('enterprise edition', () => {
test.skip(!IS_EE, 'Enterprise Only');
test.beforeAll(async ({ api }) => {
await expect((await api.post('/settings/Layout_Home_Body', { value: 'Hello admin' })).status()).toBe(200);
await expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: true })).status()).toBe(200);
await expect((await api.post('/settings/Layout_Custom_Body_Only', { value: true })).status()).toBe(200);
});
test('display custom content only', async () => {
await test.step('expect default layout to not be visible (show only custom content card)', async () => {
await expect(adminPage.locator('role=heading[name="Welcome to Rocket.Chat"]')).not.toBeVisible();
});
await test.step('expect correct state for card buttons', async () => {
await expect(adminPage.locator('role=button[name="Hide on workspace"]')).toBeDisabled();
await expect(adminPage.locator('role=button[name="Show default content"]')).not.toBeDisabled();
});
await test.step('expect visibility tag to show "visible to workspace"', async () => {
await expect(adminPage.locator('span >> text="Visible to workspace"')).toBeVisible();
});
});
});
});
});
test.describe('for regular users', () => {
const notVisibleCards = [CardNames.Users, CardNames.Custom];
test.beforeAll(async ({ api, browser }) => {
expect((await api.post('/settings/Layout_Home_Body', { value: '' })).status()).toBe(200);
regularUserPage = await browser.newPage({ storageState: Users.user2.state });
await new HomeChannel(regularUserPage).goto();
});
test.afterAll(async () => {
await regularUserPage.close();
});
test('the option customize is not be active', async () => {
await test.step('expect to not show customize button', async () => {
await expect(regularUserPage.locator('role=button[name="Customize"]')).not.toBeVisible();
});
await test.step(`expect ${notVisibleCards.join(' and ')} cards to not be visible`, async () => {
await Promise.all(notVisibleCards.map((name) => expect(regularUserPage.getByRole('region', { name })).not.toBeVisible()));
});
await test.step('expect all other cards to be visible', async () => {
await Promise.all(
Object.values(CardNames)
.filter((name) => !notVisibleCards.includes(name))
.map((name) => expect(regularUserPage.getByRole('region', { name })).toBeVisible()),
);
});
await test.step('expect welcome text to use Site_Name default setting', async () => {
await expect(regularUserPage.locator('role=heading[name="Welcome to Rocket.Chat"]')).toBeVisible();
});
await test.step('expect header text to use Layout_Home_Title default setting', async () => {
await expect(regularUserPage.getByRole('main').getByRole('heading', { level: 1, name: 'Home', exact: true })).toBeVisible();
});
});
test.describe('custom values', () => {
test.beforeAll(async ({ api }) => {
expect((await api.post('/settings/Site_Name', { value: 'NewSiteName' })).status()).toBe(200);
expect((await api.post('/settings/Layout_Home_Title', { value: 'NewTitle' })).status()).toBe(200);
// the home heading is the setting under test, so wait for its new value rather than the default one
await new HomeChannel(regularUserPage).gotoExpecting(
regularUserPage.getByRole('main').getByRole('heading', { level: 1, name: 'NewTitle', exact: true }),
);
});
test.afterAll(async ({ api }) => {
expect((await api.post('/settings/Site_Name', { value: 'Rocket.Chat' })).status()).toBe(200);
expect((await api.post('/settings/Layout_Home_Title', { value: 'Home' })).status()).toBe(200);
});
test('expect welcome text and header text to be correct', async () => {
await test.step('expect welcome text to be NewSiteName', async () => {
await expect(regularUserPage.locator('role=heading[name="Welcome to NewSiteName"]')).toBeVisible();
});
await test.step('expect header text to be Layout_Home_Title setting', async () => {
await expect(regularUserPage.getByRole('main').getByRole('heading', { name: 'NewTitle', exact: true })).toBeVisible();
});
});
});
test.describe('custom body with content', () => {
test.beforeAll(async ({ api }) => {
expect((await api.post('/settings/Layout_Home_Body', { value: 'Hello' })).status()).toBe(200);
expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: true })).status()).toBe(200);
await new HomeChannel(regularUserPage).goto();
});
test.afterAll(async ({ api }) => {
expect((await api.post('/settings/Layout_Home_Body', { value: '' })).status()).toBe(200);
expect((await api.post('/settings/Layout_Home_Custom_Block_Visible', { value: false })).status()).toBe(200);
});
test('expect custom body to be visible', async () => {
await expect(regularUserPage.locator('div >> text="Hello"')).toBeVisible();
});
test.describe('enterprise edition', () => {
test.skip(!IS_EE, 'Enterprise Only');
test.beforeAll(async ({ api }) => {
expect((await api.post('/settings/Layout_Custom_Body_Only', { value: true })).status()).toBe(200);
});
test.afterAll(async ({ api }) => {
expect((await api.post('/settings/Layout_Custom_Body_Only', { value: false })).status()).toBe(200);
});
test('expect default layout not be visible and custom body visible', async () => {
await test.step('expect default layout to not be visible', async () => {
await expect(
regularUserPage.getByRole('main').getByRole('heading', { level: 2, name: 'Welcome to Rocket.chat', exact: true }),
).not.toBeVisible();
});
await test.step('expect custom body to be visible', async () => {
await expect(regularUserPage.locator('div >> text="Hello"')).toBeVisible();
});
});
});
});
});
});