From fd5766ba5c65023e34bcd35229c3893c0fa393e0 Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Fri, 22 Dec 2023 10:00:15 +0300 Subject: [PATCH] feat(tests): TESTS-15 done Create a new Company test (#4242) Signed-off-by: Alex Velichko --- .../recruiting/common-recruiting-page.ts | 46 +++++++++++++++++++ .../tests/model/recruiting/companies-page.ts | 43 +++++++++++++++++ .../model/recruiting/company-details-page.ts | 23 ++++++++++ .../model/recruiting/navigation-menu-page.ts | 2 + .../model/recruiting/talent-details-page.ts | 29 ------------ tests/sanity/tests/model/recruiting/types.ts | 10 ++++ .../tests/recruiting/applications.spec.ts | 2 +- .../sanity/tests/recruiting/companies.spec.ts | 44 ++++++++++++++++++ .../sanity/tests/recruiting/interview.spec.ts | 2 +- tests/sanity/tests/recruiting/reviews.spec.ts | 2 +- tests/sanity/tests/recruiting/skills.spec.ts | 2 +- tests/sanity/tests/recruiting/talents.spec.ts | 12 ++--- .../sanity/tests/recruiting/vacancies.spec.ts | 2 +- 13 files changed, 179 insertions(+), 40 deletions(-) create mode 100644 tests/sanity/tests/model/recruiting/companies-page.ts create mode 100644 tests/sanity/tests/model/recruiting/company-details-page.ts create mode 100644 tests/sanity/tests/recruiting/companies.spec.ts diff --git a/tests/sanity/tests/model/recruiting/common-recruiting-page.ts b/tests/sanity/tests/model/recruiting/common-recruiting-page.ts index fde30911f8..acb4c60f0e 100644 --- a/tests/sanity/tests/model/recruiting/common-recruiting-page.ts +++ b/tests/sanity/tests/model/recruiting/common-recruiting-page.ts @@ -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 { @@ -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 { + await this.buttonAddSocialLinks.click() + await this.selectFromDropdown(this.page, link) + await this.fillToDropdown(this.page, linkDescription) + } + + async addSocialLink (social: SocialLink): Promise { + await this.addSocialLinks(social.type, social.value) + } + + async checkSocialLinks (link: string, value: string): Promise { + 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}`) + } + } } diff --git a/tests/sanity/tests/model/recruiting/companies-page.ts b/tests/sanity/tests/model/recruiting/companies-page.ts new file mode 100644 index 0000000000..2938a7902b --- /dev/null +++ b/tests/sanity/tests/model/recruiting/companies-page.ts @@ -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 { + 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 { + await this.page.locator('tr a', { hasText: companyName }).click() + } +} diff --git a/tests/sanity/tests/model/recruiting/company-details-page.ts b/tests/sanity/tests/model/recruiting/company-details-page.ts new file mode 100644 index 0000000000..25c12e2a8a --- /dev/null +++ b/tests/sanity/tests/model/recruiting/company-details-page.ts @@ -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 { + await expect(this.inputName).toHaveValue(data.name) + if (data.socials != null) { + for (const social of data.socials) { + await this.checkSocialLinks(social.type, social.value) + } + } + } +} diff --git a/tests/sanity/tests/model/recruiting/navigation-menu-page.ts b/tests/sanity/tests/model/recruiting/navigation-menu-page.ts index 7ab2dee8bd..87209d79cc 100644 --- a/tests/sanity/tests/model/recruiting/navigation-menu-page.ts +++ b/tests/sanity/tests/model/recruiting/navigation-menu-page.ts @@ -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' }) } } diff --git a/tests/sanity/tests/model/recruiting/talent-details-page.ts b/tests/sanity/tests/model/recruiting/talent-details-page.ts index 5be7f4aae5..ac691e070a 100644 --- a/tests/sanity/tests/model/recruiting/talent-details-page.ts +++ b/tests/sanity/tests/model/recruiting/talent-details-page.ts @@ -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 { - await this.buttonAddSocialLinks.click() - await this.selectFromDropdown(this.page, link) - await this.fillToDropdown(this.page, linkDescription) - } - - async checkSocialLinks (link: string): Promise { - 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 { await this.buttonInputTitle.click() await this.fillToSelectPopup(this.page, title) diff --git a/tests/sanity/tests/model/recruiting/types.ts b/tests/sanity/tests/model/recruiting/types.ts index 7bdbd93a39..ca6fa09d48 100644 --- a/tests/sanity/tests/model/recruiting/types.ts +++ b/tests/sanity/tests/model/recruiting/types.ts @@ -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[] +} diff --git a/tests/sanity/tests/recruiting/applications.spec.ts b/tests/sanity/tests/recruiting/applications.spec.ts index a24cff2fd3..37dc06e033 100644 --- a/tests/sanity/tests/recruiting/applications.spec.ts +++ b/tests/sanity/tests/recruiting/applications.spec.ts @@ -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() }) diff --git a/tests/sanity/tests/recruiting/companies.spec.ts b/tests/sanity/tests/recruiting/companies.spec.ts new file mode 100644 index 0000000000..a7c108dce5 --- /dev/null +++ b/tests/sanity/tests/recruiting/companies.spec.ts @@ -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) + }) +}) diff --git a/tests/sanity/tests/recruiting/interview.spec.ts b/tests/sanity/tests/recruiting/interview.spec.ts index 02476633b6..5817dec463 100644 --- a/tests/sanity/tests/recruiting/interview.spec.ts +++ b/tests/sanity/tests/recruiting/interview.spec.ts @@ -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() }) diff --git a/tests/sanity/tests/recruiting/reviews.spec.ts b/tests/sanity/tests/recruiting/reviews.spec.ts index 642aa07f85..3427524f83 100644 --- a/tests/sanity/tests/recruiting/reviews.spec.ts +++ b/tests/sanity/tests/recruiting/reviews.spec.ts @@ -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() }) diff --git a/tests/sanity/tests/recruiting/skills.spec.ts b/tests/sanity/tests/recruiting/skills.spec.ts index c53abc0050..61fb43773f 100644 --- a/tests/sanity/tests/recruiting/skills.spec.ts +++ b/tests/sanity/tests/recruiting/skills.spec.ts @@ -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() }) diff --git a/tests/sanity/tests/recruiting/talents.spec.ts b/tests/sanity/tests/recruiting/talents.spec.ts index 7d42b8f2a8..8cb164c78f 100644 --- a/tests/sanity/tests/recruiting/talents.spec.ts +++ b/tests/sanity/tests/recruiting/talents.spec.ts @@ -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() diff --git a/tests/sanity/tests/recruiting/vacancies.spec.ts b/tests/sanity/tests/recruiting/vacancies.spec.ts index e53f0b8c23..8f06f7e72b 100644 --- a/tests/sanity/tests/recruiting/vacancies.spec.ts +++ b/tests/sanity/tests/recruiting/vacancies.spec.ts @@ -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() })