113 lines
3.1 KiB
TypeScript
Raw Normal View History

feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
/* eslint-disable sonarjs/no-duplicate-string */
/* eslint-disable sonarjs/no-identical-functions */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { fireEvent, render, screen } from '@testing-library/react';
import { USER_PREFERENCES } from 'constants/userPreferences';
import MockQueryClientProvider from 'providers/test/MockQueryClientProvider';
import {
ChangelogSchema,
DeploymentType,
} from 'types/api/changelog/getChangelogByVersion';
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
import ChangelogModal from '../ChangelogModal';
const mockChangelog: ChangelogSchema = {
id: 1,
documentId: 'doc-1',
version: 'v1.0.0',
createdAt: '2025-06-09T12:00:00Z',
updatedAt: '2025-06-09T13:00:00Z',
publishedAt: '2025-06-09T14:00:00Z',
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
release_date: '2025-06-10',
features: [
{
id: 1,
title: 'Feature 1',
description: 'Description for feature 1',
media: null,
documentId: 'feature-1',
sort_order: 1,
createdAt: '2025-06-09T12:00:00Z',
updatedAt: '2025-06-09T13:00:00Z',
publishedAt: '2025-06-09T14:00:00Z',
deployment_type: DeploymentType.ALL,
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
},
],
bug_fixes: 'Bug fix details',
maintenance: 'Maintenance details',
};
// Mock react-markdown to just render children as plain text
jest.mock(
'react-markdown',
() =>
function ReactMarkdown({ children }: any) {
return <div>{children}</div>;
},
);
// mock useAppContext
jest.mock('providers/App/App', () => ({
useAppContext: jest.fn(() => ({
updateUserPreferenceInContext: jest.fn(),
userPreferences: [
{
name: USER_PREFERENCES.LAST_SEEN_CHANGELOG_VERSION,
value: 'v1.0.0',
},
],
})),
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
}));
function renderChangelog(onClose: () => void = jest.fn()): void {
render(
<MockQueryClientProvider>
<ChangelogModal changelog={mockChangelog} onClose={onClose} />
</MockQueryClientProvider>,
);
}
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
describe('ChangelogModal', () => {
it('renders modal with changelog data', () => {
renderChangelog();
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
expect(
screen.getByText('Whats New ⎯ Changelog : June 10, 2025'),
).toBeInTheDocument();
expect(screen.getByText('Feature 1')).toBeInTheDocument();
expect(screen.getByText('Description for feature 1')).toBeInTheDocument();
expect(screen.getByText('Bug fix details')).toBeInTheDocument();
expect(screen.getByText('Maintenance details')).toBeInTheDocument();
});
it('calls onClose when Skip for now is clicked', () => {
const onClose = jest.fn();
renderChangelog(onClose);
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
fireEvent.click(screen.getByText('Skip for now'));
expect(onClose).toHaveBeenCalled();
});
it('opens migration docs when Update my workspace is clicked', () => {
window.open = jest.fn();
renderChangelog();
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
fireEvent.click(screen.getByText('Update my workspace'));
expect(window.open).toHaveBeenCalledWith(
'https://signoz.io/upgrade-path',
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
'_blank',
'noopener,noreferrer',
);
});
it('scrolls for more when Scroll for more is clicked', () => {
renderChangelog();
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
const scrollBtn = screen.getByTestId('scroll-more-btn');
const contentDiv = screen.getByTestId('changelog-content');
if (contentDiv) {
contentDiv.scrollTo = jest.fn();
}
fireEvent.click(scrollBtn);
if (contentDiv) {
expect(contentDiv.scrollTo).toHaveBeenCalled();
}
});
});