Skip to content

Commit 4ac71d0

Browse files
fix(PageHeader): deprecate components and docs, point to ibm-products (#22120)
* fix(PageHeader): deprecate components and docs, point to ibm-products * fix: revert live demo back to original * fix: pageheader.mdx formatting * fix: update cli use * fix(upgrade): propagate migration flags and merge PageHeader imports --------- Co-authored-by: Sangeetha Babu <sangeetha9223@gmail.com>
1 parent bccb4fd commit 4ac71d0

29 files changed

Lines changed: 612 additions & 1265 deletions

packages/react/src/components/PageHeader/PageHeader-test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
/**
8+
* @deprecated PageHeader has moved to Carbon for IBM Products.
9+
* See https://github.com/carbon-design-system/carbon/issues/21926
10+
*/
711

812
import { render, screen, act, waitFor } from '@testing-library/react';
913
import userEvent from '@testing-library/user-event';
@@ -14,6 +18,8 @@ import {
1418
PageHeaderBreadcrumbBar as PageHeaderBreadcrumbBarDirect,
1519
PageHeaderContent as PageHeaderContentDirect,
1620
PageHeaderContentPageActions as PageHeaderContentPageActionsDirect,
21+
PageHeaderContentText as PageHeaderContentTextDirect,
22+
PageHeaderHeroImage as PageHeaderHeroImageDirect,
1723
PageHeaderTabBar as PageHeaderTabBarDirect,
1824
} from '../PageHeader';
1925
import * as hooks from '../../internal/useMatchMedia';
@@ -39,13 +45,68 @@ jest.mock('@carbon/utilities', () => ({
3945
}));
4046

4147
describe('PageHeader', () => {
48+
let consoleWarn;
49+
4250
beforeEach(() => {
4351
mockUseOverflowItems.mockReset();
4452
mockUseOverflowItems.mockReturnValue({
4553
visibleItems: [],
4654
hiddenItems: [],
4755
itemRefHandler: jest.fn(),
4856
});
57+
consoleWarn = jest.spyOn(console, 'warn').mockImplementation(() => {});
58+
});
59+
60+
afterEach(() => {
61+
consoleWarn.mockRestore();
62+
});
63+
64+
describe('deprecation warnings', () => {
65+
it('should warn once for each deprecated surface', () => {
66+
window.matchMedia = jest.fn().mockImplementation(() => ({
67+
matches: false,
68+
addEventListener: jest.fn(),
69+
removeEventListener: jest.fn(),
70+
}));
71+
72+
render(
73+
<>
74+
<PageHeaderDirect />
75+
<PageHeaderBreadcrumbBarDirect />
76+
<PageHeaderContentDirect title="title" />
77+
<PageHeaderContentPageActionsDirect
78+
actions={[]}
79+
menuButtonLabel="Actions"
80+
/>
81+
<PageHeaderContentTextDirect subtitle="subtitle" />
82+
<PageHeaderHeroImageDirect />
83+
<PageHeaderTabBarDirect />
84+
</>
85+
);
86+
87+
expect(consoleWarn).toHaveBeenCalledTimes(7);
88+
expect(consoleWarn).toHaveBeenCalledWith(
89+
'Warning: The `PageHeader` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
90+
);
91+
expect(consoleWarn).toHaveBeenCalledWith(
92+
'Warning: The `PageHeaderBreadcrumbBar` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
93+
);
94+
expect(consoleWarn).toHaveBeenCalledWith(
95+
'Warning: The `PageHeaderContent` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
96+
);
97+
expect(consoleWarn).toHaveBeenCalledWith(
98+
'Warning: The `PageHeaderContentPageActions` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
99+
);
100+
expect(consoleWarn).toHaveBeenCalledWith(
101+
'Warning: The `PageHeaderContentText` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
102+
);
103+
expect(consoleWarn).toHaveBeenCalledWith(
104+
'Warning: The `PageHeaderHeroImage` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
105+
);
106+
expect(consoleWarn).toHaveBeenCalledWith(
107+
'Warning: The `PageHeaderTabBar` component in `@carbon/react` has been deprecated and moved to `@carbon/ibm-products`. See https://github.com/carbon-design-system/carbon/issues/21926'
108+
);
109+
});
49110
});
50111

51112
describe('export configuration', () => {

0 commit comments

Comments
 (0)