Skip to content

Commit

Permalink
[MS] Fixed e2e tests for user modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 committed Nov 7, 2024
1 parent 2e74c83 commit b8e55c5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
8 changes: 4 additions & 4 deletions client/src/parsec/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export async function listUsers(skipRevoked = true, pattern = ''): Promise<Resul
currentProfile: UserProfile.Admin,
createdOn: DateTime.utc(2002, 7, 3),
createdBy: 'device',
revokedOn: DateTime.now(),
revokedOn: DateTime.utc(2022, 4, 7),
revokedBy: 'device',
isRevoked: (): boolean => true,
isFrozen: (): boolean => false,
Expand All @@ -121,7 +121,7 @@ export async function listUsers(skipRevoked = true, pattern = ''): Promise<Resul
currentProfile: UserProfile.Outsider,
createdOn: DateTime.utc(2019, 7, 16),
createdBy: 'device',
revokedOn: DateTime.now(),
revokedOn: DateTime.utc(2023, 11, 3),
revokedBy: 'device',
isRevoked: (): boolean => true,
isFrozen: (): boolean => false,
Expand All @@ -131,9 +131,9 @@ export async function listUsers(skipRevoked = true, pattern = ''): Promise<Resul
// cspell:disable-next-line
humanHandle: { label: 'Valygar Corthala', email: '[email protected]' },
currentProfile: UserProfile.Standard,
createdOn: DateTime.now(),
createdOn: DateTime.utc(2015, 2, 17),
createdBy: 'device',
revokedOn: DateTime.now(),
revokedOn: DateTime.utc(2024, 5, 18),
revokedBy: 'device',
isRevoked: (): boolean => true,
isFrozen: (): boolean => false,
Expand Down
28 changes: 18 additions & 10 deletions client/tests/pw/e2e/user_details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { msTest } from '@tests/pw/helpers/fixtures';
async function openModalWithUser(usersPage: Page, userIndex: number): Promise<Locator> {
await expect(usersPage.locator('.user-details-modal')).toBeHidden();
const user = usersPage.locator('#users-page-user-list').getByRole('listitem').nth(userIndex);
const isRevoked = (await user.locator('.user-status').innerText()) === 'Revoked';
await user.hover();
await user.locator('.options-button').click();
const popover = usersPage.locator('.user-context-menu');
await popover.getByRole('listitem').nth(3).click();
await popover
.getByRole('listitem')
.nth(isRevoked ? 1 : 3)
.click();
const modal = usersPage.locator('.user-details-modal');
await expect(modal).toBeVisible();
return modal;
Expand All @@ -21,11 +25,11 @@ msTest('User details modal', async ({ usersPage }) => {

await expect(modal.locator('.ms-modal-header__title')).toHaveText('User details');
const detailsItems = modal.locator('.ms-modal-content').locator('.details-item');
await expect(detailsItems.nth(0).locator('.details-item__title')).toHaveText('Name');
await expect(detailsItems.nth(0).locator('.details-item-name__title')).toHaveText('Name');
// cspell:disable-next-line
await expect(detailsItems.nth(0).locator('.details-item__text')).toHaveText('Cernd');
await expect(detailsItems.nth(1).locator('.details-item__title')).toHaveText('Joined');
await expect(detailsItems.nth(1).locator('.details-item__text')).toHaveText(/^now|< 1 minute$/);
await expect(detailsItems.nth(0).locator('.details-item-name__text')).toHaveText('Cernd');
await expect(detailsItems.nth(1).locator('.details-item-name__title')).toHaveText('Joined');
await expect(detailsItems.nth(1).locator('.details-item-name__text')).toHaveText(/^now|< 1 minute$/);
await expect(modal.locator('.workspace-list')).toBeVisible();
await expect(modal.locator('.workspace-empty')).toBeHidden();
await expect(modal.locator('.workspace-list').locator('.workspace-list-item').locator('.item-container__name')).toHaveText([
Expand All @@ -36,14 +40,18 @@ msTest('User details modal', async ({ usersPage }) => {
});

msTest('User details modal no common workspaces', async ({ usersPage }) => {
const modal = await openModalWithUser(usersPage, 4);
const modal = await openModalWithUser(usersPage, 2);

await expect(modal.locator('.ms-modal-header__title')).toHaveText('User details');
const detailsItems = modal.locator('.ms-modal-content').locator('.details-item');
await expect(detailsItems.nth(0).locator('.details-item__title')).toHaveText('Name');
await expect(detailsItems.nth(0).locator('.details-item__text')).toHaveText('Patches');
await expect(detailsItems.nth(1).locator('.details-item__title')).toHaveText('Joined');
await expect(detailsItems.nth(1).locator('.details-item__text')).toHaveText('Oct 6, 2009');
await expect(detailsItems.nth(0).locator('.details-item-name__title')).toHaveText('Name');
// cspell:disable-next-line
await expect(detailsItems.nth(0).locator('.details-item-name__text')).toHaveText('Arthas Menethil');
await expect(detailsItems.nth(0).locator('.revoked-chip')).toBeVisible();
await expect(detailsItems.nth(1).locator('.details-item-name__title')).toHaveText('Joined');
await expect(detailsItems.nth(1).locator('.details-item-name__text')).toHaveText('Jul 3, 2002');
await expect(detailsItems.nth(2).locator('.details-item-name__title')).toHaveText('Revoked since');
await expect(detailsItems.nth(2).locator('.details-item-name__text')).toHaveText('Apr 7, 2022');
await expect(modal.locator('.workspace-list')).toBeHidden();
await expect(modal.locator('.workspace-empty')).toBeVisible();
await expect(modal.locator('.workspace-empty')).toHaveText('You have no workspaces in common with this user.');
Expand Down
1 change: 1 addition & 0 deletions newsfragments/8862.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Displays the revocation date in the user details modal

0 comments on commit b8e55c5

Please sign in to comment.