Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Optimize settings form displays "use snippet instructions" flash. #4093

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function UseSnippetInstructions() {
}

// If we don't use auto insert gtag, but use auto insert gtm. Show instruction of how to implement it on GTM.
if ( ! analyticsUseSnippet && gtmActive && gtmUseSnippet ) {
if ( false === analyticsUseSnippet && gtmActive && gtmUseSnippet ) {
return (
<Fragment>
<p>
Expand Down Expand Up @@ -124,7 +124,7 @@ export default function UseSnippetInstructions() {
);
}

if ( ! analyticsUseSnippet ) {
if ( false === analyticsUseSnippet ) {
return (
<Fragment>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,24 @@ describe( 'UseSnippetInstructions', () => {
unsubscribeFromAll( registry );
} );

it( 'should not render with analytics active and unresolved useSnippet', async () => {
registry.dispatch( MODULES_OPTIMIZE ).setOptimizeID( 'OPT-1234567' );
registry
.dispatch( CORE_MODULES )
.receiveGetModules( withActive( 'analytics' ) );
const { container } = render( <UseSnippetInstructions />, {
registry,
} );

expect( container ).toBeEmptyDOMElement();
} );

it( 'should render with analytics active and no useSnippet', async () => {
registry.dispatch( MODULES_OPTIMIZE ).setOptimizeID( 'OPT-1234567' );
registry
.dispatch( CORE_MODULES )
.receiveGetModules( withActive( 'analytics' ) );
registry.dispatch( MODULES_ANALYTICS ).setUseSnippet( false );
const { container } = render( <UseSnippetInstructions />, {
registry,
} );
Expand Down Expand Up @@ -96,6 +109,7 @@ describe( 'UseSnippetInstructions', () => {
registry.dispatch( MODULES_OPTIMIZE ).setOptimizeID( 'OPT-1234567' );
registry.dispatch( CORE_MODULES ).receiveGetModules( newFixtures );
registry.dispatch( MODULES_TAGMANAGER ).setUseSnippet( true );
registry.dispatch( MODULES_ANALYTICS ).setUseSnippet( false );

const { container } = render( <UseSnippetInstructions />, {
registry,
Expand Down