TESTS-16: feat(tests): done Edit a Company test (#4243)

This commit is contained in:
Alex Velichko 2023-12-24 14:24:27 +03:00 committed by GitHub
parent c1c9f30f3b
commit 5bbfa26dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 0 deletions

View File

@ -19,6 +19,7 @@ export class CommonRecruitingPage extends CalendarPage {
readonly inputSocialValue: Locator
readonly buttonSocialCancel: Locator
readonly buttonSocialSave: Locator
readonly buttonContactLinkedIn: Locator
constructor (page: Page) {
super(page)
@ -41,6 +42,9 @@ export class CommonRecruitingPage extends CalendarPage {
this.inputSocialValue = page.locator('div.popup input.search')
this.buttonSocialCancel = page.locator('div.popup button[type="button"]:not([id])')
this.buttonSocialSave = page.locator('button#channel-ok')
this.buttonContactLinkedIn = page.locator(
'div[class^="popupPanel-body"] div.horizontal button[id="contact:string:LinkedIn"]'
)
}
async addComment (comment: string): Promise<void> {
@ -106,6 +110,12 @@ export class CommonRecruitingPage extends CalendarPage {
await expect(this.inputSocialValue).toHaveValue(value)
await this.buttonSocialSave.click()
break
case 'LinkedIn':
await expect(this.buttonContactLinkedIn).toBeVisible()
await this.buttonContactLinkedIn.click()
await expect(this.inputSocialValue).toHaveValue(value)
await this.buttonSocialSave.click()
break
default:
throw new Error(`Unknown case ${link}`)
}

View File

@ -5,11 +5,15 @@ import { CommonRecruitingPage } from './common-recruiting-page'
export class CompanyDetailsPage extends CommonRecruitingPage {
readonly page: Page
readonly inputName: Locator
readonly buttonCompanyDetails: Locator
readonly buttonLocation: Locator
constructor (page: Page) {
super(page)
this.page = page
this.inputName = page.locator('div.antiEditBox input')
this.buttonCompanyDetails = page.locator('div.flex-row-center > span', { hasText: 'Company' })
this.buttonLocation = page.locator('//span[text()="Location"]/following-sibling::div[1]/button/span')
}
async checkCompany (data: NewCompany): Promise<void> {
@ -19,5 +23,23 @@ export class CompanyDetailsPage extends CommonRecruitingPage {
await this.checkSocialLinks(social.type, social.value)
}
}
if (data.location != null) {
await expect(this.buttonLocation).toHaveText(data.location)
}
}
async editCompany (data: NewCompany): Promise<void> {
await this.inputName.fill(data.name)
if (data.socials != null && data.socials.length !== 0) {
for (const social of data.socials) {
await this.addSocialLink(social)
}
}
if (data.location != null) {
await this.buttonCompanyDetails.click()
await this.buttonLocation.click()
await this.fillToSelectPopup(this.page, data.location)
}
}
}

View File

@ -34,4 +34,5 @@ export interface SocialLink {
export interface NewCompany {
name: string
socials?: SocialLink[]
location?: string
}

View File

@ -41,4 +41,41 @@ test.describe('Companies tests', () => {
const companyDetailsPage = new CompanyDetailsPage(page)
await companyDetailsPage.checkCompany(newCompany)
})
test('Edit a Company', async ({ page }) => {
const createdCompany = `Edit Company--${generateId()}`
const editCompany: NewCompany = {
name: `Updated Edit Company-${generateId()}`,
socials: [
{
type: 'Phone',
value: '+79835227364'
},
{
type: 'Email',
value: 'edit-company+1@gmail.com'
},
{
type: 'LinkedIn',
value: 'https://www.linkedin.com/in/test-contact/'
}
],
location: 'London'
}
const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.buttonCompanies.click()
const companiesPage = new CompaniesPage(page)
await companiesPage.createNewCompany({ name: createdCompany })
await companiesPage.openCompanyByName(createdCompany)
const companyDetailsPage = new CompanyDetailsPage(page)
await companyDetailsPage.checkCompany({
name: createdCompany
})
await companyDetailsPage.editCompany(editCompany)
await companyDetailsPage.checkCompany(editCompany)
})
})