From 3b67b0e7e7ec09a98f73d36b3cf546474da6605d Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Thu, 14 Dec 2023 19:36:50 +0300 Subject: [PATCH] TESTS-42: feat(tests): done Edit Sub-Issue test (#4191) Signed-off-by: Alex Velichko --- .../model/tracker/issues-details-page.ts | 6 + .../sanity/tests/model/tracker/issues-page.ts | 6 +- tests/sanity/tests/tracker/subissues.spec.ts | 105 ++++++++++++++++++ tests/sanity/tests/tracker/tracker.spec.ts | 33 ------ 4 files changed, 115 insertions(+), 35 deletions(-) create mode 100644 tests/sanity/tests/tracker/subissues.spec.ts diff --git a/tests/sanity/tests/model/tracker/issues-details-page.ts b/tests/sanity/tests/model/tracker/issues-details-page.ts index d08e5238fb..27a16066b9 100644 --- a/tests/sanity/tests/model/tracker/issues-details-page.ts +++ b/tests/sanity/tests/model/tracker/issues-details-page.ts @@ -19,6 +19,7 @@ export class IssuesDetailsPage extends CommonTrackerPage { readonly buttonCloseIssue: Locator readonly buttonMoreActions: Locator readonly textParentTitle: Locator + readonly buttonAddSubIssue: Locator constructor (page: Page) { super(page) @@ -38,6 +39,7 @@ export class IssuesDetailsPage extends CommonTrackerPage { this.buttonCloseIssue = page.locator('div.popupPanel-title > button') this.buttonMoreActions = page.locator('div.popupPanel-title div.flex-row-center > button:first-child') this.textParentTitle = page.locator('span.issue-title') + this.buttonAddSubIssue = page.locator('#add-sub-issue') } async editIssue (data: Issue): Promise { @@ -109,4 +111,8 @@ export class IssuesDetailsPage extends CommonTrackerPage { await this.buttonMoreActions.click() await this.selectFromDropdown(this.page, action) } + + async waitDetailsOpened (issueTitle: string): Promise { + await this.page.waitForSelector(`div[class*="main"] div:has-text("${issueTitle}")`) + } } diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index 268c8e0d58..e4f6000bdf 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -72,7 +72,11 @@ export class IssuesPage extends CommonTrackerPage { async createNewIssue (data: NewIssue): Promise { await this.buttonCreateNewIssue.click() + await this.fillNewIssueForm(data) + await this.buttonCreateIssue.click() + } + async fillNewIssueForm (data: NewIssue): Promise { await this.inputPopupCreateNewIssueTitle.fill(data.title) await this.inputPopupCreateNewIssueDescription.fill(data.description) if (data.status != null) { @@ -124,8 +128,6 @@ export class IssuesPage extends CommonTrackerPage { await this.buttonPopupCreateNewIssueParent.click() await this.selectMenuItem(this.page, data.parentIssue, true) } - - await this.buttonCreateIssue.click() } async searchIssueByName (issueName: string): Promise { diff --git a/tests/sanity/tests/tracker/subissues.spec.ts b/tests/sanity/tests/tracker/subissues.spec.ts new file mode 100644 index 0000000000..4b104a2ea7 --- /dev/null +++ b/tests/sanity/tests/tracker/subissues.spec.ts @@ -0,0 +1,105 @@ +import { test } from '@playwright/test' +import { allure } from 'allure-playwright' +import { IssuesPage } from '../model/tracker/issues-page' +import { generateId, PlatformSetting, PlatformURI } from '../utils' +import { + checkIssue, + checkIssueDraft, + createIssue, + DEFAULT_STATUSES, + DEFAULT_USER, + fillIssueForm, + navigate +} from './tracker.utils' +import { Issue, NewIssue } from '../model/tracker/types' +import { LeftSideMenuPage } from '../model/left-side-menu-page' +import { IssuesDetailsPage } from '../model/tracker/issues-details-page' + +test.use({ + storageState: PlatformSetting +}) +test.describe('Tracker sub-issues tests', () => { + test.beforeEach(async ({ page }) => { + await allure.parentSuite('Tracker tests') + await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() + }) + + test('create sub-issue', async ({ page }) => { + await navigate(page) + + const props = { + name: `issue-${generateId(5)}`, + description: 'description', + status: DEFAULT_STATUSES[1], + priority: 'Urgent', + assignee: DEFAULT_USER + } + await navigate(page) + await createIssue(page, props) + await page.click('text="Issues"') + + const issuesPage = new IssuesPage(page) + await issuesPage.modelSelectorAll.click() + await issuesPage.searchIssueByName(props.name) + await issuesPage.openIssueByName(props.name) + + await checkIssue(page, props) + props.name = `sub${props.name}` + await page.click('button:has-text("Add sub-issue")') + await fillIssueForm(page, props) + await page.keyboard.press('Escape') + await page.keyboard.press('Escape') + + await page.locator('#new-issue').click() + await checkIssueDraft(page, props) + }) + + test('Edit a sub-issue', async ({ page }) => { + const newIssue: NewIssue = { + title: `Issue for the sub-issue-${generateId()}`, + description: 'Description Issue for the sub-issue' + } + const newSubIssue: NewIssue = { + title: `New Sub-Issue with parameter-${generateId()}`, + description: 'New Description Sub-Issue with parameter' + } + const editSubIssue: Issue = { + status: 'In Progress', + priority: 'Urgent', + assignee: 'Appleseed John', + createLabel: true, + labels: `EDIT-SUB-ISSUE-${generateId()}`, + component: 'No component', + estimation: '8', + milestone: 'No Milestone', + duedate: 'today', + filePath: 'cat.jpeg' + } + + const leftSideMenuPage = new LeftSideMenuPage(page) + await leftSideMenuPage.buttonTracker.click() + + const issuesPage = new IssuesPage(page) + await issuesPage.modelSelectorAll.click() + await issuesPage.createNewIssue(newIssue) + await issuesPage.searchIssueByName(newIssue.title) + await issuesPage.openIssueByName(newIssue.title) + + const issuesDetailsPage = new IssuesDetailsPage(page) + await issuesDetailsPage.buttonAddSubIssue.click() + + await issuesPage.fillNewIssueForm(newSubIssue) + await issuesPage.buttonCreateIssue.click() + await issuesPage.openIssueByName(newSubIssue.title) + + await issuesDetailsPage.waitDetailsOpened(newSubIssue.title) + await issuesDetailsPage.editIssue(editSubIssue) + await issuesDetailsPage.checkIssue({ + ...newSubIssue, + ...editSubIssue, + milestone: 'Milestone', + estimation: '1d', + parentIssue: newIssue.title + }) + }) +}) diff --git a/tests/sanity/tests/tracker/tracker.spec.ts b/tests/sanity/tests/tracker/tracker.spec.ts index 93031d6cb4..9df4f32fd4 100644 --- a/tests/sanity/tests/tracker/tracker.spec.ts +++ b/tests/sanity/tests/tracker/tracker.spec.ts @@ -4,12 +4,9 @@ import { IssuesPage } from '../model/tracker/issues-page' import { PlatformSetting, fillSearch, generateId } from '../utils' import { DEFAULT_STATUSES, - DEFAULT_USER, ViewletSelectors, - checkIssue, checkIssueDraft, createIssue, - fillIssueForm, navigate, openIssue, toTime @@ -310,34 +307,4 @@ test.describe('Tracker tests', () => { dueDate: '24' }) }) - - test('sub-issue-draft', async ({ page }) => { - await navigate(page) - - const props = { - name: getIssueName(), - description: 'description', - status: DEFAULT_STATUSES[1], - priority: 'Urgent', - assignee: DEFAULT_USER - } - await navigate(page) - await createIssue(page, props) - await page.click('text="Issues"') - - const issuesPage = new IssuesPage(page) - await issuesPage.modelSelectorAll.click() - await issuesPage.searchIssueByName(props.name) - await issuesPage.openIssueByName(props.name) - - await checkIssue(page, props) - props.name = `sub${props.name}` - await page.click('button:has-text("Add sub-issue")') - await fillIssueForm(page, props) - await page.keyboard.press('Escape') - await page.keyboard.press('Escape') - - await page.locator('#new-issue').click() - await checkIssueDraft(page, props) - }) })