Create util function for toggling product editor tour
This commit is contained in:
parent
906d501688
commit
8b152bcecf
|
@ -3,10 +3,13 @@ const api = require( './api' );
|
|||
const site = require( './site' );
|
||||
const variableProducts = require( './variable-products' );
|
||||
const features = require( './features' );
|
||||
const tours = require( './tours' );
|
||||
|
||||
module.exports = {
|
||||
onboarding,
|
||||
api,
|
||||
site,
|
||||
variableProducts,
|
||||
features
|
||||
features,
|
||||
tours,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
const { admin } = require( '../test-data/data' );
|
||||
|
||||
const base64String = Buffer.from(
|
||||
`${ admin.username }:${ admin.password }`
|
||||
).toString( 'base64' );
|
||||
|
||||
const headers = {
|
||||
Authorization: `Basic ${ base64String }`,
|
||||
cookie: '',
|
||||
};
|
||||
|
||||
/**
|
||||
* Enables or disables the product editor tour.
|
||||
*
|
||||
* @param {import('@playwright/test').APIRequestContext} request Request context from calling function.
|
||||
* @param {boolean} enable Set to `true` if you want to enable the block product tour. `false` if otherwise.
|
||||
*/
|
||||
const toggleBlockProductTour = async ( request, enable ) => {
|
||||
const url = '/wp-json/wc-admin/options';
|
||||
const params = { _locale: 'user' };
|
||||
const toggleValue = enable ? 'no' : 'yes';
|
||||
const data = { woocommerce_block_product_tour_shown: toggleValue };
|
||||
|
||||
await request.post( url, {
|
||||
data,
|
||||
params,
|
||||
headers,
|
||||
} );
|
||||
};
|
||||
|
||||
module.exports = { toggleBlockProductTour };
|
Loading…
Reference in New Issue