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-23: feat(tests): done Export vacancies tests #4253

Merged
merged 2 commits into from
Dec 24, 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
30 changes: 30 additions & 0 deletions tests/sanity/tests/model/recruiting/vacancies-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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> {
Expand Down Expand Up @@ -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)
})
}
}
9 changes: 9 additions & 0 deletions tests/sanity/tests/recruiting/vacancies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})