diff --git a/tests/sanity/tests/model/tracker/common-tracker-page.ts b/tests/sanity/tests/model/tracker/common-tracker-page.ts index 1d8a5831ea..4921ac8c66 100644 --- a/tests/sanity/tests/model/tracker/common-tracker-page.ts +++ b/tests/sanity/tests/model/tracker/common-tracker-page.ts @@ -146,7 +146,7 @@ export class CommonTrackerPage extends CalendarPage { } async checkActivityExist (activity: string): Promise { - await expect(this.textActivity.filter({ hasText: activity })).toBeVisible() + await expect(this.textActivity.filter({ hasText: activity }).first()).toBeVisible() } async fillMoveIssuesModal (newProjectName: string, keepOriginalAttributes: boolean = false): Promise { diff --git a/tests/sanity/tests/model/tracker/issue-comment-popup.ts b/tests/sanity/tests/model/tracker/issue-comment-popup.ts new file mode 100644 index 0000000000..1cc53bacac --- /dev/null +++ b/tests/sanity/tests/model/tracker/issue-comment-popup.ts @@ -0,0 +1,30 @@ +import { IssuesPage } from './issues-page' +import { type Locator, type Page, expect } from '@playwright/test' +import path from 'path' + +export class IssueCommentPopup extends IssuesPage { + readonly page: Page + readonly inputCommentText: Locator + readonly inputAttachFile: Locator + readonly textAttachFileName: Locator + readonly buttonSendComment: Locator + + constructor (page: Page) { + super(page) + this.page = page + this.inputCommentText = page.locator('div[class*="commentPopup"] div.tiptap') + this.inputAttachFile = page.locator('div[class*="commentPopup"] input#file') + this.textAttachFileName = page.locator('div[class*="commentPopup"] div[class*="attachment"] div.name') + this.buttonSendComment = page.locator('div[class*="commentPopup"] div.buttons-panel > button[type="button"]') + } + + async addCommentInPopup (commentText: string, attachmentFileName?: string): Promise { + await this.inputCommentText.fill(commentText) + if (attachmentFileName != null) { + await this.inputAttachFile.setInputFiles(path.join(__dirname, `../../files/${attachmentFileName}`)) + await expect(this.textAttachFileName).toHaveText(attachmentFileName) + } + + await this.buttonSendComment.click() + } +} diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index 9e377abe01..b3822c9e90 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -250,4 +250,23 @@ export class IssuesPage extends CommonTrackerPage { await this.page.locator('div.row span', { hasText: issueName }).locator('xpath=..').locator('a > button').click() await expect(this.textPopupAddAttachmentsFile.filter({ hasText: filePath })).toBeVisible() } + + async checkCommentsCount (issueName: string, count: string): Promise { + await expect( + this.page + .locator('div.row span', { hasText: issueName }) + .locator('xpath=..') + .locator('button > div[slot="content"]') + .first() + ).toHaveText(count) + } + + async openCommentPopupForIssueByName (issueName: string): Promise { + await this.page + .locator('div.row span', { hasText: issueName }) + .locator('xpath=..') + .locator('button') + .first() + .click() + } } diff --git a/tests/sanity/tests/tracker/attachments.spec.ts b/tests/sanity/tests/tracker/attachments.spec.ts index 4fa8be607b..e6bc71cd6c 100644 --- a/tests/sanity/tests/tracker/attachments.spec.ts +++ b/tests/sanity/tests/tracker/attachments.spec.ts @@ -63,5 +63,6 @@ test.describe('Attachments tests', () => { const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.checkIssueContainsAttachment('cat.jpeg') await issuesDetailsPage.checkIssueContainsAttachment('cat3.jpeg') + await issuesDetailsPage.checkActivityExist('uploaded an attachment') }) }) diff --git a/tests/sanity/tests/tracker/common-steps.ts b/tests/sanity/tests/tracker/common-steps.ts index 88b6b31e75..7c12f0aea1 100644 --- a/tests/sanity/tests/tracker/common-steps.ts +++ b/tests/sanity/tests/tracker/common-steps.ts @@ -12,3 +12,15 @@ export async function prepareNewIssueStep (page: Page, issue: NewIssue): Promise return await issuesPage.getIssueId(issue.title) }) } + +export async function prepareNewIssueWithOpenStep (page: Page, issue: NewIssue): Promise { + return await test.step('Prepare document', async () => { + const issuesPage = new IssuesPage(page) + await issuesPage.modelSelectorAll.click() + + await issuesPage.createNewIssue(issue) + await issuesPage.searchIssueByName(issue.title) + await issuesPage.openIssueByName(issue.title) + return await issuesPage.getIssueId(issue.title) + }) +} diff --git a/tests/sanity/tests/tracker/issues.spec.ts b/tests/sanity/tests/tracker/issues.spec.ts index 408812cee5..c82303a126 100644 --- a/tests/sanity/tests/tracker/issues.spec.ts +++ b/tests/sanity/tests/tracker/issues.spec.ts @@ -5,6 +5,8 @@ import { IssuesPage } from '../model/tracker/issues-page' import { IssuesDetailsPage } from '../model/tracker/issues-details-page' import { Issue, NewIssue } from '../model/tracker/types' import { TrackerNavigationMenuPage } from '../model/tracker/tracker-navigation-menu-page' +import { prepareNewIssueWithOpenStep } from './common-steps' +import { IssueCommentPopup } from '../model/tracker/issue-comment-popup' test.use({ storageState: PlatformSetting @@ -13,6 +15,9 @@ test.use({ test.describe('Tracker issue tests', () => { test.beforeEach(async ({ page }) => { await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() + + const leftSideMenuPage = new LeftSideMenuPage(page) + await leftSideMenuPage.buttonTracker.click() }) test('Create an issue with all parameters and attachments', async ({ page }) => { @@ -31,15 +36,7 @@ test.describe('Tracker issue tests', () => { 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) - + await prepareNewIssueWithOpenStep(page, newIssue) const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.checkIssue({ ...newIssue, @@ -53,7 +50,6 @@ test.describe('Tracker issue tests', () => { title: `Issue with all parameters and attachments-${generateId()}`, description: 'Created issue with all parameters and attachments description' } - const editIssue: Issue = { status: 'Done', priority: 'High', @@ -64,15 +60,7 @@ test.describe('Tracker issue tests', () => { milestone: 'Milestone', duedate: 'today' } - - 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) + await prepareNewIssueWithOpenStep(page, newIssue) const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.editIssue(editIssue) @@ -117,9 +105,6 @@ test.describe('Tracker issue tests', () => { description: 'Created issue to be parent issue' } - const leftSideMenuPage = new LeftSideMenuPage(page) - await leftSideMenuPage.buttonTracker.click() - const issuesPage = new IssuesPage(page) await issuesPage.modelSelectorAll.click() await issuesPage.createNewIssue(parentIssue) @@ -204,25 +189,15 @@ test.describe('Tracker issue tests', () => { title: `Issue to another project-${generateId()}`, description: 'Issue to move to another project' } - - 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.createNewIssue(moveIssue) - await issuesPage.searchIssueByName(moveIssue.title) - await issuesPage.openIssueByName(moveIssue.title) - + await prepareNewIssueWithOpenStep(page, moveIssue) const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.moreActionOnIssue('Move to project') await issuesDetailsPage.fillMoveIssuesModal(secondProjectName, true) + const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page) await trackerNavigationMenuPage.openIssuesForProject(secondProjectName) + const issuesPage = new IssuesPage(page) await issuesPage.openIssueByName(moveIssue.title) await issuesDetailsPage.checkIssue({ ...moveIssue @@ -238,18 +213,7 @@ test.describe('Tracker issue tests', () => { title: `Issue for stored comment-${generateId()}`, description: 'Issue for comment stored after reload the page' } - - 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.createNewIssue(commentIssue) - await issuesPage.searchIssueByName(commentIssue.title) - await issuesPage.openIssueByName(commentIssue.title) + await prepareNewIssueWithOpenStep(page, commentIssue) const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.waitDetailsOpened(commentIssue.title) @@ -271,13 +235,6 @@ test.describe('Tracker issue tests', () => { component: 'Default component', milestone: 'Edit Milestone' } - - 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() @@ -298,10 +255,6 @@ test.describe('Tracker issue tests', () => { title: 'Issue for deletion', description: 'Description Issue for deletion' } - - const leftSideMenuPage = new LeftSideMenuPage(page) - await leftSideMenuPage.buttonTracker.click() - const issuesPage = new IssuesPage(page) await issuesPage.modelSelectorAll.click() await issuesPage.searchIssueByName(deleteIssue.title) @@ -322,15 +275,7 @@ test.describe('Tracker issue tests', () => { title: `Check the changed description activity-${generateId()}`, description: 'Check the changed description activity description' } - - const leftSideMenuPage = new LeftSideMenuPage(page) - await leftSideMenuPage.buttonTracker.click() - - const issuesPage = new IssuesPage(page) - await issuesPage.modelSelectorAll.click() - await issuesPage.createNewIssue(changedDescriptionIssue) - await issuesPage.searchIssueByName(changedDescriptionIssue.title) - await issuesPage.openIssueByName(changedDescriptionIssue.title) + await prepareNewIssueWithOpenStep(page, changedDescriptionIssue) const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.waitDetailsOpened(changedDescriptionIssue.title) @@ -345,19 +290,42 @@ test.describe('Tracker issue tests', () => { title: `Add comment with image attachment-${generateId()}`, description: 'Add comment with image attachment' } - - const leftSideMenuPage = new LeftSideMenuPage(page) - await leftSideMenuPage.buttonTracker.click() - - const issuesPage = new IssuesPage(page) - await issuesPage.modelSelectorAll.click() - await issuesPage.createNewIssue(commentImageIssue) - await issuesPage.searchIssueByName(commentImageIssue.title) - await issuesPage.openIssueByName(commentImageIssue.title) + await prepareNewIssueWithOpenStep(page, commentImageIssue) const issuesDetailsPage = new IssuesDetailsPage(page) await issuesDetailsPage.waitDetailsOpened(commentImageIssue.title) await issuesDetailsPage.addCommentWithImage('Added comment with atttachment', 'cat3.jpeg') await issuesDetailsPage.checkCommentWithImageExist('left a comment', 'cat3.jpeg') }) + + test('Add comment by popup', async ({ page }) => { + const commentInside = `Comment for the inside issue-${generateId()}` + const commentPopup = `Comment for the popup-${generateId()}` + const commentIssue: NewIssue = { + title: `Issue for add comment by popup-${generateId()}`, + description: 'Issue for add comment by popup' + } + await prepareNewIssueWithOpenStep(page, commentIssue) + + const issuesDetailsPage = new IssuesDetailsPage(page) + await issuesDetailsPage.waitDetailsOpened(commentIssue.title) + await issuesDetailsPage.addComment(commentInside) + await issuesDetailsPage.checkCommentExist(commentInside) + + const trackerNavigationMenuPage = new TrackerNavigationMenuPage(page) + await trackerNavigationMenuPage.openIssuesForProject('Default') + + const issuesPage = new IssuesPage(page) + await issuesPage.checkCommentsCount(commentIssue.title, '1') + await issuesPage.openCommentPopupForIssueByName(commentIssue.title) + + const issueCommentPopup = new IssueCommentPopup(page) + await issueCommentPopup.addCommentInPopup(commentPopup, 'cat2.jpeg') + await issueCommentPopup.checkCommentWithImageExist('left a comment', 'cat2.jpeg') + await issueCommentPopup.checkCommentExist(commentPopup) + + await issuesPage.modelSelectorAll.click() + + await issuesPage.checkCommentsCount(commentIssue.title, '2') + }) })