diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.component.tsx index 207f561feb5..666836fa01f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.component.tsx @@ -18,7 +18,6 @@ import { useTranslation } from 'react-i18next'; import { ReactComponent as CloseIcon } from '../../../../assets/svg/close.svg'; import { ReactComponent as RocketIcon } from '../../../../assets/svg/rocket.svg'; import { ROUTES, VERSION } from '../../../../constants/constants'; -import { useAuth } from '../../../../hooks/authHooks'; import { useApplicationStore } from '../../../../hooks/useApplicationStore'; import useCustomLocation from '../../../../hooks/useCustomLocation/useCustomLocation'; import brandClassBase from '../../../../utils/BrandData/BrandClassBase'; @@ -31,13 +30,14 @@ const cookieStorage = new CookieStorage(); const WhatsNewAlert = () => { const { t } = useTranslation(); const location = useCustomLocation(); - const { isFirstTimeUser } = useAuth(); const { appVersion } = useApplicationStore(); const [showWhatsNew, setShowWhatsNew] = useState({ alert: false, modal: false, }); - const cookieKey = getVersionedStorageKey(VERSION, appVersion); + const cookieKey = useMemo(() => { + return appVersion ? getVersionedStorageKey(VERSION, appVersion) : null; + }, [appVersion]); const { releaseLink, blogLink, isMajorRelease } = useMemo(() => { return { @@ -63,18 +63,22 @@ const WhatsNewAlert = () => { ); const handleCancel = useCallback(() => { - cookieStorage.setItem(cookieKey, 'true', { - expires: getReleaseVersionExpiry(), - }); + if (cookieKey) { + cookieStorage.setItem(cookieKey, 'true', { + expires: getReleaseVersionExpiry(), + }); + } onModalCancel(); }, [cookieStorage, onModalCancel, getReleaseVersionExpiry, cookieKey]); useEffect(() => { - setShowWhatsNew({ - alert: cookieStorage.getItem(cookieKey) !== 'true', - modal: false, - }); - }, [isFirstTimeUser, cookieKey]); + if (cookieKey) { + setShowWhatsNew((prev) => ({ + ...prev, + alert: cookieStorage.getItem(cookieKey) !== 'true', + })); + } + }, [cookieKey]); return ( <> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.test.tsx index 225367be287..36ff99ac523 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/WhatsNewModal/WhatsNewAlert/WhatsNewAlert.test.tsx @@ -209,9 +209,10 @@ describe('WhatsNewAlert', () => { appVersion: undefined, })); - const { findByText } = render(); + const { queryByTestId } = render(); - expect(await findByText('Version')).toBeInTheDocument(); + // Should not render the alert when appVersion is undefined + expect(queryByTestId('whats-new-alert-card')).not.toBeInTheDocument(); }); it('should call brandClassBase methods with correct version', () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.component.tsx index b422a06b1d8..4784fedec6f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.component.tsx @@ -16,7 +16,6 @@ import ButtonGroup from 'antd/lib/button/button-group'; import { CookieStorage } from 'cookie-storage'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Link } from 'react-router-dom'; import { ReactComponent as CloseIcon } from '../../../assets/svg/close.svg'; import { ReactComponent as StarGithubIcon } from '../../../assets/svg/ic-star-github.svg'; import { ReactComponent as StarIcon } from '../../../assets/svg/ic-start-filled-github.svg'; @@ -150,23 +149,15 @@ const GithubStarCard = () => { - + - + - + - + diff --git a/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.test.tsx index 42d620f1b49..38b8e048e75 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/MyData/GithubStarCard/GithubStarCard.test.tsx @@ -16,20 +16,10 @@ import { TWO_MINUTE_IN_MILLISECOND } from '../../../constants/constants'; import useCustomLocation from '../../../hooks/useCustomLocation/useCustomLocation'; import GithubStarCard from './GithubStarCard.component'; -const mockLinkButton = jest.fn(); - jest.mock('../../../hooks/useCustomLocation/useCustomLocation', () => { return jest.fn().mockImplementation(() => ({ pathname: '/my-data' })); }); -jest.mock('react-router-dom', () => ({ - Link: jest.fn().mockImplementation(({ children, ...rest }) => ( - - {children} - - )), -})); - jest.mock('../../../utils/WhatsNewModal.util', () => ({ getReleaseVersionExpiry: jest.fn().mockImplementation(() => new Date()), })); @@ -72,21 +62,26 @@ describe('GithubStarCard', () => { expect(screen.getByRole('button', { name: '10' })).toBeInTheDocument(); }); - it('check redirect buttons', async () => { + it('check redirect buttons have correct links', async () => { render(); jest.advanceTimersByTime(TWO_MINUTE_IN_MILLISECOND); - const starTextButton = await screen.findByRole('button', { - name: 'label.star', - }); + await screen.findByTestId('github-star-popup-card'); - fireEvent.click(starTextButton); + // Check that both links point to the correct GitHub repository + const links = screen.getAllByRole('link'); - const countButton = screen.getByRole('button', { name: '10' }); - - fireEvent.click(countButton); - - expect(mockLinkButton).toHaveBeenCalledTimes(2); + expect(links).toHaveLength(2); + expect(links[0]).toHaveAttribute( + 'href', + 'https://star-us.open-metadata.org/' + ); + expect(links[0]).toHaveAttribute('target', '_blank'); + expect(links[1]).toHaveAttribute( + 'href', + 'https://star-us.open-metadata.org/' + ); + expect(links[1]).toHaveAttribute('target', '_blank'); }); it('should close the alert when the close button is clicked', async () => {