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(
|
test( 'it shows the "offline banner" when the network is offline', async ( {
|
||||||
'it shows the "offline banner" when the network is offline',
|
page,
|
||||||
{ tag: '@skip-on-default-pressable' },
|
context,
|
||||||
async ( { page, context } ) => {
|
} ) => {
|
||||||
await page.goto( CUSTOMIZE_STORE_URL );
|
await page.goto( CUSTOMIZE_STORE_URL );
|
||||||
await expect(
|
await expect(
|
||||||
page.locator( 'text=Design your own' )
|
page.locator( 'text=Design your own' )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await context.setOffline( true );
|
await context.setOffline( true );
|
||||||
|
|
||||||
await expect( page.locator( '.offline-banner' ) ).toBeVisible();
|
await expect( page.locator( '.offline-banner' ) ).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.locator(
|
page.locator( 'text=Looking to design your store using AI?' )
|
||||||
'text=Looking to design your store using AI?'
|
).toBeVisible();
|
||||||
)
|
} );
|
||||||
).toBeVisible();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
test( 'it shows the "no AI" banner on Core when the task is not completed', async ( {
|
test( 'it shows the "no AI" banner on Core when the task is not completed', async ( {
|
||||||
page,
|
page,
|
||||||
|
@ -118,38 +115,34 @@ test.describe(
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test(
|
test( 'it shows the "non default block theme" banner when the theme is a block theme different than TT4', async ( {
|
||||||
'it shows the "non default block theme" banner when the theme is a block theme different than TT4',
|
page,
|
||||||
{ tag: '@skip-on-default-pressable' },
|
} ) => {
|
||||||
async ( { page } ) => {
|
await activateTheme( 'twentytwentythree' );
|
||||||
await activateTheme( 'twentytwentythree' );
|
|
||||||
|
|
||||||
await page.goto( CUSTOMIZE_STORE_URL );
|
await page.goto( CUSTOMIZE_STORE_URL );
|
||||||
|
|
||||||
await expect( page.locator( 'h1' ) ).toHaveText(
|
await expect( page.locator( 'h1' ) ).toHaveText(
|
||||||
'Customize your theme'
|
'Customize your theme'
|
||||||
);
|
);
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole( 'button', { name: 'Go to the Editor' } )
|
page.getByRole( 'button', { name: 'Go to the Editor' } )
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
test( 'clicking on "Go to the Customizer" with a classic theme should go to the customizer', async ( {
|
||||||
'clicking on "Go to the Customizer" with a classic theme should go to the customizer',
|
page,
|
||||||
{ tag: '@skip-on-default-pressable' },
|
} ) => {
|
||||||
async ( { page } ) => {
|
await activateTheme( 'twentytwenty' );
|
||||||
await activateTheme( 'twentytwenty' );
|
|
||||||
|
|
||||||
await page.goto( CUSTOMIZE_STORE_URL );
|
await page.goto( CUSTOMIZE_STORE_URL );
|
||||||
|
|
||||||
await page
|
await page
|
||||||
.getByRole( 'button', { name: 'Go to the Customizer' } )
|
.getByRole( 'button', { name: 'Go to the Customizer' } )
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
await page.waitForNavigation();
|
await page.waitForNavigation();
|
||||||
await expect( page.url() ).toContain( 'customize.php' );
|
await expect( page.url() ).toContain( 'customize.php' );
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,20 +60,17 @@ test.describe(
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test(
|
test( 'Accessing the transitional page when the CYS flow is not completed should redirect to the Intro page', async ( {
|
||||||
'Accessing the transitional page when the CYS flow is not completed should redirect to the Intro page',
|
page,
|
||||||
{ tag: '@skip-on-default-pressable' },
|
baseURL,
|
||||||
async ( { page, baseURL } ) => {
|
} ) => {
|
||||||
await page.goto( TRANSITIONAL_URL );
|
await page.goto( TRANSITIONAL_URL );
|
||||||
|
|
||||||
const locator = page.locator( 'h1:visible' );
|
const locator = page.locator( 'h1:visible' );
|
||||||
await expect( locator ).not.toHaveText(
|
await expect( locator ).not.toHaveText( 'Your store looks great!' );
|
||||||
'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 ( {
|
test( 'Clicking on "Finish customizing" in the assembler should go to the transitional page', async ( {
|
||||||
pageObject,
|
pageObject,
|
||||||
|
|
|
@ -74,7 +74,7 @@ async function runComingSoonTests( themeContext = '' ) {
|
||||||
|
|
||||||
test.describe(
|
test.describe(
|
||||||
'Launch Your Store front end - logged out',
|
'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 } ) => {
|
test.afterAll( async ( { baseURL } ) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,18 +1,61 @@
|
||||||
const { exec } = require( 'node:child_process' );
|
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 DEFAULT_THEME = 'twentytwentythree';
|
||||||
|
|
||||||
export const activateTheme = ( themeName ) => {
|
export const activateTheme = ( themeName ) => {
|
||||||
return new Promise( ( resolve, reject ) => {
|
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 ) => {
|
exec( command, ( error, stdout ) => {
|
||||||
if ( error ) {
|
if ( error ) {
|
||||||
console.error( `Error executing command: ${ error }` );
|
console.error( `Error executing command: ${ error }` );
|
||||||
return reject( 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