-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dashboard and user management e2e tests
- Loading branch information
Showing
6 changed files
with
179 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
admin-frontend/e2e/pages/user-management/user-management-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { expect, Locator } from 'playwright/test'; | ||
import { AdminPortalPage } from '../admin-portal-page'; | ||
|
||
export class UserManagementPage extends AdminPortalPage { | ||
pendingAccessButton: Locator; | ||
addUserButton: Locator; | ||
|
||
async setup() { | ||
await super.setup(); | ||
this.pendingAccessButton = this.page.getByRole('button', { | ||
name: 'Pending Access', | ||
}); | ||
this.addUserButton = this.page.getByRole('button', { | ||
name: 'Add New User', | ||
}); | ||
|
||
await expect(this.pendingAccessButton).toBeVisible(); | ||
await expect(this.addUserButton).toBeVisible(); | ||
} | ||
|
||
async verifyOpenAndClosePendingAccess() { | ||
const waitForAccessResponse = this.waitForUserInvitesToLoad(); | ||
await this.pendingAccessButton.click(); | ||
const modalTitle = await this.page.getByText('Pending User Access'); | ||
await expect(modalTitle).toBeVisible(); | ||
const response = await waitForAccessResponse; | ||
const data = await response.json(); | ||
if (data.length === 0) { | ||
const noPendingAccess = await this.page.getByText( | ||
'No pending invitations', | ||
); | ||
await expect(noPendingAccess).toBeVisible(); | ||
} else { | ||
for (const { admin_user_onboarding_id, first_name, email } of data) { | ||
const inviteName = await this.page.getByTestId( | ||
`name-${admin_user_onboarding_id}`, | ||
); | ||
await expect(inviteName).toBeVisible(); | ||
await expect(inviteName).toContainText(first_name); | ||
const inviteEmail = await this.page.getByTestId( | ||
`email-${admin_user_onboarding_id}`, | ||
); | ||
await expect(inviteEmail).toBeVisible(); | ||
await expect(inviteEmail).toContainText(email); | ||
} | ||
} | ||
|
||
const closeButton = await this.page.getByRole('button', { name: 'Close' }); | ||
await closeButton.click(); | ||
await expect(modalTitle).not.toBeVisible(); | ||
} | ||
|
||
async addNewUserAndVerify(user: { name: string; email: string }) { | ||
await this.addUserButton.click(); | ||
const nameInput = await this.page.getByLabel('Name'); | ||
await expect(nameInput).toBeVisible(); | ||
const emailInput = await this.page.getByLabel('Email'); | ||
await expect(emailInput).toBeVisible(); | ||
const submitButton = await this.page.getByRole('button', { name: 'Add', exact: true }); | ||
|
||
// Fill out form | ||
await nameInput.fill(user.name); | ||
await emailInput.fill(user.email); | ||
const addUserResponse = this.waitForUserToBeAdded(); | ||
await submitButton.click(); | ||
const continueButton = await this.page.getByRole('button', { | ||
name: 'Continue', | ||
}); | ||
await continueButton.click(); | ||
const response = await addUserResponse; | ||
await response.json(); | ||
const snackbar = await this.page.getByText( | ||
'User successfully onboarded. An email has been sent for them to activate their account for the application. Once they activate their account the user will be displayed for user management', | ||
); | ||
await expect(snackbar).toBeVisible(); | ||
} | ||
|
||
waitForUserToBeAdded() { | ||
return this.page.waitForResponse( | ||
(response) => | ||
response.url().includes('/v1/user-invites') && | ||
response.status() === 200 && response.request().method() === 'POST', | ||
); | ||
} | ||
|
||
async waitForUserInvitesToLoad() { | ||
return this.page.waitForResponse( | ||
(response) => | ||
response.url().includes('/v1/user-invites') && | ||
response.status() === 200 && | ||
response.request().method() === 'GET', | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { test } from '@playwright/test'; | ||
import { UserManagementPage } from './pages/user-management/user-management-page'; | ||
import { faker } from '@faker-js/faker'; | ||
import { PagePaths } from './utils'; | ||
|
||
const user = { | ||
name: faker.person.fullName(), | ||
email: faker.internet.userName(), | ||
}; | ||
test.describe.serial('User Management', () => { | ||
let userManagementPage: UserManagementPage; | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(PagePaths.USER_MANAGEMENT); | ||
userManagementPage = new UserManagementPage(page); | ||
await userManagementPage.setup(); | ||
}); | ||
test('add new user', async () => { | ||
await userManagementPage.addNewUserAndVerify(user); | ||
}); | ||
test('verify open and close pending access', async () => { | ||
await userManagementPage.verifyOpenAndClosePendingAccess(); | ||
}); | ||
}); |