CYS - Run appropriate tests depending on the WordPress version (#50016)
* WIP * Add changefile(s) from automation for the following project(s): woocommerce * Add missing code in before all * Fix lint --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
11c8567c4c
commit
df4bd38297
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: update
|
||||||
|
|
||||||
|
CYS - Run appropriate tests depending on the WordPress version.
|
|
@ -2,7 +2,7 @@ const { test: base, expect, request } = require( '@playwright/test' );
|
||||||
const { AssemblerPage } = require( './assembler.page' );
|
const { AssemblerPage } = require( './assembler.page' );
|
||||||
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
|
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
|
||||||
const { setOption } = require( '../../../utils/options' );
|
const { setOption } = require( '../../../utils/options' );
|
||||||
const { setFeatureFlag } = require( '../../../utils/features' );
|
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
|
||||||
|
|
||||||
const test = base.extend( {
|
const test = base.extend( {
|
||||||
pageObject: async ( { page }, use ) => {
|
pageObject: async ( { page }, use ) => {
|
||||||
|
@ -51,12 +51,13 @@ test.describe( 'Assembler -> Full composability', { tag: '@gutenberg' }, () => {
|
||||||
console.log( 'Store completed option not updated' );
|
console.log( 'Store completed option not updated' );
|
||||||
}
|
}
|
||||||
|
|
||||||
await setFeatureFlag(
|
const wordPressVersion = await getInstalledWordPressVersion();
|
||||||
request,
|
|
||||||
baseURL,
|
if ( wordPressVersion <= 6.5 ) {
|
||||||
'pattern-toolkit-full-composability',
|
test.skip(
|
||||||
true
|
'Skipping Full Composability tests: WordPress version is below 6.5, which does not support this feature.'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test.afterAll( async ( { baseURL } ) => {
|
test.afterAll( async ( { baseURL } ) => {
|
||||||
|
|
|
@ -3,7 +3,6 @@ const { AssemblerPage } = require( './assembler.page' );
|
||||||
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
|
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
|
||||||
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
|
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
|
||||||
const { setOption } = require( '../../../utils/options' );
|
const { setOption } = require( '../../../utils/options' );
|
||||||
const { setFeatureFlag } = require( '../../../utils/features' );
|
|
||||||
const { encodeCredentials } = require( '../../../utils/plugin-utils' );
|
const { encodeCredentials } = require( '../../../utils/plugin-utils' );
|
||||||
|
|
||||||
const test = base.extend( {
|
const test = base.extend( {
|
||||||
|
@ -39,12 +38,13 @@ test.describe( 'Assembler -> Homepage', { tag: '@gutenberg' }, () => {
|
||||||
console.log( 'Store completed option not updated' );
|
console.log( 'Store completed option not updated' );
|
||||||
}
|
}
|
||||||
|
|
||||||
await setFeatureFlag(
|
const wordPressVersion = await getInstalledWordPressVersion();
|
||||||
request,
|
|
||||||
baseURL,
|
if ( wordPressVersion > 6.5 ) {
|
||||||
'pattern-toolkit-full-composability',
|
test.skip(
|
||||||
false
|
'Skipping Assembler Homepage tests: WordPress version is above 6.5, which does not support this feature.'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test.afterAll( async ( { baseURL } ) => {
|
test.afterAll( async ( { baseURL } ) => {
|
||||||
|
@ -219,145 +219,116 @@ test.describe( 'Assembler -> Homepage', { tag: '@gutenberg' }, () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test.describe( 'Homepage tracking banner', () => {
|
|
||||||
test.beforeAll( async ( { baseURL } ) => {
|
|
||||||
await setFeatureFlag(
|
|
||||||
request,
|
|
||||||
baseURL,
|
|
||||||
'pattern-toolkit-full-composability',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'Should show the "Want more patterns?" banner with the Opt-in message when tracking is not allowed', async ( {
|
|
||||||
pageObject,
|
|
||||||
baseURL,
|
|
||||||
} ) => {
|
|
||||||
await setOption(
|
|
||||||
request,
|
|
||||||
baseURL,
|
|
||||||
'woocommerce_allow_tracking',
|
|
||||||
'no'
|
|
||||||
);
|
|
||||||
|
|
||||||
await prepareAssembler( pageObject, baseURL );
|
|
||||||
|
|
||||||
const assembler = await pageObject.getAssembler();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText( 'Want more patterns?' )
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText(
|
|
||||||
'Opt in to usage tracking to get access to more patterns.'
|
|
||||||
)
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'Should show the "Want more patterns?" banner with the offline message when the user is offline and tracking is not allowed', async ( {
|
|
||||||
context,
|
|
||||||
pageObject,
|
|
||||||
baseURL,
|
|
||||||
} ) => {
|
|
||||||
await setOption(
|
|
||||||
request,
|
|
||||||
baseURL,
|
|
||||||
'woocommerce_allow_tracking',
|
|
||||||
'no'
|
|
||||||
);
|
|
||||||
|
|
||||||
await prepareAssembler( pageObject, baseURL );
|
|
||||||
|
|
||||||
await context.setOffline( true );
|
|
||||||
|
|
||||||
const assembler = await pageObject.getAssembler();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText( 'Want more patterns?' )
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText(
|
|
||||||
"Looks like we can't detect your network. Please double-check your internet connection and refresh the page."
|
|
||||||
)
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'Should not show the "Want more patterns?" banner when tracking is allowed', async ( {
|
|
||||||
baseURL,
|
|
||||||
pageObject,
|
|
||||||
} ) => {
|
|
||||||
await setOption(
|
|
||||||
request,
|
|
||||||
baseURL,
|
|
||||||
'woocommerce_allow_tracking',
|
|
||||||
'yes'
|
|
||||||
);
|
|
||||||
|
|
||||||
await prepareAssembler( pageObject, baseURL );
|
|
||||||
|
|
||||||
const assembler = await pageObject.getAssembler();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText( 'Want more patterns?' )
|
|
||||||
).toBeHidden();
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test.describe(
|
test.describe( 'Homepage tracking banner', () => {
|
||||||
'Assembler -> Homepage -> PTK API is down',
|
test.use( { storageState: process.env.ADMINSTATE } );
|
||||||
{ tag: '@gutenberg' },
|
|
||||||
() => {
|
|
||||||
test.use( { storageState: process.env.ADMINSTATE } );
|
|
||||||
|
|
||||||
test.beforeAll( async ( { baseURL } ) => {
|
test.beforeAll( async ( { baseURL } ) => {
|
||||||
const wordPressVersion = await getInstalledWordPressVersion();
|
try {
|
||||||
|
// In some environments the tour blocks clicking other elements.
|
||||||
if ( wordPressVersion <= 6.5 ) {
|
|
||||||
test.skip(
|
|
||||||
'Skipping PTK API test: WordPress version is below 6.5, which does not support this feature.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
// In some environments the tour blocks clicking other elements.
|
|
||||||
await setOption(
|
|
||||||
request,
|
|
||||||
baseURL,
|
|
||||||
'woocommerce_customize_store_onboarding_tour_hidden',
|
|
||||||
'yes'
|
|
||||||
);
|
|
||||||
} catch ( error ) {
|
|
||||||
console.log( 'Store completed option not updated' );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
test( 'Should show the "Want more patterns?" banner with the PTK API unavailable message', async ( {
|
|
||||||
baseURL,
|
|
||||||
pageObject,
|
|
||||||
page,
|
|
||||||
} ) => {
|
|
||||||
await setOption(
|
await setOption(
|
||||||
request,
|
request,
|
||||||
baseURL,
|
baseURL,
|
||||||
'woocommerce_allow_tracking',
|
'woocommerce_customize_store_onboarding_tour_hidden',
|
||||||
'no'
|
'yes'
|
||||||
);
|
);
|
||||||
|
} catch ( error ) {
|
||||||
|
console.log( 'Store completed option not updated' );
|
||||||
|
}
|
||||||
|
|
||||||
await page.route( '**/wp-json/wc/private/patterns*', ( route ) => {
|
const wordPressVersion = await getInstalledWordPressVersion();
|
||||||
route.fulfill( {
|
|
||||||
status: 500,
|
if ( wordPressVersion <= 6.5 ) {
|
||||||
} );
|
test.skip(
|
||||||
|
'Skipping PTK API test: WordPress version is below 6.5, which does not support this feature.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
test( 'Should show the "Want more patterns?" banner with the PTK API unavailable message', async ( {
|
||||||
|
baseURL,
|
||||||
|
pageObject,
|
||||||
|
page,
|
||||||
|
} ) => {
|
||||||
|
await setOption( request, baseURL, 'woocommerce_allow_tracking', 'no' );
|
||||||
|
|
||||||
|
await page.route( '**/wp-json/wc/private/patterns*', ( route ) => {
|
||||||
|
route.fulfill( {
|
||||||
|
status: 500,
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await prepareAssembler( pageObject, baseURL );
|
|
||||||
|
|
||||||
const assembler = await pageObject.getAssembler();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText( 'Want more patterns?' )
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
assembler.getByText(
|
|
||||||
"Unfortunately, we're experiencing some technical issues — please come back later to access more patterns."
|
|
||||||
)
|
|
||||||
).toBeVisible();
|
|
||||||
} );
|
} );
|
||||||
}
|
|
||||||
);
|
await prepareAssembler( pageObject, baseURL );
|
||||||
|
|
||||||
|
const assembler = await pageObject.getAssembler();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText( 'Want more patterns?' )
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText(
|
||||||
|
"Unfortunately, we're experiencing some technical issues — please come back later to access more patterns."
|
||||||
|
)
|
||||||
|
).toBeVisible();
|
||||||
|
} );
|
||||||
|
|
||||||
|
test( 'Should show the "Want more patterns?" banner with the Opt-in message when tracking is not allowed', async ( {
|
||||||
|
pageObject,
|
||||||
|
baseURL,
|
||||||
|
} ) => {
|
||||||
|
await setOption( request, baseURL, 'woocommerce_allow_tracking', 'no' );
|
||||||
|
|
||||||
|
await prepareAssembler( pageObject, baseURL );
|
||||||
|
|
||||||
|
const assembler = await pageObject.getAssembler();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText( 'Want more patterns?' )
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText(
|
||||||
|
'Opt in to usage tracking to get access to more patterns.'
|
||||||
|
)
|
||||||
|
).toBeVisible();
|
||||||
|
} );
|
||||||
|
|
||||||
|
test( 'Should show the "Want more patterns?" banner with the offline message when the user is offline and tracking is not allowed', async ( {
|
||||||
|
context,
|
||||||
|
pageObject,
|
||||||
|
baseURL,
|
||||||
|
} ) => {
|
||||||
|
await setOption( request, baseURL, 'woocommerce_allow_tracking', 'no' );
|
||||||
|
|
||||||
|
await prepareAssembler( pageObject, baseURL );
|
||||||
|
|
||||||
|
await context.setOffline( true );
|
||||||
|
|
||||||
|
const assembler = await pageObject.getAssembler();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText( 'Want more patterns?' )
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText(
|
||||||
|
"Looks like we can't detect your network. Please double-check your internet connection and refresh the page."
|
||||||
|
)
|
||||||
|
).toBeVisible();
|
||||||
|
} );
|
||||||
|
|
||||||
|
test( 'Should not show the "Want more patterns?" banner when tracking is allowed', async ( {
|
||||||
|
baseURL,
|
||||||
|
pageObject,
|
||||||
|
} ) => {
|
||||||
|
await setOption(
|
||||||
|
request,
|
||||||
|
baseURL,
|
||||||
|
'woocommerce_allow_tracking',
|
||||||
|
'yes'
|
||||||
|
);
|
||||||
|
|
||||||
|
await prepareAssembler( pageObject, baseURL );
|
||||||
|
|
||||||
|
const assembler = await pageObject.getAssembler();
|
||||||
|
await expect(
|
||||||
|
assembler.getByText( 'Want more patterns?' )
|
||||||
|
).toBeHidden();
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
|
Loading…
Reference in New Issue