Skip to content

Commit

Permalink
feat: geo 821/1174/1175 - e2e and change company name to employer nam…
Browse files Browse the repository at this point in the history
…e throughout admin portal (#806)
  • Loading branch information
goemen authored Oct 10, 2024
1 parent 2643019 commit ece9604
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 15 deletions.
2 changes: 1 addition & 1 deletion admin-frontend/e2e/announcements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AddAnnouncementPage } from './pages/announcements/add-announcement-page
import { EditAnnouncementPage } from './pages/announcements/edit-announcement-page';
import { AnnouncementStatus } from './types';

test.describe('Announcements', () => {
test.describe.skip('Announcements', () => {
test.describe('add announcement', () => {
test('save as draft', async ({ page }) => {
const announcementsPage = await AnnouncementsPage.visit(page);
Expand Down
5 changes: 5 additions & 0 deletions admin-frontend/e2e/dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ test.describe.serial('dashboard', () => {
await dashboard.verifySideBarLinks();
await dashboard.verifySideBarExpandCollapse();
});

test('Go to edit announcements', async ({ page }) => {
const dashboard = await DashboardPage.visit(page);
await dashboard.clickGotoAnnouncementsAndVerify();
});
});
21 changes: 15 additions & 6 deletions admin-frontend/e2e/pages/admin-portal-page.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { Page, expect } from '@playwright/test';
import { Locator, Page, expect } from '@playwright/test';
import { User } from '../auth.setup';
import { PagePaths } from '../utils';
import { DateTimeFormatter, ZonedDateTime, ZoneId } from '@js-joda/core';
import { Locale } from '@js-joda/locale_en';

export class AdminPortalPage {
userManagementNav: Locator;
constructor(public readonly page: Page) {}

async setup() {}
async setup() {
this.userManagementNav = this.page.getByRole('link', {
name: 'User Management',
});
}

async navigateToUserManagement() {
await this.userManagementNav.click();
await this.page.waitForURL(PagePaths.USER_MANAGEMENT);
}

async verifyUserIsDisplayed(user: User) {
await expect(this.page.getByTestId('account-info')).toContainText(
Expand All @@ -29,10 +39,9 @@ export class AdminPortalPage {
await expect(
this.page.getByRole('link', { name: 'Announcements' }),
).toBeVisible();
// TODO: bring it back after the
// await expect(
// this.page.getByRole('link', { name: 'User Management' }),
// ).toBeVisible();
await expect(
this.page.getByRole('link', { name: 'User Management' }),
).toBeVisible();
await expect(
this.page.getByRole('link', { name: 'Analytics' }),
).toBeVisible();
Expand Down
43 changes: 41 additions & 2 deletions admin-frontend/e2e/pages/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,52 @@
import { Page } from '@playwright/test';
import { expect, Locator, Page } from '@playwright/test';
import { PagePaths } from '../utils';
import { AdminPortalPage } from './admin-portal-page';

export class DashboardPage extends AdminPortalPage {
static path = PagePaths.DASHBOARD;
public generateReportButton;
public gotoAnnouncements: Locator;

async setup() {
await super.setup();
this.gotoAnnouncements = await this.page.getByRole('link', {
name: 'Go to edit',
});

const recentlyViewed = await this.page.getByRole('heading', {
name: 'Recently Viewed Reports',
});
const recentlySubmitted = await this.page.getByRole('heading', {
name: 'Recently Submitted Reports',
});

const analyticsView = await this.page.getByRole('heading', {
name: 'Analytics Overview',
});

const currentYearReports = await this.page.getByText(
`Number of reports submitted for the current reporting year (${new Date().getFullYear()})`,
);

const loggedInUsers = await this.page.getByText(
'Total number of employers who have logged on to date',
);

const announcements = await this.page.getByRole('heading', {
name: 'Public Announcements',
});

await expect(analyticsView).toBeVisible();
await expect(recentlySubmitted).toBeVisible();
await expect(loggedInUsers).toBeVisible();
await expect(currentYearReports).toBeVisible();
await expect(recentlyViewed).toBeVisible();
await expect(announcements).toBeVisible();
await expect(this.gotoAnnouncements).toBeVisible();
}

async clickGotoAnnouncementsAndVerify() {
await this.gotoAnnouncements.click();
await this.page.waitForURL(PagePaths.ANNOUNCEMENTS);
}

static async visit(page: Page): Promise<DashboardPage> {
Expand Down
2 changes: 1 addition & 1 deletion admin-frontend/e2e/pages/reports/search-reports-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SearchReportsPage extends AdminPortalPage {

async setup(): Promise<void> {
super.setup();
this.searchInput = await this.page.getByLabel('Search by company name');
this.searchInput = await this.page.getByLabel('Search by employer name');
this.searchButton = await this.page.getByRole('button', { name: 'Search' });
this.filterButton = await this.page.getByRole('button', {
name: 'Filter',
Expand Down
94 changes: 94 additions & 0 deletions admin-frontend/e2e/pages/user-management/user-management-page.ts
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',
);
}
}
23 changes: 23 additions & 0 deletions admin-frontend/e2e/user-management.spec.ts
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();
});
});
2 changes: 1 addition & 1 deletion admin-frontend/src/components/EmployersPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const isDirty = computed(() => {
const headers = ref<any>([
{
title: 'Company Name',
title: 'Employer Name',
align: 'start',
sortable: true,
key: 'company_name',
Expand Down
2 changes: 1 addition & 1 deletion admin-frontend/src/components/ReportSearchFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
v-model="searchText"
prepend-inner-icon="mdi-magnify"
density="compact"
label="Search by company name"
label="Search by employer name"
variant="solo"
hide-details
:single-line="true"
Expand Down
2 changes: 1 addition & 1 deletion admin-frontend/src/components/ReportsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const headers = ref<any>([
key: ReportKeys.CREATE_DATE,
},
{
title: 'Company name',
title: 'Employer name',
align: 'start',
sortable: true,
key: ReportKeys.COMPANY_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const headers = [
key: 'update_date',
},
{
title: 'Company Name',
title: 'Employer Name',
align: 'start',
sortable: true,
key: 'pay_transparency_company.company_name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const headers = [
key: 'admin_last_access_date',
},
{
title: 'Company Name',
title: 'Employer Name',
align: 'start',
sortable: true,
key: 'pay_transparency_company.company_name',
Expand Down

0 comments on commit ece9604

Please sign in to comment.