| import { Page } from 'playwright'; |
|
|
| const selectors = { |
| |
| mySiteButton: '[data-tip-target="my-sites"]', |
| mobileMenuButton: '[data-tip-target="mobile-menu"]', |
| editorBackButton: '[data-tip-target="back-home"]', |
| notificationsButton: 'a[href="/notifications"]', |
| meButton: 'a[data-tip-target="me"]', |
| }; |
| |
| |
| |
| export class NavbarComponent { |
| private page: Page; |
|
|
| |
| |
| |
| |
| |
| constructor( page: Page ) { |
| this.page = page; |
| } |
|
|
| |
| |
| |
| |
| |
| async clickMySites(): Promise< void > { |
| await this.page.click( selectors.mySiteButton ); |
| } |
|
|
| |
| |
| |
| |
| |
| async clickMobileMenu(): Promise< void > { |
| await this.page.click( selectors.mobileMenuButton ); |
| } |
|
|
| |
| |
| |
| |
| |
| async clickEditorBackButton(): Promise< void > { |
| await this.page.click( selectors.editorBackButton ); |
| } |
|
|
| |
| |
| |
| async clickMe(): Promise< void > { |
| await Promise.all( [ this.page.waitForNavigation(), this.page.click( selectors.meButton ) ] ); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| async openNotificationsPanel( { |
| useKeyboard = false, |
| }: { useKeyboard?: boolean } = {} ): Promise< void > { |
| if ( useKeyboard ) { |
| return await this.page.keyboard.type( 'n' ); |
| } |
|
|
| const notificationsButtonLocator = this.page.locator( selectors.notificationsButton ); |
|
|
| return await notificationsButtonLocator.click(); |
| } |
| } |
|
|