TESTS-23: feat(tests): done Export vacancies tests (#4253)

This commit is contained in:
Alex Velichko 2023-12-24 14:47:30 +03:00 committed by GitHub
parent 5bbfa26dd1
commit b8464be5bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -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)
})
}
}

View File

@ -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')
})
})