mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
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:
parent
2ba02fa195
commit
d02e88737d
BIN
tests/sanity/tests/files/cat2.jpeg
Normal file
BIN
tests/sanity/tests/files/cat2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
tests/sanity/tests/files/cat3.jpeg
Normal file
BIN
tests/sanity/tests/files/cat3.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
69
tests/sanity/tests/tracker/attachments.spec.ts
Normal file
69
tests/sanity/tests/tracker/attachments.spec.ts
Normal 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')
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user