|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +import React from 'react'; |
| 4 | +import { waitFor } from '@testing-library/react'; |
| 5 | + |
| 6 | +import AppLayout from '../../../lib/components/app-layout'; |
| 7 | +import { describeWithAppLayoutFeatureFlagEnabled } from '../../internal/widgets/__tests__/utils'; |
| 8 | +import { describeEachAppLayout, renderComponent } from './utils'; |
| 9 | + |
| 10 | +jest.mock('../../../lib/components/internal/widgets/loader-mock', () => { |
| 11 | + // set this flag before the module is instantiated |
| 12 | + (window as any)[Symbol.for('awsui-custom-flags')] = { appLayoutDelayedWidget: true }; |
| 13 | + return jest.requireActual('../../../lib/components/internal/widgets/loader-mock'); |
| 14 | +}); |
| 15 | + |
| 16 | +describeEachAppLayout({ themes: ['refresh-toolbar'], sizes: ['desktop'] }, () => { |
| 17 | + test('renders instantly when widget is not activated', () => { |
| 18 | + const { wrapper } = renderComponent(<AppLayout />); |
| 19 | + expect(wrapper.findNavigation()).toBeTruthy(); |
| 20 | + expect(wrapper.findTools()).toBeTruthy(); |
| 21 | + }); |
| 22 | + |
| 23 | + describeWithAppLayoutFeatureFlagEnabled(() => { |
| 24 | + test('renders app layout with a delay', async () => { |
| 25 | + const { wrapper } = renderComponent(<AppLayout />); |
| 26 | + expect(wrapper.findNavigation()).toBeFalsy(); |
| 27 | + expect(wrapper.findTools()).toBeFalsy(); |
| 28 | + |
| 29 | + await waitFor(() => { |
| 30 | + expect(wrapper.findNavigation()).toBeTruthy(); |
| 31 | + expect(wrapper.findTools()).toBeTruthy(); |
| 32 | + }); |
| 33 | + }); |
| 34 | + }); |
| 35 | +}); |
0 commit comments