TESTS-56: feat(tests): done Create a Template test (#4063)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2023-11-27 12:14:42 +03:00 committed by GitHub
parent 6bf7469bcc
commit 1fe85ceba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,49 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { CommonTrackerPage } from './common-tracker-page'
import { NewIssue } from './types'
export class TemplateDetailsPage extends CommonTrackerPage {
readonly page: Page
readonly inputTitle: Locator
readonly inputDescription: Locator
readonly buttonPriority: Locator
readonly buttonAssignee: Locator
readonly buttonAddLabel: Locator
readonly textLabels: Locator
readonly buttonComponent: Locator
readonly textEstimation: 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.buttonPriority = page.locator('//span[text()="Priority"]/../button[1]//span')
this.buttonAssignee = page.locator('(//span[text()="Assignee"]/../div/button)[1]')
this.textLabels = page.locator('div.menu-group span')
this.buttonAddLabel = page.locator('//span[text()="Labels"]/../button[2]//span')
this.buttonComponent = page.locator('//span[text()="Component"]/../div/div/button')
this.textEstimation = page.locator('(//span[text()="Estimation"]/../div/button)[3]')
}
async checkTemplate (data: NewIssue): Promise<void> {
await expect(this.inputTitle).toHaveValue(data.title)
await expect(this.inputDescription).toHaveText(data.description)
if (data.priority != null) {
await expect(this.buttonPriority).toHaveText(data.priority)
}
if (data.assignee != null) {
await expect(this.buttonAssignee).toHaveText(data.assignee)
}
if (data.labels != null) {
await this.buttonAddLabel.click()
await expect(this.page.locator('div.menu-group span', { hasText: data.labels })).toBeVisible()
}
if (data.component != null) {
await expect(this.buttonComponent).toHaveText(data.component)
}
if (data.estimation != null) {
await expect(this.textEstimation).toHaveText(data.estimation)
}
}
}

View File

@ -0,0 +1,85 @@
import { type Locator, type Page } from '@playwright/test'
import { CommonTrackerPage } from './common-tracker-page'
import { NewIssue } from './types'
export class TemplatePage extends CommonTrackerPage {
readonly page: Page
readonly buttonNewTemplate: Locator
readonly inputIssueTitle: Locator
readonly inputIssueDescription: Locator
readonly buttonPopupCreateNewTemplatePriority: Locator
readonly buttonPopupCreateNewTemplateAssignee: Locator
readonly buttonPopupCreateNewTemplateLabels: Locator
readonly buttonPopupCreateNewTemplateEstimation: Locator
readonly buttonPopupCreateNewTemplateComponent: Locator
readonly buttonPopupCreateNewTemplateMilestone: Locator
readonly buttonSaveTemplate: Locator
constructor (page: Page) {
super(page)
this.page = page
this.buttonNewTemplate = page.locator('button > span', { hasText: 'Template' })
this.inputIssueTitle = page.locator('form[id$="NewProcess"] input')
this.inputIssueDescription = page.locator('form[id$="NewProcess"] div.tiptap')
this.buttonPopupCreateNewTemplatePriority = page.locator(
'form[id$="NewProcess"] div.antiCard-pool > button:first-child'
)
this.buttonPopupCreateNewTemplateAssignee = page.locator('form[id$="NewProcess"] div.antiCard-pool > div > button')
this.buttonPopupCreateNewTemplateLabels = page.locator(
'form[id$="NewProcess"] div.antiCard-pool > button:nth-child(3)'
)
this.buttonPopupCreateNewTemplateEstimation = page.locator(
'form[id$="NewProcess"] div.antiCard-pool > button:nth-child(4)'
)
this.buttonPopupCreateNewTemplateComponent = page.locator(
'form[id$="NewProcess"] div.antiCard-pool > button:nth-child(5)'
)
this.buttonPopupCreateNewTemplateMilestone = page.locator(
'form[id$="NewProcess"] div.antiCard-pool > button:nth-child(6)'
)
this.buttonSaveTemplate = page.locator('form[id$="NewProcess"] div[class*="footer"] button')
}
async createNewTemplate (data: NewIssue): Promise<void> {
await this.buttonNewTemplate.click()
await this.inputIssueTitle.fill(data.title)
await this.inputIssueDescription.fill(data.description)
if (data.priority != null) {
await this.buttonPopupCreateNewTemplatePriority.click()
await this.selectMenuItem(this.page, data.priority)
}
if (data.assignee != null) {
await this.buttonPopupCreateNewTemplateAssignee.click()
await this.selectAssignee(this.page, data.assignee)
}
if (data.labels != null && data.createLabel != null) {
await this.buttonPopupCreateNewTemplateLabels.click()
if (data.createLabel) {
await this.pressCreateButtonSelectPopup(this.page)
await this.addNewTagPopup(this.page, data.labels, 'Tag from templateNewIssue')
}
await this.checkFromDropdown(this.page, data.labels)
// await this.inputIssueTitle.click({ force: true })
await this.buttonPopupCreateNewTemplatePriority.click({ force: true })
}
if (data.estimation != null) {
await this.buttonPopupCreateNewTemplateEstimation.click()
await this.fillToSelectPopup(this.page, data.estimation)
}
if (data.component != null) {
await this.buttonPopupCreateNewTemplateComponent.click()
await this.selectMenuItem(this.page, data.component)
}
if (data.milestone != null) {
await this.buttonPopupCreateNewTemplateMilestone.click()
await this.selectMenuItem(this.page, data.milestone)
}
await this.buttonSaveTemplate.click()
}
async openTemplate (templateName: string): Promise<void> {
await this.page.locator('span.issuePresenterRoot > span', { hasText: templateName }).click()
}
}

View File

@ -3,9 +3,11 @@ import { type Locator, type Page } from '@playwright/test'
export class TrackerNavigationMenuPage {
readonly page: Page
readonly buttonIssues: Locator
readonly buttonTemplates: Locator
constructor (page: Page) {
this.page = page
this.buttonIssues = page.locator('a span', { hasText: 'Issues' })
this.buttonTemplates = page.locator('a[href$="templates"]')
}
}

View File

@ -0,0 +1,49 @@
import { test } from '@playwright/test'
import { generateId, PlatformSetting, PlatformURI } from '../utils'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
import { NewIssue } from '../model/tracker/types'
import { allure } from 'allure-playwright'
import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page'
import { TemplatePage } from '../model/tracker/templates-page'
import { TemplateDetailsPage } from '../model/tracker/template-details-page'
test.use({
storageState: PlatformSetting
})
test.describe('Tracker template tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Tracker tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished()
})
test('Create a Template', async ({ page }) => {
const newTemplate: NewIssue = {
title: `Template with all parameters-${generateId()}`,
description: 'Created template with all parameters',
priority: 'Urgent',
assignee: 'Dirak Kainin',
createLabel: true,
labels: `CREATE-TEMPLATE-${generateId()}`,
component: 'No component',
estimation: '2',
milestone: 'No Milestone'
}
const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.buttonTracker.click()
const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page)
await trackerNavigationMenuPage.buttonTemplates.click()
const templatePage = new TemplatePage(page)
await templatePage.createNewTemplate(newTemplate)
await templatePage.openTemplate(newTemplate.title)
const templateDetailsPage = new TemplateDetailsPage(page)
await templateDetailsPage.checkTemplate({
...newTemplate,
estimation: '2h'
})
})
})