From ee10d0aa9c6198a4f3412d4a1988d593f71a7370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Gr=C3=A4=C3=9Fl?= Date: Wed, 15 Nov 2023 11:24:46 +0100 Subject: [PATCH] fix(TitleColumn): Use react router Link InsightsLink is not fully working in scenarios where the Link is in another applications. --- src/components/InventoryTable/TitleColumn.js | 5 ++-- .../InventoryTable/TitleColumn.test.js | 12 ++++++++- .../__snapshots__/TitleColumn.test.js.snap | 26 +++++++++++++++++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/components/InventoryTable/TitleColumn.js b/src/components/InventoryTable/TitleColumn.js index 3e1e86d05..83e956a9f 100644 --- a/src/components/InventoryTable/TitleColumn.js +++ b/src/components/InventoryTable/TitleColumn.js @@ -1,6 +1,6 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import Link from '@redhat-cloud-services/frontend-components/InsightsLink'; +import { Link } from 'react-router-dom'; /** * Helper function to proprly calculate what to do when user clicks on first cell. @@ -39,9 +39,8 @@ const TitleColumn = ({ children, id, item, ...props }) => ( children ) : ( { diff --git a/src/components/InventoryTable/TitleColumn.test.js b/src/components/InventoryTable/TitleColumn.test.js index b44371be8..87983264c 100644 --- a/src/components/InventoryTable/TitleColumn.test.js +++ b/src/components/InventoryTable/TitleColumn.test.js @@ -4,7 +4,7 @@ import { act, fireEvent, render } from '@testing-library/react'; jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), - Link: ({ children, ...props }) => {children}, // eslint-disable-line + Link: ({ children, ...props }) => {children}, // eslint-disable-line })); describe('TitleColumn', () => { @@ -40,6 +40,16 @@ describe('TitleColumn', () => { expect(asFragment()).toMatchSnapshot(); }); + it('should render correctly with to', () => { + const { asFragment } = render( + + something + + ); + + expect(asFragment()).toMatchSnapshot(); + }); + it('should render correctly no detail with data', () => { const { asFragment } = render( @@ -42,6 +42,7 @@ exports[`TitleColumn should render correctly with data 1`] = ` class="" > something @@ -60,7 +61,8 @@ exports[`TitleColumn should render correctly with href 1`] = ` class="" > something @@ -81,6 +83,7 @@ exports[`TitleColumn should render correctly with os_release 1`] = ` class="" > something @@ -89,3 +92,22 @@ exports[`TitleColumn should render correctly with os_release 1`] = ` `; + +exports[`TitleColumn should render correctly with to 1`] = ` + + + +`;