[go: nahoru, domu]

Skip to content

Commit

Permalink
add custom attribute test and setup (hcengineering#5897)
Browse files Browse the repository at this point in the history
Signed-off-by: Jasmin <jasmin@hardcoreeng.com>
  • Loading branch information
JasminMus committed Jun 21, 2024
1 parent 189feb8 commit 32861f2
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 1 deletion.
90 changes: 90 additions & 0 deletions tests/sanity/tests/custom-atributes/class-properties-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { expect, type Locator, type Page } from '@playwright/test'

export enum DataType {
URL,
String,
Boolean,
Number,
Date,
Ref,
Array,
Enum
}

export class ClassProperties {
readonly page: Page

constructor (page: Page) {
this.page = page
}

url = (): Locator => this.page.getByRole('button', { name: 'URL' })
string = (): Locator => this.page.getByRole('button', { name: 'String' })
boolean = (): Locator => this.page.getByRole('button', { name: 'Boolean' })
number = (): Locator => this.page.getByRole('button', { name: 'Number' })
date = (): Locator => this.page.getByRole('button', { name: 'Date' })
ref = (): Locator => this.page.getByRole('button', { name: 'Ref' })
array = (): Locator => this.page.getByRole('button', { name: 'Array' })
enum = (): Locator => this.page.getByRole('button', { name: 'Enum', exact: true })

addedCustomAttribute = (attribute: string): Locator => this.page.getByRole('button', { name: attribute })
inputName = (): Locator => this.page.getByPlaceholder('Name')
createButton = (): Locator => this.page.getByRole('button', { name: 'Create' })
enterTextString = (): Locator => this.page.getByPlaceholder('Type text...')
confirmChange = (): Locator => this.page.locator('.ml-2 > .antiButton')

async selectDataType (dataType: DataType): Promise<void> {
switch (dataType) {
case DataType.URL:
await this.url().click()
break
case DataType.String:
await this.string().click()
break
case DataType.Boolean:
await this.boolean().click()
break
case DataType.Number:
await this.number().click()
break
case DataType.Date:
await this.date().click()
break
case DataType.Ref:
await this.ref().click()
break
case DataType.Array:
await this.array().click()
break
case DataType.Enum:
await this.enum().click()
break
default:
throw new Error('Unknown data type')
}
}

async clickCustomAttribute (attribute: string): Promise<void> {
await this.addedCustomAttribute(attribute).click()
}

async fillName (name: string): Promise<void> {
await this.inputName().fill(name)
}

async clickCreateButton (): Promise<void> {
await this.createButton().click()
}

async fillEnterTextString (newString: string): Promise<void> {
await this.enterTextString().fill(newString)
}

async clickConfirmChange (): Promise<void> {
await this.confirmChange().click()
}

async checkIfStringIsUpdated (customAttribute: string): Promise<void> {
await expect(this.addedCustomAttribute(customAttribute)).toBeVisible()
}
}
163 changes: 163 additions & 0 deletions tests/sanity/tests/custom-atributes/custom-attributes-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import { expect, type Locator, type Page } from '@playwright/test'

export enum CustomAttributesButtons {
Member,
Contact,
Person,
Employee,
Worker,
Talent,
Company,
Customer,
Vacancy,
DefaultVacancy,
Funnel,
DefaultFunnel,
Project,
ClassicProject,
Board,
Task,
Application,
Applicant,
Lead,
Issue,
Card,
Product
}

export class CustomAttributesPage {
readonly page: Page

constructor (page: Page) {
this.page = page
}

member = (): Locator => this.page.getByRole('button', { name: 'Member' })
contact = (): Locator => this.page.getByRole('button', { name: 'Contact' })
person = (): Locator => this.page.getByRole('button', { name: 'Person' })
employee = (): Locator => this.page.getByRole('button', { name: 'Employee' })
worker = (): Locator => this.page.getByRole('button', { name: 'Worker' })
talent = (): Locator => this.page.getByRole('button', { name: 'Talent' })
company = (): Locator => this.page.getByRole('button', { name: 'Company' })
customer = (): Locator => this.page.getByRole('button', { name: 'Customer' })
vacancy = (): Locator => this.page.getByRole('button', { name: 'Vacancy', exact: true })
defaultVacancy = (): Locator => this.page.getByRole('button', { name: 'Default vacancy', exact: true })
funnel = (): Locator => this.page.getByRole('button', { name: 'Funnel', exact: true })
defaultFunnel = (): Locator => this.page.getByRole('button', { name: 'Default funnel' })
project = (): Locator => this.page.getByRole('button', { name: 'Project', exact: true })
classicProject = (): Locator => this.page.getByRole('button', { name: 'Classic project', exact: true })
board = (): Locator => this.page.getByRole('button', { name: 'Board' })
task = (): Locator => this.page.getByRole('button', { name: 'Task' })
application = (): Locator => this.page.getByRole('button', { name: 'Application' })
applicant = (): Locator => this.page.getByRole('button', { name: 'Applicant' })
lead = (): Locator => this.page.getByRole('button', { name: 'Lead' })
issue = (): Locator => this.page.getByRole('button', { name: 'Issue' })
card = (): Locator => this.page.getByRole('button', { name: 'Card' })
product = (): Locator => this.page.getByRole('button', { name: 'Product' })

addAttribute = (): Locator => this.page.locator('.hulyTableAttr-header > .font-medium-14')

async clickAddAttribute (): Promise<void> {
await this.addAttribute().click()
}

async selectEntityTab (button: CustomAttributesButtons): Promise<void> {
switch (button) {
case CustomAttributesButtons.Member:
await this.member().click()
break
case CustomAttributesButtons.Contact:
await this.contact().click()
break
case CustomAttributesButtons.Person:
await this.person().click()
break
case CustomAttributesButtons.Employee:
await this.employee().click()
break
case CustomAttributesButtons.Worker:
await this.worker().click()
break
case CustomAttributesButtons.Talent:
await this.talent().click()
break
case CustomAttributesButtons.Company:
await this.company().click()
break
case CustomAttributesButtons.Customer:
await this.customer().click()
break
case CustomAttributesButtons.Vacancy:
await this.vacancy().click()
break
case CustomAttributesButtons.DefaultVacancy:
await this.defaultVacancy().click()
break
case CustomAttributesButtons.Funnel:
await this.funnel().click()
break
case CustomAttributesButtons.DefaultFunnel:
await this.defaultFunnel().click()
break
case CustomAttributesButtons.Project:
await this.project().click()
break
case CustomAttributesButtons.ClassicProject:
await this.classicProject().click()
break
case CustomAttributesButtons.Board:
await this.board().click()
break
case CustomAttributesButtons.Task:
await this.task().click()
break
case CustomAttributesButtons.Application:
await this.application().click()
break
case CustomAttributesButtons.Applicant:
await this.applicant().click()
break
case CustomAttributesButtons.Lead:
await this.lead().click()
break
case CustomAttributesButtons.Issue:
await this.issue().click()
break
case CustomAttributesButtons.Card:
await this.card().click()
break
case CustomAttributesButtons.Product:
await this.product().click()
break
default:
throw new Error('Unknown button type')
}
}

async checkIfClassesExists (): Promise<void> {
await expect(this.member()).toBeVisible()
await expect(this.contact()).toBeVisible()
await expect(this.person()).toBeVisible()
await expect(this.employee()).toBeVisible()
await expect(this.worker()).toBeVisible()
await expect(this.talent()).toBeVisible()
await expect(this.company()).toBeVisible()
await expect(this.customer()).toBeVisible()
await expect(this.vacancy()).toBeVisible()
await expect(this.defaultVacancy()).toBeVisible()
await expect(this.funnel()).toBeVisible()
await expect(this.defaultFunnel()).toBeVisible()
await expect(this.project()).toBeVisible()
await expect(this.classicProject()).toBeVisible()
await expect(this.board()).toBeVisible()
await expect(this.task()).toBeVisible()
await expect(this.application()).toBeVisible()
await expect(this.applicant()).toBeVisible()
await expect(this.lead().nth(0)).toBeVisible()
await expect(this.lead().nth(1)).toBeVisible()
await expect(this.issue().nth(0)).toBeVisible()
await expect(this.issue().nth(1)).toBeVisible()
await expect(this.card()).toBeVisible()
await expect(this.product()).toBeVisible()
}
}
93 changes: 93 additions & 0 deletions tests/sanity/tests/custom-atributes/custom-attributes.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { test } from '@playwright/test'
import { PlatformURI, generateId, generateTestData } from '../utils'
import { LeftSideMenuPage } from '../model/left-side-menu-page'
import { ApiEndpoint } from '../API/Api'
import { LoginPage } from '../model/login-page'
import { faker } from '@faker-js/faker'
import { WorkspaceSettingsPage, ButtonType } from '../model/workspace/workspace-settings-page'
import { UserProfilePage } from '../model/profile/user-profile-page'
import { CustomAttributesPage, CustomAttributesButtons } from './custom-attributes-page'
import { ClassProperties, DataType } from './class-properties-page'
import { NewCompany } from '../model/recruiting/types'
import { NavigationMenuPage } from '../model/recruiting/navigation-menu-page'
import { CompaniesPage } from '../model/recruiting/companies-page'
import { CompanyDetailsPage } from '../model/recruiting/company-details-page'

test.describe('Custom attributes tests', () => {
let leftSideMenuPage: LeftSideMenuPage
let loginPage: LoginPage
let userProfilePage: UserProfilePage
let workspaceSettingsPage: WorkspaceSettingsPage
let customAttributesPage: CustomAttributesPage
let classProperties: ClassProperties
let navigationMenuPage: NavigationMenuPage
let companyDetailsPage: CompanyDetailsPage
let companiesPage: CompaniesPage
let api: ApiEndpoint
let data: { workspaceName: string, userName: string, firstName: string, lastName: string, channelName: string }

test.beforeEach(async ({ page, request }) => {
data = generateTestData()
leftSideMenuPage = new LeftSideMenuPage(page)
loginPage = new LoginPage(page)
userProfilePage = new UserProfilePage(page)
workspaceSettingsPage = new WorkspaceSettingsPage(page)
customAttributesPage = new CustomAttributesPage(page)
classProperties = new ClassProperties(page)
navigationMenuPage = new NavigationMenuPage(page)
companiesPage = new CompaniesPage(page)
companyDetailsPage = new CompanyDetailsPage(page)
api = new ApiEndpoint(request)
await api.createAccount(data.userName, '1234', data.firstName, data.lastName)
await api.createWorkspaceWithLogin(data.workspaceName, data.userName, '1234')
await (await page.goto(`${PlatformURI}`))?.finished()
await loginPage.login(data.userName, '1234')
await (await page.goto(`${PlatformURI}/workbench/${data.workspaceName}`))?.finished()
})

test('Check if all custom attributes exists', async ({ browser, page }) => {
await userProfilePage.openProfileMenu()
await userProfilePage.clickSettings()
await workspaceSettingsPage.selectWorkspaceSettingsTab(ButtonType.Classes)
await customAttributesPage.checkIfClassesExists()
})

test('create company add custom string attribute and check if it exists in member section', async ({
browser,
page
}) => {
const customAttribute = faker.word.words()
const addStringCustomAttribute = faker.word.words()
const newCompany: NewCompany = {
name: `Create a new Company test-${generateId()}`,
socials: [
{
type: 'Phone',
value: '3213221321213'
},
{
type: 'Email',
value: 'test+321313123@gmail.com'
}
]
}
await userProfilePage.openProfileMenu()
await userProfilePage.clickSettings()
await workspaceSettingsPage.selectWorkspaceSettingsTab(ButtonType.Classes)
await customAttributesPage.selectEntityTab(CustomAttributesButtons.Member)
await customAttributesPage.clickAddAttribute()
await classProperties.selectDataType(DataType.String)
await classProperties.fillName(customAttribute)
await classProperties.clickCreateButton()
await leftSideMenuPage.clickRecruiting()

await navigationMenuPage.clickButtonCompanies()
await companiesPage.createNewCompany(newCompany)
await companiesPage.openCompanyByName(newCompany.name)
await companyDetailsPage.addMember(data.lastName + ' ' + data.firstName)
await classProperties.clickCustomAttribute(customAttribute)
await classProperties.fillEnterTextString(addStringCustomAttribute)
await classProperties.clickConfirmChange()
await classProperties.checkIfStringIsUpdated(addStringCustomAttribute)
})
})
5 changes: 5 additions & 0 deletions tests/sanity/tests/model/left-side-menu-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class LeftSideMenuPage extends CommonPage {
buttonChunter = (): Locator => this.page.locator('button[id$="ApplicationLabelChunter"]')
buttonContacts = (): Locator => this.page.locator('button[id$="Contacts"]')
buttonTracker = (): Locator => this.page.locator('button[id$="TrackerApplication"]')
buttonRecruiting = (): Locator => this.page.locator('[id="app-recruit\\:string\\:RecruitApplication"]')
buttonNotification = (): Locator => this.page.locator('button[id$="Inbox"]')
buttonDocuments = (): Locator => this.page.locator('button[id$="document:string:DocumentApplication"]')
profileButton = (): Locator => this.page.locator('#profile-button')
Expand Down Expand Up @@ -52,6 +53,10 @@ export class LeftSideMenuPage extends CommonPage {
await this.buttonDocuments().click()
}

async clickRecruiting (): Promise<void> {
await this.buttonRecruiting().click()
}

async clickOnCloseInvite (): Promise<void> {
await this.clickCloseOnInviteLinkButton().click()
}
Expand Down
10 changes: 10 additions & 0 deletions tests/sanity/tests/model/recruiting/company-details-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export class CompanyDetailsPage extends CommonRecruitingPage {
readonly buttonLocation = (): Locator =>
this.page.locator('//span[text()="Location"]/following-sibling::div[1]/button/span')

readonly addMemberButton = (): Locator => this.page.locator('[id="contact\\:string\\:AddMember"]')
readonly selectMember = (memberName: string): Locator => this.page.getByRole('button', { name: memberName })
readonly member = (memberName: string): Locator => this.page.getByRole('link', { name: memberName })

async checkCompany (data: NewCompany): Promise<void> {
await expect(this.inputName()).toHaveValue(data.name)
if (data.socials != null) {
Expand All @@ -41,4 +45,10 @@ export class CompanyDetailsPage extends CommonRecruitingPage {
await this.fillToSelectPopup(this.page, data.location)
}
}

async addMember (member: string): Promise<void> {
await this.addMemberButton().click()
await this.selectMember(member).click()
await this.member(member).click()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class WorkspaceSettingsPage {
branding = (): Locator => this.page.getByRole('button', { name: 'Branding' })
textTemplate = (): Locator => this.page.getByRole('button', { name: 'Text Templates' })
relatedIssues = (): Locator => this.page.getByRole('button', { name: 'Related issues' })
classes = (): Locator => this.page.getByRole('button', { name: 'Classes' })
classes = (): Locator => this.page.locator('#navGroup-setting').getByRole('button', { name: 'Classes' })
enums = (): Locator => this.page.getByRole('button', { name: 'Enums' })
inviteSettings = (): Locator => this.page.getByRole('button', { name: 'Invite settings' })

Expand Down

0 comments on commit 32861f2

Please sign in to comment.