Skip to content

Commit e80f9f6

Browse files
committed
CONSOLE-4619: Migrate failing tests to RTL and improve ExternalLinkWithCopy
1 parent c487f63 commit e80f9f6

File tree

20 files changed

+243
-444
lines changed

20 files changed

+243
-444
lines changed

frontend/packages/console-app/locales/en/console-app.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@
284284
"{{fileName}} cannot be uploaded. Only {{fileExtensions}} files are supported currently. Try another file.": "{{fileName}} cannot be uploaded. Only {{fileExtensions}} files are supported currently. Try another file.",
285285
"Access our new quick starts where you can learn more about creating or deploying an application using OpenShift Developer Console. You can also restart this tour anytime here.": "Access our new quick starts where you can learn more about creating or deploying an application using OpenShift Developer Console. You can also restart this tour anytime here.",
286286
"Set your individual console preferences including default views, language, import settings, and more.": "Set your individual console preferences including default views, language, import settings, and more.",
287-
"Stay up-to-date with everything OpenShift on our <2>{t('console-app~blog')}</2> or continue to learn more in our <6>{t('console-app~documentation')}</6>.": "Stay up-to-date with everything OpenShift on our <2>{t('console-app~blog')}</2> or continue to learn more in our <6>{t('console-app~documentation')}</6>.",
288-
"blog": "blog",
289-
"documentation": "documentation",
287+
"Stay up-to-date with everything OpenShift on our <2>blog</2> or continue to learn more in our <6>documentation</6>.": "Stay up-to-date with everything OpenShift on our <2>blog</2> or continue to learn more in our <6>documentation</6>.",
290288
"Welcome to the new OpenShift experience!": "Welcome to the new OpenShift experience!",
291289
"Our new update with OpenShift 4.19 gives a more modern look to help enhance your experience and streamline your workflow, such as improved navigation and infrastructure. Want us to show you around?": "Our new update with OpenShift 4.19 gives a more modern look to help enhance your experience and streamline your workflow, such as improved navigation and infrastructure. Want us to show you around?",
292290
"Here is where you can view all of your OpenShift environments, including your projects and inventory. You can also access APIs and software catalogs.": "Here is where you can view all of your OpenShift environments, including your projects and inventory. You can also access APIs and software catalogs.",

frontend/packages/console-app/src/__tests__/network-policies/network-policy-selector-preview.spec.tsx

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

frontend/packages/console-app/src/components/guided-tour/GuidedTourText.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export const FinishTourText: React.FC = () => {
4040
<Trans t={t} ns="console-app">
4141
Stay up-to-date with everything OpenShift on our{' '}
4242
<ExternalLink href={openshiftBlogLink} data-test="openshift-blog-link">
43-
{t('console-app~blog')}
43+
blog
4444
</ExternalLink>{' '}
4545
or continue to learn more in our{' '}
4646
<ExternalLink href={openshiftHelpBase} data-test="openshift-help-link">
47-
{t('console-app~documentation')}
47+
documentation
4848
</ExternalLink>
4949
.
5050
</Trans>
Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,48 @@
1-
import { cleanup, configure, render, screen } from '@testing-library/react';
2-
import { useK8sWatchResource } from '@console/internal/components/utils/k8s-watch-hook';
3-
import { FinishTourText } from '../GuidedTourText';
1+
import { configure, render, screen } from '@testing-library/react';
2+
import { helpTourText, userPreferencesTourText, FinishTourText } from '../GuidedTourText';
3+
import '@testing-library/jest-dom';
44

5-
configure({ testIdAttribute: 'data-test' });
6-
7-
jest.mock('@console/internal/components/utils/k8s-watch-hook', () => {
8-
return {
9-
useK8sWatchResource: jest.fn(),
10-
};
11-
});
5+
// Mock k8s-watch-hook
6+
jest.mock('@console/internal/components/utils/k8s-watch-hook', () => ({
7+
useK8sWatchResource: () => [
8+
[{ metadata: { name: 'openshift-blog' }, spec: { href: 'https://blog.example.com' } }],
9+
],
10+
}));
1211

1312
describe('GuidedTourText', () => {
14-
afterEach(() => cleanup());
15-
16-
it('should render openshift-blog and openshift-docs link', () => {
17-
(useK8sWatchResource as jest.Mock).mockReturnValueOnce([[], true, '']);
18-
render(<FinishTourText />);
19-
20-
screen.getByTestId('openshift-blog-link');
21-
screen.getByTestId('openshift-docs-link');
13+
beforeAll(() => {
14+
configure({ testIdAttribute: 'data-test' });
2215
});
2316

24-
it('should render the openshift-blog href with link from consoleLinks', () => {
25-
(useK8sWatchResource as jest.Mock).mockReturnValueOnce([
26-
[{ metadata: { name: 'openshift-blog' }, spec: { href: 'https://blog.openshift.com/' } }],
27-
true,
28-
'',
29-
]);
30-
const { getByTestId } = render(<FinishTourText />);
31-
expect(getByTestId('openshift-blog-link').getAttribute('href')).toEqual(
32-
'https://blog.openshift.com/',
33-
);
17+
it('renders helpTourText', () => {
18+
render(helpTourText);
19+
expect(
20+
screen.getByText(
21+
'Access our new quick starts where you can learn more about creating or deploying an application using OpenShift Developer Console. You can also restart this tour anytime here.',
22+
),
23+
).toBeInTheDocument();
3424
});
3525

36-
it('should render the openshift-blog href with default link if consoleLinks are not available', () => {
37-
(useK8sWatchResource as jest.Mock).mockReturnValueOnce([[], true, '']);
38-
const { getByTestId } = render(<FinishTourText />);
39-
expect(getByTestId('openshift-blog-link').getAttribute('href')).toEqual(
40-
'https://developers.redhat.com/products/openshift/whats-new',
41-
);
26+
it('renders userPreferencesTourText', () => {
27+
render(userPreferencesTourText);
28+
expect(
29+
screen.getByText(
30+
'Set your individual console preferences including default views, language, import settings, and more.',
31+
),
32+
).toBeInTheDocument();
4233
});
4334

44-
it('should render openshift-docs href with default link', () => {
45-
(useK8sWatchResource as jest.Mock).mockReturnValueOnce([[], true, '']);
46-
const { getByTestId } = render(<FinishTourText />);
47-
expect(getByTestId('openshift-docs-link').getAttribute('href')).toEqual(
35+
it('renders FinishTourText with blog and documentation links', () => {
36+
render(<FinishTourText />);
37+
expect(screen.getByTestId('openshift-blog-link')).toHaveAttribute(
38+
'href',
39+
'https://blog.example.com',
40+
);
41+
expect(screen.getByTestId('openshift-help-link')).toHaveAttribute(
42+
'href',
4843
'https://docs.okd.io/latest/',
4944
);
45+
expect(screen.getByText('blog')).toBeInTheDocument();
46+
expect(screen.getByText('documentation')).toBeInTheDocument();
5047
});
5148
});

frontend/packages/console-dynamic-plugin-sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ This section documents notable changes in Console provided shared modules and ot
211211
> [!WARNING]
212212
> Usage of non-PatternFly CSS provided by Console in plugins is not supported. This section only serves
213213
> as a courtesy for plugins which use these unsupported CSS classes.
214-
215214
- Removed support for the Bootstrap Grid system (`.row`, `.col-*`, etc.). Use
216215
[PatternFly Grid](https://www.patternfly.org/layouts/grid) instead.
216+
- Removed `co-external-link` styling. Use PatternFly Buttons with `variant="link"` instead.
217217

218218
### PatternFly 5+ dynamic modules
219219

frontend/packages/console-shared/src/components/getting-started/GettingStartedCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const GettingStartedCard: React.FC<GettingStartedCardProps> = ({
8484
<SimpleList isControlled={false} className="ocs-getting-started-card__list">
8585
{links.map((link) =>
8686
link.loading ? (
87-
<li key={link.id}>
87+
<li key={link.id} data-test="getting-started-skeleton">
8888
<Skeleton fontSize="sm" />
8989
</li>
9090
) : (

0 commit comments

Comments
 (0)