mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
fix(atlas): clear the client gates of the globe Atlas
Client lint, checks and tests were red on the globe Atlas: - The views own the globe and sky refs and hand them into useAtlasGlobe, so reading its state while rendering no longer counts as reading refs. - Helpers that shared a file with components move to their own modules (badge tiers, medal label, Dawarich notes, hub tabs, period label). - The place search derives its loading state, the search resets its active row on input, and the two silenced hook dependencies are named. - placeLabels, the hover chip and the overview figures are split up. - Raw text sizes become type tiers, the badge unlock docks on --z-overlay. - The stats card test follows the GlobeStat props; baselines lowered to the counts the run reported.
This commit is contained in:
@@ -1,38 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render, screen } from '../../../helpers/render';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { Award, Flag, Globe, MapIcon, Plane, Star } from 'lucide-react';
|
||||
import { fireEvent, render, screen } from '../../../helpers/render';
|
||||
import MAtlasStatsCard from '../../../../src/mobile/screens/atlas/MAtlasStatsCard';
|
||||
import type { GlobeStat } from '../../../../src/components/AtlasGlobe/GlobeStatsBar';
|
||||
|
||||
// FE-MOB-ATLAS-010 to FE-MOB-ATLAS-012
|
||||
|
||||
const stats = { totalCountries: 3, totalTrips: 2, totalPlaces: 125, totalCities: 31, totalDays: 26 };
|
||||
const stat = (key: string, value: number | string, label: string, icon = Flag): GlobeStat => ({ key, value, label, icon, onClick: vi.fn() });
|
||||
|
||||
const stats: GlobeStat[] = [
|
||||
stat('countries', 37, 'Countries'),
|
||||
stat('continents', 6, 'Continents', Globe),
|
||||
stat('regions', 42, 'Regions', MapIcon),
|
||||
stat('flights', '152k', 'Flight km', Plane),
|
||||
stat('badges', 22, 'Badges', Award),
|
||||
stat('wishlist', 4, 'Wishlist', Star),
|
||||
];
|
||||
|
||||
describe('MAtlasStatsCard', () => {
|
||||
it('FE-MOB-ATLAS-010: renders the five stat columns with their values', () => {
|
||||
it('FE-MOB-ATLAS-010: shows the five phone figures in their order', () => {
|
||||
render(<MAtlasStatsCard stats={stats} />);
|
||||
|
||||
for (const label of ['Countries', 'Trips', 'Places', 'Cities', 'Days']) {
|
||||
expect(screen.getByText(label)).toBeInTheDocument();
|
||||
}
|
||||
for (const value of ['3', '2', '125', '31', '26']) {
|
||||
expect(screen.getByText(value)).toBeInTheDocument();
|
||||
}
|
||||
// No planned countries, no superscript — the column reads as a plain number.
|
||||
expect(screen.getByText('Countries').parentElement).toHaveTextContent(/^3Countries$/);
|
||||
const labels = screen.getAllByRole('button').map((b) => b.textContent);
|
||||
expect(labels).toEqual(['37Countries', '6Continents', '42Regions', '22Badges', '4Wishlist']);
|
||||
});
|
||||
|
||||
it('FE-MOB-ATLAS-011: hangs the planned countries off the country total as a superscript (#1048)', () => {
|
||||
render(<MAtlasStatsCard stats={{ ...stats, totalCountriesPlanned: 4 }} />);
|
||||
it('FE-MOB-ATLAS-011: leaves out the figures the phone card has no room for', () => {
|
||||
render(<MAtlasStatsCard stats={stats} />);
|
||||
|
||||
expect(screen.getByText('+4')).toBeInTheDocument();
|
||||
expect(screen.getByText('Countries').parentElement).toHaveTextContent(/^3\+4Countries$/);
|
||||
// Only the first column carries it — the other four stay untouched.
|
||||
expect(screen.getByText('Trips').parentElement).toHaveTextContent(/^2Trips$/);
|
||||
expect(screen.queryByText('Flight km')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-ATLAS-012: a zero planned count is left off entirely', () => {
|
||||
render(<MAtlasStatsCard stats={{ ...stats, totalCountriesPlanned: 0 }} />);
|
||||
it('FE-MOB-ATLAS-012: a column opens what it counts', () => {
|
||||
render(<MAtlasStatsCard stats={stats} />);
|
||||
|
||||
expect(screen.queryByText('+0')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Countries').parentElement).toHaveTextContent(/^3Countries$/);
|
||||
fireEvent.click(screen.getByText('Badges'));
|
||||
expect(stats[4]?.onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user