Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TESTS-92: feat(tests): done Tracker filters tests - Modified date #4094

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion tests/sanity/tests/model/tracker/common-tracker-page.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,61 @@
import { Page } from '@playwright/test'
import { expect, Locator, Page } from '@playwright/test'
import { CalendarPage } from '../calendar-page'

export class CommonTrackerPage extends CalendarPage {
readonly page: Page
readonly buttonFilter: Locator

constructor (page: Page) {
super(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 })
}
}
8 changes: 8 additions & 0 deletions tests/sanity/tests/model/tracker/issues-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,12 @@ export class IssuesPage extends CommonTrackerPage {
async checkIssueNotExist (issueName: string): Promise<void> {
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 changes: 113 additions & 0 deletions tests/sanity/tests/tracker/filter.spec.ts
Original file line number Diff line number Diff line change
@@ -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)
})
})
})