| | import { Page } from 'playwright'; |
| | import { getCalypsoURL } from '../../data-helper'; |
| | import { clickNavTab } from '../../element-helper'; |
| |
|
| | type MarketingPageTab = |
| | | 'Marketing Tools' |
| | | 'Traffic' |
| | | 'Connections' |
| | | 'Sharing Buttons' |
| | | 'Business Tools'; |
| | type SEOPageTitleStructureCategories = 'Front Page' | 'Posts' | 'Pages' | 'Tags' | 'Archives'; |
| | type SEOExternalServices = 'Google search' | 'Facebook' | 'Twitter'; |
| | type SocialConnection = 'Facebook' | 'LinkedIn' | 'Tumblr' | 'Mastodon' | 'Instagram Business'; |
| |
|
| | const selectors = { |
| | pageTitleStructureInput: '.title-format-editor', |
| | }; |
| |
|
| | |
| | |
| | |
| | export class MarketingPage { |
| | private page: Page; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | constructor( page: Page ) { |
| | this.page = page; |
| | } |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | async visitTab( siteSlug: string, tabSlug: string ) { |
| | await this.page.goto( getCalypsoURL( `marketing/${ tabSlug }/${ siteSlug }` ) ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async clickTab( name: MarketingPageTab ) { |
| | await clickNavTab( this.page, name ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async clickButton( name: string ) { |
| | await this.page.getByRole( 'button', { name: name } ).click(); |
| | } |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | async saveSettings() { |
| | await this.page.getByRole( 'button', { name: 'Save' } ).first().click(); |
| |
|
| | await this.page.waitForResponse( /settings/ ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async enterExternalPreviewText( text: string ) { |
| | await this.page.getByRole( 'textbox', { name: 'Front Page Meta Description' } ).fill( text ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | async validateExternalPreview( service: SEOExternalServices, text: string ) { |
| | await this.page.locator( '.vertical-menu__social-item' ).filter( { hasText: service } ).click(); |
| |
|
| | await this.page.locator( '.seo-preview-pane__preview' ).getByText( text ).waitFor(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async enterPageTitleStructure( category: SEOPageTitleStructureCategories, text: string ) { |
| | const target = this.page |
| | .locator( selectors.pageTitleStructureInput ) |
| | .filter( { has: this.page.getByText( category ) } ) |
| | .getByRole( 'textbox' ); |
| |
|
| | await target.scrollIntoViewIfNeeded(); |
| |
|
| | await target.fill( text ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async validatePreviewTextForPageStructureCategory( text: string ) { |
| | await this.page |
| | .locator( '.title-format-editor__preview' ) |
| | .filter( { hasText: text } ) |
| | .waitFor(); |
| | } |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async clickSocialConnectButton( target: SocialConnection ): Promise< Page > { |
| | |
| | const popupPromise = this.page.waitForEvent( 'popup' ); |
| |
|
| | await this.page |
| | .getByRole( 'main' ) |
| | .getByRole( 'listitem' ) |
| | .filter( { hasText: target } ) |
| | .getByRole( 'button', { name: 'Connect' } ) |
| | .click(); |
| |
|
| | return await popupPromise; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | async validateSocialConnected( target: SocialConnection ): Promise< void > { |
| | await this.page |
| | .getByRole( 'main' ) |
| | .getByRole( 'listitem' ) |
| | .filter( { hasText: target } ) |
| | .getByRole( 'button', { name: 'Disconnect' } ) |
| | .waitFor(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async setupTumblr( popup: Page, { username, password }: { username: string; password: string } ) { |
| | |
| | await popup.waitForSelector( '[data-tumblr-ready="true"]' ); |
| |
|
| | |
| | await popup.getByRole( 'textbox', { name: 'email' } ).fill( username ); |
| | await popup.getByPlaceholder( 'Password' ).fill( password ); |
| |
|
| | |
| | await popup.getByRole( 'button', { name: 'Log in' } ).click(); |
| |
|
| | |
| | const popupClosePromise = popup.waitForEvent( 'close' ); |
| | await popup.getByRole( 'button', { name: 'Allow' } ).click(); |
| | await popupClosePromise; |
| |
|
| | |
| | await this.page.getByRole( 'dialog' ).getByRole( 'button', { name: 'Connect' } ).click(); |
| | } |
| | } |
| |
|