diff --git a/tests/sanity/tests/model/common-page.ts b/tests/sanity/tests/model/common-page.ts index e0493ffe43..e419d9b578 100644 --- a/tests/sanity/tests/model/common-page.ts +++ b/tests/sanity/tests/model/common-page.ts @@ -29,4 +29,8 @@ export class CommonPage { await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] div.text-editor-view').fill(description) await page.locator('div.popup form[id="recruit:string:CreateReviewParams"] button[type="submit"]').click() } + + async pressYesDeletePopup (page: Page): Promise { + await page.locator('form[id="view:string:DeleteObject"] button.accented').click() + } } diff --git a/tests/sanity/tests/model/recruiting/applications-details-page.ts b/tests/sanity/tests/model/recruiting/applications-details-page.ts index 32f8e93cfc..1eddecc7e8 100644 --- a/tests/sanity/tests/model/recruiting/applications-details-page.ts +++ b/tests/sanity/tests/model/recruiting/applications-details-page.ts @@ -11,6 +11,9 @@ export class ApplicationsDetailsPage extends CommonPage { readonly textAttachmentName: Locator readonly buttonCreateFirstReview: Locator readonly buttonChangeStatusDone: Locator + readonly textApplicationId: Locator + readonly buttonMoreActions: Locator + readonly buttonDelete: Locator constructor (page: Page) { super() @@ -22,6 +25,9 @@ export class ApplicationsDetailsPage extends CommonPage { this.textAttachmentName = page.locator('div.name a') this.buttonCreateFirstReview = page.locator('span:has-text("Create review")') this.buttonChangeStatusDone = page.locator('div[class*="aside-grid"] > div:nth-of-type(2) > button') + this.textApplicationId = page.locator('div.popupPanel-title div.title-wrapper > span') + this.buttonMoreActions = page.locator('div.popupPanel-title div.buttons-group > button:nth-of-type(2)') + this.buttonDelete = page.locator('button[class*="menuItem"] span', { hasText: 'Delete' }) } async addComment (comment: string): Promise { @@ -34,7 +40,6 @@ export class ApplicationsDetailsPage extends CommonPage { } async addAttachments (filePath: string): Promise { - console.log(`__dirname: ${__dirname}`) await this.inputAddAttachment.setInputFiles(path.join(__dirname, `../../files/${filePath}`)) await expect(await this.textAttachmentName.filter({ hasText: filePath })).toBeVisible() } @@ -48,4 +53,16 @@ export class ApplicationsDetailsPage extends CommonPage { await this.buttonChangeStatusDone.click() await this.selectFromDropdown(this.page, status) } + + async getApplicationId (): Promise { + const applicationId = await this.textApplicationId.textContent() + expect(applicationId !== null).toBeTruthy() + return applicationId != null ? applicationId : '' + } + + async deleteApplication (): Promise { + await this.buttonMoreActions.click() + await this.buttonDelete.click() + await this.pressYesDeletePopup(this.page) + } } diff --git a/tests/sanity/tests/model/recruiting/applications-page.ts b/tests/sanity/tests/model/recruiting/applications-page.ts index 0fdc8d89d3..d4fff8f065 100644 --- a/tests/sanity/tests/model/recruiting/applications-page.ts +++ b/tests/sanity/tests/model/recruiting/applications-page.ts @@ -12,6 +12,7 @@ export class ApplicationsPage extends CommonPage { readonly buttonAssignedRecruiter: Locator readonly buttonCreateNewApplication: Locator readonly buttonTabCreated: Locator + readonly textTableFirstCell: Locator constructor (page: Page) { super() @@ -23,6 +24,7 @@ export class ApplicationsPage extends CommonPage { this.buttonAssignedRecruiter = page.locator('button div.label', { hasText: 'Assigned recruiter' }) this.buttonCreateNewApplication = page.locator('form[id="recruit:string:CreateApplication"] button[type="submit"]') this.buttonTabCreated = page.locator('div[data-id="tab-created"]') + this.textTableFirstCell = page.locator('div[class$="firstCell"]') } async createNewApplication (data: NewApplication): Promise { @@ -87,4 +89,8 @@ export class ApplicationsPage extends CommonPage { .nth(6) ).toHaveText(done) } + + async checkApplicationNotExist (applicationId: string): Promise { + await expect(await this.textTableFirstCell.filter({ hasText: applicationId })).toHaveCount(0) + } } diff --git a/tests/sanity/tests/recruiting/applications.spec.ts b/tests/sanity/tests/recruiting/applications.spec.ts index fc948a117e..e8e7a0d4bb 100644 --- a/tests/sanity/tests/recruiting/applications.spec.ts +++ b/tests/sanity/tests/recruiting/applications.spec.ts @@ -47,6 +47,7 @@ test.describe('Application tests', () => { await expect( await page.locator('[id="recruit:string:CreateApplication"] button:has-text("HR Interview")') ).toBeVisible() + // We need to be sure state is proper one, no other way to do it. await page.waitForTimeout(100) @@ -106,4 +107,25 @@ test.describe('Application tests', () => { await applicationsPage.buttonTabCreated.click() await applicationsPage.checkApplicationDoneStatus(talentName, 'Won') }) + + test('Delete an Application', async ({ page }) => { + const navigationMenuPage = new NavigationMenuPage(page) + await navigationMenuPage.buttonApplications.click() + + const applicationsPage = new ApplicationsPage(page) + const talentName = await applicationsPage.createNewApplicationWithNewTalent({ + vacancy: 'first', + recruiterName: 'first' + }) + await applicationsPage.openApplicationByTalentName(talentName) + + const applicationsDetailsPage = new ApplicationsDetailsPage(page) + const applicationId = await applicationsDetailsPage.getApplicationId() + + await applicationsDetailsPage.deleteApplication() + expect(page.url()).toContain(applicationId) + + await navigationMenuPage.buttonApplications.click() + await applicationsPage.checkApplicationNotExist(applicationId) + }) })