From d02e88737d5aaa1dcf2483c60ad4bb869ca88d7f Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Tue, 30 Jan 2024 11:07:36 +0300 Subject: [PATCH] TESTS-159: feat(tests): done Create issue with several attachment tests (#4464) Signed-off-by: Alex Velichko --- tests/sanity/tests/files/cat2.jpeg | Bin 0 -> 4408 bytes tests/sanity/tests/files/cat3.jpeg | Bin 0 -> 3649 bytes .../model/tracker/issues-details-page.ts | 4 + .../sanity/tests/model/tracker/issues-page.ts | 43 ++++++++++- .../sanity/tests/tracker/attachments.spec.ts | 69 ++++++++++++++++++ 5 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 tests/sanity/tests/files/cat2.jpeg create mode 100644 tests/sanity/tests/files/cat3.jpeg create mode 100644 tests/sanity/tests/tracker/attachments.spec.ts diff --git a/tests/sanity/tests/files/cat2.jpeg b/tests/sanity/tests/files/cat2.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..6899f24339e55988aede660a18fd8901c73adae5 GIT binary patch literal 4408 zcmZ8hcT^KjmrZEWq*p0|^cEnY{}7}FLMMPoR}iI0?^RSlq?eFLjdTzpf=D0;QRzqz zy@*2SpcJJCKEB=k_MF{2Gw-}}@65Y1^T)fKzWf1TGK9jQ03Z+m0A3Bi~yiBpD;Pee-Q|KW=GZ%#_;KZ(p$dbR#dU&YJM0A^|c7RX8tyaga*29h%a zFFOG|000>|@ZVSc56H*?KnhB#YgZzK2|z{$BqyVwpaN2m|JMc}88bNri=ey(rPc#~ z)?3dq!P>?3Uq*M?gy27^AbVGbxPgHGTkz@^D9FhuuOtEHD(%g#IW$YBm)J6DhB~iv%(^Y=y^8c+RY|t*Q5Xw6;Dy}9v+CrvVoUi46zgjTh zRY@%3&dmHBe+8B2BQO4;EY7+!^30nyOF==>;Qm_yt9vQ${1sfa{W}RM<`&{F9o`^} z3L@xb1Q14X(5hInL=TEg9m!`biC~IK7dBD zts()kk^FVa%Zr-0$_azt`~LwuuZu{S`}oZO@M4OdD+Jd81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=w?L_TYz&bdzew;bp)bH1u1a zbiz6_|L25Qt(>2wm_VHMR9J@_Mrf^;!dXsqq3*oEYoa1t6A@#K2IGI# zCK|XWjrP-(@3IUAvItz)?z^2kz_KgcdtB+C<<7VwMtbW@V38aRUV?gOw<)4}6R{lBt{W_NP&5OZQ$4WvLf2ocuf~6Ic9mD#L`gvGA zm>68ZS=kb*q?3`BmN8xV&l^=-u+X(t-gxTZ~e>Y=N+Z9`~@e; zwShUw4)C)nIL_B&EuPb!OtZD8*@N%OCRLNKlHcj+SmYoTLTV(ZL4F?q0&8d&O0XzxJeVe$7?-i-lOx zd{b-Wg#}x0+zz11MA>64IOF*4c%l8kAI)hiqE8_`=H9=qH9j&aI1#hTtxV$On$87n zd(3}Kz8Y~1;onQ2#L-5`_yx0LfZFv?>Pw39#$cRgo-X4O@|qBksr@!b{ZCwxWK(02ZPg0!+ z(yt`fS!#KD$2LDSyUrzDs!NT-= z=2k^otBw4efe4Lx8pCCvD*Hkc>@5anljt(>d>FMMQaG|=y8YRQAgn~~0Fqp?EZFAY zSuU}2hNO6EblvpRSi62Bx*lgQXV_SHAiua={+Ky)w13W-Ac4xfErFD8Bgt} zPzPqAw~uQQ!os(X{Qmsq>z<+dk>UAUxCi}V!*fAj=w(9O!DGQbH}j#s%@HvBK0%-( zu_WomJK;P%YE<98#M#;9X{O~#^(UO5Hz_}vfA|~Ut`g(hyVpd)5b%ldJ+oH { await this.page.locator('div.main div.listGrid a', { hasText: issueName }).click() } + + async checkIssueContainsAttachment (fileName: string): Promise { + await this.page.locator('div.attachment-grid div.name', { hasText: fileName }).click() + } } diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index 1d76c33422..e456750053 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -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 { @@ -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 { + await this.inputPopupCreateNewIssueFile.setInputFiles(path.join(__dirname, `../../files/${filePath}`)) + await expect(this.textPopupCreateNewIssueFile.filter({ hasText: filePath })).toBeVisible() + } + + async checkAttachmentsCount (issueName: string, count: string): Promise { + 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 { + 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 { + 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 { + await this.page.locator('div.row span', { hasText: issueName }).locator('xpath=..').locator('a > button').click() + await expect(this.textPopupAddAttachmentsFile.filter({ hasText: filePath })).toBeVisible() + } } diff --git a/tests/sanity/tests/tracker/attachments.spec.ts b/tests/sanity/tests/tracker/attachments.spec.ts new file mode 100644 index 0000000000..47700420e6 --- /dev/null +++ b/tests/sanity/tests/tracker/attachments.spec.ts @@ -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') + }) +})