mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +03:00
TESTS-23: feat(tests): done Export vacancies tests (#4253)
This commit is contained in:
parent
5bbfa26dd1
commit
b8464be5bf
@ -11,6 +11,7 @@ export class VacanciesPage extends CommonRecruitingPage {
|
||||
readonly inputCreateVacancyDescription: Locator
|
||||
readonly buttonCreateVacancyLocation: Locator
|
||||
readonly buttonCreateVacancy: Locator
|
||||
readonly buttonExport: Locator
|
||||
|
||||
constructor (page: Page) {
|
||||
super(page)
|
||||
@ -24,6 +25,7 @@ export class VacanciesPage extends CommonRecruitingPage {
|
||||
hasText: 'Location'
|
||||
})
|
||||
this.buttonCreateVacancy = page.locator('form[id="recruit:string:CreateVacancy"] button[type="submit"]')
|
||||
this.buttonExport = page.locator('button[type="button"] > span', { hasText: 'Export' })
|
||||
}
|
||||
|
||||
async createNewVacancy ({ title, description, location }: NewVacancy): Promise<void> {
|
||||
@ -65,4 +67,32 @@ export class VacanciesPage extends CommonRecruitingPage {
|
||||
async checkVacancyExist (vacancyName: string, message: string): Promise<void> {
|
||||
await expect(this.page.locator('tr', { hasText: vacancyName }), message).toHaveCount(1)
|
||||
}
|
||||
|
||||
async selectAll (): Promise<void> {
|
||||
const count = await this.page.locator('tr[class*="row"]').count()
|
||||
for (let i = 0; i < count; i++) {
|
||||
await this.page.locator('tr[class*="row"] td:first-child > div').nth(i).click()
|
||||
}
|
||||
}
|
||||
|
||||
async exportVacanciesWithCheck (textToCheck: string): Promise<void> {
|
||||
const downloadPromise = this.page.waitForEvent('download')
|
||||
await this.buttonExport.click()
|
||||
const download = await downloadPromise
|
||||
|
||||
const chunks: string[] = []
|
||||
const readable = await download.createReadStream()
|
||||
|
||||
readable.on('readable', () => {
|
||||
let chunk
|
||||
while ((chunk = readable.read()) !== null) {
|
||||
chunks.push(chunk)
|
||||
}
|
||||
})
|
||||
|
||||
readable.on('end', () => {
|
||||
const content = chunks.join('')
|
||||
expect(content).toContain(textToCheck)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -141,4 +141,13 @@ test.describe('Vacancy tests', () => {
|
||||
`Archieved vacancy "${vacancyName}" not visible when hide archved back on.`
|
||||
)
|
||||
})
|
||||
|
||||
test('Export vacancies', async ({ page }) => {
|
||||
const navigationMenuPage = new NavigationMenuPage(page)
|
||||
await navigationMenuPage.buttonVacancies.click()
|
||||
|
||||
const vacanciesPage = new VacanciesPage(page)
|
||||
await vacanciesPage.selectAll()
|
||||
await vacanciesPage.exportVacanciesWithCheck('Software Engineer')
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user