Skip to content

Commit

Permalink
Fix uitests (#6804)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
  • Loading branch information
SasLord authored Oct 4, 2024
1 parent 3ed53bf commit ec696d0
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 18 deletions.
5 changes: 2 additions & 3 deletions tests/sanity/tests/model/channel-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,8 @@ export class ChannelPage extends CommonPage {
}

async checkIfNameIsChanged (channel: string): Promise<void> {
await expect(this.channel(channel).nth(0)).toBeVisible()
await expect(this.channel(channel).nth(1)).toBeVisible()
await expect(this.channel(channel).nth(2)).toBeVisible()
await expect(this.channelContainers().filter({ hasText: channel })).toBeVisible()
await expect(this.buttonBreadcrumb(channel)).toBeVisible()
}

async makeActionWithChannelInMenu (channelName: string, action: string): Promise<void> {
Expand Down
6 changes: 6 additions & 0 deletions tests/sanity/tests/model/common-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class CommonPage {
selectPopupInputSearch = (): Locator => this.page.locator('div.popup input.search')
selectPopupListItem = (name: string): Locator => this.page.locator('div.selectPopup div.list-item', { hasText: name })
selectPopupListItemFirst = (): Locator => this.page.locator('div.selectPopup div.list-item')
selectPopupApMenuItem = (hasText: string): Locator => this.page.locator('div.popup button.ap-menuItem', { hasText })
selectPopupAddButton = (): Locator => this.page.locator('div.selectPopup button[data-id="btnAdd"]')
selectPopupButton = (): Locator => this.page.locator('div.selectPopup button')
selectPopupExpandButton = (): Locator => this.page.locator('div.selectPopup button[data-id="btnExpand"]')
Expand Down Expand Up @@ -89,6 +90,7 @@ export class CommonPage {
this.page.locator('div.date-popup-container div.input:last-child span.digit:nth-child(5)')

submitButton = (): Locator => this.page.locator('div.date-popup-container button[type="submit"]')
buttonBreadcrumb = (hasText?: string): Locator => this.page.locator('button.hulyBreadcrumb-container', { hasText })

async selectMenuItem (page: Page, name: string, fullWordFilter: boolean = false): Promise<void> {
if (name !== 'first') {
Expand Down Expand Up @@ -194,6 +196,10 @@ export class CommonPage {
await this.selectPopupListItem(name).click({ delay: 100 })
}

async selectPopupAp (name: string): Promise<void> {
await this.selectPopupApMenuItem(name).click({ delay: 100 })
}

async selectPopupItem (name: string): Promise<void> {
await this.hulyPopupRowButton(name).click({ delay: 100 })
}
Expand Down
47 changes: 45 additions & 2 deletions tests/sanity/tests/model/planning/planning-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,20 @@ export class PlanningPage extends CalendarPage {

readonly buttonMenuDelete = (): Locator => this.page.locator('button.ap-menuItem span', { hasText: 'Delete' })
readonly buttonPopupSelectDateNextMonth = (): Locator =>
this.popup().locator('div.header > div:last-child > button:last-child')
this.popup().locator('div.month-container > div.header > div:last-child > button:last-child')

readonly buttonPopupSelectDatePrevMonth = (): Locator =>
this.popup().locator('div.month-container > div.header > div:last-child > button:first-child')

readonly buttonPrevDayInSchedule = (): Locator =>
this.page
.locator('div.hulyHeader-container', { hasText: 'Schedule:' })
.locator('div.hulyHeader-buttonsGroup > button:first-child')

readonly buttonNextDayInSchedule = (): Locator =>
this.page
.locator('div.hulyHeader-container', { hasText: 'Schedule:' })
.locator('div.hulyHeader-buttonsGroup > button:last-child')

readonly selectInputToDo = (): Locator =>
this.toDosContainer().getByPlaceholder('Add Action Item, press Enter to save')
Expand Down Expand Up @@ -102,6 +115,14 @@ export class PlanningPage extends CalendarPage {
.locator('xpath=..')
.locator('button.reference')

async clickButtonPrevDayInSchedule (): Promise<void> {
await this.buttonPrevDayInSchedule().click()
}

async clickButtonNextDayInSchedule (): Promise<void> {
await this.buttonNextDayInSchedule().click()
}

async dragToCalendar (title: string, column: number, time: string, addHalf: boolean = false): Promise<void> {
await this.toDosContainer().getByRole('button', { name: title }).hover()

Expand Down Expand Up @@ -224,14 +245,36 @@ export class PlanningPage extends CalendarPage {
await row.locator('div.dateEditor-container:first-child > div.min-w-28:first-child .hulyButton').click()
if (slot.dateStart === 'today') {
await this.buttonCalendarToday().click()
} else {
} else if (typeof slot.dateStart === 'string') {
if (slot.dateStart === '1') {
await this.buttonPopupSelectDateNextMonth().click()
}
await this.page
.locator('div.popup div.calendar button.day')
.filter({ has: this.page.locator(`text="${slot.dateStart}"`) })
.click()
} else {
const today = new Date()
const target = new Date(
parseInt(slot.dateStart.year, 10),
parseInt(slot.dateStart.month, 10) - 1,
parseInt(slot.dateStart.day, 10)
)
const before: boolean = target.getTime() < today.getTime()
const diffYear: number = Math.abs(target.getFullYear() - today.getFullYear())
const diffMonth: number =
diffYear === 0
? Math.abs(target.getMonth() - today.getMonth())
: (diffYear - 1) * 12 +
(before ? today.getMonth() + 12 - target.getMonth() : target.getMonth() + 12 - today.getMonth())
for (let i = 0; i < diffMonth; i++) {
if (before) await this.buttonPopupSelectDatePrevMonth().click()
else await this.buttonPopupSelectDateNextMonth().click()
}
await this.page
.locator('div.popup div.calendar button.day')
.filter({ has: this.page.locator(`text="${target.getDate()}"`) })
.click()
}
// timeStart
const hours = slot.timeStart.substring(0, 2)
Expand Down
6 changes: 3 additions & 3 deletions tests/sanity/tests/model/planning/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export interface NewToDo {
}

export interface Slot {
dateStart: string
dateStart: string | TDate
timeStart: string
dateEnd: Date
dateEnd: TDate
timeEnd: string
}

export interface Date {
export interface TDate {
day: string
month: string
year: string
Expand Down
7 changes: 7 additions & 0 deletions tests/sanity/tests/model/settings-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export class SettingsPage extends CommonPage {
asideFooterButton = (hasText: string): Locator =>
this.page.locator('div.hulyModal-container.type-aside div.hulyModal-footer button', { hasText })

buttonRoleInComponent = (hasText: string): Locator =>
this.page.locator('div.hulyComponent-content > div.flex-row-center', { hasText }).locator('button')

async clickButtonRoleInComponent (name: string): Promise<void> {
await this.buttonRoleInComponent(name).click()
}

async navigateToWorkspace (workspaceUrl: string): Promise<void> {
const response = await this.page.goto(workspaceUrl)
if (response === null || response === undefined) {
Expand Down
23 changes: 14 additions & 9 deletions tests/sanity/tests/planning/plan.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
generateTestData,
getTimeForPlanner,
getSecondPageByInvite,
getInviteLink
getInviteLink,
convertDate
} from '../utils'
import { PlanningPage } from '../model/planning/planning-page'
import { NewToDo } from '../model/planning/types'
Expand Down Expand Up @@ -344,23 +345,21 @@ test.describe('Planning ToDo tests', () => {
})
})

test.skip('Change ToDo start and end times by dragging', async ({ page }) => {
test('Change ToDo start and end times by dragging', async ({ page }) => {
const planningPage = new PlanningPage(page)
const planningNavigationMenuPage = new PlanningNavigationMenuPage(page)
const dateEnd = new Date()
const today = new Date()
const date = new Date()
date.setDate(date.getDate() + 3)

const toDoWithLabel: NewToDo = {
title: `ToDo to change duration-${generateId()}`,
description: 'Description for ToDo to change duration',
slots: [
{
dateStart: 'today',
dateStart: convertDate(date),
timeStart: '1400',
dateEnd: {
day: dateEnd.getDate().toString(),
month: (dateEnd.getMonth() + 1).toString(),
year: dateEnd.getFullYear().toString()
},
dateEnd: convertDate(date),
timeEnd: '1500'
}
]
Expand All @@ -369,6 +368,12 @@ test.describe('Planning ToDo tests', () => {
await test.step('Prepare ToDo', async () => {
await planningNavigationMenuPage.clickOnButtonToDoAll()
await planningPage.createNewToDo(toDoWithLabel)
const diff = date.getTime() - today.getTime()
for (let i = 0; i < Math.abs(diff) / 86400000; i++) {
if (diff < 0) await planningPage.clickButtonPrevDayInSchedule()
else await planningPage.clickButtonNextDayInSchedule()
}
await planningPage.selectTimeCell('10am').scrollIntoViewIfNeeded()
})

await test.step('Resize ToDo', async () => {
Expand Down
17 changes: 16 additions & 1 deletion tests/sanity/tests/recruiting/vacancies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page'
import { VacanciesPage } from '../model/recruiting/vacancies-page'
import { VacancyDetailsPage } from '../model/recruiting/vacancy-details-page'
import { NewVacancy } from '../model/recruiting/types'
import { SettingsPage } from '../model/settings-page'
import { WorkspaceSettingsPage } from '../model/workspace/workspace-settings-page'

test.use({
storageState: PlatformSetting
Expand All @@ -21,7 +23,20 @@ test.describe('Vacancy tests', () => {
await (await page.goto(`${PlatformURI}/workbench/sanity-ws/recruit`))?.finished()
})

test('create-vacancy', async () => {
test('create-vacancy', async ({ page }) => {
const settingsPage: SettingsPage = new SettingsPage(page)
await settingsPage.profileButton().click()
await settingsPage.selectPopupAp('Settings')
const wsPage: WorkspaceSettingsPage = new WorkspaceSettingsPage(page)
await wsPage.owners().click()
await settingsPage.checkOpened('Owners')
await settingsPage.clickButtonRoleInComponent('Appleseed John')
await settingsPage.selectPopupMenu('Owner').click()
const count = await page.locator('div[id="workbench:component:WorkbenchTabs"] div.container.main').count()
for (let i = 1; i < count; i++) {
await page.locator('div[id="workbench:component:WorkbenchTabs"] div.container.main:first-child button').click()
}

const vacancyId = 'My vacancy ' + generateId(4)
await vacanciesPage.createVacancy(vacancyId)
await vacanciesPage.modifyVacancy(vacancyId)
Expand Down
8 changes: 8 additions & 0 deletions tests/sanity/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,11 @@ export async function createAccountAndWorkspace (page: Page, request: APIRequest
await api.createWorkspaceWithLogin(data.workspaceName, data.userName, '1234')
await reLogin(page, data)
}

export const convertDate = (date: Date): { day: string, month: string, year: string } => {
return {
day: date.getDate().toString(),
month: (date.getMonth() + 1).toString(),
year: date.getFullYear().toString()
}
}

0 comments on commit ec696d0

Please sign in to comment.