diff --git a/tests/sanity/tests/model/tracker/issues-page.ts b/tests/sanity/tests/model/tracker/issues-page.ts index 6281f02cad..a049d3af9f 100644 --- a/tests/sanity/tests/model/tracker/issues-page.ts +++ b/tests/sanity/tests/model/tracker/issues-page.ts @@ -2,6 +2,7 @@ import { expect, type Locator, type Page } from '@playwright/test' import { NewIssue } from './types' import path from 'path' import { CommonTrackerPage } from './common-tracker-page' +import { iterateLocator } from '../../utils' export class IssuesPage extends CommonTrackerPage { readonly page: Page @@ -25,6 +26,7 @@ export class IssuesPage extends CommonTrackerPage { readonly inputSearch: Locator readonly linkSidebarAll: Locator readonly linkSidebarMyIssue: Locator + readonly buttonClearFilers: Locator constructor (page: Page) { super(page) @@ -61,6 +63,7 @@ export class IssuesPage extends CommonTrackerPage { this.inputSearch = page.locator('input[placeholder="Search"]') this.linkSidebarAll = page.locator('a[href$="all-issues"]') this.linkSidebarMyIssue = page.locator('a[href$="my-issues"]') + this.buttonClearFilers = page.locator('div.search-start > div:first-child button') } async createNewIssue (data: NewIssue): Promise { @@ -137,4 +140,12 @@ export class IssuesPage extends CommonTrackerPage { async checkFilteredIssueNotExist (issueName: string): Promise { await expect(this.page.locator('div.row span', { hasText: issueName })).toHaveCount(0) } + + async checkAllIssuesInStatus (statusId: string | undefined): Promise { + if (statusId === undefined) throw new Error(`Unknown status id ${statusId}`) + + for await (const locator of iterateLocator(this.page.locator('div.listGrid'))) { + await expect(locator.locator('div[class*="square"] > svg')).toHaveAttribute('id', statusId) + } + } } diff --git a/tests/sanity/tests/tracker/filter.spec.ts b/tests/sanity/tests/tracker/filter.spec.ts index 6eff916e8a..2ffdccb00a 100644 --- a/tests/sanity/tests/tracker/filter.spec.ts +++ b/tests/sanity/tests/tracker/filter.spec.ts @@ -4,6 +4,7 @@ import { LeftSideMenuPage } from '../model/left-side-menu-page' import { IssuesPage } from '../model/tracker/issues-page' import { NewIssue } from '../model/tracker/types' import { allure } from 'allure-playwright' +import { DEFAULT_STATUSES, DEFAULT_STATUSES_ID } from './tracker.utils' test.use({ storageState: PlatformSetting @@ -206,32 +207,21 @@ test.describe('Tracker filters tests', () => { }) test('Status filter', async ({ page }) => { - const newIssue: NewIssue = { - title: `Issue for the Created filter-${generateId()}`, - description: 'Issue for the Created filter', - status: 'In Progress', - priority: 'Urgent', - assignee: 'Appleseed John', - createLabel: true, - component: 'No component', - estimation: '2', - milestone: 'No Milestone', - duedate: 'today', - 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 test.step('Check Filter Today', async () => { - await issuesPage.selectFilter('Created date', 'Today') - await issuesPage.checkFilter('Created date', 'Today') + for (const status of DEFAULT_STATUSES) { + await test.step(`Status Filter ${status}`, async () => { + await issuesPage.selectFilter('Status', status) + await issuesPage.inputSearch.press('Escape') - await issuesPage.checkFilteredIssueExist(newIssue.title) - }) + await issuesPage.checkFilter('Status', 'is') + await issuesPage.checkAllIssuesInStatus(DEFAULT_STATUSES_ID.get(status)) + await issuesPage.buttonClearFilers.click() + }) + } }) }) diff --git a/tests/sanity/tests/tracker/loading.spec.ts b/tests/sanity/tests/tracker/loading.spec.ts index df7499ebdf..52055bff7a 100644 --- a/tests/sanity/tests/tracker/loading.spec.ts +++ b/tests/sanity/tests/tracker/loading.spec.ts @@ -1,4 +1,4 @@ -import { test } from '@playwright/test' +import { test, expect } from '@playwright/test' import { IssuesPage } from '../model/tracker/issues-page' import { PlatformSetting, PlatformURI } from '../utils' import { allure } from 'allure-playwright' @@ -15,10 +15,9 @@ test('check-status-loading', async ({ page }) => { const issuesPage = new IssuesPage(page) await issuesPage.modelSelectorAll.click() - // TODO: Test should create issues before checking for status loading - // await expect(page.locator('.categoryHeader :text-is("In Progress")').first()).toBeVisible() - // await expect(page.locator('.categoryHeader :text-is("Backlog")').first()).toBeVisible() - // await expect(page.locator('.categoryHeader :text-is("Todo")').first()).toBeVisible() - // await expect(page.locator('.categoryHeader :text-is("Done")').first()).toBeVisible() - // await expect(page.locator('.categoryHeader :text-is("Canceled")').first()).toBeVisible() + await expect(page.locator('.categoryHeader :text-is("In Progress")').first()).toBeVisible() + await expect(page.locator('.categoryHeader :text-is("Backlog")').first()).toBeVisible() + await expect(page.locator('.categoryHeader :text-is("Todo")').first()).toBeVisible() + await expect(page.locator('.categoryHeader :text-is("Done")').first()).toBeVisible() + await expect(page.locator('.categoryHeader :text-is("Canceled")').first()).toBeVisible() }) diff --git a/tests/sanity/tests/tracker/tracker.utils.ts b/tests/sanity/tests/tracker/tracker.utils.ts index 03fb80e175..bd1ff30a9b 100644 --- a/tests/sanity/tests/tracker/tracker.utils.ts +++ b/tests/sanity/tests/tracker/tracker.utils.ts @@ -23,6 +23,14 @@ export const PRIORITIES = ['No priority', 'Urgent', 'High', 'Medium', 'Low'] export const DEFAULT_STATUSES = ['Backlog', 'Todo', 'In Progress', 'Done', 'Canceled'] export const DEFAULT_USER = 'Appleseed John' +export const DEFAULT_STATUSES_ID = new Map([ + ['Backlog', 'tracker:issueStatusCategory:Backlog'], + ['Todo', 'tracker:issueStatusCategory:Unstarted'], + ['In Progress', 'tracker:issueStatusCategory:Started'], + ['Done', 'tracker:issueStatusCategory:Completed'], + ['Canceled', 'tracker:issueStatusCategory:Canceled'] +]) + export async function navigate (page: Page): Promise { await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished() await page.click('[id="app-tracker\\:string\\:TrackerApplication"]') diff --git a/tests/sanity/tests/utils.ts b/tests/sanity/tests/utils.ts index 31b1caccda..e1da17c852 100644 --- a/tests/sanity/tests/utils.ts +++ b/tests/sanity/tests/utils.ts @@ -68,3 +68,9 @@ export function expectToContainsOrdered (val: Locator, text: string[], timeout?: const origIssuesExp = new RegExp('.*' + text.join('.*') + '.*') return expect(val).toHaveText(origIssuesExp, { timeout }) } + +export async function * iterateLocator (locator: Locator): AsyncGenerator { + for (let index = 0; index < (await locator.count()); index++) { + yield locator.nth(index) + } +}