mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-09 17:05:01 +00:00
Add test for filtering companies
Signed-off-by: Alexander Manakov <novskt@gmail.com>
This commit is contained in:
parent
d270572056
commit
61b89cb783
@ -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<void> {
|
||||
await this.buttonFilter().click()
|
||||
async selectFilter (filter: string, filterSecondLevel?: string, addButton: Locator = this.buttonFilter()): Promise<void> {
|
||||
await addButton.click()
|
||||
await this.selectPopupMenu(filter).click()
|
||||
|
||||
if (filterSecondLevel !== null && typeof filterSecondLevel === 'string') {
|
||||
@ -325,4 +330,8 @@ export class CommonPage {
|
||||
async pressEscape (): Promise<void> {
|
||||
await this.page.keyboard.press('Escape')
|
||||
}
|
||||
|
||||
async removeFilterOption (label: string): Promise<void> {
|
||||
await this.filterCloseButton(label).click()
|
||||
}
|
||||
}
|
||||
|
@ -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<void> {
|
||||
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<void> {
|
||||
await expect(this.companyByName(companyName)).toHaveCount(count)
|
||||
}
|
||||
|
||||
async checkCompanyNotExist (companyName: string): Promise<void> {
|
||||
await expect(this.companyByName(companyName)).toHaveCount(0)
|
||||
await this.checkCompanyRowCount(companyName)
|
||||
}
|
||||
|
||||
async checkCompanyExist (companyName: string): Promise<void> {
|
||||
await this.checkCompanyRowCount(companyName, 1)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user