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
7 changes: 3 additions & 4 deletions apps/meteor/tests/e2e/admin-users-role-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ test.describe('Admin > Users Role Management', () => {
await test.step('should be visible in the All tab', async () => {
await admin.getTabByName().click();
await expect(admin.getUserRowByUsername(userWithoutAdminAccess.data.username)).toBeVisible();
await expect(admin.getUserRowByUsername(userWithoutAdminAccess.data.username)).toHaveCount(1);
});

await test.step('make a user admin', async () => {
await admin.openUserActionMenu(userWithoutAdminAccess.data.username);
await admin.menuItemMakeAdmin.click();
await admin.dispatchUserAction(userWithoutAdminAccess.data.username, 'Make Admin');
await expect(poToastBar.alert).toBeVisible();
await expect(poToastBar.alert).toHaveText('User is now an admin');
});
Expand All @@ -60,8 +60,7 @@ test.describe('Admin > Users Role Management', () => {
});

await test.step('remove admin role', async () => {
await admin.openUserActionMenu(userWithAdminAccess.data.username);
await admin.menuItemRemoveAdmin.click();
await admin.dispatchUserAction(userWithAdminAccess.data.username, 'Remove Admin');
await expect(poToastBar.alert).toBeVisible();
await expect(poToastBar.alert).toHaveText('User is no longer an admin');
});
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/tests/e2e/admin-users-status-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { BrowserContext, Page } from '@playwright/test';

import { DEFAULT_USER_CREDENTIALS } from './config/constants';
import { Users } from './fixtures/userStates';
import { AdminUsers, Registration, Utils } from './page-objects';
import { AdminUsers, Registration, Authenticated } from './page-objects';
import { test, expect } from './utils/test';
import type { ITestUser } from './utils/user-helpers';
import { createTestUser } from './utils/user-helpers';
Expand All @@ -22,13 +22,13 @@ test.describe.serial('Admin > Users', () => {
let context: BrowserContext;
let page: Page;
let poRegistration: Registration;
let poUtils: Utils;
let poAuth: Authenticated;

test.beforeAll(async ({ browser }) => {
context = await browser.newContext();
page = await context.newPage();
poRegistration = new Registration(page);
poUtils = new Utils(page);
poAuth = new Authenticated(page);
});

test.afterAll(async () => {
Expand All @@ -44,7 +44,7 @@ test.describe.serial('Admin > Users', () => {
});

await test.step('Assert user is logged in', async () => {
await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});
});
});
Expand Down
7 changes: 3 additions & 4 deletions apps/meteor/tests/e2e/admin-users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test.describe('Admin > Users', () => {
admin = new AdminUsers(page);
await page.goto('/admin/users');
});

test('New user shows in correct tabs when deactivated', async () => {
await admin.inputSearchUsers.fill(user.data.username);

Expand All @@ -47,17 +48,15 @@ test.describe('Admin > Users', () => {

await test.step('should move from Pending to Deactivated tab', async () => {
await admin.getTabByName('Pending').click();
await admin.btnMoreActionsMenu.click();
await admin.menuItemDeactivated.click();
await admin.dispatchUserAction(user.data.username, 'Deactivate');
await expect(admin.getUserRowByUsername(user.data.username)).not.toBeVisible();
await admin.getTabByName('Deactivated').click();
await expect(admin.getUserRowByUsername(user.data.username)).toBeVisible();
});

await test.step('should move from Deactivated to Pending tab', async () => {
await admin.getTabByName('Deactivated').click();
await admin.btnMoreActionsMenu.click();
await admin.menuItemActivate.click();
await admin.dispatchUserAction(user.data.username, 'Activate');
await expect(admin.getUserRowByUsername(user.data.username)).not.toBeVisible();
await admin.getTabByName('Pending').click();
await expect(admin.getUserRowByUsername(user.data.username)).toBeVisible();
Expand Down
18 changes: 10 additions & 8 deletions apps/meteor/tests/e2e/administration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ import type { IUser } from '@rocket.chat/apps-engine/definition/users';

import { IS_EE } from './config/constants';
import { Users } from './fixtures/userStates';
import { Utils, AdminUsers, AdminRoles, AdminRooms, AdminThirdPartyLogin, AdminIntegrations } from './page-objects';
import { AdminUsers, AdminRoles, AdminRooms, AdminThirdPartyLogin, AdminIntegrations } from './page-objects';
import { ToastMessages } from './page-objects/fragments';
import { createTargetChannel, setSettingValueById } from './utils';
import { test, expect } from './utils/test';

test.use({ storageState: Users.admin.state });

test.describe.parallel('administration', () => {
let poUtils: Utils;
let targetChannel: string;

test.beforeEach(async ({ page }) => {
poUtils = new Utils(page);
});

test.describe('Workspace', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/admin/info');
Expand Down Expand Up @@ -119,6 +115,11 @@ test.describe.parallel('administration', () => {
const emptyChannelName = faker.string.uuid();
let ownerUser: IUser;
let user: IUser;
let poToastMessage: ToastMessages;

test.beforeEach(({ page }) => {
poToastMessage = new ToastMessages(page);
});

test.beforeAll(async ({ api }) => {
const createUserResponse = await api.post('/users.create', {
Expand Down Expand Up @@ -168,7 +169,7 @@ test.describe.parallel('administration', () => {
await expect(page.getByRole('dialog').getByRole('button', { name: 'Delete' })).toBeVisible();

await page.getByRole('dialog').getByRole('button', { name: 'Delete' }).click();
await expect(poUtils.toastBarSuccess).toBeVisible();
await poToastMessage.waitForDisplay();
await expect(page.getByRole('heading', { name: 'No users' })).toBeVisible();
});

Expand All @@ -177,7 +178,8 @@ test.describe.parallel('administration', () => {
await expect(page.getByRole('dialog', { name: 'Are you sure?' })).toBeVisible();

await page.getByRole('dialog').getByRole('button', { name: 'Delete' }).click();
await expect(poUtils.toastBarSuccess).toBeVisible();

await poToastMessage.waitForDisplay();
await expect(page.getByRole('heading', { name: 'No users' })).toBeVisible();
});
});
Expand Down
13 changes: 7 additions & 6 deletions apps/meteor/tests/e2e/delete-account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DEFAULT_USER_CREDENTIALS } from './config/constants';
import { AccountProfile, Registration, Utils } from './page-objects';
import { AccountProfile, Registration, Authenticated } from './page-objects';
import { ToastBar } from './page-objects/toastBar';
import { test, expect } from './utils/test';
import { createTestUser, type ITestUser } from './utils/user-helpers';
Expand All @@ -8,7 +8,7 @@ test.describe('Delete Own Account', () => {
let poAccountProfile: AccountProfile;
let poRegistration: Registration;
let poToastBar: ToastBar;
let poUtils: Utils;
let poAuth: Authenticated;
let userToDelete: ITestUser;
let userWithInvalidPassword: ITestUser;
let userWithoutPermissions: ITestUser;
Expand All @@ -25,7 +25,7 @@ test.describe('Delete Own Account', () => {
poAccountProfile = new AccountProfile(page);
poRegistration = new Registration(page);
poToastBar = new ToastBar(page);
poUtils = new Utils(page);
poAuth = new Authenticated(page);
await page.goto('/home');
});

Expand All @@ -43,7 +43,7 @@ test.describe('Delete Own Account', () => {
await poRegistration.username.fill(userWithInvalidPassword.data.username);
await poRegistration.inputPassword.fill(DEFAULT_USER_CREDENTIALS.password);
await poRegistration.btnLogin.click();
await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});

await test.step('navigate to profile and locate Delete My Account button', async () => {
Expand Down Expand Up @@ -81,7 +81,7 @@ test.describe('Delete Own Account', () => {
await poRegistration.username.fill(userToDelete.data.username);
await poRegistration.inputPassword.fill(DEFAULT_USER_CREDENTIALS.password);
await poRegistration.btnLogin.click();
await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});

await test.step('navigate to profile and locate Delete My Account button', async () => {
Expand All @@ -105,6 +105,7 @@ test.describe('Delete Own Account', () => {
});

await test.step('verify user is redirected to login page', async () => {
await poRegistration.waitForDisplay();
await expect(poRegistration.btnLogin).toBeVisible();
userToDelete.markAsDeleted();
});
Expand All @@ -121,7 +122,7 @@ test.describe('Delete Own Account', () => {
await poRegistration.username.fill(userWithoutPermissions.data.username);
await poRegistration.inputPassword.fill(DEFAULT_USER_CREDENTIALS.password);
await poRegistration.btnLogin.click();
await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});

await test.step('navigate to profile and locate Delete My Account button', async () => {
Expand Down
20 changes: 12 additions & 8 deletions apps/meteor/tests/e2e/export-messages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { faker } from '@faker-js/faker';

import { Users } from './fixtures/userStates';
import { HomeChannel, Utils } from './page-objects';
import { ExportMessagesTab } from './page-objects/fragments/export-messages-tab';
import { HomeChannel } from './page-objects';
import { ExportMessagesTab } from './page-objects/fragments';
import { createTargetChannel, deleteChannel } from './utils';
import { test, expect } from './utils/test';

Expand All @@ -12,7 +12,6 @@ const uniqueMessage = (): string => `msg-${faker.string.uuid()}`;

test.describe('export-messages', () => {
let poHomeChannel: HomeChannel;
let poUtils: Utils;
let targetChannel: string;

test.beforeAll(async ({ api }) => {
Expand All @@ -21,7 +20,6 @@ test.describe('export-messages', () => {

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
poUtils = new Utils(page);

await page.goto('/home');
});
Expand Down Expand Up @@ -90,7 +88,9 @@ test.describe('export-messages', () => {
await exportMessagesTab.send();

await expect(
poUtils.getAlertByText('You must select one or more users or provide one or more email addresses, separated by commas'),
page.locator('[role="alert"]', {
hasText: 'You must select one or more users or provide one or more email addresses, separated by commas',
}),
).toBeVisible();
});

Expand All @@ -104,7 +104,11 @@ test.describe('export-messages', () => {
await exportMessagesTab.setAdditionalEmail('mail@mail.com');
await exportMessagesTab.send();

await expect(poUtils.getAlertByText(`You haven't selected any messages`)).toBeVisible();
await expect(
page.locator('[role="alert"]', {
hasText: `You haven't selected any messages`,
}),
).toBeVisible();
});

test('should be able to send messages after closing export messages', async () => {
Expand Down Expand Up @@ -134,7 +138,7 @@ test.describe('export-messages', () => {

await poHomeChannel.tabs.kebab.click({ force: true });
await poHomeChannel.tabs.btnExportMessages.click();
await expect(exportMessagesTab.dialog).toBeVisible();
await exportMessagesTab.waitForDisplay();

await poHomeChannel.content.getMessageByText(message1).click();

Expand Down Expand Up @@ -162,7 +166,7 @@ test.describe('export-messages', () => {
await poHomeChannel.tabs.kebab.click({ force: true });
await poHomeChannel.tabs.btnExportMessages.click();

await expect(exportMessagesTab.dialog).toBeVisible();
await exportMessagesTab.waitForDisplay();
await poHomeChannel.content.getMessageByText(message1).click();

await expect(exportMessagesTab.getMessageCheckbox(message1)).toBeChecked();
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/tests/e2e/iframe-authentication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import fs from 'fs';
import path from 'path';

import { Users } from './fixtures/userStates';
import { Utils, Registration } from './page-objects';
import { Registration, Authenticated } from './page-objects';
import { test, expect } from './utils/test';

const IFRAME_URL = 'http://iframe.rocket.chat';
const API_URL = 'http://auth.rocket.chat/api/login';

test.describe('iframe-authentication', () => {
let poRegistration: Registration;
let poUtils: Utils;
let poAuth: Authenticated;

test.beforeAll(async ({ api }) => {
await api.post('/settings/Accounts_iframe_enabled', { value: true });
Expand All @@ -28,7 +28,7 @@ test.describe('iframe-authentication', () => {

test.beforeEach(async ({ page }) => {
poRegistration = new Registration(page);
poUtils = new Utils(page);
poAuth = new Authenticated(page);

await page.route(API_URL, async (route) => {
await route.fulfill({
Expand Down Expand Up @@ -77,7 +77,7 @@ test.describe('iframe-authentication', () => {
});

await page.goto('/home');
await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});

test('should show login page when API returns invalid token', async ({ page }) => {
Expand All @@ -100,7 +100,7 @@ test.describe('iframe-authentication', () => {

await poRegistration.loginIframeSubmitButton.click();

await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});

test('should return error to iframe when login fails', async ({ page }) => {
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/tests/e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { faker } from '@faker-js/faker';

import { DEFAULT_USER_CREDENTIALS } from './config/constants';
import { Utils, Registration } from './page-objects';
import { Registration, Authenticated } from './page-objects';
import { setSettingValueById } from './utils/setSettingValueById';
import { test, expect } from './utils/test';

test.describe.parallel('Login', () => {
let poRegistration: Registration;
let poUtils: Utils;
let poAuth: Authenticated;

test.beforeEach(async ({ page }) => {
poRegistration = new Registration(page);
poUtils = new Utils(page);
poAuth = new Authenticated(page);

await page.goto('/home');
});
Expand Down Expand Up @@ -42,7 +42,7 @@ test.describe.parallel('Login', () => {
await poRegistration.inputPassword.type(DEFAULT_USER_CREDENTIALS.password);
await poRegistration.btnLogin.click();

await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});
});

Expand All @@ -52,7 +52,7 @@ test.describe.parallel('Login', () => {
await poRegistration.inputPassword.type(DEFAULT_USER_CREDENTIALS.password);
await poRegistration.btnLogin.click();

await expect(poUtils.mainContent).toBeVisible();
await poAuth.waitForDisplay();
});
});

Expand Down
Loading
Loading