mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-24 01:07:50 +00:00
TESTS-92: feat(tests): done Tracker filters tests - Modified date (#4094)
Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
parent
cd68dd7d10
commit
fe78bba3d0
@ -1,11 +1,61 @@
|
|||||||
import { Page } from '@playwright/test'
|
import { expect, Locator, Page } from '@playwright/test'
|
||||||
import { CalendarPage } from '../calendar-page'
|
import { CalendarPage } from '../calendar-page'
|
||||||
|
|
||||||
export class CommonTrackerPage extends CalendarPage {
|
export class CommonTrackerPage extends CalendarPage {
|
||||||
readonly page: Page
|
readonly page: Page
|
||||||
|
readonly buttonFilter: Locator
|
||||||
|
|
||||||
constructor (page: Page) {
|
constructor (page: Page) {
|
||||||
super(page)
|
super(page)
|
||||||
this.page = page
|
this.page = page
|
||||||
|
this.buttonFilter = page.locator('div.search-start > div:first-child button')
|
||||||
|
}
|
||||||
|
|
||||||
|
async selectFilter (filter: string, filterSecondLevel?: string): Promise<void> {
|
||||||
|
await this.buttonFilter.click()
|
||||||
|
await this.page.locator('div.selectPopup [class*="menu"]', { hasText: filter }).click()
|
||||||
|
if (filterSecondLevel !== null) {
|
||||||
|
await this.page.locator('div.selectPopup [class*="menu"]', { hasText: filterSecondLevel }).click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkFilter (filter: string, filterSecondLevel?: string, filterThirdLevel?: string): Promise<void> {
|
||||||
|
await expect(this.page.locator('div.filter-section button:nth-child(1)')).toHaveText(filter)
|
||||||
|
if (filterSecondLevel !== undefined) {
|
||||||
|
await expect(this.page.locator('div.filter-section button:nth-child(2)')).toContainText(filterSecondLevel)
|
||||||
|
}
|
||||||
|
if (filterThirdLevel !== undefined) {
|
||||||
|
await expect(this.page.locator('div.filter-section button:nth-child(3)')).toContainText(filterThirdLevel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateFilterDimension (filterSecondLevel: string, dateStart?: string): Promise<void> {
|
||||||
|
await this.page.locator('div.filter-section button:nth-child(2)').click()
|
||||||
|
await this.page.locator('div.selectPopup [class*="menu"]', { hasText: filterSecondLevel }).click()
|
||||||
|
|
||||||
|
if (dateStart !== undefined) {
|
||||||
|
switch (dateStart) {
|
||||||
|
case 'Today':
|
||||||
|
await this.page.locator('div.month-container div.today').click()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
await this.page.locator('div.month-container div.day', { hasText: dateStart }).click()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fillBetweenDate (dateStart: string, dateEnd: string): Promise<void> {
|
||||||
|
await this.page
|
||||||
|
.locator('div.date-popup-container div.input:first-child span.digit:first-child')
|
||||||
|
.click({ delay: 100 })
|
||||||
|
await this.page.type('div.date-popup-container div.input:first-child', dateStart)
|
||||||
|
|
||||||
|
await this.page
|
||||||
|
.locator('div.date-popup-container div.input:last-child span.digit:first-child')
|
||||||
|
.click({ delay: 100 })
|
||||||
|
await this.page.type('div.date-popup-container div.input:last-child', dateEnd)
|
||||||
|
|
||||||
|
await this.page.locator('div.date-popup-container button[type="submit"]').click({ delay: 100 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,4 +129,12 @@ export class IssuesPage extends CommonTrackerPage {
|
|||||||
async checkIssueNotExist (issueName: string): Promise<void> {
|
async checkIssueNotExist (issueName: string): Promise<void> {
|
||||||
await expect(this.page.locator('tr', { hasText: issueName })).toHaveCount(0)
|
await expect(this.page.locator('tr', { hasText: issueName })).toHaveCount(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async checkFilteredIssueExist (issueName: string): Promise<void> {
|
||||||
|
await expect(this.page.locator('div.row span', { hasText: issueName })).toHaveCount(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkFilteredIssueNotExist (issueName: string): Promise<void> {
|
||||||
|
await expect(this.page.locator('div.row span', { hasText: issueName })).toHaveCount(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
113
tests/sanity/tests/tracker/filter.spec.ts
Normal file
113
tests/sanity/tests/tracker/filter.spec.ts
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
import { test } from '@playwright/test'
|
||||||
|
import { generateId, PlatformSetting, PlatformURI } from '../utils'
|
||||||
|
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'
|
||||||
|
|
||||||
|
test.use({
|
||||||
|
storageState: PlatformSetting
|
||||||
|
})
|
||||||
|
|
||||||
|
test.describe('Tracker filters tests', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await allure.parentSuite('Tracker tests')
|
||||||
|
await (await page.goto(`${PlatformURI}/workbench/sanity-ws`))?.finished()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Modified date', async ({ page }) => {
|
||||||
|
const newIssue: NewIssue = {
|
||||||
|
title: `Issue for the filter-${generateId()}`,
|
||||||
|
description: 'Issue for the filter',
|
||||||
|
status: 'In Progress',
|
||||||
|
priority: 'Urgent',
|
||||||
|
assignee: 'Appleseed John',
|
||||||
|
createLabel: true,
|
||||||
|
labels: `FILTER-ISSUE-${generateId()}`,
|
||||||
|
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('Modified date', 'Today')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'Today')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter Yesterday', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('Yesterday')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'Yesterday')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueNotExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter This week', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('This week')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'This week')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter This month', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('This month')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'This month')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter Exact date - Today', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('Exact date', 'Today')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'is', 'Today')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter Before date - Today', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('Before date')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'Before', 'Today')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueNotExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter After date - Today', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('After date')
|
||||||
|
await issuesPage.checkFilter('Modified date', 'After', 'Today')
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueExist(newIssue.title)
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check Filter Today', async () => {
|
||||||
|
await issuesPage.updateFilterDimension('Between dates')
|
||||||
|
const dateYesterday = new Date()
|
||||||
|
dateYesterday.setDate(dateYesterday.getDate() - 1)
|
||||||
|
const dateTomorrow = new Date()
|
||||||
|
dateTomorrow.setDate(dateTomorrow.getDate() + 1)
|
||||||
|
|
||||||
|
const dateYesterdayString = `${dateYesterday.getDate().toString().padStart(2, '0')}${(
|
||||||
|
dateYesterday.getMonth() + 1
|
||||||
|
)
|
||||||
|
.toString()
|
||||||
|
.padStart(2, '0')}${dateYesterday.getFullYear()}`
|
||||||
|
const dateTomorrowString = `${dateTomorrow.getDate().toString().padStart(2, '0')}${(dateTomorrow.getMonth() + 1)
|
||||||
|
.toString()
|
||||||
|
.padStart(2, '0')}${dateTomorrow.getFullYear()}`
|
||||||
|
|
||||||
|
await issuesPage.fillBetweenDate(dateYesterdayString, dateTomorrowString)
|
||||||
|
await issuesPage.checkFilter('Modified date', 'is between', dateYesterday.getDate().toString())
|
||||||
|
await issuesPage.checkFilter('Modified date', 'is between', dateTomorrow.getDate().toString())
|
||||||
|
|
||||||
|
await issuesPage.checkFilteredIssueExist(newIssue.title)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user