Skip to content

Commit 0e97d47

Browse files
authored
chore: Expose clear state methods in public runtime API (#4121)
1 parent 37a490c commit 0e97d47

File tree

13 files changed

+23
-29
lines changed

13 files changed

+23
-29
lines changed

src/alert/__tests__/runtime-action.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { act, fireEvent, render, screen } from '@testing-library/react';
55

66
import Alert from '../../../lib/components/alert';
77
import awsuiPlugins from '../../../lib/components/internal/plugins';
8-
import { awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
98
import { ActionConfig } from '../../../lib/components/internal/plugins/controllers/action-buttons';
109

1110
const defaultAction: ActionConfig = {
@@ -23,7 +22,7 @@ function delay() {
2322
}
2423

2524
afterEach(() => {
26-
awsuiPluginsInternal.alert.clearRegisteredActions();
25+
awsuiPlugins.alert.clearRegisteredActionsForTesting();
2726
});
2827

2928
test('renders runtime action button initially', async () => {

src/alert/__tests__/runtime-content-initial.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import testRenderer, { ReactTestRendererJSON } from 'react-test-renderer';
55

66
import Alert from '../../../lib/components/alert';
77
import awsuiPlugins from '../../../lib/components/internal/plugins';
8-
import { awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
98
import { AlertFlashContentConfig } from '../../../lib/components/internal/plugins/controllers/alert-flash-content';
109

1110
import stylesCss from '../../../lib/components/alert/styles.css.js';
1211

1312
afterEach(() => {
14-
awsuiPluginsInternal.alertContent.clearRegisteredReplacer();
13+
awsuiPlugins.alertContent.clearRegisteredReplacerForTesting();
1514
jest.resetAllMocks();
1615
jest.restoreAllMocks();
1716
});

src/alert/__tests__/runtime-content.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Alert from '../../../lib/components/alert';
77
import Button from '../../../lib/components/button';
88
import { metrics } from '../../../lib/components/internal/metrics';
99
import awsuiPlugins from '../../../lib/components/internal/plugins';
10-
import { awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
1110
import { AlertFlashContentConfig } from '../../../lib/components/internal/plugins/controllers/alert-flash-content';
1211
import createWrapper from '../../../lib/components/test-utils/dom';
1312
import { expectContent } from './runtime-content-utils';
@@ -36,7 +35,7 @@ beforeEach(() => {
3635
});
3736

3837
afterEach(() => {
39-
awsuiPluginsInternal.alertContent.clearRegisteredReplacer();
38+
awsuiPlugins.alertContent.clearRegisteredReplacerForTesting();
4039
jest.resetAllMocks();
4140
jest.restoreAllMocks();
4241
});

src/app-layout-toolbar/__tests__/analytics-metadata.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { clearVisualRefreshState } from '@cloudscape-design/component-toolkit/in
1212

1313
import AppLayoutToolbar, { AppLayoutToolbarProps } from '../../../lib/components/app-layout-toolbar';
1414
import Header from '../../../lib/components/header';
15-
import { awsuiPlugins, awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
15+
import awsuiPlugins from '../../../lib/components/internal/plugins';
1616
import SplitPanel from '../../../lib/components/split-panel';
1717
import createWrapper from '../../../lib/components/test-utils/dom';
1818
import { validateComponentNameAndLabels } from '../../internal/__tests__/analytics-metadata-test-utils';
@@ -48,7 +48,7 @@ const globalWithFlags = globalThis as any;
4848

4949
beforeEach(() => {
5050
globalWithFlags[Symbol.for('awsui-visual-refresh-flag')] = () => true;
51-
awsuiPluginsInternal.appLayout.clearRegisteredDrawers();
51+
awsuiPlugins.appLayout.clearRegisteredDrawersForTesting();
5252
});
5353

5454
afterEach(() => {

src/app-layout/__tests__/runtime-drawers-layout.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { act, render, waitFor } from '@testing-library/react';
66
import AppLayout from '../../../lib/components/app-layout';
77
import { useAppLayoutPlacement } from '../../../lib/components/app-layout/utils/use-app-layout-placement';
88
import { computeHorizontalLayout } from '../../../lib/components/app-layout/visual-refresh-toolbar/compute-layout';
9-
import { awsuiPlugins, awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
9+
import awsuiPlugins from '../../../lib/components/internal/plugins';
1010
import { DrawerConfig } from '../../../lib/components/internal/plugins/controllers/drawers';
1111
import * as awsuiWidgetInternal from '../../../lib/components/internal/plugins/widget/core';
1212
import * as awsuiWidgetPlugins from '../../../lib/components/internal/plugins/widget/index';
@@ -15,7 +15,7 @@ import { KeyCode } from '../../internal/keycode';
1515
import { describeEachAppLayout, getGlobalDrawersTestUtils, testDrawer } from './utils';
1616

1717
beforeEach(() => {
18-
awsuiPluginsInternal.appLayout.clearRegisteredDrawers();
18+
awsuiPlugins.appLayout.clearRegisteredDrawersForTesting();
1919
awsuiWidgetInternal.clearInitialMessages();
2020
});
2121

src/app-layout/__tests__/runtime-drawers.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getGeneratedAnalyticsMetadata } from '@cloudscape-design/component-tool
99
import { Button } from '../../../lib/components';
1010
import AppLayout, { AppLayoutProps } from '../../../lib/components/app-layout';
1111
import { TOOLS_DRAWER_ID } from '../../../lib/components/app-layout/utils/use-drawers';
12-
import { awsuiPlugins, awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
12+
import awsuiPlugins from '../../../lib/components/internal/plugins';
1313
import { DrawerConfig } from '../../../lib/components/internal/plugins/controllers/drawers';
1414
import * as awsuiWidgetInternal from '../../../lib/components/internal/plugins/widget/core';
1515
import * as awsuiWidgetPlugins from '../../../lib/components/internal/plugins/widget/index';
@@ -32,7 +32,7 @@ import toolbarStyles from '../../../lib/components/app-layout/visual-refresh-too
3232
import toolbarTriggerStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/toolbar/trigger-button/styles.selectors.js';
3333

3434
beforeEach(() => {
35-
awsuiPluginsInternal.appLayout.clearRegisteredDrawers();
35+
awsuiPlugins.appLayout.clearRegisteredDrawersForTesting();
3636
awsuiWidgetInternal.clearInitialMessages();
3737
activateAnalyticsMetadata(true);
3838
});

src/app-layout/__tests__/use-runtime-drawer-context.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ReactDOM, { unmountComponentAtNode } from 'react-dom';
55
import { act, render } from '@testing-library/react';
66

77
import AppLayout from '../../../lib/components/app-layout';
8-
import { awsuiPlugins, awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
8+
import awsuiPlugins from '../../../lib/components/internal/plugins';
99
import createWrapper from '../../../lib/components/test-utils/dom';
1010
import { useRuntimeDrawerContext } from '../runtime-drawer/use-runtime-drawer-context';
1111
import { describeEachAppLayout, getGlobalDrawersTestUtils, testDrawer } from './utils';
@@ -29,7 +29,7 @@ function delay() {
2929
}
3030

3131
beforeEach(() => {
32-
awsuiPluginsInternal.appLayout.clearRegisteredDrawers();
32+
awsuiPlugins.appLayout.clearRegisteredDrawersForTesting();
3333
});
3434

3535
jest.mock('@cloudscape-design/component-toolkit', () => ({

src/flashbar/__tests__/runtime-action.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { act, fireEvent, render, screen } from '@testing-library/react';
55

66
import Flashbar, { FlashbarProps } from '../../../lib/components/flashbar';
77
import awsuiPlugins from '../../../lib/components/internal/plugins';
8-
import { awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
98
import { ActionConfig } from '../../../lib/components/internal/plugins/controllers/action-buttons';
109
import createWrapper, { ElementWrapper } from '../../../lib/components/test-utils/dom';
1110

@@ -26,7 +25,7 @@ function delay() {
2625
}
2726

2827
afterEach(() => {
29-
awsuiPluginsInternal.flashbar.clearRegisteredActions();
28+
awsuiPlugins.flashbar.clearRegisteredActionsForTesting();
3029
});
3130

3231
test('renders runtime action button initially', async () => {

src/flashbar/__tests__/runtime-content-initial.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import testRenderer, { ReactTestRenderer, ReactTestRendererJSON } from 'react-te
55

66
import Flashbar from '../../../lib/components/flashbar';
77
import awsuiPlugins from '../../../lib/components/internal/plugins';
8-
import { awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
98
import { AlertFlashContentConfig } from '../../../lib/components/internal/plugins/controllers/alert-flash-content';
109

1110
import stylesCss from '../../../lib/components/flashbar/styles.css.js';
1211

1312
afterEach(() => {
14-
awsuiPluginsInternal.flashContent.clearRegisteredReplacer();
13+
awsuiPlugins.flashContent.clearRegisteredReplacerForTesting();
1514
jest.resetAllMocks();
1615
jest.restoreAllMocks();
1716
});

src/flashbar/__tests__/runtime-content.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Button from '../../../lib/components/button';
77
import Flashbar from '../../../lib/components/flashbar';
88
import { metrics } from '../../../lib/components/internal/metrics';
99
import awsuiPlugins from '../../../lib/components/internal/plugins';
10-
import { awsuiPluginsInternal } from '../../../lib/components/internal/plugins/api';
1110
import { AlertFlashContentConfig } from '../../../lib/components/internal/plugins/controllers/alert-flash-content';
1211
import createWrapper from '../../../lib/components/test-utils/dom';
1312
import { expectContent } from '../../alert/__tests__/runtime-content-utils';
@@ -29,7 +28,7 @@ const defaultContent: AlertFlashContentConfig = {
2928
};
3029

3130
afterEach(() => {
32-
awsuiPluginsInternal.flashContent.clearRegisteredReplacer();
31+
awsuiPlugins.flashContent.clearRegisteredReplacerForTesting();
3332
jest.resetAllMocks();
3433
jest.restoreAllMocks();
3534
});

0 commit comments

Comments
 (0)