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,10 +58,10 @@ test.describe(
|
|||
);
|
||||
} );
|
||||
|
||||
test(
|
||||
'it shows the "offline banner" when the network is offline',
|
||||
{ tag: '@skip-on-default-pressable' },
|
||||
async ( { page, context } ) => {
|
||||
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' )
|
||||
|
@ -70,12 +70,9 @@ test.describe(
|
|||
|
||||
await expect( page.locator( '.offline-banner' ) ).toBeVisible();
|
||||
await expect(
|
||||
page.locator(
|
||||
'text=Looking to design your store using AI?'
|
||||
)
|
||||
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,10 +115,9 @@ 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 } ) => {
|
||||
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 );
|
||||
|
@ -132,13 +128,11 @@ test.describe(
|
|||
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 } ) => {
|
||||
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 );
|
||||
|
@ -149,7 +143,6 @@ test.describe(
|
|||
|
||||
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 } ) => {
|
||||
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!'
|
||||
);
|
||||
await expect( locator ).not.toHaveText( 'Your store looks great!' );
|
||||
|
||||
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,9 +1,16 @@
|
|||
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 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 ) => {
|
||||
|
@ -11,8 +18,44 @@ export const activateTheme = ( themeName ) => {
|
|||
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',
|
||||
},
|
||||
};
|
||||
|
||||
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