diff --git a/tests/sanity/tests/model/recruiting/talent-details-page.ts b/tests/sanity/tests/model/recruiting/talent-details-page.ts index fa280f6164..f49fc93da7 100644 --- a/tests/sanity/tests/model/recruiting/talent-details-page.ts +++ b/tests/sanity/tests/model/recruiting/talent-details-page.ts @@ -1,5 +1,6 @@ import { expect, type Locator, type Page } from '@playwright/test' import { CommonRecruitingPage } from './common-recruiting-page' +import { MergeContacts } from './types' export class TalentDetailsPage extends CommonRecruitingPage { readonly page: Page @@ -9,6 +10,12 @@ export class TalentDetailsPage extends CommonRecruitingPage { readonly buttonContactPhone: Locator readonly inputLocation: Locator readonly buttonInputTitle: Locator + readonly buttonInputSource: Locator + readonly buttonContactEmail: Locator + readonly buttonMergeContacts: Locator + readonly buttonFinalContact: Locator + readonly buttonMergeRow: Locator + readonly buttonPopupMergeContacts: Locator constructor (page: Page) { super(page) @@ -21,6 +28,18 @@ export class TalentDetailsPage extends CommonRecruitingPage { ) 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' + }) + this.buttonMergeRow = page.locator('form[id="contact:string:MergePersons"] div.box') + this.buttonPopupMergeContacts = page.locator('form[id="contact:string:MergePersons"] button > span', { + hasText: 'Merge contacts' + }) } async addSkill (skillTag: string, skillDescription: string): Promise { @@ -49,6 +68,9 @@ export class TalentDetailsPage extends CommonRecruitingPage { case 'Phone': await expect(this.buttonContactPhone).toBeVisible() break + case 'Email': + await expect(this.buttonContactEmail).toBeVisible() + break default: throw new Error(`Unknown case ${link}`) } @@ -58,4 +80,40 @@ export class TalentDetailsPage extends CommonRecruitingPage { await this.buttonInputTitle.click() await this.fillToSelectPopup(this.page, title) } + + async addSource (source: string): Promise { + await this.buttonInputSource.click() + await this.fillToSelectPopup(this.page, source) + } + + async mergeContacts (talentName: MergeContacts): Promise { + await this.buttonMoreActions.click() + await this.buttonMergeContacts.click() + + await this.buttonFinalContact.click() + await this.selectMenuItem(this.page, talentName.finalContactName) + + await this.buttonMergeRow.locator('div.flex-center', { hasText: talentName.name }).locator('label.checkbox').click() + + if (talentName.mergeLocation) { + await this.buttonMergeRow + .locator('div.flex-center', { hasText: talentName.location }) + .locator('label.checkbox') + .click() + } + if (talentName.mergeTitle) { + await this.buttonMergeRow + .locator('div.flex-center', { hasText: talentName.title }) + .locator('label.checkbox') + .click() + } + if (talentName.mergeSource) { + await this.buttonMergeRow + .locator('div.flex-center', { hasText: talentName.source }) + .locator('label.checkbox') + .click() + } + + await this.buttonPopupMergeContacts.click() + } } diff --git a/tests/sanity/tests/model/recruiting/types.ts b/tests/sanity/tests/model/recruiting/types.ts index 818e2c1688..aabba370a4 100644 --- a/tests/sanity/tests/model/recruiting/types.ts +++ b/tests/sanity/tests/model/recruiting/types.ts @@ -8,3 +8,14 @@ export interface TalentName { firstName: string lastName: string } + +export interface MergeContacts { + finalContactName: string + name: string + mergeLocation: boolean + location: string + mergeTitle: boolean + title: string + mergeSource: boolean + source: string +} diff --git a/tests/sanity/tests/recruiting/talents.spec.ts b/tests/sanity/tests/recruiting/talents.spec.ts index 422d68c3fb..7fa4249e98 100644 --- a/tests/sanity/tests/recruiting/talents.spec.ts +++ b/tests/sanity/tests/recruiting/talents.spec.ts @@ -107,4 +107,58 @@ test.describe('candidate/talents tests', () => { await navigationMenuPage.buttonTalents.click() await talentsPage.checkTalentNotExist(talentName) }) + + test('Merge contacts', async ({ page, context }) => { + const navigationMenuPage = new NavigationMenuPage(page) + await navigationMenuPage.buttonTalents.click() + const talentsPage = new TalentsPage(page) + + // talent1 + const talentNameFirst = await talentsPage.createNewTalent() + await talentsPage.openTalentByTalentName(talentNameFirst) + let talentDetailsPage = new TalentDetailsPage(page) + await talentDetailsPage.inputLocation.fill('Awesome Location Merge1') + const titleTalent1 = 'TitleMerge1' + await talentDetailsPage.addTitle(titleTalent1) + const sourceTalent1 = 'SourceTalent1' + await talentDetailsPage.addSource(sourceTalent1) + await talentDetailsPage.addSocialLinks('Phone', '123123213213') + await talentDetailsPage.checkSocialLinks('Phone') + + // talent 2 + await navigationMenuPage.buttonTalents.click() + const talentNameSecond = await talentsPage.createNewTalent() + await talentsPage.openTalentByTalentName(talentNameSecond) + talentDetailsPage = new TalentDetailsPage(page) + await talentDetailsPage.inputLocation.fill('Awesome Location Merge2') + const titleTalent2 = 'TitleMerge2' + await talentDetailsPage.addTitle(titleTalent2) + const sourceTalent2 = 'SourceTalent2' + await talentDetailsPage.addSource(sourceTalent2) + await talentDetailsPage.addSocialLinks('Email', 'test-merge-2@gmail.com') + await talentDetailsPage.checkSocialLinks('Email') + + // merge + await navigationMenuPage.buttonTalents.click() + await talentsPage.openTalentByTalentName(talentNameFirst) + + await talentDetailsPage.mergeContacts({ + finalContactName: talentNameSecond.lastName, + name: `${talentNameFirst.lastName} ${talentNameFirst.firstName}`, + mergeLocation: true, + location: 'Awesome Location Merge1', + mergeTitle: true, + title: titleTalent1, + mergeSource: true, + source: sourceTalent1 + }) + + await navigationMenuPage.buttonTalents.click() + await talentsPage.openTalentByTalentName(talentNameFirst) + await talentDetailsPage.checkSocialLinks('Phone') + await talentDetailsPage.checkSocialLinks('Email') + 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() + }) })