TESTS-159: feat(tests): done Create issue with several attachment tests (#4464)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2024-01-30 11:07:36 +03:00 committed by GitHub
parent 2ba02fa195
commit d02e88737d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 114 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -122,4 +122,8 @@ export class IssuesDetailsPage extends CommonTrackerPage {
async openSubIssueByName (issueName: string): Promise<void> {
await this.page.locator('div.main div.listGrid a', { hasText: issueName }).click()
}
async checkIssueContainsAttachment (fileName: string): Promise<void> {
await this.page.locator('div.attachment-grid div.name', { hasText: fileName }).click()
}
}

View File

@ -30,6 +30,8 @@ export class IssuesPage extends CommonTrackerPage {
readonly issuesList: Locator
readonly buttonPopupCreateNewIssueParent: Locator
readonly buttonPopupCreateNewIssueTemplate: Locator
readonly inputPopupAddAttachmentsFile: Locator
readonly textPopupAddAttachmentsFile: Locator
constructor (page: Page) {
super(page)
@ -72,6 +74,8 @@ export class IssuesPage extends CommonTrackerPage {
this.buttonPopupCreateNewIssueTemplate = page.locator(
'form[id="tracker:string:NewIssue"] div[class*="title"] > div > button'
)
this.inputPopupAddAttachmentsFile = page.locator('div.popup-tooltip input#file')
this.textPopupAddAttachmentsFile = page.locator('div.popup-tooltip div.item div.name')
}
async createNewIssue (data: NewIssue, closeNotification: boolean = false): Promise<void> {
@ -128,8 +132,7 @@ export class IssuesPage extends CommonTrackerPage {
}
}
if (data.filePath != null) {
await this.inputPopupCreateNewIssueFile.setInputFiles(path.join(__dirname, `../../files/${data.filePath}`))
await expect(this.textPopupCreateNewIssueFile.filter({ hasText: data.filePath })).toBeVisible()
await this.attachFileToNewIssueForm(data.filePath)
}
if (data.parentIssue != null) {
await this.buttonPopupCreateNewIssueParent.click()
@ -204,4 +207,40 @@ export class IssuesPage extends CommonTrackerPage {
await this.buttonPopupCreateNewIssueTemplate.click()
await this.selectMenuItem(this.page, templateName)
}
async attachFileToNewIssueForm (filePath: string): Promise<void> {
await this.inputPopupCreateNewIssueFile.setInputFiles(path.join(__dirname, `../../files/${filePath}`))
await expect(this.textPopupCreateNewIssueFile.filter({ hasText: filePath })).toBeVisible()
}
async checkAttachmentsCount (issueName: string, count: string): Promise<void> {
await expect(
this.page
.locator('div.row span', { hasText: issueName })
.locator('xpath=..')
.locator('a > button > div[slot="content"]')
).toHaveText(count)
}
async addAttachmentToIssue (issueName: string, filePath: string): Promise<void> {
await this.page.locator('div.row span', { hasText: issueName }).locator('xpath=..').locator('a > button').click()
await this.inputPopupAddAttachmentsFile.setInputFiles(path.join(__dirname, `../../files/${filePath}`))
await expect(this.textPopupAddAttachmentsFile.filter({ hasText: filePath })).toBeVisible()
}
async deleteAttachmentToIssue (issueName: string, filePath: string): Promise<void> {
await this.page.locator('div.row span', { hasText: issueName }).locator('xpath=..').locator('a > button').click()
await this.page.locator(`div.popup-tooltip div.item div.name a[download="${filePath}"]`).hover()
await this.page
.locator(`div.popup-tooltip div.item div.name a[download="${filePath}"]`)
.locator('xpath=../..')
.locator('span.remove-link')
.click()
await expect(this.textPopupAddAttachmentsFile.filter({ hasText: filePath })).toBeVisible({ visible: false })
}
async checkAddAttachmentPopupContainsFile (issueName: string, filePath: string): Promise<void> {
await this.page.locator('div.row span', { hasText: issueName }).locator('xpath=..').locator('a > button').click()
await expect(this.textPopupAddAttachmentsFile.filter({ hasText: filePath })).toBeVisible()
}
}

View File

@ -0,0 +1,69 @@
import { test } from '@playwright/test'
import { allure } from 'allure-playwright'
import { IssuesPage } from '../model/tracker/issues-page'
import { generateId, PlatformSetting, PlatformURI } from '../utils'
import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page'
import { IssuesDetailsPage } from '../model/tracker/issues-details-page'
import { NewIssue } from '../model/tracker/types'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
test.use({
storageState: PlatformSetting
})
test.describe('Attachments tests', () => {
test.beforeEach(async ({ page }) => {
await allure.parentSuite('Attachments tests')
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished()
})
test('Create issue with several attachment test', async ({ page }) => {
const newIssue: NewIssue = {
title: `Create issue with several attachment tests-${generateId()}`,
description: 'Create issue with several attachment tests description'
}
const leftSideMenuPage = new LeftSideMenuPage(page)
await leftSideMenuPage.buttonTracker.click()
const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page)
await trackerNavigationMenuPage.openIssuesForProject('Default')
const issuesPage = new IssuesPage(page)
await issuesPage.modelSelectorAll.click()
await issuesPage.buttonCreateNewIssue.click()
await issuesPage.fillNewIssueForm(newIssue)
await issuesPage.attachFileToNewIssueForm('cat.jpeg')
await issuesPage.attachFileToNewIssueForm('cat2.jpeg')
await issuesPage.buttonCreateIssue.click()
await issuesPage.searchIssueByName(newIssue.title)
await issuesPage.checkAttachmentsCount(newIssue.title, '2')
await test.step('Add attachments in the popup', async () => {
await issuesPage.checkAddAttachmentPopupContainsFile(newIssue.title, 'cat.jpeg')
await issuesPage.checkAddAttachmentPopupContainsFile(newIssue.title, 'cat2.jpeg')
await issuesPage.addAttachmentToIssue(newIssue.title, 'cat3.jpeg')
await issuesPage.checkAddAttachmentPopupContainsFile(newIssue.title, 'cat.jpeg')
await issuesPage.checkAddAttachmentPopupContainsFile(newIssue.title, 'cat2.jpeg')
await issuesPage.checkAttachmentsCount(newIssue.title, '3')
})
await test.step('Delete attachments in the popup', async () => {
await issuesPage.deleteAttachmentToIssue(newIssue.title, 'cat2.jpeg')
await issuesPage.checkAddAttachmentPopupContainsFile(newIssue.title, 'cat.jpeg')
await issuesPage.checkAddAttachmentPopupContainsFile(newIssue.title, 'cat3.jpeg')
await issuesPage.checkAttachmentsCount(newIssue.title, '2')
})
await issuesPage.openIssueByName(newIssue.title)
const issuesDetailsPage = new IssuesDetailsPage(page)
await issuesDetailsPage.checkIssueContainsAttachment('cat.jpeg')
await issuesDetailsPage.checkIssueContainsAttachment('cat3.jpeg')
})
})