diff --git a/admin-frontend/e2e/announcements.spec.ts b/admin-frontend/e2e/announcements.spec.ts index f4a1d32f..8cd24229 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 00000000..4abc4065 --- /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 00000000..fa0ad2f2 --- /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 2936ba26..2ef58c3e 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 1d650c3b..5c15313d 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 5f97a89b..5207d0f6 100644 --- a/admin-frontend/src/components/AnnouncementsPage.vue +++ b/admin-frontend/src/components/AnnouncementsPage.vue @@ -1,4 +1,6 @@