New Sidebar tests + fix flaky tests (#6664)

This commit is contained in:
Rostislav Nazmeev 2024-09-23 03:56:49 +02:00 committed by GitHub
parent 6f4713d603
commit 52ac3fee30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 324 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import { SignUpData } from '../model/common-types'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
import { LoginPage } from '../model/login-page'
import { SelectWorkspacePage } from '../model/select-workspace-page'
import { SidebarPage } from '../model/sidebar-page'
import {
PlatformURI,
generateTestData,
@ -19,6 +20,7 @@ test.describe('Channel tests', () => {
let leftSideMenuPage: LeftSideMenuPage
let chunterPage: ChunterPage
let channelPage: ChannelPage
let sidebarPage: SidebarPage
let loginPage: LoginPage
let api: ApiEndpoint
let newUser2: SignUpData
@ -32,6 +34,7 @@ test.describe('Channel tests', () => {
chunterPage = new ChunterPage(page)
channelPage = new ChannelPage(page)
loginPage = new LoginPage(page)
sidebarPage = new SidebarPage(page)
api = new ApiEndpoint(request)
await api.createAccount(data.userName, '1234', data.firstName, data.lastName)
await api.createWorkspaceWithLogin(data.workspaceName, data.userName, '1234')
@ -395,7 +398,7 @@ test.describe('Channel tests', () => {
await channelPageSecond.checkMessageExist(`@${mentionName}`, true, `@${mentionName}`)
})
test('User can star and unstar a channel', async () => {
test('User is able to star and unstar a channel', async () => {
await test.step('Prepare channel', async () => {
await leftSideMenuPage.clickChunter()
await chunterPage.clickChannelBrowser()
@ -419,7 +422,7 @@ test.describe('Channel tests', () => {
})
})
test('User can leave and join a channel', async () => {
test('User is able to leave and join a channel', async () => {
await test.step('Prepare channel', async () => {
await leftSideMenuPage.clickChunter()
await chunterPage.clickChannelBrowser()
@ -461,7 +464,7 @@ test.describe('Channel tests', () => {
})
})
test('User can filter channels in table', async () => {
test('User is able to filter channels in table', async () => {
await test.step('Prepare channel', async () => {
await leftSideMenuPage.clickChunter()
await chunterPage.clickChannelBrowser()
@ -486,7 +489,7 @@ test.describe('Channel tests', () => {
})
})
test('User can search channel in table', async () => {
test('User is able to search channel in table', async () => {
await test.step('Prepare channel', async () => {
await leftSideMenuPage.clickChunter()
await chunterPage.clickChannelBrowser()
@ -512,4 +515,110 @@ test.describe('Channel tests', () => {
await channelPage.checkIfChannelTableExist('general', true)
})
})
test('User is able to work with a channel in a sidebar', async () => {
await test.step('Prepare channel', async () => {
await leftSideMenuPage.clickChunter()
await chunterPage.clickChannelBrowser()
await chunterPage.clickNewChannelHeader()
await chunterPage.createPrivateChannel(data.channelName, false)
await channelPage.checkIfChannelDefaultExist(true, data.channelName)
await leftSideMenuPage.clickChunter()
await channelPage.clickChooseChannel(data.channelName)
await channelPage.sendMessage('Test message')
})
await test.step('Open channel in sidebar', async () => {
await sidebarPage.checkIfSidebarPageButtonIsExist(false, 'chat')
await channelPage.makeActionWithChannelInMenu(data.channelName, 'Open in sidebar')
await sidebarPage.checkIfSidebarPageButtonIsExist(true, 'chat')
await sidebarPage.checkIfSidebarHasVerticalTab(true, data.channelName)
await sidebarPage.checkIfSidebarIsOpen(true)
await sidebarPage.checkIfChatSidebarTabIsOpen(true, data.channelName)
})
await test.step('Go to another page and check if sidebar will be keeping', async () => {
await leftSideMenuPage.clickTracker()
await sidebarPage.checkIfSidebarIsOpen(true)
await sidebarPage.checkIfChatSidebarTabIsOpen(true, data.channelName)
await leftSideMenuPage.clickChunter()
})
await test.step('Close channel in sidebar', async () => {
await sidebarPage.closeOpenedVerticalTab()
await sidebarPage.checkIfSidebarHasVerticalTab(false, data.channelName)
await sidebarPage.checkIfSidebarIsOpen(false)
})
await test.step('Reopen channel in sidebar', async () => {
await channelPage.makeActionWithChannelInMenu(data.channelName, 'Open in sidebar')
await sidebarPage.checkIfSidebarHasVerticalTab(true, data.channelName)
await sidebarPage.checkIfChatSidebarTabIsOpen(true, data.channelName)
})
await test.step('Open general in sidebar too', async () => {
await channelPage.makeActionWithChannelInMenu('general', 'Open in sidebar')
await sidebarPage.checkIfSidebarHasVerticalTab(true, data.channelName)
await sidebarPage.checkIfSidebarHasVerticalTab(true, 'general')
await sidebarPage.checkIfChatSidebarTabIsOpen(true, 'general')
})
await test.step('Pin and unpin channel tab', async () => {
await sidebarPage.pinVerticalTab(data.channelName)
await sidebarPage.checkIfVerticalTabIsPinned(true, data.channelName)
await sidebarPage.unpinVerticalTab(data.channelName)
await sidebarPage.checkIfVerticalTabIsPinned(false, data.channelName)
})
await test.step('Close sidebar tab by close button in vertical tab', async () => {
await sidebarPage.clickVerticalTab(data.channelName)
await sidebarPage.closeVerticalTabByCloseButton(data.channelName)
await sidebarPage.checkIfSidebarHasVerticalTab(false, data.channelName)
await sidebarPage.checkIfChatSidebarTabIsOpen(true, 'general')
})
await test.step('Close sidebar tab by context menu', async () => {
await channelPage.makeActionWithChannelInMenu('random', 'Open in sidebar')
await sidebarPage.closeVerticalTabByRightClick('random')
await sidebarPage.checkIfSidebarHasVerticalTab(false, 'random')
await sidebarPage.checkIfChatSidebarTabIsOpen(true, 'general')
})
await test.step('Close the last channel tab in Sidebar', async () => {
await sidebarPage.closeVerticalTabByCloseButton('general')
await sidebarPage.checkIfSidebarIsOpen(false)
await sidebarPage.checkIfSidebarPageButtonIsExist(false, 'chat')
})
})
test('User is able to create thread automatically in Sidebar', async () => {
await test.step('Prepare channel', async () => {
await leftSideMenuPage.clickChunter()
await chunterPage.clickChannelBrowser()
await chunterPage.clickNewChannelHeader()
await chunterPage.createPrivateChannel(data.channelName, false)
await channelPage.checkIfChannelDefaultExist(true, data.channelName)
await leftSideMenuPage.clickChunter()
await channelPage.clickChooseChannel(data.channelName)
await channelPage.sendMessage('Test message')
})
await test.step('Open channel in Sidebar', async () => {
await channelPage.replyToMessage('Test message', 'Reply message')
await sidebarPage.checkIfSidebarIsOpen(true)
await sidebarPage.checkIfSidebarHasVerticalTab(true, data.channelName)
await sidebarPage.checkIfChatSidebarTabIsOpen(true, 'Thread')
await sidebarPage.checkIfChatSidebarTabIsOpen(true, data.channelName)
})
await test.step('User go to another chat and Sidebar with tread disappears', async () => {
await channelPage.clickChannel('random')
await sidebarPage.checkIfSidebarIsOpen(false)
})
})
})

View File

@ -151,7 +151,7 @@ test.describe('Content in the Documents tests', () => {
})
test.describe('Image in the document', () => {
test('Check Image alignment setting', async ({ page }) => {
test('Check image alignment setting', async ({ page }) => {
await documentContentPage.addImageToDocument(page)
await test.step('Align image to right', async () => {
@ -170,9 +170,8 @@ test.describe('Content in the Documents tests', () => {
})
})
test.skip('Check Image view and size actions', async ({ page }) => {
test.skip('Check Image size manipulations', async ({ page }) => {
await documentContentPage.addImageToDocument(page)
const imageSrc = await documentContentPage.firstImageInDocument().getAttribute('src')
await test.step('Set size of image to the 25%', async () => {
await documentContentPage.clickImageSizeButton('25%')
@ -194,6 +193,11 @@ test.describe('Content in the Documents tests', () => {
await documentContentPage.clickImageSizeButton('Unset')
await documentContentPage.checkImageSize(IMAGE_ORIGINAL_SIZE)
})
})
test('Check Image views', async ({ page, context }) => {
await documentContentPage.addImageToDocument(page)
const imageSrc = await documentContentPage.firstImageInDocument().getAttribute('src')
await test.step('User can open image in fullscreen on current page', async () => {
await documentContentPage.clickImageFullscreenButton()
@ -203,12 +207,11 @@ test.describe('Content in the Documents tests', () => {
})
await test.step('User can open image original in the new tab', async () => {
const [newPage] = await Promise.all([
page.waitForEvent('popup'),
documentContentPage.clickImageOriginalButton()
])
const pagePromise = context.waitForEvent('page')
await documentContentPage.clickImageOriginalButton()
const newPage = await pagePromise
await newPage.waitForLoadState('domcontentloaded')
await newPage.waitForLoadState()
expect(newPage.url()).toBe(imageSrc)
await newPage.close()
})

View File

@ -16,7 +16,7 @@ export class CommonPage {
selectPopupButton = (): Locator => this.page.locator('div.selectPopup button')
selectPopupExpandButton = (): Locator => this.page.locator('div.selectPopup button[data-id="btnExpand"]')
popupSpanLabel = (point: string): Locator =>
this.page.locator('div[class$="opup"] span[class*="label"]', { hasText: point })
this.page.locator(`div[class$="opup"] span[class*="label"]:has-text("${point}")`)
readonly inputSearchIcon = (): Locator => this.page.locator('.searchInput-icon')

View File

@ -16,6 +16,7 @@ export class PlanningPage extends CalendarPage {
private readonly panel = (): Locator => this.page.locator('div.hulyModal-container')
private readonly toDosContainer = (): Locator => this.page.locator('div.toDos-container')
private readonly schedule = (): Locator => this.page.locator('div.hulyComponent.modal')
private readonly sidebarSchedule = (): Locator => this.page.locator('#sidebar .calendar-container')
readonly pageHeader = (): Locator =>
this.page.locator('div[class*="navigator"] div[class*="header"]', { hasText: 'Planning' })
@ -81,6 +82,9 @@ export class PlanningPage extends CalendarPage {
readonly eventInSchedule = (title: string): Locator =>
this.schedule().locator('div.event-container', { hasText: title })
readonly eventInSidebarSchedule = (title: string): Locator =>
this.sidebarSchedule().locator('div.event-container', { hasText: title })
readonly toDoInToDos = (hasText: string): Locator =>
this.toDosContainer().locator('button.hulyToDoLine-container', { hasText })

View File

@ -19,12 +19,13 @@ export class TalentDetailsPage extends CommonRecruitingPage {
readonly buttonMergeContacts = (): Locator =>
this.page.locator('button[class*="menuItem"] span', { hasText: 'Merge contacts' })
readonly buttonFinalContact = (): Locator =>
this.page.locator('form[id="contact:string:MergePersons"] button', { hasText: 'Final contact' })
readonly formMergeContacts = (): Locator => this.page.locator('form[id="contact:string:MergePersons"]')
readonly buttonMergeRow = (): Locator => this.page.locator('form[id="contact:string:MergePersons"] div.box')
readonly buttonFinalContact = (): Locator => this.formMergeContacts().locator('button', { hasText: 'Final contact' })
readonly buttonMergeRow = (): Locator => this.formMergeContacts().locator('div.box')
readonly buttonPopupMergeContacts = (): Locator =>
this.page.locator('form[id="contact:string:MergePersons"] button > span', { hasText: 'Merge contacts' })
this.formMergeContacts().locator('button:has-text("Merge contacts")')
readonly textAttachmentName = (): Locator => this.page.locator('div.name a')
readonly titleAndSourceTalent = (title: string): Locator => this.page.locator('button > span', { hasText: title })
@ -42,6 +43,12 @@ export class TalentDetailsPage extends CommonRecruitingPage {
await expect(this.textTagItem().first()).toContainText(skillTag)
}
async enterLocation (location: string): Promise<void> {
const input = this.inputLocation()
await input.click()
await input.fill(location)
}
async addTitle (title: string): Promise<void> {
await this.buttonInputTitle().click()
await this.fillToSelectPopup(this.page, title)
@ -97,8 +104,8 @@ export class TalentDetailsPage extends CommonRecruitingPage {
}
}
async checkMergeContacts (talentName: string, title: string, source: string): Promise<void> {
await expect(this.page.locator('div.location input')).toHaveValue(talentName)
async checkMergeContacts (location: string, title: string, source: string): Promise<void> {
await expect(this.page.locator('div.location input')).toHaveValue(location)
await expect(this.titleAndSourceTalent(title)).toBeVisible()
await expect(this.titleAndSourceTalent(source)).toBeVisible()
}

View File

@ -0,0 +1,120 @@
import { expect, Locator, Page } from '@playwright/test'
import { CommonPage } from './common-page'
export type SidebarTabTypes = 'calendar' | 'office' | 'chat'
export class SidebarPage extends CommonPage {
readonly page: Page
constructor (page: Page) {
super(page)
this.page = page
}
sidebar = (): Locator => this.page.locator('#sidebar')
content = (): Locator => this.sidebar().locator('.content')
contentHeaderByTitle = (title: string): Locator =>
this.content().locator(`.hulyHeader-titleGroup:has-text("${title}")`)
contentCloseButton = (): Locator => this.content().locator('.hulyHeader-container button.iconOnly').last()
calendarSidebarButton = (): Locator => this.sidebar().locator('button[id$="Calendar"]')
officeSidebarButton = (): Locator => this.sidebar().locator('button[id$="Office"]')
chatSidebarButton = (): Locator => this.sidebar().locator('button[id$="Chat"]')
verticalTabs = (): Locator => this.sidebar().locator('.tabs').locator('.container')
verticalTabByName = (name: string): Locator =>
this.sidebar().locator('.tabs').locator(`.container:has-text("${name}")`)
verticalTabCloseButton = (name: string): Locator => this.verticalTabByName(name).locator('.close-button button')
currentYear = new Date().getFullYear().toString()
plannerSidebarNextDayButton = (): Locator =>
this.sidebar().locator('.hulyHeader-buttonsGroup').getByRole('button').last()
// buttonOpenChannelInSidebar =
// Actions
async checkIfSidebarIsOpen (isOpen: boolean): Promise<void> {
await expect(this.content()).toBeVisible({ visible: isOpen })
}
async checkIfSidebarHasVerticalTab (isExist: boolean, tabName: string): Promise<void> {
await expect(this.verticalTabByName(tabName)).toBeVisible({ visible: isExist })
}
async clickVerticalTab (tabName: string): Promise<void> {
await this.verticalTabByName(tabName).click()
}
async closeVerticalTabByCloseButton (tabName: string): Promise<void> {
await this.verticalTabCloseButton(tabName).click()
}
async closeOpenedVerticalTab (): Promise<void> {
await this.contentCloseButton().click()
}
async pinVerticalTab (tabName: string): Promise<void> {
await this.verticalTabByName(tabName).click({ button: 'right' })
await this.page.locator('.popup').locator('button:has-text("Pin")').click()
}
async unpinVerticalTab (tabName: string): Promise<void> {
await this.verticalTabByName(tabName).click({ button: 'right' })
await this.page.locator('.popup').locator('button:has-text("Unpin")').click()
}
async closeVerticalTabByRightClick (tabName: string): Promise<void> {
await this.verticalTabByName(tabName).click({ button: 'right' })
await this.page.locator('.popup').locator('button:has-text("Close")').click()
}
async checkIfVerticalTabIsPinned (needBePinned: boolean, tabName: string): Promise<void> {
await expect(this.verticalTabCloseButton(tabName)).toBeVisible({ visible: !needBePinned })
}
async checkNumberOfVerticalTabs (count: number): Promise<void> {
await expect(this.verticalTabs()).toHaveCount(count)
}
async checkIfPlanerSidebarTabIsOpen (isExist: boolean): Promise<void> {
await expect(this.contentHeaderByTitle(this.currentYear)).toBeVisible({ visible: isExist })
}
async checkIfChatSidebarTabIsOpen (isExist: boolean, channelName: string): Promise<void> {
await expect(this.contentHeaderByTitle(channelName)).toBeVisible({ visible: isExist })
}
async checkIfOfficeSidebarTabIsOpen (isExist: boolean, channelName: string): Promise<void> {
await expect(this.contentHeaderByTitle('Office')).toBeVisible({ visible: isExist })
}
async checkIfSidebarPageButtonIsExist (isExist: boolean, type: SidebarTabTypes): Promise<void> {
switch (type) {
case 'chat':
await expect(this.chatSidebarButton()).toBeVisible({ visible: isExist })
break
case 'office':
await expect(this.officeSidebarButton()).toBeVisible({ visible: isExist })
break
case 'calendar':
await expect(this.calendarSidebarButton()).toBeVisible({ visible: isExist })
break
}
}
async clickSidebarPageButton (type: SidebarTabTypes): Promise<void> {
switch (type) {
case 'chat':
await this.chatSidebarButton().click()
break
case 'office':
await this.officeSidebarButton().click()
break
case 'calendar':
await this.calendarSidebarButton().click()
break
}
}
}

View File

@ -1,5 +1,13 @@
import { test } from '@playwright/test'
import { generateId, PlatformSetting, PlatformURI, generateTestData, getTimeForPlanner } from '../utils'
import {
generateId,
PlatformSetting,
PlatformURI,
generateTestData,
getTimeForPlanner,
getSecondPageByInvite,
getInviteLink
} from '../utils'
import { PlanningPage } from '../model/planning/planning-page'
import { NewToDo } from '../model/planning/types'
import { PlanningNavigationMenuPage } from '../model/planning/planning-navigation-menu-page'
@ -9,9 +17,10 @@ import { faker } from '@faker-js/faker'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
import { ApiEndpoint } from '../API/Api'
import { LoginPage } from '../model/login-page'
import { SignInJoinPage } from '../model/signin-page'
import { SidebarPage } from '../model/sidebar-page'
import { TeamPage } from '../model/team-page'
import { SelectWorkspacePage } from '../model/select-workspace-page'
import { ChannelPage } from '../model/channel-page'
test.use({
storageState: PlatformSetting
@ -171,6 +180,9 @@ test.describe('Planning ToDo tests', () => {
test('Adding ToDo by dragging and checking visibility in the Team Planner', async ({ browser, page, request }) => {
const data: TestData = generateTestData()
const leftMenuPage = new LeftSideMenuPage(page)
const channelPage = new ChannelPage(page)
const newUser2: SignUpData = {
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
@ -213,16 +225,11 @@ test.describe('Planning ToDo tests', () => {
await planningPage.buttonPopupOnlyVisibleToYou().click()
await planningPage.buttonPopupSave().click()
await leftSideMenuPage.openProfileMenu()
await leftSideMenuPage.inviteToWorkspace()
await leftSideMenuPage.getInviteLink()
const linkText = await page.locator('.antiPopup .link').textContent()
const page2 = await browser.newPage()
const leftSideMenuPageSecond = new LeftSideMenuPage(page2)
const linkText = await getInviteLink(page)
await api.createAccount(newUser2.email, newUser2.password, newUser2.firstName, newUser2.lastName)
await page2.goto(linkText ?? '')
const joinPage = new SignInJoinPage(page2)
await joinPage.join(newUser2)
using _page2 = await getSecondPageByInvite(browser, linkText, newUser2)
const page2 = _page2.page
const leftSideMenuPageSecond = new LeftSideMenuPage(page2)
await leftSideMenuPageSecond.clickTeam()
const teamPage = new TeamPage(page2)
@ -234,6 +241,40 @@ test.describe('Planning ToDo tests', () => {
.locator('div.item', { hasText: 'Busy 30m' })
.isVisible()
await page2.close()
await test.step('Go to another page to check work in Sidebar', async () => {
await leftMenuPage.clickChunter()
await channelPage.clickChannel('general')
})
const sidebarPage = new SidebarPage(page)
await test.step('Check visibility of task in sidebar planner', async () => {
await sidebarPage.clickSidebarPageButton('calendar')
await sidebarPage.checkIfPlanerSidebarTabIsOpen(true)
})
await test.step('Change event title from sidebar calendar', async () => {
await sidebarPage.plannerSidebarNextDayButton().click()
await planningPage.eventInSidebarSchedule(titleV).click()
await planningPage.buttonPopupCreateVisible().click()
await planningPage.buttonPopupOnlyVisibleToYou().click()
await planningPage.buttonPopupSave().click()
})
})
test('User is able to open Planner in Sidebar', async ({ browser, page, request }) => {
const leftMenuPage = new LeftSideMenuPage(page)
const channelPage = new ChannelPage(page)
await test.step('Go to any another page', async () => {
await leftMenuPage.clickChunter()
await channelPage.clickChannel('general')
})
await test.step('Open planner via sidebar icon button', async () => {
const sidebarPage = new SidebarPage(page)
await sidebarPage.clickSidebarPageButton('calendar')
await sidebarPage.checkIfPlanerSidebarTabIsOpen(true)
})
})
})

View File

@ -74,11 +74,15 @@ test.describe('candidate/talents tests', () => {
})
test('Merge contacts', async () => {
const firstLocation = 'Location 1'
const secondLocation = 'Location 2'
await navigationMenuPage.clickButtonTalents()
// talent1
const talentNameFirst = await talentsPage.createNewTalent()
await talentsPage.openTalentByTalentName(talentNameFirst)
await talentDetailsPage.inputLocation().fill('Awesome Location Merge1')
await talentDetailsPage.enterLocation(firstLocation)
const titleTalent1 = 'TitleMerge1'
await talentDetailsPage.addTitle(titleTalent1)
const sourceTalent1 = 'SourceTalent1'
@ -89,7 +93,8 @@ test.describe('candidate/talents tests', () => {
await navigationMenuPage.clickButtonTalents()
const talentNameSecond = await talentsPage.createNewTalent()
await talentsPage.openTalentByTalentName(talentNameSecond)
await talentDetailsPage.inputLocation().fill('Awesome Location Merge2')
await talentDetailsPage.enterLocation(secondLocation)
const titleTalent2 = 'TitleMerge2'
await talentDetailsPage.addTitle(titleTalent2)
const sourceTalent2 = 'SourceTalent2'
@ -104,7 +109,7 @@ test.describe('candidate/talents tests', () => {
finalContactName: talentNameSecond.lastName,
name: `${talentNameFirst.lastName} ${talentNameFirst.firstName}`,
mergeLocation: true,
location: 'Awesome Location Merge1',
location: firstLocation,
mergeTitle: true,
title: titleTalent1,
mergeSource: true,
@ -116,7 +121,7 @@ test.describe('candidate/talents tests', () => {
await talentsPage.openTalentByTalentName(talentNameFirst)
await talentDetailsPage.checkSocialLinks('Phone', '123123213213')
await talentDetailsPage.checkSocialLinks('Email', 'test-merge-2@gmail.com')
await talentDetailsPage.checkMergeContacts('Awesome Location Merge1', titleTalent2, sourceTalent2)
await talentDetailsPage.checkMergeContacts(firstLocation, titleTalent2, sourceTalent2)
})
test('Match to vacancy', async () => {