diff --git a/tests/sanity/tests/model/common-page.ts b/tests/sanity/tests/model/common-page.ts index b5044b51b8a..8d4686d9999 100644 --- a/tests/sanity/tests/model/common-page.ts +++ b/tests/sanity/tests/model/common-page.ts @@ -57,8 +57,13 @@ export class CommonPage { buttonFilterApply = (): Locator => this.page.locator('div.selectPopup button[type="button"]', { hasText: 'Apply' }) buttonClearFilters = (): Locator => this.page.locator('button > span', { hasText: 'Clear filters' }) filterButton = (index: number): Locator => this.page.locator(`div.filter-section button:nth-child(${index})`) + filterRow = (): Locator => this.page.locator('div.filterbar-container') selectFilterSection = (label: string): Locator => - this.page.locator('div.filterbar-container div.filter-section', { hasText: label }) + this.filterRow().locator('div.filter-section', { hasText: label }) + + filterCloseButton = (label: string): Locator => this.selectFilterSection(label).locator('button .btn-icon') + + addFilterButton = (): Locator => this.filterRow().locator('div.add-filter') selectPopupMenu = (filter: string): Locator => this.page.locator('div.selectPopup [class*="menu"]', { hasText: filter }) @@ -216,8 +221,8 @@ export class CommonPage { await this.menuPopupItemButton(itemText).first().click() } - async selectFilter (filter: string, filterSecondLevel?: string): Promise { - await this.buttonFilter().click() + async selectFilter (filter: string, filterSecondLevel?: string, addButton: Locator = this.buttonFilter()): Promise { + await addButton.click() await this.selectPopupMenu(filter).click() if (filterSecondLevel !== null && typeof filterSecondLevel === 'string') { @@ -325,4 +330,8 @@ export class CommonPage { async pressEscape (): Promise { await this.page.keyboard.press('Escape') } + + async removeFilterOption (label: string): Promise { + await this.filterCloseButton(label).click() + } } diff --git a/tests/sanity/tests/model/recruiting/companies-page.ts b/tests/sanity/tests/model/recruiting/companies-page.ts index f336786e1b1..b0685c0b7a5 100644 --- a/tests/sanity/tests/model/recruiting/companies-page.ts +++ b/tests/sanity/tests/model/recruiting/companies-page.ts @@ -22,7 +22,11 @@ export class CompaniesPage extends CommonRecruitingPage { readonly inputCreateOrganizationModalCreate = (): Locator => this.page.locator('form[id="contact:string:CreateOrganization"] button[type="submit"]') - readonly companyByName = (companyName: string): Locator => this.page.locator('tr a', { hasText: companyName }) + readonly companyPanel = (): Locator => + this.page.locator('xpath=//div[@data-id="contentPanel" and .//button[.//text()="Company"]]') + + readonly companyByName = (companyName: string): Locator => + this.companyPanel().locator('tr a', { hasText: companyName }) async createNewCompany (data: NewCompany): Promise { await expect(this.pageHeader()).toBeVisible() @@ -43,7 +47,15 @@ export class CompaniesPage extends CommonRecruitingPage { await this.companyByName(companyName).click() } + async checkCompanyRowCount (companyName: string, count: number = 0): Promise { + await expect(this.companyByName(companyName)).toHaveCount(count) + } + async checkCompanyNotExist (companyName: string): Promise { - await expect(this.companyByName(companyName)).toHaveCount(0) + await this.checkCompanyRowCount(companyName) + } + + async checkCompanyExist (companyName: string): Promise { + await this.checkCompanyRowCount(companyName, 1) } } diff --git a/tests/sanity/tests/recruiting/companies.spec.ts b/tests/sanity/tests/recruiting/companies.spec.ts index 2265bd403de..1d4f597207e 100644 --- a/tests/sanity/tests/recruiting/companies.spec.ts +++ b/tests/sanity/tests/recruiting/companies.spec.ts @@ -4,6 +4,7 @@ import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page' import { CompaniesPage } from '../model/recruiting/companies-page' import { NewCompany } from '../model/recruiting/types' import { CompanyDetailsPage } from '../model/recruiting/company-details-page' +import { DEFAULT_USER } from '../tracker/tracker.utils' test.use({ storageState: PlatformSetting @@ -86,4 +87,36 @@ test.describe('Companies tests', () => { await navigationMenuPage.clickButtonCompanies() await companiesPage.checkCompanyNotExist(deleteCompany.name) }) + + test('Filtering companies', async ({ page }) => { + const firstCompany: NewCompany = { + name: `Company for filtering one-${generateId()}` + } + const secondCompany: NewCompany = { + name: `Company for filtering two-${generateId()}` + } + await test.step('Create companies', async () => { + await navigationMenuPage.clickButtonCompanies() + await companiesPage.createNewCompany(firstCompany) + await companiesPage.checkCompanyExist(firstCompany.name) + await companiesPage.createNewCompany(secondCompany) + await companiesPage.checkCompanyExist(secondCompany.name) + }) + await test.step('Filtering by creator', async () => { + await companiesPage.selectFilter('Created by', DEFAULT_USER) + await companiesPage.pressEscape() + await companiesPage.checkCompanyExist(firstCompany.name) + await companiesPage.checkCompanyExist(secondCompany.name) + }) + await test.step('Filtering by name', async () => { + await companiesPage.selectFilter('Name', firstCompany.name, companiesPage.addFilterButton()) + await companiesPage.checkCompanyExist(firstCompany.name) + await companiesPage.checkCompanyNotExist(secondCompany.name) + }) + await test.step('Remove name filter', async () => { + await companiesPage.removeFilterOption('Name') + await companiesPage.checkCompanyExist(firstCompany.name) + await companiesPage.checkCompanyExist(secondCompany.name) + }) + }) })