Files
TREK/client/src/components/Settings/AboutTab.test.tsx
T
Maurice bcdcd69a64 feat(notices): 5.2.0 release modal and Patreon for monthly support
The release modal now shows 5.2.0: booking mails that land in the trip,
live flight status and the new trip PDF, each with its own drawn card,
and links the 5.2.0 release notes. The maintainer note and the support
block are rewritten, shorter and without the sponsor wording.

Patreon joins Buy Me a Coffee and Ko-fi as the monthly way to support
TREK: a full-width button in the release and thank-you notices (a new
optional tertiaryCta on the notice contract), a tile in About and in the
admin GitHub panel on desktop and phone, the README badges and
FUNDING.yml. Like the other donation links it stays hidden inside the
native apps.
2026-11-23 21:15:54 +01:00

156 lines
6.9 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen } from '../../../tests/helpers/render';
import { resetAllStores } from '../../../tests/helpers/store';
import AboutTab from './AboutTab';
beforeEach(() => {
resetAllStores();
vi.clearAllMocks();
});
describe('AboutTab', () => {
it('FE-COMP-ABOUT-001: renders without crashing', () => {
render(<AboutTab appVersion="2.9.10" />);
expect(document.body).toBeInTheDocument();
});
it('FE-COMP-ABOUT-002: displays the version badge', () => {
render(<AboutTab appVersion="2.9.10" />);
expect(screen.getByText('v2.9.10')).toBeInTheDocument();
});
it('FE-COMP-ABOUT-003: displays Ko-fi link with correct href', () => {
render(<AboutTab appVersion="2.9.10" />);
const link = screen.getByText('Ko-fi').closest('a');
expect(link).toHaveAttribute('href', 'https://ko-fi.com/mauriceboe');
});
it('FE-COMP-ABOUT-004: displays Buy Me a Coffee link with correct href', () => {
render(<AboutTab appVersion="2.9.10" />);
const link = screen.getByText('Buy Me a Coffee').closest('a');
expect(link).toHaveAttribute('href', 'https://buymeacoffee.com/mauriceboe');
});
it('FE-COMP-ABOUT-005: displays Discord link with correct href', () => {
render(<AboutTab appVersion="2.9.10" />);
const link = screen.getByText('Discord').closest('a');
expect(link).toHaveAttribute('href', 'https://discord.gg/NhZBDSd4qW');
});
it('FE-COMP-ABOUT-006: displays bug report link', () => {
render(<AboutTab appVersion="2.9.10" />);
const link = document.querySelector('a[href*="issues/new"]');
expect(link).toBeInTheDocument();
expect(link).toHaveAttribute('href', 'https://github.com/liketrek/TREK/issues/new?template=bug_report.yml');
});
it('FE-COMP-ABOUT-007: displays feature request link', () => {
render(<AboutTab appVersion="2.9.10" />);
const link = document.querySelector('a[href*="discussions/new"]');
expect(link).toBeInTheDocument();
expect(link).toHaveAttribute('target', '_blank');
});
it('FE-COMP-ABOUT-008: displays wiki link', () => {
render(<AboutTab appVersion="2.9.10" />);
const link = document.querySelector('a[href*="wiki"]');
expect(link).toBeInTheDocument();
});
it('FE-COMP-ABOUT-009: all external links have rel="noopener noreferrer"', () => {
render(<AboutTab appVersion="2.9.10" />);
const links = document.querySelectorAll('a');
// Seven tiles, and the sponsor panel: its logo, its button and the name in its title and body.
expect(links).toHaveLength(11);
expect(document.querySelector('a[href="https://www.patreon.com/cw/mauriceboe"]')).not.toBeNull();
links.forEach((link) => {
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
});
});
it('FE-COMP-ABOUT-010: all external links open in a new tab', () => {
render(<AboutTab appVersion="2.9.10" />);
const links = document.querySelectorAll('a');
links.forEach((link) => {
expect(link).toHaveAttribute('target', '_blank');
});
});
it('FE-COMP-ABOUT-011: version prop change is reflected', () => {
render(<AboutTab appVersion="1.0.0" />);
expect(screen.getByText('v1.0.0')).toBeInTheDocument();
expect(screen.queryByText('v2.9.10')).toBeNull();
});
// The hover look lives in Tailwind classes driven by the tile's `--tile`
// colour now, so the tests pin the colour each tile hands its classes.
const tile = (link: HTMLAnchorElement) => ({
color: link.style.getPropertyValue('--tile'),
hovers: link.className.includes('hover:border-[color:var(--tile)]'),
});
it('FE-COMP-ABOUT-012: the Ko-fi tile carries its brand colour for the hover border', () => {
render(<AboutTab appVersion="1.0.0" />);
const link = screen.getByText('Ko-fi').closest('a') as HTMLAnchorElement;
expect(link).toHaveAttribute('href', 'https://ko-fi.com/mauriceboe');
expect(tile(link)).toEqual({ color: '#ff5e5b', hovers: true });
});
it('FE-COMP-ABOUT-013: the Buy Me a Coffee tile carries its brand colour for the hover border', () => {
render(<AboutTab appVersion="1.0.0" />);
const link = screen.getByText('Buy Me a Coffee').closest('a') as HTMLAnchorElement;
expect(link).toHaveAttribute('href', 'https://buymeacoffee.com/mauriceboe');
expect(tile(link)).toEqual({ color: '#ffdd00', hovers: true });
});
it('FE-COMP-ABOUT-014: the Discord tile carries its brand colour for the hover border', () => {
render(<AboutTab appVersion="1.0.0" />);
const link = screen.getByText('Discord').closest('a') as HTMLAnchorElement;
expect(link).toHaveAttribute('href', 'https://discord.gg/NhZBDSd4qW');
expect(tile(link)).toEqual({ color: '#5865F2', hovers: true });
});
it('FE-COMP-ABOUT-015: the bug report tile uses the danger token', () => {
render(<AboutTab appVersion="1.0.0" />);
const link = document.querySelector('a[href*="issues/new"]') as HTMLAnchorElement;
expect(link).toHaveAttribute('target', '_blank');
expect(tile(link)).toEqual({ color: 'var(--danger)', hovers: true });
});
it('FE-COMP-ABOUT-016: the feature request tile uses the warning token', () => {
render(<AboutTab appVersion="1.0.0" />);
const link = document.querySelector('a[href*="discussions/new"]') as HTMLAnchorElement;
expect(link).toHaveAttribute('target', '_blank');
expect(tile(link)).toEqual({ color: 'var(--warning)', hovers: true });
});
it('FE-COMP-ABOUT-017: the wiki tile uses the info token and no inline hover styles are left', () => {
render(<AboutTab appVersion="1.0.0" />);
const link = document.querySelector('a[href*="wiki"]') as HTMLAnchorElement;
expect(tile(link)).toEqual({ color: 'var(--info)', hovers: true });
fireEvent.mouseEnter(link);
expect(link.style.borderColor).toBe('');
expect(link.style.boxShadow).toBe('');
});
it('FE-COMP-ABOUT-018: the sponsor panel links dataforest cloud wherever it is named, with both logos bundled', () => {
render(<AboutTab appVersion="1.0.0" />);
const links = document.querySelectorAll('a[href="https://cloud.dataforest.net/en?mtm_campaign=trek"]');
// The logo tile, the call to action, and the brand name in the title and in the body.
expect(links).toHaveLength(4);
for (const link of links) {
expect(link).toHaveAttribute('target', '_blank');
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
}
const logos = [...document.querySelectorAll('img')].map((img) => img.getAttribute('src'));
expect(logos).toEqual(
expect.arrayContaining(['/brands/dataforest-cloud.svg', '/brands/dataforest-cloud-dark.svg'])
);
// Served by TREK itself: opening Settings must not reach a third party.
expect(logos.every((src) => src?.startsWith('/'))).toBe(true);
expect(screen.getByText('Place search')).toBeInTheDocument();
expect(screen.getByText('Address search')).toBeInTheDocument();
expect(screen.getByText('Routing')).toBeInTheDocument();
});
});