|
| 1 | +import type {Locator, Page} from '@playwright/test'; |
| 2 | + |
| 3 | +import {VISIBILITY_TIMEOUT} from '../../TenantPage'; |
| 4 | + |
| 5 | +export enum TemplateCategory { |
| 6 | + Tables = 'Tables', |
| 7 | + Topics = 'Topics', |
| 8 | + AsyncReplication = 'Async replication', |
| 9 | + CDC = 'Change data capture', |
| 10 | + Users = 'Users', |
| 11 | +} |
| 12 | + |
| 13 | +export enum AsyncReplicationTemplates { |
| 14 | + Create = 'Create async replication', |
| 15 | + Alter = 'Alter async replication', |
| 16 | + Drop = 'Drop async replication', |
| 17 | +} |
| 18 | + |
| 19 | +export class NewSqlDropdownMenu { |
| 20 | + private dropdownButton: Locator; |
| 21 | + private menu: Locator; |
| 22 | + private subMenu: Locator; |
| 23 | + |
| 24 | + constructor(page: Page) { |
| 25 | + this.dropdownButton = page.locator( |
| 26 | + '.ydb-query-editor-controls .g-dropdown-menu__switcher-wrapper button', |
| 27 | + ); |
| 28 | + this.menu = page.locator('.g-dropdown-menu__menu'); |
| 29 | + this.subMenu = page.locator('.g-dropdown-menu__sub-menu'); |
| 30 | + } |
| 31 | + |
| 32 | + async clickNewSqlButton() { |
| 33 | + await this.dropdownButton.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); |
| 34 | + await this.dropdownButton.click(); |
| 35 | + } |
| 36 | + |
| 37 | + async hoverCategory(category: TemplateCategory) { |
| 38 | + const categoryItem = this.menu.getByRole('menuitem').filter({hasText: category}); |
| 39 | + await categoryItem.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); |
| 40 | + await categoryItem.hover(); |
| 41 | + } |
| 42 | + |
| 43 | + async selectTemplate(template: AsyncReplicationTemplates) { |
| 44 | + const templateItem = this.subMenu.getByRole('menuitem').filter({hasText: template}); |
| 45 | + await templateItem.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); |
| 46 | + await templateItem.click(); |
| 47 | + } |
| 48 | + |
| 49 | + async isMenuVisible() { |
| 50 | + await this.menu.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); |
| 51 | + return true; |
| 52 | + } |
| 53 | + |
| 54 | + async isSubMenuVisible() { |
| 55 | + await this.subMenu.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); |
| 56 | + return true; |
| 57 | + } |
| 58 | +} |
0 commit comments