From 5b13c9be83b226b5536f44b45f02e823302ea423 Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Mon, 30 Oct 2023 22:42:09 +0300 Subject: [PATCH] feat(tests): TESTS-39 done edit issue test Signed-off-by: Alex Velichko --- tests/sanity/tests/model/calendar-page.ts | 13 ++++ tests/sanity/tests/model/common-page.ts | 4 +- .../recruiting/common-recruiting-page.ts | 6 +- .../model/recruiting/vacancy-details-page.ts | 2 - .../model/tracker/common-tracker-page.ts | 6 +- .../model/tracker/issues-details-page.ts | 74 ++++++++++++++----- .../sanity/tests/model/tracker/issues-page.ts | 2 - tests/sanity/tests/model/tracker/types.ts | 5 +- tests/sanity/tests/tracker/issues.spec.ts | 39 +++++++++- 9 files changed, 119 insertions(+), 32 deletions(-) create mode 100644 tests/sanity/tests/model/calendar-page.ts diff --git a/tests/sanity/tests/model/calendar-page.ts b/tests/sanity/tests/model/calendar-page.ts new file mode 100644 index 00000000000..3d0db97729f --- /dev/null +++ b/tests/sanity/tests/model/calendar-page.ts @@ -0,0 +1,13 @@ +import { Locator, Page } from '@playwright/test' +import { CommonPage } from './common-page' + +export class CalendarPage extends CommonPage { + readonly page: Page + readonly buttonDatePopupToday: Locator + + constructor (page: Page) { + super() + this.page = page + this.buttonDatePopupToday = page.locator('div.popup div.today:not(.wrongMonth)') + } +} diff --git a/tests/sanity/tests/model/common-page.ts b/tests/sanity/tests/model/common-page.ts index f732f76d30a..7c3fbc5f175 100644 --- a/tests/sanity/tests/model/common-page.ts +++ b/tests/sanity/tests/model/common-page.ts @@ -5,7 +5,7 @@ export class CommonPage { if (name !== 'first') { await page.locator('div.selectPopup input').fill(name.split(' ')[0]) } - await page.locator('div.selectPopup div.list-item:first-child').click() + await page.locator('div.selectPopup div.list-item:first-child').click({ delay: 500 }) } async pressCreateButtonSelectPopup (page: Page): Promise { @@ -50,6 +50,6 @@ export class CommonPage { if (name !== 'first') { await page.locator('div.selectPopup input').fill(name.split(' ')[0]) } - await page.locator('div.selectPopup div.list-item').click() + await page.locator('div.selectPopup div.list-item').click({ delay: 500 }) } } diff --git a/tests/sanity/tests/model/recruiting/common-recruiting-page.ts b/tests/sanity/tests/model/recruiting/common-recruiting-page.ts index c791374d22d..7705d24bdac 100644 --- a/tests/sanity/tests/model/recruiting/common-recruiting-page.ts +++ b/tests/sanity/tests/model/recruiting/common-recruiting-page.ts @@ -1,8 +1,8 @@ import { expect, Locator, Page } from '@playwright/test' -import { CommonPage } from '../common-page' import path from 'path' +import { CalendarPage } from '../calendar-page' -export class CommonRecruitingPage extends CommonPage { +export class CommonRecruitingPage extends CalendarPage { readonly page: Page readonly inputComment: Locator readonly buttonSendComment: Locator @@ -14,7 +14,7 @@ export class CommonRecruitingPage extends CommonPage { readonly buttonDelete: Locator constructor (page: Page) { - super() + super(page) this.page = page this.inputComment = page.locator('div.text-input div.tiptap') this.buttonSendComment = page.locator('g#Send') diff --git a/tests/sanity/tests/model/recruiting/vacancy-details-page.ts b/tests/sanity/tests/model/recruiting/vacancy-details-page.ts index d855f09c4e4..bf62ebec400 100644 --- a/tests/sanity/tests/model/recruiting/vacancy-details-page.ts +++ b/tests/sanity/tests/model/recruiting/vacancy-details-page.ts @@ -10,7 +10,6 @@ export class VacancyDetailsPage extends CommonRecruitingPage { readonly inputAttachFile: Locator readonly buttonInputCompany: Locator readonly buttonInputDueDate: Locator - readonly buttonDatePopupToday: Locator readonly buttonDatePopupSave: Locator readonly inputComment: Locator @@ -23,7 +22,6 @@ export class VacancyDetailsPage extends CommonRecruitingPage { 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:not(.wrongMonth)') this.buttonDatePopupSave = page.locator('div.popup button[type="submit"]') this.inputComment = page.locator('div.text-input div.tiptap') } diff --git a/tests/sanity/tests/model/tracker/common-tracker-page.ts b/tests/sanity/tests/model/tracker/common-tracker-page.ts index a1cf0e37bc4..ac3d8bdc2a6 100644 --- a/tests/sanity/tests/model/tracker/common-tracker-page.ts +++ b/tests/sanity/tests/model/tracker/common-tracker-page.ts @@ -1,11 +1,11 @@ import { Page } from '@playwright/test' -import { CommonPage } from '../common-page' +import { CalendarPage } from '../calendar-page' -export class CommonTrackerPage extends CommonPage { +export class CommonTrackerPage extends CalendarPage { readonly page: Page constructor (page: Page) { - super() + super(page) this.page = page } } diff --git a/tests/sanity/tests/model/tracker/issues-details-page.ts b/tests/sanity/tests/model/tracker/issues-details-page.ts index ed1d3c2374b..4ceb7031ec6 100644 --- a/tests/sanity/tests/model/tracker/issues-details-page.ts +++ b/tests/sanity/tests/model/tracker/issues-details-page.ts @@ -1,53 +1,93 @@ import { expect, type Locator, type Page } from '@playwright/test' import { CommonTrackerPage } from './common-tracker-page' -import { NewIssue } from './types' +import { Issue, NewIssue } from './types' export class IssuesDetailsPage extends CommonTrackerPage { readonly page: Page readonly inputTitle: Locator readonly inputDescription: Locator - readonly textStatus: Locator - readonly textPriority: Locator - readonly textAssignee: Locator + readonly buttonStatus: Locator + readonly buttonPriority: Locator + readonly buttonAssignee: Locator readonly textLabels: Locator - readonly textComponent: Locator - readonly textMilestone: Locator + readonly buttonAddLabel: Locator + readonly buttonComponent: Locator + readonly buttonMilestone: Locator readonly textEstimation: Locator + readonly buttonEstimation: Locator constructor (page: Page) { super(page) this.page = page this.inputTitle = page.locator('div.popupPanel-body input[type="text"]') this.inputDescription = page.locator('div.popupPanel-body div.textInput p') - this.textStatus = page.locator('//span[text()="Status"]/../button[1]//span') - this.textPriority = page.locator('//span[text()="Status"]/../button[2]//span') - this.textAssignee = page.locator('(//span[text()="Assignee"]/../div/button)[2]') + this.buttonStatus = page.locator('//span[text()="Status"]/../button[1]//span') + this.buttonPriority = page.locator('//span[text()="Priority"]/../button[2]//span') + this.buttonAssignee = page.locator('(//span[text()="Assignee"]/../div/button)[2]') this.textLabels = page.locator('div.step-container div.listitems-container') - this.textComponent = page.locator('(//span[text()="Component"]/../div/div/button)[2]') - this.textMilestone = page.locator('(//span[text()="Milestone"]/../div/div/button)[3]') + this.buttonAddLabel = page.locator('button.tag-button') + this.buttonComponent = page.locator('(//span[text()="Component"]/../div/div/button)[2]') + this.buttonMilestone = page.locator('(//span[text()="Milestone"]/../div/div/button)[3]') this.textEstimation = page.locator('(//span[text()="Estimation"]/../div/button)[4]') + this.buttonEstimation = page.locator('(//span[text()="Estimation"]/../div/button)[3]') } - async checkIssueDescription (data: NewIssue): Promise { + async editIssue (data: Issue): Promise { + if (data.status != null) { + await this.buttonStatus.click() + await this.selectFromDropdown(this.page, data.status) + } + if (data.priority != null) { + await this.buttonPriority.click() + await this.selectMenuItem(this.page, data.priority) + } + if (data.assignee != null) { + await this.buttonAssignee.click() + await this.selectAssignee(this.page, data.assignee) + } + if (data.labels != null && data.createLabel != null) { + if (data.createLabel) { + await this.buttonAddLabel.click() + await this.pressCreateButtonSelectPopup(this.page) + await this.addNewTagPopup(this.page, data.labels, 'Tag from editIssue') + } + await this.checkFromDropdown(this.page, data.labels) + await this.inputTitle.click({ force: true }) + } + if (data.component != null) { + await this.buttonComponent.click() + await this.selectMenuItem(this.page, data.component) + } + if (data.milestone != null) { + await this.buttonMilestone.click() + await this.selectMenuItem(this.page, data.milestone) + } + if (data.estimation != null) { + await this.buttonEstimation.click() + await this.fillToSelectPopup(this.page, data.estimation) + } + } + + async checkIssue (data: NewIssue): Promise { await expect(this.inputTitle).toHaveValue(data.title) await expect(this.inputDescription).toHaveText(data.description) if (data.status != null) { - await expect(this.textStatus).toHaveText(data.status) + await expect(this.buttonStatus).toHaveText(data.status) } if (data.priority != null) { - await expect(this.textPriority).toHaveText(data.priority) + await expect(this.buttonPriority).toHaveText(data.priority) } if (data.assignee != null) { - await expect(this.textAssignee).toHaveText(data.assignee) + await expect(this.buttonAssignee).toHaveText(data.assignee) } if (data.labels != null) { await expect(this.textLabels).toHaveText(data.labels) } if (data.component != null) { - await expect(this.textComponent).toHaveText(data.component) + await expect(this.buttonComponent).toHaveText(data.component) } if (data.milestone != null) { - await expect(this.textMilestone).toHaveText(data.milestone) + await expect(this.buttonMilestone).toHaveText(data.milestone) } if (data.estimation != null) { await expect(this.textEstimation).toHaveText(data.estimation) diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index 173d124fa75..00e3a24300c 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -17,7 +17,6 @@ export class IssuesPage extends CommonTrackerPage { readonly buttonPopupCreateNewIssueEstimation: Locator readonly buttonPopupCreateNewIssueMilestone: Locator readonly buttonPopupCreateNewIssueDuedate: Locator - readonly buttonDatePopupToday: Locator readonly inputPopupCreateNewIssueFile: Locator readonly textPopupCreateNewIssueFile: Locator readonly buttonCreateIssue: Locator @@ -50,7 +49,6 @@ export class IssuesPage extends CommonTrackerPage { 'form[id="tracker:string:NewIssue"] div#milestone-editor button' ) this.buttonPopupCreateNewIssueDuedate = page.locator('form[id="tracker:string:NewIssue"] div#duedate-editor button') - this.buttonDatePopupToday = page.locator('div.popup div.today:not(.wrongMonth)') this.inputPopupCreateNewIssueFile = page.locator('form[id="tracker:string:NewIssue"] input[type="file"]') this.textPopupCreateNewIssueFile = page.locator('div[class*="attachments"] > div[class*="attachment"]') this.buttonCreateIssue = page.locator('button > span', { hasText: 'Create issue' }) diff --git a/tests/sanity/tests/model/tracker/types.ts b/tests/sanity/tests/model/tracker/types.ts index d2c6f730fde..69816deedcf 100644 --- a/tests/sanity/tests/model/tracker/types.ts +++ b/tests/sanity/tests/model/tracker/types.ts @@ -1,6 +1,9 @@ -export interface NewIssue { +export interface NewIssue extends Issue { title: string description: string +} + +export interface Issue { status?: string priority?: string assignee?: string diff --git a/tests/sanity/tests/tracker/issues.spec.ts b/tests/sanity/tests/tracker/issues.spec.ts index 7b03a710235..97543c1167c 100644 --- a/tests/sanity/tests/tracker/issues.spec.ts +++ b/tests/sanity/tests/tracker/issues.spec.ts @@ -3,7 +3,7 @@ import { generateId, PlatformSetting, PlatformURI } from '../utils' import { LeftSideMenuPage } from '../model/left-side-menu-page' import { IssuesPage } from '../model/tracker/issues-page' import { IssuesDetailsPage } from '../model/tracker/issues-details-page' -import { NewIssue } from '../model/tracker/types' +import { Issue, NewIssue } from '../model/tracker/types' test.use({ storageState: PlatformSetting @@ -39,10 +39,45 @@ test.describe('tracker issue tests', () => { await issuesPage.openIssueByName(newIssue.title) const issuesDetailsPage = new IssuesDetailsPage(page) - await issuesDetailsPage.checkIssueDescription({ + await issuesDetailsPage.checkIssue({ ...newIssue, milestone: 'Milestone', estimation: '2h' }) }) + + test('Edit an issue', async ({ page }) => { + const newIssue: NewIssue = { + title: `Issue with all parameters and attachments-${generateId()}`, + description: 'Created issue with all parameters and attachments description' + } + + const editIssue: Issue = { + status: 'Done', + priority: 'High', + createLabel: true, + labels: `EDIT-ISSUE-${generateId()}`, + component: 'No component', + estimation: '8', + milestone: 'Milestone', + duedate: 'today' + } + + const leftSideMenuPage = new LeftSideMenuPage(page) + await leftSideMenuPage.buttonTracker.click() + + const issuesPage = new IssuesPage(page) + await issuesPage.createNewIssue(newIssue) + await issuesPage.searchIssueByName(newIssue.title) + await issuesPage.openIssueByName(newIssue.title) + + const issuesDetailsPage = new IssuesDetailsPage(page) + await issuesDetailsPage.editIssue(editIssue) + + await issuesDetailsPage.checkIssue({ + ...newIssue, + ...editIssue, + estimation: '1d' + }) + }) })