2020-06-05 16:49:07 +00:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { setup as setupPuppeteer } from 'jest-environment-puppeteer';
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
setupSettings,
|
2020-07-29 13:39:15 +00:00
|
|
|
setupPageSettings,
|
2020-06-05 16:49:07 +00:00
|
|
|
createTaxes,
|
|
|
|
createCoupons,
|
|
|
|
createProducts,
|
2020-07-02 10:32:42 +00:00
|
|
|
createReviews,
|
2020-07-06 18:48:39 +00:00
|
|
|
createCategories,
|
2020-06-05 16:49:07 +00:00
|
|
|
createShippingZones,
|
2020-06-15 14:59:18 +00:00
|
|
|
createBlockPages,
|
2020-06-05 16:49:07 +00:00
|
|
|
enablePaymentGateways,
|
|
|
|
} from '../fixtures/fixture-loaders';
|
|
|
|
|
|
|
|
module.exports = async ( globalConfig ) => {
|
|
|
|
// we need to load puppeteer global setup here.
|
|
|
|
await setupPuppeteer( globalConfig );
|
|
|
|
|
2020-06-17 20:28:11 +00:00
|
|
|
try {
|
|
|
|
/**
|
|
|
|
* Promise.all will return an array of all promises resolved values.
|
|
|
|
* Some functions like setupSettings and enablePaymentGateways resolve
|
|
|
|
* to server data so we ignore the values here.
|
|
|
|
*/
|
|
|
|
const results = await Promise.all( [
|
|
|
|
setupSettings(),
|
|
|
|
createTaxes(),
|
|
|
|
createCoupons(),
|
2020-07-06 18:48:39 +00:00
|
|
|
createCategories(),
|
2020-06-17 20:28:11 +00:00
|
|
|
createShippingZones(),
|
|
|
|
createBlockPages(),
|
|
|
|
enablePaymentGateways(),
|
2020-07-29 13:39:15 +00:00
|
|
|
setupPageSettings(),
|
2020-06-17 20:28:11 +00:00
|
|
|
] );
|
2020-07-06 18:48:39 +00:00
|
|
|
const [ , taxes, coupons, categories, shippingZones, pages ] = results;
|
|
|
|
|
|
|
|
// Create products after categories.
|
|
|
|
const products = await createProducts( categories );
|
2020-07-02 10:32:42 +00:00
|
|
|
|
|
|
|
/**
|
2020-07-06 18:48:39 +00:00
|
|
|
* Create fixture reviews data for each product.
|
2020-07-02 10:32:42 +00:00
|
|
|
*/
|
2020-07-06 18:48:39 +00:00
|
|
|
products.forEach( async ( productId ) => {
|
|
|
|
await createReviews( productId );
|
|
|
|
} );
|
2020-07-02 10:32:42 +00:00
|
|
|
|
2020-06-17 20:28:11 +00:00
|
|
|
global.fixtureData = {
|
|
|
|
taxes,
|
|
|
|
coupons,
|
|
|
|
products,
|
|
|
|
shippingZones,
|
|
|
|
pages,
|
|
|
|
};
|
|
|
|
} catch ( e ) {
|
|
|
|
console.log( e );
|
|
|
|
}
|
2020-06-05 16:49:07 +00:00
|
|
|
};
|