2024-02-16 14:15:00 +00:00
|
|
|
import { Locator, Page, expect } from '@playwright/test'
|
|
|
|
|
|
|
|
export class Toolbar {
|
|
|
|
readonly toolLock: Locator
|
|
|
|
readonly moreToolsButton: Locator
|
|
|
|
readonly moreToolsPopover: Locator
|
|
|
|
readonly mobileStylesButton: Locator
|
|
|
|
readonly tools: { [key: string]: Locator }
|
|
|
|
readonly popOverTools: { [key: string]: Locator }
|
|
|
|
|
|
|
|
constructor(public readonly page: Page) {
|
|
|
|
this.page = page
|
2024-02-23 14:37:15 +00:00
|
|
|
this.toolLock = this.page.getByTestId('tool-lock')
|
|
|
|
this.moreToolsButton = this.page.getByTestId('tools.more-button')
|
|
|
|
this.moreToolsPopover = this.page.getByTestId('tools.more-content')
|
|
|
|
this.mobileStylesButton = this.page.getByTestId('mobile-styles.button')
|
2024-02-16 14:15:00 +00:00
|
|
|
this.tools = {
|
2024-02-23 14:37:15 +00:00
|
|
|
select: this.page.getByTestId('tools.select'),
|
|
|
|
draw: this.page.getByTestId('tools.draw'),
|
|
|
|
arrow: this.page.getByTestId('tools.arrow'),
|
|
|
|
cloud: this.page.getByTestId('tools.cloud'),
|
|
|
|
eraser: this.page.getByTestId('tools.eraser'),
|
|
|
|
rectangle: this.page.getByTestId('tools.rectangle'),
|
2024-02-16 14:15:00 +00:00
|
|
|
}
|
|
|
|
this.popOverTools = {
|
2024-02-23 14:37:15 +00:00
|
|
|
popoverCloud: this.page.getByTestId('tools.more.cloud'),
|
|
|
|
popoverFrame: this.page.getByTestId('tools.more.frame'),
|
|
|
|
popoverRectangle: this.page.getByTestId('tools.more.rectangle'),
|
2024-02-16 14:15:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
async clickTool(tool: Locator) {
|
|
|
|
await tool.click()
|
|
|
|
}
|
2024-02-23 14:37:15 +00:00
|
|
|
async isSelected(tool: Locator) {
|
2024-02-16 14:15:00 +00:00
|
|
|
// pseudo elements aren't exposed to the DOM, but we can check the color as a proxy
|
2024-02-23 14:37:15 +00:00
|
|
|
const expectedColor = 'rgb(255, 255, 255)'
|
|
|
|
await expect(tool).toHaveCSS('color', expectedColor)
|
|
|
|
}
|
|
|
|
async isNotSelected(tool: Locator) {
|
|
|
|
const expectedColor = 'rgb(46, 46, 46)'
|
2024-02-16 14:15:00 +00:00
|
|
|
await expect(tool).toHaveCSS('color', expectedColor)
|
|
|
|
}
|
|
|
|
}
|