Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TESTS-18: feat(tests): added edit vacancy test #3901

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class CommonRecruitingPage extends CommonPage {
constructor (page: Page) {
super()
this.page = page
this.inputComment = page.locator('div.tiptap')
this.inputComment = page.locator('div.text-input div.tiptap')
this.buttonSendComment = page.locator('g#Send')
this.textComment = page.locator('div.msgactivity-container p')
this.inputAddAttachment = page.locator('div.antiSection #file')
Expand Down
2 changes: 2 additions & 0 deletions tests/sanity/tests/model/recruiting/navigation-menu-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export class NavigationMenuPage {
readonly buttonApplications: Locator
readonly buttonMyApplications: Locator
readonly buttonTalents: Locator
readonly buttonVacancies: Locator

constructor (page: Page) {
this.page = page
this.buttonApplications = page.locator('a[href$="candidates"]', { hasText: 'Applications' })
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' })
}
}
2 changes: 0 additions & 2 deletions tests/sanity/tests/model/recruiting/talents-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ export class TalentsPage extends CommonRecruitingPage {
readonly page: Page
readonly pageHeader: Locator
readonly buttonCreateTalent: Locator
readonly textTableFirstCell: Locator

constructor (page: Page) {
super(page)
this.page = page
this.pageHeader = page.locator('span[class*="header"]', { hasText: 'Talents' })
this.buttonCreateTalent = page.locator('div[class*="ac-header"] button > span', { hasText: 'Talent' })
this.textTableFirstCell = page.locator('div[class$="firstCell"]')
}

async createNewTalent (): Promise<TalentName> {
Expand Down
6 changes: 6 additions & 0 deletions tests/sanity/tests/model/recruiting/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ export interface MergeContacts {
mergeSource: boolean
source: string
}

export interface NewVacancy {
title: string
description: string
location?: string
}
49 changes: 49 additions & 0 deletions tests/sanity/tests/model/recruiting/vacancies-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { NewVacancy } from './types'
import { CommonRecruitingPage } from './common-recruiting-page'

export class VacanciesPage extends CommonRecruitingPage {
readonly page: Page
readonly pageHeader: Locator
readonly buttonCreateNewVacancy: Locator
readonly textTableFirstCell: Locator
readonly inputCreateVacancyTitle: Locator
readonly inputCreateVacancyDescription: Locator
readonly buttonCreateVacancyLocation: Locator
readonly buttonCreateVacancy: Locator

constructor (page: Page) {
super(page)
this.page = page
this.pageHeader = page.locator('span[class*="header"]', { hasText: 'Vacancies' })
this.buttonCreateNewVacancy = page.locator('button > span', { hasText: 'Vacancy' })
this.textTableFirstCell = page.locator('div[class$="firstCell"]')
this.inputCreateVacancyTitle = page.locator('form[id="recruit:string:CreateVacancy"] input[type="text"]')
this.inputCreateVacancyDescription = page.locator('form[id="recruit:string:CreateVacancy"] div.text-editor-view')
this.buttonCreateVacancyLocation = page.locator('form[id="recruit:string:CreateVacancy"] button span', {
hasText: 'Location'
})
this.buttonCreateVacancy = page.locator('form[id="recruit:string:CreateVacancy"] button[type="submit"]')
}

async createNewVacancy ({ title, description, location }: NewVacancy): Promise<void> {
await this.buttonCreateNewVacancy.click()

await this.inputCreateVacancyTitle.fill(title)
await this.inputCreateVacancyDescription.fill(description)
if (location != null) {
await this.buttonCreateVacancyLocation.click()
await this.fillToSelectPopup(this.page, location)
}

await this.buttonCreateVacancy.click()
}

async openVacancyByName (vacancyName: string): Promise<void> {
await this.page.locator('tr', { hasText: vacancyName }).locator('div[class$="firstCell"]').click()
}

async checkVacancyNotExist (vacancyName: string): Promise<void> {
await expect(this.page.locator('tr', { hasText: vacancyName })).toHaveCount(0)
}
}
60 changes: 60 additions & 0 deletions tests/sanity/tests/model/recruiting/vacancy-details-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { CommonRecruitingPage } from './common-recruiting-page'
import path from 'path'

export class VacancyDetailsPage extends CommonRecruitingPage {
readonly page: Page
readonly inputDescription: Locator
readonly buttonInputDescription: Locator
readonly buttonInputLocation: Locator
readonly inputAttachFile: Locator
readonly buttonInputCompany: Locator
readonly buttonInputDueDate: Locator
readonly buttonDatePopupToday: Locator
readonly buttonDatePopupSave: Locator
readonly inputComment: Locator

constructor (page: Page) {
super(page)
this.page = page
this.inputDescription = page.locator('div[class*="full"] div.tiptap')
this.buttonInputDescription = page.locator('button > span', { hasText: 'Description' })
this.buttonInputLocation = page.locator('button > span', { hasText: 'Location' })
this.inputAttachFile = page.locator('div[class*="full"] input[name="file"]')
this.buttonInputCompany = page.locator('button > div', { hasText: 'Company' })
this.buttonInputDueDate = page.locator('button > div', { hasText: 'Due date' })
this.buttonDatePopupToday = page.locator('div.popup div.today')
this.buttonDatePopupSave = page.locator('div.popup button[type="submit"]')
this.inputComment = page.locator('div.text-input div.tiptap')
}

async addComment (comment: string): Promise<void> {
await this.inputComment.fill(comment)
await this.buttonSendComment.click()
}

async addAttachments (filePath: string): Promise<void> {
await this.inputAttachFile.setInputFiles(path.join(__dirname, `../../files/${filePath}`))
await expect(await this.textAttachmentName.filter({ hasText: filePath })).toBeVisible()
}

async addDescription (description: string): Promise<void> {
await this.buttonInputDescription.click()
await this.fillToSelectPopup(this.page, description)
}

async addLocation (location: string): Promise<void> {
await this.buttonInputLocation.click()
await this.fillToSelectPopup(this.page, location)
}

async addCompany (company: string): Promise<void> {
await this.buttonInputCompany.click()
await this.selectMenuItem(this.page, company)
}

async addDueDateToday (): Promise<void> {
await this.buttonInputDueDate.click()
await this.buttonDatePopupToday.click()
}
}
34 changes: 33 additions & 1 deletion tests/sanity/tests/recruiting/vacancies.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { expect, test } from '@playwright/test'
import { generateId, PlatformSetting, PlatformURI } from '../utils'
import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page'
import { VacanciesPage } from '../model/recruiting/vacancies-page'
import { VacancyDetailsPage } from '../model/recruiting/vacancy-details-page'

test.use({
storageState: PlatformSetting
Expand Down Expand Up @@ -52,7 +55,7 @@ test.describe('recruit tests', () => {
})

// test('application-search', async ({ page }) => {
// TODO: Application search is brokeb, since indexer now index from child to parent.
// TODO: Application search is broken, since indexer now index from child to parent.
// await page.locator('[id="app-recruit\\:string\\:RecruitApplication"]').click()

// await page.locator('text=Vacancies').click()
Expand All @@ -73,4 +76,33 @@ test.describe('recruit tests', () => {
// await expect(page.locator('text=M. Marina')).toBeVisible()
// expect(await page.locator('.antiTable-body__row').count()).toBeGreaterThan(2)
// })

test('Edit a Vacancy', async ({ page }) => {
const vacancyName = 'Edit Vacancy ' + generateId(4)

const navigationMenuPage = new NavigationMenuPage(page)
await navigationMenuPage.buttonVacancies.click()
const vacanciesPage = new VacanciesPage(page)
await vacanciesPage.createNewVacancy({
title: vacancyName,
description: 'Vacancy description from Edit a Vacancy test',
location: 'Edit a Vacancy location'
})

await vacanciesPage.openVacancyByName(vacancyName)

const vacancyDetailsPage = new VacancyDetailsPage(page)
await vacancyDetailsPage.addComment('Test Vacancy Comment 12345')
await vacancyDetailsPage.checkCommentExist('Test Vacancy Comment 12345')

await vacancyDetailsPage.inputDescription.fill('Edit a Vacancy description')
await expect(vacancyDetailsPage.inputDescription).toHaveText('Edit a Vacancy description')

await vacancyDetailsPage.addAttachments('cat.jpeg')

await vacancyDetailsPage.addDescription('Vacancy Description left-side menu')
await vacancyDetailsPage.addLocation('Edit Vacancy Location')
await vacancyDetailsPage.addCompany('Apple')
await vacancyDetailsPage.addDueDateToday()
})
})