Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function logoutUser() {
if ( ! isCurrentURL( 'wp-login.php' ) ) {
await page.goto(
createURL( 'wp-login.php', 'action=logout' )
);
}
// Since we're directly navigating to the logout URL,
// WP will ask for confirmation due to the missing nonce.
await Promise.all( [
page.waitForNavigation(),
expect( page ).toClick( 'a', { text: /log out/i } ),
] );
}
export async function logoutUser() {
await page.goto( createURL( 'wp-login.php', 'action=logout' ) );
await clickAndWait( 'a' );
}
export async function visitPage( path, query ) {
await page.goto( createURL( path, query ) );
}
constructor( page ) {
const expectedSelector = '.login';
const url = createURL( 'wp-login.php' );
super( page, { expectedSelector, url } );
}
export async function toHaveAdSenseTag( path ) {
const result = {};
const page = await browser.newPage();
await page.goto( createURL( path ) );
try {
await expect( page ).toMatchElement( 'script[src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"]' );
result.pass = true;
result.message = () => `Expected ${ path } not to contain an Adsense tag.`;
} catch {
result.pass = false;
result.message = () => `Expected ${ path } to contain an Adsense tag.`;
}
await page.close();
return result;
}