2021-03-17 08:22:33 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-11-18 17:15:19 +00:00
|
|
|
import {
|
|
|
|
filterBusinessExtensions,
|
2022-01-18 13:46:10 +00:00
|
|
|
isSellingElsewhere,
|
|
|
|
isSellingOtherPlatformInPerson,
|
2021-11-18 17:15:19 +00:00
|
|
|
prepareExtensionTrackingData,
|
2022-01-24 16:23:12 +00:00
|
|
|
prepareExtensionTrackingInstallationData,
|
2021-11-18 17:15:19 +00:00
|
|
|
} from '../flows/selective-bundle';
|
2021-12-29 08:32:19 +00:00
|
|
|
import { createInstallExtensionOptions } from '../flows/selective-bundle/selective-extensions-bundle';
|
2021-03-17 08:22:33 +00:00
|
|
|
|
|
|
|
describe( 'BusinessDetails', () => {
|
|
|
|
test( 'filtering extensions', () => {
|
|
|
|
const extensions = {
|
|
|
|
'creative-mail-by-constant-contact': true,
|
|
|
|
'facebook-for-woocommerce': true,
|
|
|
|
install_extensions: true,
|
|
|
|
jetpack: true,
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listings-and-ads': true,
|
2021-03-17 08:22:33 +00:00
|
|
|
'mailchimp-for-woocommerce': true,
|
|
|
|
'woocommerce-payments': true,
|
|
|
|
'woocommerce-services:shipping': true,
|
|
|
|
'woocommerce-services:tax': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectedExtensions = [
|
|
|
|
'creative-mail-by-constant-contact',
|
|
|
|
'facebook-for-woocommerce',
|
|
|
|
'jetpack',
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listings-and-ads',
|
2021-03-17 08:22:33 +00:00
|
|
|
'mailchimp-for-woocommerce',
|
|
|
|
'woocommerce-payments',
|
|
|
|
'woocommerce-services',
|
|
|
|
];
|
|
|
|
|
|
|
|
const filteredExtensions = filterBusinessExtensions( extensions );
|
|
|
|
|
|
|
|
expect( filteredExtensions ).toEqual( expectedExtensions );
|
|
|
|
} );
|
2021-06-09 03:29:45 +00:00
|
|
|
|
2021-11-18 17:15:19 +00:00
|
|
|
describe( 'prepareExtensionTrackingData', () => {
|
|
|
|
test( 'preparing extensions for tracking', () => {
|
|
|
|
const extensions = {
|
|
|
|
'creative-mail-by-constant-contact': true,
|
|
|
|
'facebook-for-woocommerce': false,
|
|
|
|
install_extensions: true,
|
|
|
|
jetpack: false,
|
|
|
|
'google-listings-and-ads': true,
|
|
|
|
'mailchimp-for-woocommerce': false,
|
2022-01-24 16:23:12 +00:00
|
|
|
'woocommerce-payments:us': true,
|
2021-11-18 17:15:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const expectedExtensions = {
|
|
|
|
install_creative_mail_by_constant_contact: true,
|
|
|
|
install_facebook_for_woocommerce: false,
|
|
|
|
install_jetpack: false,
|
|
|
|
install_google_listings_and_ads: true,
|
|
|
|
install_mailchimp_for_woocommerce: false,
|
|
|
|
install_wcpay: true,
|
|
|
|
};
|
|
|
|
|
2022-06-21 08:37:34 +00:00
|
|
|
const installedExtensions =
|
|
|
|
prepareExtensionTrackingData( extensions );
|
2021-11-18 17:15:19 +00:00
|
|
|
|
|
|
|
expect( installedExtensions ).toEqual( expectedExtensions );
|
|
|
|
} );
|
|
|
|
test( 'preparing shipping and tax extensions for tracking', () => {
|
|
|
|
const extensions = {
|
|
|
|
'woocommerce-services:shipping': true,
|
|
|
|
'woocommerce-services:tax': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectedExtensions = {
|
|
|
|
install_woocommerce_services: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
expect( prepareExtensionTrackingData( extensions ) ).toEqual(
|
|
|
|
expectedExtensions
|
|
|
|
);
|
|
|
|
|
|
|
|
extensions[ 'woocommerce-services:shipping' ] = false;
|
|
|
|
extensions[ 'woocommerce-services:tax' ] = true;
|
|
|
|
|
|
|
|
expect( prepareExtensionTrackingData( extensions ) ).toEqual(
|
|
|
|
expectedExtensions
|
|
|
|
);
|
|
|
|
|
|
|
|
extensions[ 'woocommerce-services:shipping' ] = true;
|
|
|
|
extensions[ 'woocommerce-services:tax' ] = false;
|
|
|
|
|
|
|
|
expect( prepareExtensionTrackingData( extensions ) ).toEqual(
|
|
|
|
expectedExtensions
|
|
|
|
);
|
|
|
|
|
|
|
|
extensions[ 'woocommerce-services:shipping' ] = false;
|
|
|
|
extensions[ 'woocommerce-services:tax' ] = false;
|
|
|
|
expectedExtensions.install_woocommerce_services = false;
|
|
|
|
|
|
|
|
expect( prepareExtensionTrackingData( extensions ) ).toEqual(
|
|
|
|
expectedExtensions
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2022-01-24 16:23:12 +00:00
|
|
|
describe( 'extension installation tracking', () => {
|
|
|
|
const extensions = {
|
|
|
|
'creative-mail-by-constant-contact': true,
|
|
|
|
'facebook-for-woocommerce': false,
|
|
|
|
install_extensions: true,
|
|
|
|
jetpack: false,
|
|
|
|
'google-listings-and-ads': true,
|
|
|
|
'mailchimp-for-woocommerce': false,
|
|
|
|
'woocommerce-payments:us': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
it( 'should return a list of installed and activated extensions', () => {
|
|
|
|
const data = prepareExtensionTrackingInstallationData( extensions, {
|
|
|
|
data: {
|
|
|
|
activated: [
|
|
|
|
'woocommerce-payments',
|
|
|
|
'google-listings-and-ads',
|
|
|
|
],
|
|
|
|
install_time: {
|
|
|
|
'woocommerce-payments': 2000,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
expect( data.installed_extensions ).toEqual( [ 'wcpay' ] );
|
|
|
|
expect( data.activated_extensions ).toEqual( [
|
|
|
|
'woocommerce-payments',
|
|
|
|
'google-listings-and-ads',
|
|
|
|
] );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should add install_time_extension_name prop if install_time is set with correct timebox', () => {
|
|
|
|
const data = prepareExtensionTrackingInstallationData( extensions, {
|
|
|
|
data: {
|
|
|
|
activated: [
|
|
|
|
'woocommerce-payments',
|
|
|
|
'google-listings-and-ads',
|
|
|
|
],
|
|
|
|
install_time: {
|
|
|
|
'woocommerce-payments': 200,
|
|
|
|
'google-listings-and-ads': 12023,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} );
|
|
|
|
expect( data.install_time_wcpay ).toEqual( '0-2s' );
|
|
|
|
expect( data.install_time_google_listings_and_ads ).toEqual(
|
|
|
|
'10-15s'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2021-12-29 08:32:19 +00:00
|
|
|
describe( 'createInstallExtensionOptions', () => {
|
2021-06-09 03:29:45 +00:00
|
|
|
test( 'selected by default', () => {
|
2022-01-17 02:03:32 +00:00
|
|
|
const installableExtensions = [
|
2021-06-09 03:29:45 +00:00
|
|
|
{
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
key: 'visible-and-not-selected',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'visible-and-selected',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2022-02-25 21:26:44 +00:00
|
|
|
const values = createInstallExtensionOptions(
|
|
|
|
installableExtensions
|
|
|
|
);
|
2021-06-09 03:29:45 +00:00
|
|
|
|
|
|
|
expect( values ).toEqual(
|
|
|
|
expect.objectContaining( {
|
2022-02-25 21:26:44 +00:00
|
|
|
install_extensions: true,
|
|
|
|
'visible-and-not-selected': true,
|
2021-06-09 03:29:45 +00:00
|
|
|
'visible-and-selected': true,
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
2022-01-18 13:46:10 +00:00
|
|
|
|
|
|
|
describe( 'Currently selling elsewhere', () => {
|
|
|
|
test( 'isSellingElsewhere', () => {
|
|
|
|
const sellingElsewhere = isSellingElsewhere( 'other' );
|
|
|
|
const notSellingElsewhere = isSellingElsewhere( 'no' );
|
|
|
|
|
|
|
|
expect( sellingElsewhere ).toBeTruthy();
|
|
|
|
expect( notSellingElsewhere ).toBeFalsy();
|
|
|
|
} );
|
|
|
|
test( 'isSellingOtherPlatformInPerson', () => {
|
2022-06-21 08:37:34 +00:00
|
|
|
const sellingAnotherPlatformAndInPerson =
|
|
|
|
isSellingOtherPlatformInPerson( 'brick-mortar-other' );
|
|
|
|
const notSellingAnotherPlatformAndInPerson =
|
|
|
|
isSellingOtherPlatformInPerson( 'no' );
|
2022-01-18 13:46:10 +00:00
|
|
|
|
|
|
|
expect( sellingAnotherPlatformAndInPerson ).toBeTruthy();
|
|
|
|
expect( notSellingAnotherPlatformAndInPerson ).toBeFalsy();
|
|
|
|
} );
|
|
|
|
} );
|
2021-03-17 08:22:33 +00:00
|
|
|
} );
|