Skip to content

Commit

Permalink
Simplify stories for Ads SettingsView.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaemnnosttv committed May 31, 2024
1 parent b93ff7c commit 7e52a02
Showing 1 changed file with 30 additions and 63 deletions.
93 changes: 30 additions & 63 deletions assets/js/modules/ads/components/settings/SettingsView.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants';
import { provideModules } from '../../../../../../tests/js/utils';
import WithRegistrySetup from '../../../../../../tests/js/WithRegistrySetup';

function Template( {} ) {
function Template() {
return (
<div className="googlesitekit-layout">
<div className="googlesitekit-settings-module googlesitekit-settings-module--active googlesitekit-settings-module--analytics">
Expand All @@ -46,14 +46,30 @@ function Template( {} ) {

export const Default = Template.bind( null );
Default.storyName = 'Default';
Default.scenario = {
label: 'Modules/Ads/Settings/SettingsView',
Default.scenario = {};

export const IceEnabled = Template.bind( null );
IceEnabled.storyName = 'With ICE enabled';
IceEnabled.parameters = {
features: [ 'conversionInfra' ],
};
IceEnabled.args = {
enhancedConversionTracking: true,
};

export const IceDisabled = Template.bind( null );
IceDisabled.storyName = 'With ICE disabled';
IceDisabled.parameters = {
features: [ 'conversionInfra' ],
};
IceDisabled.args = {
enhancedConversionTracking: false,
};

export default {
title: 'Modules/Ads/Settings/SettingsView',
decorators: [
( Story ) => {
( Story, { args } ) => {
const setupRegistry = ( registry ) => {
provideModules( registry, [
{
Expand All @@ -66,6 +82,14 @@ export default {
registry.dispatch( MODULES_ADS ).receiveGetSettings( {
conversionID: 'AW-123456789',
} );

if ( args.hasOwnProperty( 'enhancedConversionTracking' ) ) {
registry
.dispatch( CORE_SITE )
.setConversionTrackingEnabled(
args.enhancedConversionTracking
);
}
};

return (
Expand All @@ -86,7 +110,7 @@ PaxConnected.parameters = {
features: [ 'adsPax' ],
};
PaxConnected.decorators = [
( Story, { parameters } ) => {
( Story ) => {
const setupRegistry = ( registry ) => {
// Unset the value set in the prrevious scenario.
registry.dispatch( MODULES_ADS ).setConversionID( null );
Expand All @@ -98,64 +122,7 @@ PaxConnected.decorators = [
};

return (
<WithRegistrySetup
func={ setupRegistry }
features={ parameters.features || [] }
>
<Story />
</WithRegistrySetup>
);
},
];

export const IceEnabled = Template.bind( null );
IceEnabled.storyName = 'With ICE enabled';
IceEnabled.scenario = {
label: 'Modules/Ads/Settings/SettingsView/ICE/Enabled',
};
IceEnabled.parameters = {
features: [ 'conversionInfra' ],
};
IceEnabled.decorators = [
( Story, { parameters } ) => {
const setupRegistry = ( registry ) => {
registry.dispatch( MODULES_ADS ).setConversionID( 'AW-12345' );
registry.dispatch( CORE_SITE ).setConversionTrackingEnabled( true );
};

return (
<WithRegistrySetup
func={ setupRegistry }
features={ parameters.features || [] }
>
<Story />
</WithRegistrySetup>
);
},
];

export const IceDisabled = Template.bind( null );
IceDisabled.storyName = 'With ICE disabled';
IceDisabled.scenario = {
label: 'Modules/Ads/Settings/SettingsView/ICE/Disabled',
};
IceDisabled.parameters = {
features: [ 'conversionInfra' ],
};
IceDisabled.decorators = [
( Story, { parameters } ) => {
const setupRegistry = ( registry ) => {
registry.dispatch( MODULES_ADS ).setConversionID( 'AW-12345' );
registry
.dispatch( CORE_SITE )
.setConversionTrackingEnabled( false );
};

return (
<WithRegistrySetup
func={ setupRegistry }
features={ parameters.features || [] }
>
<WithRegistrySetup func={ setupRegistry }>
<Story />
</WithRegistrySetup>
);
Expand Down

0 comments on commit 7e52a02

Please sign in to comment.