| import { Page } from 'playwright'; |
| import { DataHelper } from '../..'; |
|
|
| |
| |
| |
| export class LoggedOutHomePage { |
| private page: Page; |
|
|
| |
| |
| |
| constructor( page: Page ) { |
| this.page = page; |
| } |
|
|
| |
| |
| |
| async selectFirstTheme() { |
| |
| |
| const themeContainer = this.page.locator( '.lp-content.lp-content-area--scrolling' ).first(); |
| await themeContainer.hover( { force: true } ); |
|
|
| |
| const themeCard = themeContainer.locator( '.lp-image-top-row' ).last(); |
| await themeCard.hover(); |
|
|
| const themeButton = themeCard.getByText( 'Start with this theme' ); |
| const calypsoUrl = new URL( DataHelper.getCalypsoURL() ); |
| const themeButtonUrl = new URL( ( await themeButton.getAttribute( 'href' ) ) || '' ); |
|
|
| if ( calypsoUrl.hostname !== 'wordpress.com' ) { |
| |
| await this.page.route( themeButtonUrl.href, async ( route ) => { |
| themeButtonUrl.host = calypsoUrl.host; |
| themeButtonUrl.protocol = calypsoUrl.protocol; |
|
|
| await route.abort(); |
| await this.page.unrouteAll( { behavior: 'ignoreErrors' } ); |
| await this.page.goto( themeButtonUrl.href, { waitUntil: 'load' } ); |
| } ); |
| } |
| |
| const pageMatch = new URL( themeButtonUrl.href ).search.match( 'theme=([a-z]*)?&' ); |
| const themeSlug = pageMatch?.[ 1 ] || null; |
|
|
| |
| await themeCard.hover( { force: true } ); |
| await themeCard.getByText( 'Start with this theme' ).click( { force: true } ); |
|
|
| return themeSlug; |
| } |
|
|
| |
| |
| |
| async clickExploreThemes() { |
| return Promise.all( [ |
| this.page.waitForNavigation( { waitUntil: 'load' } ), |
| this.page.getByRole( 'link', { name: 'Explore themes' } ).click(), |
| ] ); |
| } |
| } |
|
|