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
12 changes: 3 additions & 9 deletions apps/meteor/tests/e2e/admin-users-custom-fields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ test.describe('Admin users custom fields', () => {

test('should allow admin to add user custom fields', async () => {
await test.step('should find and click on add test user', async () => {
await poAdmin.inputSearchUsers.fill(addTestUser.data.username);

await expect(poAdmin.getUserRowByUsername(addTestUser.data.username)).toBeVisible();
await poAdmin.searchUser(addTestUser.data.username);
await poAdmin.getUserRowByUsername(addTestUser.data.username).click();
});

Expand Down Expand Up @@ -93,9 +91,7 @@ test.describe('Admin users custom fields', () => {

test('should allow admin to update existing user custom fields', async () => {
await test.step('should find and click on update test user', async () => {
await poAdmin.inputSearchUsers.fill(updateTestUser.data.username);

await expect(poAdmin.getUserRowByUsername(updateTestUser.data.username)).toBeVisible();
await poAdmin.searchUser(updateTestUser.data.username);
await poAdmin.getUserRowByUsername(updateTestUser.data.username).click();
});

Expand Down Expand Up @@ -144,9 +140,7 @@ test.describe('Admin users custom fields', () => {

test('should not render fields with invalid custom field type', async () => {
await test.step('should find and click on add test user', async () => {
await poAdmin.inputSearchUsers.fill(addTestUser.data.username);

await expect(poAdmin.getUserRowByUsername(addTestUser.data.username)).toBeVisible();
await poAdmin.searchUser(addTestUser.data.username);
await poAdmin.getUserRowByUsername(addTestUser.data.username).click();
});

Expand Down
8 changes: 2 additions & 6 deletions apps/meteor/tests/e2e/admin-users-role-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ test.describe('Admin > Users Role Management', () => {
});

test('Make a newly created user as admin', async () => {
await admin.inputSearchUsers.fill(userWithoutAdminAccess.data.username);

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 admin.searchUser(userWithoutAdminAccess.data.username);
});

await test.step('make a user admin', async () => {
Expand All @@ -49,10 +46,9 @@ test.describe('Admin > Users Role Management', () => {
});

test('Remove role as admin', async () => {
await admin.inputSearchUsers.fill(userWithAdminAccess.data.username);
await test.step('User should be visible in the All tab', async () => {
await admin.getTabByName().click();
await expect(admin.getUserRowByUsername(userWithAdminAccess.data.username)).toBeVisible();
await admin.searchUser(userWithAdminAccess.data.username);
});

await test.step('remove admin role', async () => {
Expand Down
6 changes: 2 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 @@ -58,11 +58,9 @@ test.describe.serial('Admin > Users', () => {
});

test('After the first login, the user gets listed under the Active tab', async () => {
await adminUsers.inputSearchUsers.fill(user.data.username);

await test.step('should be visible in the All tab', async () => {
await adminUsers.getTabByName('Active').click();
await expect(adminUsers.getUserRowByUsername(user.data.username)).toBeVisible();
await adminUsers.getTabByName().click();
await adminUsers.searchUser(user.data.username);
});

await test.step('should not be visible in the Pending tab', async () => {
Expand Down
4 changes: 1 addition & 3 deletions apps/meteor/tests/e2e/admin-users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ test.describe('Admin > Users', () => {
});

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

await test.step('should be visible in the All tab', async () => {
await admin.getTabByName().click();
await expect(admin.getUserRowByUsername(user.data.username)).toBeVisible();
await admin.searchUser(user.data.username);
});

await test.step('should be visible in the Pending tab', async () => {
Expand Down
8 changes: 3 additions & 5 deletions apps/meteor/tests/e2e/administration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ test.describe.parallel('administration', () => {
await page.goto('/admin/users');
});

test('expect find "user1" user', async ({ page }) => {
await poAdminUsers.inputSearchUsers.fill('user1');

await expect(page.locator('table tr[qa-user-id="user1"]')).toBeVisible();
test('expect find "user1" user', async () => {
await poAdminUsers.searchUser('user1');
});

test('expect create a user', async () => {
Expand Down Expand Up @@ -103,7 +101,7 @@ test.describe.parallel('administration', () => {
await expect(poAdminUsers.editUser.joinDefaultChannels).toBeVisible();
await poAdminUsers.editUser.btnAddUser.click();

await poAdminUsers.inputSearchUsers.fill(username);
await poAdminUsers.searchUser(username);
await poAdminUsers.getUserRowByUsername(username).click();
await poAdminUsers.userInfo.btnEdit.click();
await expect(poAdminUsers.editUser.inputUserName).toHaveValue(username);
Expand Down
12 changes: 9 additions & 3 deletions apps/meteor/tests/e2e/page-objects/admin-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Locator, Page } from '@playwright/test';

import { Admin } from './admin';
import { MenuMoreActions, UserInfoFlexTab, EditUserFlexTab } from './fragments';
import { expect } from '../utils/test';

type UserActions = 'Make Admin' | 'Remove Admin' | 'Activate' | 'Deactivate';

Expand All @@ -27,7 +28,7 @@ export class AdminUsers extends Admin {
return this.page.getByRole('button', { name: 'Invite', exact: true });
}

get inputSearchUsers(): Locator {
private get inputSearchUsers(): Locator {
return this.page.getByRole('textbox', { name: 'Search Users' });
}

Expand All @@ -36,7 +37,7 @@ export class AdminUsers extends Admin {
}

getUserRowByUsername(username: string): Locator {
return this.page.locator('tr', { hasText: username });
return this.page.locator('tr', { hasText: username }).first();
}

getTabByName(name: 'All' | 'Pending' | 'Active' | 'Deactivated' = 'All'): Locator {
Expand All @@ -53,9 +54,14 @@ export class AdminUsers extends Admin {
}

async deleteUser(username: string): Promise<void> {
await this.inputSearchUsers.fill(username);
await this.searchUser(username);
await this.getUserRowByUsername(username).click();
await this.userInfo.btnMoreActions.click();
await this.userInfo.menuItemDeleteUser.click();
}

async searchUser(username: string): Promise<void> {
await this.inputSearchUsers.fill(username);
await expect(this.getUserRowByUsername(username)).toHaveCount(1);
}
}
Loading