feat(tests): TESTS-15 done Create a new Company test (#4242)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2023-12-22 10:00:15 +03:00 committed by GitHub
parent fa077d71a2
commit fd5766ba5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 179 additions and 40 deletions

View File

@ -1,6 +1,7 @@
import { expect, Locator, Page } from '@playwright/test'
import path from 'path'
import { CalendarPage } from '../calendar-page'
import { SocialLink } from './types'
export class CommonRecruitingPage extends CalendarPage {
readonly page: Page
@ -12,6 +13,12 @@ export class CommonRecruitingPage extends CalendarPage {
readonly buttonCreateFirstReview: Locator
readonly buttonMoreActions: Locator
readonly buttonDelete: Locator
readonly buttonAddSocialLinks: Locator
readonly buttonContactPhone: Locator
readonly buttonContactEmail: Locator
readonly inputSocialValue: Locator
readonly buttonSocialCancel: Locator
readonly buttonSocialSave: Locator
constructor (page: Page) {
super(page)
@ -24,6 +31,16 @@ export class CommonRecruitingPage extends CalendarPage {
this.buttonCreateFirstReview = page.locator('span:has-text("Create review")')
this.buttonMoreActions = page.locator('.popupPanel-title > .flex-row-center > button >> nth=0')
this.buttonDelete = page.locator('button[class*="menuItem"] span', { hasText: 'Delete' })
this.buttonAddSocialLinks = page.locator('button[id="presentation:string:AddSocialLinks"]')
this.buttonContactPhone = page.locator(
'div[class^="popupPanel-body"] div.horizontal button[id="contact:string:Phone"]'
)
this.buttonContactEmail = page.locator(
'div[class^="popupPanel-body"] div.horizontal button[id="gmail:string:Email"]'
)
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')
}
async addComment (comment: string): Promise<void> {
@ -64,4 +81,33 @@ export class CommonRecruitingPage extends CalendarPage {
await this.buttonDelete.click()
await this.pressYesDeletePopup(this.page)
}
async addSocialLinks (link: string, linkDescription: string): Promise<void> {
await this.buttonAddSocialLinks.click()
await this.selectFromDropdown(this.page, link)
await this.fillToDropdown(this.page, linkDescription)
}
async addSocialLink (social: SocialLink): Promise<void> {
await this.addSocialLinks(social.type, social.value)
}
async checkSocialLinks (link: string, value: string): Promise<void> {
switch (link) {
case 'Phone':
await expect(this.buttonContactPhone).toBeVisible()
await this.buttonContactPhone.click()
await expect(this.inputSocialValue).toHaveValue(value)
await this.buttonSocialSave.click()
break
case 'Email':
await expect(this.buttonContactEmail).toBeVisible()
await this.buttonContactEmail.click()
await expect(this.inputSocialValue).toHaveValue(value)
await this.buttonSocialSave.click()
break
default:
throw new Error(`Unknown case ${link}`)
}
}
}

View File

@ -0,0 +1,43 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { NewCompany } from './types'
import { CommonRecruitingPage } from './common-recruiting-page'
export class CompaniesPage extends CommonRecruitingPage {
readonly page: Page
readonly pageHeader: Locator
readonly buttonCreateNewCompanies: Locator
readonly inputCreateOrganizationModalName: Locator
readonly inputCreateOrganizationModalCreate: Locator
constructor (page: Page) {
super(page)
this.page = page
this.pageHeader = page.locator('span[class*="header"]', { hasText: 'Companies' })
this.buttonCreateNewCompanies = page.locator('button[type="submit"] > span', { hasText: 'Company' })
this.inputCreateOrganizationModalName = page.locator(
'form[id="contact:string:CreateOrganization"] input[type="text"]'
)
this.inputCreateOrganizationModalCreate = page.locator(
'form[id="contact:string:CreateOrganization"] button[type="submit"]'
)
}
async createNewCompany (data: NewCompany): Promise<void> {
await expect(this.pageHeader).toBeVisible()
await this.buttonCreateNewCompanies.click()
await this.inputCreateOrganizationModalName.fill(data.name)
if (data.socials != null && data.socials.length !== 0) {
for (const social of data.socials) {
await this.addSocialLink(social)
}
}
await this.inputCreateOrganizationModalCreate.click()
}
async openCompanyByName (companyName: string): Promise<void> {
await this.page.locator('tr a', { hasText: companyName }).click()
}
}

View File

@ -0,0 +1,23 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { NewCompany } from './types'
import { CommonRecruitingPage } from './common-recruiting-page'
export class CompanyDetailsPage extends CommonRecruitingPage {
readonly page: Page
readonly inputName: Locator
constructor (page: Page) {
super(page)
this.page = page
this.inputName = page.locator('div.antiEditBox input')
}
async checkCompany (data: NewCompany): Promise<void> {
await expect(this.inputName).toHaveValue(data.name)
if (data.socials != null) {
for (const social of data.socials) {
await this.checkSocialLinks(social.type, social.value)
}
}
}
}

View File

@ -6,6 +6,7 @@ export class NavigationMenuPage {
readonly buttonMyApplications: Locator
readonly buttonTalents: Locator
readonly buttonVacancies: Locator
readonly buttonCompanies: Locator
constructor (page: Page) {
this.page = page
@ -13,5 +14,6 @@ export class NavigationMenuPage {
this.buttonMyApplications = page.locator('a[href$="my-applications"]', { hasText: 'My applications' })
this.buttonTalents = page.locator('a[href$="talents"]', { hasText: 'Talents' })
this.buttonVacancies = page.locator('a[href$="vacancies"]', { hasText: 'Vacancies' })
this.buttonCompanies = page.locator('a[href$="organizations"]', { hasText: 'Companies' })
}
}

View File

@ -6,12 +6,9 @@ export class TalentDetailsPage extends CommonRecruitingPage {
readonly page: Page
readonly buttonAddSkill: Locator
readonly textTagItem: Locator
readonly buttonAddSocialLinks: Locator
readonly buttonContactPhone: Locator
readonly inputLocation: Locator
readonly buttonInputTitle: Locator
readonly buttonInputSource: Locator
readonly buttonContactEmail: Locator
readonly buttonMergeContacts: Locator
readonly buttonFinalContact: Locator
readonly buttonMergeRow: Locator
@ -22,16 +19,9 @@ export class TalentDetailsPage extends CommonRecruitingPage {
this.page = page
this.buttonAddSkill = page.locator('button#add-tag')
this.textTagItem = page.locator('div.tag-item')
this.buttonAddSocialLinks = page.locator('button[id="presentation:string:AddSocialLinks"]')
this.buttonContactPhone = page.locator(
'div[class^="popupPanel-body"] div.horizontal button[id="contact:string:Phone"]'
)
this.inputLocation = page.locator('div.location input')
this.buttonInputTitle = page.locator('button > span', { hasText: 'Title' })
this.buttonInputSource = page.locator('button > span', { hasText: 'Source' })
this.buttonContactEmail = page.locator(
'div[class^="popupPanel-body"] div.horizontal button[id="gmail:string:Email"]'
)
this.buttonMergeContacts = page.locator('button[class*="menuItem"] span', { hasText: 'Merge contacts' })
this.buttonFinalContact = page.locator('form[id="contact:string:MergePersons"] button', {
hasText: 'Final contact'
@ -57,25 +47,6 @@ export class TalentDetailsPage extends CommonRecruitingPage {
await expect(this.textTagItem).toContainText(skillTag)
}
async addSocialLinks (link: string, linkDescription: string): Promise<void> {
await this.buttonAddSocialLinks.click()
await this.selectFromDropdown(this.page, link)
await this.fillToDropdown(this.page, linkDescription)
}
async checkSocialLinks (link: string): Promise<void> {
switch (link) {
case 'Phone':
await expect(this.buttonContactPhone).toBeVisible()
break
case 'Email':
await expect(this.buttonContactEmail).toBeVisible()
break
default:
throw new Error(`Unknown case ${link}`)
}
}
async addTitle (title: string): Promise<void> {
await this.buttonInputTitle.click()
await this.fillToSelectPopup(this.page, title)

View File

@ -25,3 +25,13 @@ export interface NewVacancy {
description: string
location?: string
}
export interface SocialLink {
type: string
value: string
}
export interface NewCompany {
name: string
socials?: SocialLink[]
}

View File

@ -13,7 +13,7 @@ test.use({
test.describe('Application tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Application tests')
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})

View File

@ -0,0 +1,44 @@
import { test } from '@playwright/test'
import { generateId, PlatformSetting, PlatformURI } from '../utils'
import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page'
import { allure } from 'allure-playwright'
import { CompaniesPage } from '../model/recruiting/companies-page'
import { NewCompany } from '../model/recruiting/types'
import { CompanyDetailsPage } from '../model/recruiting/company-details-page'
test.use({
storageState: PlatformSetting
})
test.describe('Companies tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})
test('Create a new Company', async ({ page }) => {
const newCompany: NewCompany = {
name: `Create a new Company test-${generateId()}`,
socials: [
{
type: 'Phone',
value: '3213221321213'
},
{
type: 'Email',
value: 'test+321313123@gmail.com'
}
]
}
const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.buttonCompanies.click()
const companiesPage = new CompaniesPage(page)
await companiesPage.createNewCompany(newCompany)
await companiesPage.openCompanyByName(newCompany.name)
const companyDetailsPage = new CompanyDetailsPage(page)
await companyDetailsPage.checkCompany(newCompany)
})
})

View File

@ -8,7 +8,7 @@ test.use({
test.describe('interview tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Interview tests')
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})

View File

@ -8,7 +8,7 @@ test.use({
test.describe('review tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Review tests')
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})

View File

@ -8,7 +8,7 @@ test.use({
test.describe('skill tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Skill tests')
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})

View File

@ -11,7 +11,7 @@ test.use({
test.describe('candidate/talents tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Talents tests')
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})
@ -86,7 +86,7 @@ test.describe('candidate/talents tests', () => {
await talentDetailsPage.checkSkill(skillTag)
await talentDetailsPage.addSocialLinks('Phone', '123123213213')
await talentDetailsPage.checkSocialLinks('Phone')
await talentDetailsPage.checkSocialLinks('Phone', '123123213213')
await talentDetailsPage.inputLocation.fill('Awesome Location')
const title = `Title-${generateId(4)}`
@ -124,7 +124,7 @@ test.describe('candidate/talents tests', () => {
const sourceTalent1 = 'SourceTalent1'
await talentDetailsPage.addSource(sourceTalent1)
await talentDetailsPage.addSocialLinks('Phone', '123123213213')
await talentDetailsPage.checkSocialLinks('Phone')
await talentDetailsPage.checkSocialLinks('Phone', '123123213213')
// talent 2
await navigationMenuPage.buttonTalents.click()
@ -137,7 +137,7 @@ test.describe('candidate/talents tests', () => {
const sourceTalent2 = 'SourceTalent2'
await talentDetailsPage.addSource(sourceTalent2)
await talentDetailsPage.addSocialLinks('Email', 'test-merge-2@gmail.com')
await talentDetailsPage.checkSocialLinks('Email')
await talentDetailsPage.checkSocialLinks('Email', 'test-merge-2@gmail.com')
// merge
await navigationMenuPage.buttonTalents.click()
@ -156,8 +156,8 @@ test.describe('candidate/talents tests', () => {
await navigationMenuPage.buttonTalents.click()
await talentsPage.openTalentByTalentName(talentNameFirst)
await talentDetailsPage.checkSocialLinks('Phone')
await talentDetailsPage.checkSocialLinks('Email')
await talentDetailsPage.checkSocialLinks('Phone', '123123213213')
await talentDetailsPage.checkSocialLinks('Email', 'test-merge-2@gmail.com')
await expect(talentDetailsPage.inputLocation).toHaveValue('Awesome Location Merge1')
await expect(talentDetailsPage.page.locator('button > span', { hasText: titleTalent2 })).toBeVisible()
await expect(talentDetailsPage.page.locator('button > span', { hasText: sourceTalent2 })).toBeVisible()

View File

@ -12,7 +12,7 @@ test.use({
test.describe('Vacancy tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Vacancy tests')
await allure.parentSuite('Recruiting tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})