Make themes util compatible with ext env and unskip relevant tests
This commit is contained in:
parent
d6f1cce424
commit
d86cfceda2
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
E2E tests - fixing activateTheme util to work on wp env and external envs
|
|
@ -58,24 +58,21 @@ test.describe(
|
|||
);
|
||||
} );
|
||||
|
||||
test(
|
||||
'it shows the "offline banner" when the network is offline',
|
||||
{ tag: '@skip-on-default-pressable' },
|
||||
async ( { page, context } ) => {
|
||||
await page.goto( CUSTOMIZE_STORE_URL );
|
||||
await expect(
|
||||
page.locator( 'text=Design your own' )
|
||||
).toBeVisible();
|
||||
await context.setOffline( true );
|
||||
test( 'it shows the "offline banner" when the network is offline', async ( {
|
||||
page,
|
||||
context,
|
||||
} ) => {
|
||||
await page.goto( CUSTOMIZE_STORE_URL );
|
||||
await expect(
|
||||
page.locator( 'text=Design your own' )
|
||||
).toBeVisible();
|
||||
await context.setOffline( true );
|
||||
|
||||
await expect( page.locator( '.offline-banner' ) ).toBeVisible();
|
||||
await expect(
|
||||
page.locator(
|
||||
'text=Looking to design your store using AI?'
|
||||
)
|
||||
).toBeVisible();
|
||||
}
|
||||
);
|
||||
await expect( page.locator( '.offline-banner' ) ).toBeVisible();
|
||||
await expect(
|
||||
page.locator( 'text=Looking to design your store using AI?' )
|
||||
).toBeVisible();
|
||||
} );
|
||||
|
||||
test( 'it shows the "no AI" banner on Core when the task is not completed', async ( {
|
||||
page,
|
||||
|
@ -118,38 +115,34 @@ test.describe(
|
|||
).toBeVisible();
|
||||
} );
|
||||
|
||||
test(
|
||||
'it shows the "non default block theme" banner when the theme is a block theme different than TT4',
|
||||
{ tag: '@skip-on-default-pressable' },
|
||||
async ( { page } ) => {
|
||||
await activateTheme( 'twentytwentythree' );
|
||||
test( 'it shows the "non default block theme" banner when the theme is a block theme different than TT4', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
await activateTheme( 'twentytwentythree' );
|
||||
|
||||
await page.goto( CUSTOMIZE_STORE_URL );
|
||||
await page.goto( CUSTOMIZE_STORE_URL );
|
||||
|
||||
await expect( page.locator( 'h1' ) ).toHaveText(
|
||||
'Customize your theme'
|
||||
);
|
||||
await expect(
|
||||
page.getByRole( 'button', { name: 'Go to the Editor' } )
|
||||
).toBeVisible();
|
||||
}
|
||||
);
|
||||
await expect( page.locator( 'h1' ) ).toHaveText(
|
||||
'Customize your theme'
|
||||
);
|
||||
await expect(
|
||||
page.getByRole( 'button', { name: 'Go to the Editor' } )
|
||||
).toBeVisible();
|
||||
} );
|
||||
|
||||
test(
|
||||
'clicking on "Go to the Customizer" with a classic theme should go to the customizer',
|
||||
{ tag: '@skip-on-default-pressable' },
|
||||
async ( { page } ) => {
|
||||
await activateTheme( 'twentytwenty' );
|
||||
test( 'clicking on "Go to the Customizer" with a classic theme should go to the customizer', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
await activateTheme( 'twentytwenty' );
|
||||
|
||||
await page.goto( CUSTOMIZE_STORE_URL );
|
||||
await page.goto( CUSTOMIZE_STORE_URL );
|
||||
|
||||
await page
|
||||
.getByRole( 'button', { name: 'Go to the Customizer' } )
|
||||
.click();
|
||||
await page
|
||||
.getByRole( 'button', { name: 'Go to the Customizer' } )
|
||||
.click();
|
||||
|
||||
await page.waitForNavigation();
|
||||
await expect( page.url() ).toContain( 'customize.php' );
|
||||
}
|
||||
);
|
||||
await page.waitForNavigation();
|
||||
await expect( page.url() ).toContain( 'customize.php' );
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
|
|
@ -60,20 +60,17 @@ test.describe(
|
|||
);
|
||||
} );
|
||||
|
||||
test(
|
||||
'Accessing the transitional page when the CYS flow is not completed should redirect to the Intro page',
|
||||
{ tag: '@skip-on-default-pressable' },
|
||||
async ( { page, baseURL } ) => {
|
||||
await page.goto( TRANSITIONAL_URL );
|
||||
test( 'Accessing the transitional page when the CYS flow is not completed should redirect to the Intro page', async ( {
|
||||
page,
|
||||
baseURL,
|
||||
} ) => {
|
||||
await page.goto( TRANSITIONAL_URL );
|
||||
|
||||
const locator = page.locator( 'h1:visible' );
|
||||
await expect( locator ).not.toHaveText(
|
||||
'Your store looks great!'
|
||||
);
|
||||
const locator = page.locator( 'h1:visible' );
|
||||
await expect( locator ).not.toHaveText( 'Your store looks great!' );
|
||||
|
||||
await expect( page.url() ).toBe( `${ baseURL }${ INTRO_URL }` );
|
||||
}
|
||||
);
|
||||
await expect( page.url() ).toBe( `${ baseURL }${ INTRO_URL }` );
|
||||
} );
|
||||
|
||||
test( 'Clicking on "Finish customizing" in the assembler should go to the transitional page', async ( {
|
||||
pageObject,
|
||||
|
|
|
@ -74,7 +74,7 @@ async function runComingSoonTests( themeContext = '' ) {
|
|||
|
||||
test.describe(
|
||||
'Launch Your Store front end - logged out',
|
||||
{ tag: [ '@skip-on-default-wpcom', '@skip-on-default-pressable' ] },
|
||||
{ tag: '@skip-on-default-wpcom' },
|
||||
() => {
|
||||
test.afterAll( async ( { baseURL } ) => {
|
||||
try {
|
||||
|
|
|
@ -1,18 +1,61 @@
|
|||
const { exec } = require( 'node:child_process' );
|
||||
const { encodeCredentials } = require( '../utils/plugin-utils' );
|
||||
const https = require( 'https' );
|
||||
const { admin } = require( '../test-data/data' );
|
||||
const { BASE_URL } = process.env;
|
||||
|
||||
export const DEFAULT_THEME = 'twentytwentythree';
|
||||
|
||||
export const activateTheme = ( themeName ) => {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
const command = `wp-env run tests-cli wp theme install ${ themeName } --activate`;
|
||||
const isLocalhost = BASE_URL.includes( 'localhost' );
|
||||
if ( isLocalhost ) {
|
||||
// Command for local environment
|
||||
const command = `wp-env run tests-cli wp theme install ${ themeName } --activate`;
|
||||
|
||||
exec( command, ( error, stdout ) => {
|
||||
if ( error ) {
|
||||
console.error( `Error executing command: ${ error }` );
|
||||
return reject( error );
|
||||
}
|
||||
exec( command, ( error, stdout ) => {
|
||||
if ( error ) {
|
||||
console.error( `Error executing command: ${ error }` );
|
||||
return reject( error );
|
||||
}
|
||||
resolve( stdout );
|
||||
} );
|
||||
} else {
|
||||
// HTTPS request for external environment
|
||||
const url = new URL( BASE_URL );
|
||||
const options = {
|
||||
hostname: url.hostname,
|
||||
port: url.port || 443,
|
||||
path: '/wp-json/custom/v1/activate-theme',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Basic ${ encodeCredentials(
|
||||
admin.username,
|
||||
admin.password
|
||||
) }`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
resolve( stdout );
|
||||
} );
|
||||
const req = https.request( options, ( res ) => {
|
||||
let data = '';
|
||||
|
||||
res.on( 'data', ( chunk ) => {
|
||||
data += chunk;
|
||||
} );
|
||||
|
||||
res.on( 'end', () => {
|
||||
resolve( JSON.parse( data ).message );
|
||||
} );
|
||||
} );
|
||||
|
||||
req.on( 'error', ( error ) => {
|
||||
reject( error );
|
||||
} );
|
||||
|
||||
// Send the request body
|
||||
req.write( JSON.stringify( { theme_name: themeName } ) );
|
||||
req.end();
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue