/**
 * Storybook preview config.
 *
 * Site Kit by Google, Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Internal dependencies
 */
import '../assets/sass/wpdashboard.scss';
import '../assets/sass/adminbar.scss';
import '../assets/sass/admin.scss';
import './assets/sass/wp-admin.scss';
// Ensure all globals are setup before any other imports are run.
import './polyfill-globals';
import { resetGlobals } from './utils/resetGlobals';
import { bootstrapFetchMocks } from './fetch-mocks';
import { WithTestRegistry } from '../tests/js/utils';

bootstrapFetchMocks();

export const decorators = [
	( Story ) => (
		<WithTestRegistry>
			<div className="googlesitekit-plugin-preview js">
				<div className="googlesitekit-plugin">
					<Story />
				</div>
			</div>
		</WithTestRegistry>
	),
	// Decorators run from last added to first
	( Story ) => {
		resetGlobals();

		return <Story />;
	},
];

export const parameters = {
	layout: 'fullscreen',
};

@@ -642,16 +642,110 @@
 e.%0A */%0A%0A
+/**%0A * External dependencies%0A */%0Aimport %7B useFirstMountState, useUnmount %7D from 'react-use';%0A%0A
 /**%0A * I
@@ -1183,32 +1183,133 @@
 s';%0A
-%0AbootstrapFetchMocks();%0A
+import %7B enabledFeatures %7D from '../assets/js/features';%0A%0AbootstrapFetchMocks();%0A%0A// Decorators run from last added to first.
 %0Aexp
@@ -1353,30 +1353,8 @@
 %3E (%0A
-%09%09%3CWithTestRegistry%3E%0A%09
 %09%09%3Cd
@@ -1404,17 +1404,16 @@
 js%22%3E%0A%09%09%09
-%09
 %3Cdiv cla
@@ -1443,17 +1443,16 @@
 lugin%22%3E%0A
-%09
 %09%09%09%09%3CSto
@@ -1460,25 +1460,23 @@
 y /%3E%0A%09%09%09
-%09
 %3C/div%3E%0A
-%09
 %09%09%3C/div%3E
@@ -1481,76 +1481,468 @@
 v%3E%0A%09
-%09%3C/WithTestR
+),%0A%09// Features must be set up before test r
 egistry
-%3E%0A%09),%0A%09// Decorators run from last added to first
+ is initialized.%0A%09( Story, %7B parameters %7D ) =%3E %7B%0A%09%09const %7B features = %5B%5D %7D = parameters;%0A%09%09const isFirstMount = useFirstMountState();%0A%09%09useUnmount( () =%3E enabledFeatures.clear() );%0A%0A%09%09if ( isFirstMount ) %7B%0A%09%09%09enabledFeatures.clear();%0A%09%09%09features.forEach( ( feature ) =%3E enabledFeatures.add( feature ) );%0A%09%09%7D%0A%0A%09%09return (%0A%09%09%09%3CWithTestRegistry features=%7B features %7D%3E%0A%09%09%09%09%3CStory /%3E%0A%09%09%09%3C/WithTestRegistry%3E%0A%09%09);%0A%09%7D,
 %0A%09( 

Update application of global decorators to support features via parameters.