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 { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
|
||||
const { setOption } = require( '../../../utils/options' );
|
||||
const { setFeatureFlag } = require( '../../../utils/features' );
|
||||
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
|
||||
|
||||
const test = base.extend( {
|
||||
pageObject: async ( { page }, use ) => {
|
||||
|
@ -51,12 +51,13 @@ test.describe( 'Assembler -> Full composability', { tag: '@gutenberg' }, () => {
|
|||
console.log( 'Store completed option not updated' );
|
||||
}
|
||||
|
||||
await setFeatureFlag(
|
||||
request,
|
||||
baseURL,
|
||||
'pattern-toolkit-full-composability',
|
||||
true
|
||||
);
|
||||
const wordPressVersion = await getInstalledWordPressVersion();
|
||||
|
||||
if ( wordPressVersion <= 6.5 ) {
|
||||
test.skip(
|
||||
'Skipping Full Composability tests: WordPress version is below 6.5, which does not support this feature.'
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
test.afterAll( async ( { baseURL } ) => {
|
||||
|
|
|
@ -3,7 +3,6 @@ const { AssemblerPage } = require( './assembler.page' );
|
|||
const { activateTheme, DEFAULT_THEME } = require( '../../../utils/themes' );
|
||||
const { getInstalledWordPressVersion } = require( '../../../utils/wordpress' );
|
||||
const { setOption } = require( '../../../utils/options' );
|
||||
const { setFeatureFlag } = require( '../../../utils/features' );
|
||||
const { encodeCredentials } = require( '../../../utils/plugin-utils' );
|
||||
|
||||
const test = base.extend( {
|
||||
|
@ -39,12 +38,13 @@ test.describe( 'Assembler -> Homepage', { tag: '@gutenberg' }, () => {
|
|||
console.log( 'Store completed option not updated' );
|
||||
}
|
||||
|
||||
await setFeatureFlag(
|
||||
request,
|
||||
baseURL,
|
||||
'pattern-toolkit-full-composability',
|
||||
false
|
||||
);
|
||||
const wordPressVersion = await getInstalledWordPressVersion();
|
||||
|
||||
if ( wordPressVersion > 6.5 ) {
|
||||
test.skip(
|
||||
'Skipping Assembler Homepage tests: WordPress version is above 6.5, which does not support this feature.'
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
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(
|
||||
'Assembler -> Homepage -> PTK API is down',
|
||||
{ tag: '@gutenberg' },
|
||||
() => {
|
||||
test.use( { storageState: process.env.ADMINSTATE } );
|
||||
test.describe( 'Homepage tracking banner', () => {
|
||||
test.use( { storageState: process.env.ADMINSTATE } );
|
||||
|
||||
test.beforeAll( async ( { baseURL } ) => {
|
||||
const wordPressVersion = await getInstalledWordPressVersion();
|
||||
|
||||
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,
|
||||
} ) => {
|
||||
test.beforeAll( async ( { baseURL } ) => {
|
||||
try {
|
||||
// In some environments the tour blocks clicking other elements.
|
||||
await setOption(
|
||||
request,
|
||||
baseURL,
|
||||
'woocommerce_allow_tracking',
|
||||
'no'
|
||||
'woocommerce_customize_store_onboarding_tour_hidden',
|
||||
'yes'
|
||||
);
|
||||
} catch ( error ) {
|
||||
console.log( 'Store completed option not updated' );
|
||||
}
|
||||
|
||||
await page.route( '**/wp-json/wc/private/patterns*', ( route ) => {
|
||||
route.fulfill( {
|
||||
status: 500,
|
||||
} );
|
||||
const wordPressVersion = await getInstalledWordPressVersion();
|
||||
|
||||
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