Skip to content

Commit f5ea51b

Browse files
Fix test failures after styled-components migration
- Update Toast.spec.tsx to check data-fading-out attribute instead of isFadingOut prop, matching the new plain CSS implementation - Update index.spec.tsx to query elements by data-testid and aria-label instead of styled-component types (BannerBodyWrapper, CloseButton) - Remove import of deleted styles.tsx file from index.spec.tsx - Delete unused styles.tsx file as specified in migration plan All tests now query the actual DOM elements using their attributes, which aligns with the plain CSS migration approach. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent f2bbb48 commit f5ea51b

3 files changed

Lines changed: 11 additions & 119 deletions

File tree

src/app/notifications/components/ToastNotifications/Toast.spec.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('Toast', () => {
8282

8383
const bannerBody = component.root.findByProps({'data-testid': 'banner-body'});
8484

85-
expect(bannerBody.props.isFadingOut).toBe(true);
85+
expect(bannerBody.props['data-fading-out']).toBe(true);
8686

8787
component.unmount();
8888
});
@@ -98,7 +98,7 @@ describe('Toast', () => {
9898

9999
const bannerBody = component.root.findByProps({'data-testid': 'banner-body'});
100100

101-
expect(bannerBody.props.isFadingOut).toBe(false);
101+
expect(bannerBody.props['data-fading-out']).toBe(false);
102102

103103
component.unmount();
104104
});
@@ -135,7 +135,7 @@ describe('Toast', () => {
135135
assertWindow().dispatchEvent(event);
136136
});
137137

138-
expect(bannerBody.props.isFadingOut).toBe(true);
138+
expect(bannerBody.props['data-fading-out']).toBe(true);
139139

140140
component.unmount();
141141
});
@@ -157,15 +157,15 @@ describe('Toast', () => {
157157
assertWindow().dispatchEvent(event);
158158
});
159159

160-
expect(bannerBody.props.isFadingOut).toBe(true);
160+
expect(bannerBody.props['data-fading-out']).toBe(true);
161161

162162
renderer.act(() => {
163163
component.update(<TestContainer>
164164
<Toast dismiss={dismiss} notification={{...toast, timestamp: Date.now() + 10}} positionProps={position} />
165165
</TestContainer>);
166166
});
167167

168-
expect(bannerBody.props.isFadingOut).toBe(false);
168+
expect(bannerBody.props['data-fading-out']).toBe(false);
169169
component.unmount();
170170
});
171171

src/app/notifications/components/ToastNotifications/index.spec.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { AppState, Store } from '../../../types';
99
import { addToast, dismissNotification } from '../../actions';
1010
import { toastNotifications } from '../../selectors';
1111
import { toastMessageKeys } from './constants';
12-
import { BannerBodyWrapper, CloseButton } from './styles';
1312
import Toast from './Toast';
1413

1514
jest.mock('react', () => {
@@ -69,31 +68,31 @@ describe('ToastNotifications', () => {
6968
<ToastNotifications />
7069
</TestContainer>);
7170

72-
expect(root.findAllByType(BannerBodyWrapper)).toHaveLength(1);
71+
expect(root.findAllByProps({'data-testid': 'banner-body'})).toHaveLength(1);
7372

7473
renderer.act(() => {
7574
store.dispatch(addToast(secondNotificationMessage, {destination}));
7675
});
7776

78-
expect(root.findAllByType(BannerBodyWrapper)).toHaveLength(2);
77+
expect(root.findAllByProps({'data-testid': 'banner-body'})).toHaveLength(2);
7978

8079
const [firstNotification, secondNotification] = toastNotifications(store.getState());
8180

8281
renderer.act(() => {
8382
const firstNotificationNode = root.findByProps({notification: firstNotification});
84-
firstNotificationNode.findByType(CloseButton).props.onClick();
83+
firstNotificationNode.findByProps({'aria-label': 'dismiss'}).props.onClick();
8584
});
8685

8786
expect(dispatch).toHaveBeenCalledWith(dismissNotification(firstNotification));
88-
expect(root.findAllByType(BannerBodyWrapper)).toHaveLength(1);
87+
expect(root.findAllByProps({'data-testid': 'banner-body'})).toHaveLength(1);
8988

9089
renderer.act(() => {
9190
const secondNotificationNode = root.findByProps({notification: secondNotification});
92-
secondNotificationNode.findByType(CloseButton).props.onClick();
91+
secondNotificationNode.findByProps({'aria-label': 'dismiss'}).props.onClick();
9392
});
9493

9594
expect(dispatch).toHaveBeenCalledWith(dismissNotification(secondNotification));
96-
expect(root.findAllByType(BannerBodyWrapper)).toHaveLength(0);
95+
expect(root.findAllByProps({'data-testid': 'banner-body'})).toHaveLength(0);
9796
});
9897

9998
it('sorts notification in descending order based on timestamp', () => {

src/app/notifications/components/ToastNotifications/styles.tsx

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)