Skip to content

Commit a19ac0e

Browse files
committed
chore: Refactoring, fixed skeleton test
1 parent aa1ddbc commit a19ac0e

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

src/app-layout/__tests__/skeleton.test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import React from 'react';
4+
import { waitFor } from '@testing-library/react';
45

56
import AppLayout from '../../../lib/components/app-layout';
67
import BreadcrumbGroup from '../../../lib/components/breadcrumb-group';
@@ -26,7 +27,7 @@ jest.mock('../../../lib/components/internal/widgets', () => ({
2627
}));
2728

2829
describeEachAppLayout({ themes: ['refresh-toolbar'], skipInitialTest: true }, () => {
29-
it('renders complete component by default', () => {
30+
it('renders complete component by default', async () => {
3031
const { wrapper } = renderComponent(
3132
<AppLayout
3233
navigation="test nav"
@@ -39,7 +40,9 @@ describeEachAppLayout({ themes: ['refresh-toolbar'], skipInitialTest: true }, ()
3940
expect(wrapper.findNavigation()).toBeTruthy();
4041
expect(wrapper.findBreadcrumbs()).toBeTruthy();
4142
expect(wrapper.findNotifications()).toBeTruthy();
42-
expect(wrapper.findTools()).toBeTruthy();
43+
await waitFor(() => {
44+
expect(wrapper.findTools()).toBeTruthy();
45+
});
4346
expect(wrapper.findContentRegion()).toBeTruthy();
4447
});
4548

src/app-layout/visual-refresh-toolbar/app-layout-state.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import { useAppLayout } from './use-app-layout';
1111
export interface AppLayoutStateProps {
1212
props: AppLayoutInternalProps;
1313
forwardRef: ForwardedRef<AppLayoutProps.Ref>;
14-
// onChange: (
15-
// appLayoutState: ReturnType<typeof useAppLayout>,
16-
// skeletonAttributes: ReturnType<typeof useSkeletonSlotsAttributes> | null
17-
// ) => void;
1814
stateManager: any;
1915
}
2016

src/app-layout/visual-refresh-toolbar/index.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const AppLayoutStateProvider: FC<{
1515
appLayoutState: ReturnType<typeof useAppLayout> | null,
1616
skeletonSlotsAttributes: ReturnType<typeof useSkeletonSlotsAttributes> | null
1717
) => React.ReactNode;
18-
// appLayoutStateChangeId: string;
1918
stateManager: any;
2019
}> = ({ stateManager, children }) => {
2120
const [appLayoutState, setAppLayoutState] = useState(null);
@@ -26,28 +25,18 @@ const AppLayoutStateProvider: FC<{
2625
setAppLayoutState(appLayoutState);
2726
setSkeletonAttributes(skeletonAttributes);
2827
};
29-
// addEventListener(appLayoutStateChangeId, event => {
30-
// unstable_batchedUpdates(() => {
31-
// setAppLayoutState((event as any).detail.appLayoutState);
32-
// setSkeletonAttributes((event as any).detail.skeletonAttributes);
33-
// });
34-
// });
3528
}, [stateManager]);
3629
return <>{children(appLayoutState, skeletonAttributes)}</>;
3730
};
3831

3932
const AppLayoutVisualRefreshToolbar = React.forwardRef<AppLayoutProps.Ref, AppLayoutInternalProps>(
4033
(props, forwardRef) => {
41-
// const appLayoutStateChangeId = useUniqueId('app-layout-state-change-');
4234
const stateManager = useRef<any>({});
4335

4436
return (
4537
<>
4638
<AppLayoutWidgetizedState props={props} forwardRef={forwardRef} stateManager={stateManager} />
47-
<AppLayoutStateProvider
48-
stateManager={stateManager}
49-
// appLayoutStateChangeId={appLayoutStateChangeId}
50-
>
39+
<AppLayoutStateProvider stateManager={stateManager}>
5140
{(appLayoutState, skeletonSlotsAttributes) => {
5241
return (
5342
<AppLayoutVisibilityContext.Provider value={appLayoutState?.isIntersecting ?? true}>

src/app-layout/visual-refresh-toolbar/notifications/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export function AppLayoutNotificationsImplementation({
2929

3030
useResizeObserver(rootRef, entry => {
3131
const hasContent = entry.contentBoxHeight > 0;
32-
setNotificationsHeight(hasContent ? entry.borderBoxHeight : 0);
32+
setNotificationsHeight?.(hasContent ? entry.borderBoxHeight : 0);
3333
setHasNotificationsContent(hasContent);
3434
});
3535
useEffect(() => {
3636
return () => {
37-
setNotificationsHeight(0);
37+
setNotificationsHeight?.(0);
3838
};
3939
// unmount effect only
4040
// eslint-disable-next-line react-hooks/exhaustive-deps

src/app-layout/visual-refresh-toolbar/skeleton/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const SkeletonLayout = (props: RootSkeletonLayoutProps) => {
124124
verticalOffsets,
125125
placement,
126126
navigationOpen: resolvedNavigationOpen,
127+
breadcrumbs,
127128
},
128129
toolbarProps,
129130
registered,

0 commit comments

Comments
 (0)