From 829474e7fb5a86ee36154afe495065faa08d8bf4 Mon Sep 17 00:00:00 2001 From: Alex Velichko Date: Fri, 22 Dec 2023 10:01:44 +0300 Subject: [PATCH] feat(tests): updated flaky tests (#4244) Signed-off-by: Alex Velichko --- tests/sanity/tests/collaborative/issues.spec.ts | 2 +- tests/sanity/tests/model/common-page.ts | 5 +++++ tests/sanity/tests/model/tracker/issues-page.ts | 7 +++++-- tests/sanity/tests/tracker/issues-duplicate.spec.ts | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/sanity/tests/collaborative/issues.spec.ts b/tests/sanity/tests/collaborative/issues.spec.ts index 6c322fc99a..e952a58f50 100644 --- a/tests/sanity/tests/collaborative/issues.spec.ts +++ b/tests/sanity/tests/collaborative/issues.spec.ts @@ -19,7 +19,7 @@ test.describe('Collaborative test for issue', () => { test('Issues can be assigned to another users', async ({ page, browser }) => { const newIssue: NewIssue = { - title: 'Issues can be assigned to another users', + title: `Issues can be assigned to another users-${generateId()}`, description: 'Issues can be assigned to another users', status: 'Backlog', priority: 'Urgent', diff --git a/tests/sanity/tests/model/common-page.ts b/tests/sanity/tests/model/common-page.ts index 642d1fb574..07da181d7e 100644 --- a/tests/sanity/tests/model/common-page.ts +++ b/tests/sanity/tests/model/common-page.ts @@ -27,6 +27,7 @@ export class CommonPage { } async fillToSelectPopup (page: Page, input: string): Promise { + await expect(page.locator('div.selectPopup input')).toBeVisible() await page.locator('div.selectPopup input').fill(input) await page.locator('div.selectPopup button').click() } @@ -72,4 +73,8 @@ export class CommonPage { await page.locator('div.selectPopup input').fill(point) await page.locator('div.selectPopup span[class^="lines"]', { hasText: point }).click() } + + async closeNotification (page: Page): Promise { + await page.locator('div.notify-container button[type="button"].small').nth(0).click() + } } diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index 58f3a6d6a8..35e87f7eb5 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -74,10 +74,13 @@ export class IssuesPage extends CommonTrackerPage { ) } - async createNewIssue (data: NewIssue): Promise { + async createNewIssue (data: NewIssue, closeNotification: boolean = true): Promise { await this.buttonCreateNewIssue.click() await this.fillNewIssueForm(data) await this.buttonCreateIssue.click() + if (closeNotification) { + await this.closeNotification(this.page) + } } async fillNewIssueForm (data: NewIssue): Promise { @@ -184,7 +187,7 @@ export class IssuesPage extends CommonTrackerPage { } } - async getIssueId (issueLabel: string, position: number = 1): Promise { + async getIssueId (issueLabel: string, position: number = 0): Promise { const id = await this.page.locator(`span[title="${issueLabel}"].overflow-label`).nth(position).textContent() return id?.trim() ?? '' } diff --git a/tests/sanity/tests/tracker/issues-duplicate.spec.ts b/tests/sanity/tests/tracker/issues-duplicate.spec.ts index e50f780fd3..90d00eab4d 100644 --- a/tests/sanity/tests/tracker/issues-duplicate.spec.ts +++ b/tests/sanity/tests/tracker/issues-duplicate.spec.ts @@ -42,7 +42,7 @@ test.describe('Tracker duplicate issue tests', () => { const firstIssueId = await issuesPage.getIssueId(firstIssue.title) await issuesPage.createNewIssue(secondIssue) - const secondIssueId = await issuesPage.getIssueId(secondIssue.title, 2) + const secondIssueId = await issuesPage.getIssueId(secondIssue.title, 1) expect(firstIssueId).not.toEqual(secondIssueId) await issuesPage.checkIssuesCount(firstIssue.title, 2)