|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { HelpCenterComponent, TestAccount } from '@automattic/calypso-e2e'; |
|
|
import { Browser, Page, Locator } from 'playwright'; |
|
|
|
|
|
declare const browser: Browser; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe.skip( 'Help Center in WP Admin', () => { |
|
|
const normalizeString = ( str: string | null ) => str?.replace( /\s+/g, ' ' ).trim(); |
|
|
|
|
|
let page: Page; |
|
|
let pageUrl: string; |
|
|
let testAccount: TestAccount; |
|
|
let helpCenterComponent: HelpCenterComponent; |
|
|
let helpCenterLocator: Locator; |
|
|
|
|
|
|
|
|
beforeAll( async function () { |
|
|
page = await browser.newPage(); |
|
|
testAccount = new TestAccount( 'defaultUser' ); |
|
|
pageUrl = `${ testAccount.getSiteURL( { protocol: true } ) }wp-admin/`; |
|
|
|
|
|
await testAccount.authenticate( page, { waitUntilStable: true } ); |
|
|
await page.goto( pageUrl ); |
|
|
|
|
|
helpCenterComponent = new HelpCenterComponent( page ); |
|
|
helpCenterLocator = helpCenterComponent.getHelpCenterLocator(); |
|
|
|
|
|
|
|
|
await helpCenterComponent.setZendeskStaging(); |
|
|
} ); |
|
|
|
|
|
|
|
|
afterAll( async function () { |
|
|
await page.close(); |
|
|
} ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe( 'General Interaction', () => { |
|
|
it( 'is initially closed', async () => { |
|
|
expect( await helpCenterComponent.isVisible() ).toBeFalsy(); |
|
|
} ); |
|
|
|
|
|
it( 'can be opened', async () => { |
|
|
await helpCenterComponent.openPopover(); |
|
|
|
|
|
expect( await helpCenterComponent.isVisible() ).toBeTruthy(); |
|
|
} ); |
|
|
|
|
|
it( 'is showing on the screen', async () => { |
|
|
expect( await helpCenterComponent.isPopoverShown() ).toBeTruthy(); |
|
|
} ); |
|
|
|
|
|
it( 'can be minimized', async () => { |
|
|
await helpCenterComponent.minimizePopover(); |
|
|
|
|
|
const containerHeight = await helpCenterLocator.evaluate( |
|
|
( el: HTMLElement ) => el.offsetHeight |
|
|
); |
|
|
|
|
|
expect( containerHeight ).toBe( 50 ); |
|
|
} ); |
|
|
|
|
|
it( 'the popover can be closed', async () => { |
|
|
await helpCenterComponent.closePopover(); |
|
|
|
|
|
expect( await helpCenterComponent.isVisible() ).toBeFalsy(); |
|
|
} ); |
|
|
} ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe( 'Articles', () => { |
|
|
it( 'initial articles are shown', async () => { |
|
|
await helpCenterComponent.openPopover(); |
|
|
|
|
|
const articles = helpCenterComponent.getArticles(); |
|
|
|
|
|
expect( await articles.count() ).toBeGreaterThanOrEqual( 5 ); |
|
|
} ); |
|
|
|
|
|
it( 'search returns proper results', async () => { |
|
|
await helpCenterComponent.search( 'Change a Domain Name Address' ); |
|
|
const resultTitles = await helpCenterComponent.getArticles().allTextContents(); |
|
|
expect( |
|
|
resultTitles.some( |
|
|
( title ) => normalizeString( title )?.includes( 'Change a Domain Name Address' ) |
|
|
) |
|
|
).toBeTruthy(); |
|
|
} ); |
|
|
|
|
|
it( 'post loads correctly', async () => { |
|
|
const article = await helpCenterComponent.getArticles().first(); |
|
|
const articleTitle = await article.textContent(); |
|
|
await article.click(); |
|
|
|
|
|
|
|
|
await page.waitForResponse( |
|
|
( response ) => |
|
|
response.url().includes( '/wpcom/v2/help/article' ) && response.status() === 200 |
|
|
); |
|
|
|
|
|
const articleHeader = await helpCenterLocator |
|
|
.getByRole( 'article' ) |
|
|
.getByRole( 'heading' ) |
|
|
.first(); |
|
|
await articleHeader.waitFor( { state: 'visible' } ); |
|
|
|
|
|
expect( normalizeString( await articleHeader.textContent() ) ).toBe( |
|
|
normalizeString( articleTitle ) |
|
|
); |
|
|
|
|
|
await helpCenterComponent.goBack(); |
|
|
} ); |
|
|
} ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe( 'Support Flow', () => { |
|
|
it( 'start support flow', async () => { |
|
|
await helpCenterComponent.openPopover(); |
|
|
|
|
|
const stillNeedHelpButton = helpCenterLocator.getByRole( 'link', { |
|
|
name: 'Still need help?', |
|
|
} ); |
|
|
|
|
|
await stillNeedHelpButton.waitFor( { state: 'visible' } ); |
|
|
await stillNeedHelpButton.click(); |
|
|
|
|
|
expect( await helpCenterComponent.getOdieChat().count() ).toBeTruthy(); |
|
|
} ); |
|
|
|
|
|
it.skip( 'get forwarded to a human', async () => { |
|
|
await helpCenterComponent.startAIChat( 'talk to human' ); |
|
|
|
|
|
const contactSupportButton = helpCenterComponent.getContactSupportButton(); |
|
|
await contactSupportButton.waitFor( { state: 'visible' } ); |
|
|
|
|
|
expect( await contactSupportButton.count() ).toBeTruthy(); |
|
|
} ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it.skip( 'start talking with a human', async () => { |
|
|
const contactSupportButton = await helpCenterComponent.getContactSupportButton(); |
|
|
await contactSupportButton.dispatchEvent( 'click' ); |
|
|
|
|
|
const zendeskMessaging = await page |
|
|
.frameLocator( 'iframe[title="Messaging window"]' ) |
|
|
.getByPlaceholder( 'Type a message' ); |
|
|
|
|
|
await zendeskMessaging.waitFor( { state: 'visible' } ); |
|
|
|
|
|
expect( await zendeskMessaging.count() ).toBeTruthy(); |
|
|
} ); |
|
|
} ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe( 'Action Hooks', () => { |
|
|
it( 'open help center on page load', async () => { |
|
|
await page.goto( pageUrl + '?help-center=home' ); |
|
|
|
|
|
await helpCenterLocator.waitFor( { state: 'visible' } ); |
|
|
|
|
|
expect( await helpCenterComponent.isPopoverShown() ).toBeTruthy(); |
|
|
} ); |
|
|
} ); |
|
|
} ); |
|
|
|