/**
 * ErrorNotifications component tests.
 *
 * Site Kit by Google, Copyright 2022 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 ErrorNotifications from './ErrorNotifications';
import {
	render,
	createTestRegistry,
	provideUserAuthentication,
	provideModules,
	provideSiteInfo,
} from '../../../../tests/js/test-utils';
import { CORE_USER } from '../../googlesitekit/datastore/user/constants';

describe( 'ErrorNotifications', () => {
	let registry;

	beforeEach( () => {
		registry = createTestRegistry();
		provideModules( registry );
		registry.dispatch( CORE_USER ).receiveConnectURL( 'test-url' );
	} );

	it( 'does not render UnsatisfiedScopesAlert when user is not authenticated', () => {
		provideUserAuthentication( registry, {
			authenticated: false,
			unsatisfiedScopes: [
				'https://www.googleapis.com/auth/analytics.readonly',
			],
		} );
		const { container } = render( <ErrorNotifications />, {
			registry,
		} );
		expect( container.childElementCount ).toBe( 0 );
	} );

	it( 'renders UnsatisfiedScopesAlert when user is authenticated', () => {
		provideUserAuthentication( registry, {
			unsatisfiedScopes: [
				'https://www.googleapis.com/auth/analytics.readonly',
			],
		} );
		const { container } = render( <ErrorNotifications />, {
			registry,
		} );

		expect( container ).toHaveTextContent(
			'Site Kit can’t access necessary data'
		);
	} );

	it( 'renders `Get help` link', () => {
		provideUserAuthentication( registry, {
			unsatisfiedScopes: [
				'https://www.googleapis.com/auth/analytics.readonly',
			],
		} );
		provideSiteInfo( registry, {
			setupErrorCode: 'error_code',
			setupErrorMessage: 'An error occurred',
		} );
		const { container } = render( <ErrorNotifications />, {
			registry,
		} );

		expect( container ).toHaveTextContent( 'Get help' );
	} );
} );

@@ -957,16 +957,90 @@
 stants';
+%0Aimport %7B CORE_SITE %7D from '../../googlesitekit/datastore/site/constants';
 %0A%0Adescri
@@ -2222,16 +2222,60 @@
 stry, %7B%0A
+%09%09%09proxySupportLinkURL: 'https://test.com',%0A
 %09%09%09setup
@@ -2360,32 +2360,43 @@
 onst %7B container
+, getByRole
  %7D = render( %3CEr
@@ -2490,23 +2490,244 @@
 et help' );%0A
+%09%09expect( getByRole( 'link', %7B name: /get help/i %7D ) ).toHaveAttribute(%0A%09%09%09'href',%0A%09%09%09registry.select( CORE_SITE ).getErrorTroubleshootingLinkURL( %7B%0A%09%09%09%09code: registry.select( CORE_SITE ).getSetupErrorCode(),%0A%09%09%09%7D )%0A%09%09);%0A
 %09%7D );%0A%7D );%0A

Add additional expectations about URL in test.