Skip to content

Commit bd8db92

Browse files
committed
chore: Add test with no mountItem function
1 parent 243720d commit bd8db92

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/app-layout/__tests__/runtime-feature-notifications.test.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,39 @@ describeEachAppLayout({ themes: ['refresh-toolbar'] }, () => {
132132
expect(activeDrawerWrapper!.find('a')!.getElement()).toHaveAttribute('href', '/features-page');
133133
});
134134

135+
test('registers feature notifications correctly with no mountItem', async () => {
136+
awsuiWidgetPlugins.registerFeatureNotifications({ ...featureNotificationsDefaults, mountItem: undefined });
137+
const { wrapper } = await renderComponent(<AppLayout />);
138+
expect(wrapper.findDrawerTriggerById(featureNotificationsDefaults.id)).toBeTruthy();
139+
140+
wrapper.findDrawerTriggerById(featureNotificationsDefaults.id)!.click();
141+
142+
const activeDrawerWrapper = wrapper.findActiveDrawer()!;
143+
const featureItems = activeDrawerWrapper.findList()!.findItems()!;
144+
145+
expect(activeDrawerWrapper.getElement()).toBeTruthy();
146+
147+
// We expect 2 out of 3 features to be rendered since the default filter
148+
// excludes features older than 90 days, leaving only 2 valid features
149+
expect(featureItems).toHaveLength(2);
150+
151+
// Check content
152+
expect(featureItems[0].findContent().getElement()).toHaveTextContent('New Feature 1 Header');
153+
expect(featureItems[0].findSecondaryContent()!.getElement()).toHaveTextContent(
154+
'This is the first new feature content'
155+
);
156+
expect(featureItems[0].findSecondaryContent()!.getElement()).toHaveTextContent('Category A');
157+
expect(featureItems[0].findSecondaryContent()!.getElement()).toHaveTextContent('2025-01-15');
158+
159+
expect(featureItems[1].findContent().getElement()).toHaveTextContent('New Feature 2 Header');
160+
expect(featureItems[1].findSecondaryContent()!.getElement()).toHaveTextContent(
161+
'This is the second new feature content'
162+
);
163+
expect(featureItems[1].findSecondaryContent()!.getElement()).toHaveTextContent('2024-12-01');
164+
165+
expect(activeDrawerWrapper!.find('a')!.getElement()).toHaveAttribute('href', '/features-page');
166+
});
167+
135168
test('supports custom filterFeatures function', async () => {
136169
awsuiWidgetPlugins.registerFeatureNotifications({
137170
...featureNotificationsDefaults,

0 commit comments

Comments
 (0)