feat(tests): updated filter between tests (#4488)

Signed-off-by: Alex Velichko <nestor_007@mail.ru>
This commit is contained in:
Alex Velichko 2024-02-01 13:22:03 +03:00 committed by GitHub
parent d60b0c9266
commit f3a07f976d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 83 additions and 27 deletions

View File

@ -1,5 +1,6 @@
import { expect, Locator, Page } from '@playwright/test'
import { CalendarPage } from '../calendar-page'
import { DateDivided } from './types'
export class CommonTrackerPage extends CalendarPage {
readonly page: Page
@ -65,16 +66,63 @@ export class CommonTrackerPage extends CalendarPage {
}
}
async fillBetweenDate (dateStart: string, dateEnd: string): Promise<void> {
async fillBetweenDate (dateStart: DateDivided, dateEnd: DateDivided): Promise<void> {
// TODO removed after bug fixed
if (dateStart.day === '30' || dateEnd.day === '30') {
await this.page.locator('div.date-popup-container div.day:not(.wrongMonth)', { hasText: '30' }).first().click()
}
if (dateStart.day === '31' || dateEnd.day === '31') {
await this.page.locator('div.date-popup-container div.day:not(.wrongMonth)', { hasText: '31' }).first().click()
}
// dateStart - day
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)
.click({ delay: 100, position: { x: 1, y: 1 } })
await this.page
.locator('div.date-popup-container div.input:first-child span.digit:first-child')
.pressSequentially(dateStart.day)
// dateStart - month
await this.page
.locator('div.date-popup-container div.input:first-child span.digit:nth-child(3)')
.click({ delay: 100, position: { x: 1, y: 1 } })
await this.page
.locator('div.date-popup-container div.input:first-child span.digit:nth-child(3)')
.pressSequentially(dateStart.month)
// dateStart - year
await this.page
.locator('div.date-popup-container div.input:first-child span.digit:nth-child(5)')
.click({ delay: 100, position: { x: 1, y: 1 } })
await this.page
.locator('div.date-popup-container div.input:first-child span.digit:nth-child(5)')
.pressSequentially(dateStart.year)
// dateEnd - day
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)
.click({ delay: 100, position: { x: 1, y: 1 } })
await this.page
.locator('div.date-popup-container div.input:last-child span.digit:first-child')
.pressSequentially(dateEnd.day)
// dateEnd - month
await this.page
.locator('div.date-popup-container div.input:last-child span.digit:nth-child(3)')
.click({ delay: 100, position: { x: 1, y: 1 } })
await this.page
.locator('div.date-popup-container div.input:last-child span.digit:nth-child(3)')
.pressSequentially(dateEnd.month)
// dateEnd - year
await this.page
.locator('div.date-popup-container div.input:last-child span.digit:nth-child(5)')
.click({ delay: 100, position: { x: 1, y: 1 } })
await this.page
.locator('div.date-popup-container div.input:last-child span.digit:nth-child(5)')
.pressSequentially(dateEnd.year)
await this.page.locator('div.date-popup-container button[type="submit"]').click({ delay: 100 })
}

View File

@ -46,3 +46,9 @@ export interface NewComponent {
description?: string
lead?: string
}
export interface DateDivided {
day: string
month: string
year: string
}

View File

@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test'
import { generateId, iterateLocator, 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 { DateDivided, NewIssue } from '../model/tracker/types'
import { allure } from 'allure-playwright'
import { DEFAULT_STATUSES, DEFAULT_STATUSES_ID, PRIORITIES } from './tracker.utils'
import { IssuesDetailsPage } from '../model/tracker/issues-details-page'
@ -88,23 +88,24 @@ test.describe('Tracker filters tests', () => {
await issuesPage.checkFilteredIssueExist(newIssue.title)
})
await test.step('Check Filter Check Filter Between Dates', async () => {
await test.step('Check Filter Between Dates', 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 dateYesterdayDivided: DateDivided = {
day: dateYesterday.getDate().toString(),
month: (dateYesterday.getMonth() + 1).toString(),
year: dateYesterday.getFullYear().toString()
}
const dateTomorrowDivided: DateDivided = {
day: dateTomorrow.getDate().toString(),
month: (dateTomorrow.getMonth() + 1).toString(),
year: dateTomorrow.getFullYear().toString()
}
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.fillBetweenDate(dateYesterdayDivided, dateTomorrowDivided)
await issuesPage.checkFilter('Modified date', 'is between', dateYesterday.getDate().toString())
await issuesPage.checkFilter('Modified date', 'is between', dateTomorrow.getDate().toString())
@ -189,17 +190,18 @@ test.describe('Tracker filters tests', () => {
dateYesterday.setDate(dateYesterday.getDate() - 1)
const dateTomorrow = new Date()
dateTomorrow.setDate(dateTomorrow.getDate() + 1)
const dateYesterdayDivided: DateDivided = {
day: dateYesterday.getDate().toString(),
month: (dateYesterday.getMonth() + 1).toString(),
year: dateYesterday.getFullYear().toString()
}
const dateTomorrowDivided: DateDivided = {
day: dateTomorrow.getDate().toString(),
month: (dateTomorrow.getMonth() + 1).toString(),
year: dateTomorrow.getFullYear().toString()
}
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.fillBetweenDate(dateYesterdayDivided, dateTomorrowDivided)
await issuesPage.checkFilter('Created date', 'is between', dateYesterday.getDate().toString())
await issuesPage.checkFilter('Created date', 'is between', dateTomorrow.getDate().toString())