From 1fe85ceba82bf2ffd21baf422729f12280900d38 Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Mon, 27 Nov 2023 12:14:42 +0300 Subject: [PATCH] TESTS-56: feat(tests): done Create a Template test (#4063) Signed-off-by: Alex Velichko --- .../model/tracker/template-details-page.ts | 49 +++++++++++ .../tests/model/tracker/templates-page.ts | 85 +++++++++++++++++++ .../tracker/tracker-navigation-menu-page.ts | 2 + tests/sanity/tests/tracker/template.spec.ts | 49 +++++++++++ 4 files changed, 185 insertions(+) create mode 100644 tests/sanity/tests/model/tracker/template-details-page.ts create mode 100644 tests/sanity/tests/model/tracker/templates-page.ts create mode 100644 tests/sanity/tests/tracker/template.spec.ts diff --git a/tests/sanity/tests/model/tracker/template-details-page.ts b/tests/sanity/tests/model/tracker/template-details-page.ts new file mode 100644 index 0000000000..c056d53cf7 --- /dev/null +++ b/tests/sanity/tests/model/tracker/template-details-page.ts @@ -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 { + 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) + } + } +} diff --git a/tests/sanity/tests/model/tracker/templates-page.ts b/tests/sanity/tests/model/tracker/templates-page.ts new file mode 100644 index 0000000000..8327472633 --- /dev/null +++ b/tests/sanity/tests/model/tracker/templates-page.ts @@ -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 { + 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 { + await this.page.locator('span.issuePresenterRoot > span', { hasText: templateName }).click() + } +} diff --git a/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts b/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts index 4b72642ca9..91e92226fb 100644 --- a/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts +++ b/tests/sanity/tests/model/tracker/tracker-navigation-menu-page.ts @@ -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"]') } } diff --git a/tests/sanity/tests/tracker/template.spec.ts b/tests/sanity/tests/tracker/template.spec.ts new file mode 100644 index 0000000000..f5535ca53e --- /dev/null +++ b/tests/sanity/tests/tracker/template.spec.ts @@ -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' + }) + }) +})