TESTS-25: feat(tests): done Edit project tests (#4138)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2023-12-06 06:21:49 +03:00 committed by GitHub
parent 8db7bc4475
commit 1122db7a49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 213 additions and 2 deletions

View File

@ -0,0 +1,132 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { CommonTrackerPage } from './common-tracker-page'
import { NewProject } from './types'
export class EditProjectPage extends CommonTrackerPage {
readonly page: Page
readonly popupHeader: Locator
readonly inputTitle: Locator
readonly inputIdentifier: Locator
readonly inputDescription: Locator
readonly buttonChooseIcon: Locator
readonly buttonMakePrivate: Locator
readonly buttonSaveProject: Locator
readonly buttonEditIdentifier: Locator
readonly inputEditProjectIdentifier: Locator
readonly buttonEditProjectIdentifier: Locator
readonly buttonIcons: Locator
readonly buttonSaveIcons: Locator
constructor (page: Page) {
super(page)
this.page = page
this.popupHeader = page.locator('form[id="tracker:string:EditProject"] div[class*="title"]:last-child', {
hasText: 'Edit project'
})
this.inputTitle = page.locator('input[placeholder="New project"]')
this.inputIdentifier = page.locator('input[placeholder="PRJCT"]')
this.inputDescription = page.locator('form[id="tracker:string:EditProject"] div.tiptap')
this.buttonChooseIcon = page.locator('div.antiGrid-row button.only-icon')
this.buttonMakePrivate = page.locator('div.antiGrid-row span.toggle-switch')
this.buttonSaveProject = page.locator('form[id="tracker:string:EditProject"] button[type="submit"]')
this.buttonEditIdentifier = page.locator('form[id="tracker:string:EditProject"] div.relative button.small')
this.inputEditProjectIdentifier = page.locator('form[id="tracker:string:ProjectIdentifier"] input')
this.buttonEditProjectIdentifier = page.locator('form[id="tracker:string:ProjectIdentifier"] button[type="submit"]')
this.buttonIcons = page.locator('form[id="view:string:ChooseIcon"] div.float-left > button')
this.buttonSaveIcons = page.locator('form[id="view:string:ChooseIcon"] div[class*="footer"] button[type="submit"]')
}
async checkProject (data: NewProject): Promise<void> {
await expect(this.popupHeader).toBeVisible()
if (data.type != null) {
await expect(
this.page
.locator('div[class*="header"]', { hasText: 'Project type' })
.locator('xpath=..')
.locator('button > span[class*="label"]')
).toContainText(data.type)
}
if (data.title != null) {
await expect(this.inputTitle).toHaveValue(data.title)
}
if (data.identifier != null) {
await expect(this.inputIdentifier).toHaveValue(data.identifier)
}
if (data.description != null) {
await expect(this.inputDescription).toContainText(data.description)
}
if (data.defaultAssigneeForIssues != null) {
await expect(
this.page
.locator('div[class*="header"]', { hasText: 'Default assignee for issues' })
.locator('xpath=..')
.locator('button > span[class*="label"]')
).toContainText(data.defaultAssigneeForIssues)
}
if (data.defaultIssueStatus != null) {
await expect(
this.page
.locator('div[class*="header"]', { hasText: 'Default issue status' })
.locator('xpath=..')
.locator('button > span[class*="label"]')
).toContainText(data.defaultIssueStatus)
}
}
async updateProject (data: NewProject): Promise<void> {
await expect(this.popupHeader).toBeVisible()
if (data.type != null) {
await this.page
.locator('div[class*="header"]', { hasText: 'Project type' })
.locator('xpath=..')
.locator('button')
.click()
await this.selectMenuItem(this.page, data.type)
}
if (data.title != null) {
await this.inputTitle.fill(data.title)
}
if (data.identifier != null) {
await this.buttonEditIdentifier.click()
await this.inputEditProjectIdentifier.fill(data.identifier)
await this.buttonEditProjectIdentifier.click()
}
if (data.description != null) {
await this.inputDescription.fill(data.description)
}
if (data.iconNumber != null) {
await this.page
.locator('div[class*="header"]', { hasText: 'Choose icon' })
.locator('xpath=..')
.locator('button')
.click()
await this.buttonIcons.nth(data.iconNumber).click()
await this.buttonSaveIcons.click()
}
if (data.private != null && data.private) {
await this.buttonMakePrivate.click()
}
if (data.defaultAssigneeForIssues != null) {
await this.page
.locator('div[class*="header"]', { hasText: 'Default assignee for issues' })
.locator('xpath=..')
.locator('button')
.click()
await this.selectMenuItem(this.page, data.defaultAssigneeForIssues)
}
if (data.defaultIssueStatus != null) {
await this.page
.locator('div[class*="header"]', { hasText: 'Default issue status' })
.locator('xpath=..')
.locator('button')
.click()
await this.selectFromDropdown(this.page, data.defaultIssueStatus)
}
await this.buttonSaveProject.click()
}
}

View File

@ -1,12 +1,14 @@
import { expect, type Locator, type Page } from '@playwright/test'
import { CommonPage } from '../common-page'
export class TrackerNavigationMenuPage {
export class TrackerNavigationMenuPage extends CommonPage {
readonly page: Page
readonly buttonIssues: Locator
readonly buttonCreateProject: Locator
readonly buttonProjectsParent: Locator
constructor (page: Page) {
super()
this.page = page
this.buttonIssues = page.locator('a span', { hasText: 'Issues' })
this.buttonCreateProject = page.locator('div#tree-projects').locator('xpath=..')
@ -37,4 +39,14 @@ export class TrackerNavigationMenuPage {
async openIssuesForProject (projectName: string): Promise<void> {
await this.page.locator(`a[href$="issues"][href*="${projectName}"]`).click()
}
async openProjectToEdit (projectName: string): Promise<void> {
await this.buttonProjectsParent.filter({ hasText: projectName }).hover()
await this.buttonProjectsParent
.filter({ hasText: projectName })
.locator('xpath=..')
.locator('div[class*="tool"]:not([class*="arrow"])')
.click()
await this.selectFromDropdown(this.page, 'Edit project')
}
}

View File

@ -23,6 +23,6 @@ export interface NewProject {
private: boolean
defaultAssigneeForIssues: string
defaultIssueStatus: string
icon?: string
iconNumber?: number
type?: string
}

View File

@ -204,4 +204,34 @@ test.describe('Tracker filters tests', () => {
await issuesPage.checkFilteredIssueExist(newIssue.title)
})
})
test('Status filter', async ({ page }) => {
const newIssue: NewIssue = {
title: `Issue for the Created filter-${generateId()}`,
description: 'Issue for the Created filter',
status: 'In Progress',
priority: 'Urgent',
assignee: 'Appleseed John',
createLabel: true,
component: 'No component',
estimation: '2',
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 test.step('Check Filter Today', async () => {
await issuesPage.selectFilter('Created date', 'Today')
await issuesPage.checkFilter('Created date', 'Today')
await issuesPage.checkFilteredIssueExist(newIssue.title)
})
})
})

View File

@ -4,6 +4,7 @@ import { allure } from 'allure-playwright'
import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page'
import { NewProjectPage } from '../model/tracker/new-project-page'
import { NewProject } from '../model/tracker/types'
import { EditProjectPage } from '../model/tracker/edit-project-page'
test.use({
storageState: PlatformSetting
@ -35,4 +36,40 @@ test.describe('Tracker Projects tests', () => {
await trackerNavigationMenuPage.openProject(newProjectData.title)
})
test('Edit project', async ({ page }) => {
const editProjectData: NewProject = {
title: 'EditProject',
identifier: 'EDIT',
description: 'Edit Project description',
private: true,
defaultAssigneeForIssues: 'Dirak Kainin',
defaultIssueStatus: 'In Progress'
}
const updateProjectData: NewProject = {
title: 'UpdateProject',
identifier: 'UPDAT',
description: 'Updated Project description',
private: true,
defaultAssigneeForIssues: 'Chen Rosamund',
defaultIssueStatus: 'Done'
}
const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page)
await trackerNavigationMenuPage.checkProjectNotExist(editProjectData.title)
await trackerNavigationMenuPage.pressCreateProjectButton()
const newProjectPage = new NewProjectPage(page)
await newProjectPage.createNewProject(editProjectData)
await trackerNavigationMenuPage.checkProjectExist(editProjectData.title)
await trackerNavigationMenuPage.openProjectToEdit(editProjectData.title)
const editProjectPage = new EditProjectPage(page)
await editProjectPage.checkProject(editProjectData)
await editProjectPage.updateProject(updateProjectData)
await trackerNavigationMenuPage.openProjectToEdit(updateProjectData.title)
await editProjectPage.checkProject(updateProjectData)
})
})