From 4c1fc55e6fe6e0974a3bc46f891df2aca3d99ccd Mon Sep 17 00:00:00 2001 From: Goeme Nthomiwa Date: Thu, 10 Oct 2024 16:21:02 -0700 Subject: [PATCH] fix: geo 1176 for consistency we should be capitalizing field names throughout the admin portal (#811) --- admin-frontend/e2e/announcements.spec.ts | 2 +- admin-frontend/e2e/employer-search.spec.ts | 17 +++++++ .../employer-search/employer-search-page.ts | 50 +++++++++++++++++++ admin-frontend/e2e/user-management.spec.ts | 2 +- admin-frontend/e2e/utils/index.ts | 1 + .../src/components/AnnouncementsPage.vue | 4 +- .../src/components/EmployersPage.vue | 1 + .../src/components/ReportSearchFilters.vue | 6 +-- admin-frontend/src/components/ReportsPage.vue | 8 +-- .../announcements/AnnouncementForm.vue | 2 +- .../AnnouncementSearchFilters.vue | 4 +- 11 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 admin-frontend/e2e/employer-search.spec.ts create mode 100644 admin-frontend/e2e/pages/employer-search/employer-search-page.ts diff --git a/admin-frontend/e2e/announcements.spec.ts b/admin-frontend/e2e/announcements.spec.ts index f4a1d32f8..8cd242294 100644 --- a/admin-frontend/e2e/announcements.spec.ts +++ b/admin-frontend/e2e/announcements.spec.ts @@ -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.skip('Announcements', () => { +test.describe('Announcements', () => { test.describe('add announcement', () => { test('save as draft', async ({ page }) => { const announcementsPage = await AnnouncementsPage.visit(page); diff --git a/admin-frontend/e2e/employer-search.spec.ts b/admin-frontend/e2e/employer-search.spec.ts new file mode 100644 index 000000000..4abc40655 --- /dev/null +++ b/admin-frontend/e2e/employer-search.spec.ts @@ -0,0 +1,17 @@ +import { test } from '@playwright/test'; + +import { EmployerSearchPage } from './pages/employer-search/employer-search-page'; +import { PagePaths } from './utils'; + +test.describe('Employer Search', () => { + let employerSearchPage: EmployerSearchPage; + test.beforeEach(async ({ page }) => { + await page.goto(PagePaths.EMPLOYERS); + employerSearchPage = new EmployerSearchPage(page); + await employerSearchPage.setup(); + }); + + test('search employer by name', async () => { + await employerSearchPage.searchEmployerByAndVerify(); + }); +}); diff --git a/admin-frontend/e2e/pages/employer-search/employer-search-page.ts b/admin-frontend/e2e/pages/employer-search/employer-search-page.ts new file mode 100644 index 000000000..fa0ad2f2c --- /dev/null +++ b/admin-frontend/e2e/pages/employer-search/employer-search-page.ts @@ -0,0 +1,50 @@ +import { expect, Locator } from 'playwright/test'; +import { AdminPortalPage } from '../admin-portal-page'; + +export class EmployerSearchPage extends AdminPortalPage { + searchInput: Locator; + calendarYearInput: Locator; + searchButton: Locator; + resetButton: Locator; + + async setup(): Promise { + this.searchInput = await this.page.getByLabel('Search by employer name'); + this.calendarYearInput = await this.page.getByLabel('Calendar Year(s)'); + this.searchButton = await this.page.getByRole('button', { + name: 'Search', + }); + this.resetButton = await this.page.getByRole('button', { + name: 'Reset', + }); + + await expect(this.searchInput).toBeVisible(); + await expect(this.calendarYearInput).toBeVisible(); + await expect(this.searchButton).toBeVisible(); + await expect(this.resetButton).toBeVisible(); + } + + async searchEmployerByAndVerify(): Promise { + await this.searchInput.fill(''); + const waitForResults = this.waitForResultsToLoad(); + await this.searchButton.click(); + const response = await waitForResults; + const { employers } = await response.json(); + const table = await this.page.getByRole('table'); + await expect(table).toBeVisible(); + + for (const employer of employers) { + const employerName = await this.page.getByText(employer.company_name); + const count = employers.filter((e) => e.company_name === employer.company_name).length; + await expect(await employerName.count()).toBe(count); + } + } + + private waitForResultsToLoad() { + return this.page.waitForResponse( + (response) => + response.url().includes('admin-api/v1/employers') && + response.status() === 200 && + response.request().method() === 'GET', + ); + } +} diff --git a/admin-frontend/e2e/user-management.spec.ts b/admin-frontend/e2e/user-management.spec.ts index 2936ba268..2ef58c3e2 100644 --- a/admin-frontend/e2e/user-management.spec.ts +++ b/admin-frontend/e2e/user-management.spec.ts @@ -1,7 +1,7 @@ import { test } from '@playwright/test'; -import { UserManagementPage } from './pages/user-management/user-management-page'; import { faker } from '@faker-js/faker'; import { PagePaths } from './utils'; +import { UserManagementPage } from './pages/user-management/user-management-page'; const user = { name: faker.person.fullName(), diff --git a/admin-frontend/e2e/utils/index.ts b/admin-frontend/e2e/utils/index.ts index 1d650c3b4..5c15313de 100644 --- a/admin-frontend/e2e/utils/index.ts +++ b/admin-frontend/e2e/utils/index.ts @@ -8,6 +8,7 @@ export const PagePaths = { ANNOUNCEMENTS: `${baseURL}/announcements`, ADD_ANNOUNCEMENTS: `${baseURL}/add-announcement`, EDIT_ANNOUNCEMENTS: `${baseURL}/edit-announcement`, + EMPLOYERS: `${baseURL}/employers`, USER_MANAGEMENT: `${baseURL}/user-management`, ANALYTICS: `${baseURL}/analytics`, }; diff --git a/admin-frontend/src/components/AnnouncementsPage.vue b/admin-frontend/src/components/AnnouncementsPage.vue index 5f97a89b8..5207d0f61 100644 --- a/admin-frontend/src/components/AnnouncementsPage.vue +++ b/admin-frontend/src/components/AnnouncementsPage.vue @@ -1,4 +1,6 @@