chore(flags): derive flag-test coords from board-flags source (#1165)

* feat(board-header): show subtitle on /all view

Add all_subtitle copy and render it in the board header when browsing
the aggregated all-directories feed.

* chore(flags): derive flag-test coords from board-flags source

comment-flags.test.ts hard-coded the pol/pony sprite x/y, duplicating the literals already pinned in board-flags.test.ts. A recent sprite remap updated one file and not the other, leaving master red. Derive the coords from getBoardFlagDefinition (the same source the runtime uses) so the assertion can't drift; labels stay literal as readable pins, and board-flags.test.ts remains the single place pinning the actual values.
This commit is contained in:
Tommaso Casaburi
2026-06-08 22:47:04 +07:00
committed by GitHub
parent 182ff0eadc
commit 075b917c36
38 changed files with 82 additions and 40 deletions
@@ -169,6 +169,7 @@ describe('BoardHeader', () => {
expect(container.textContent).toContain('/all/ - All 5chan Directories');
expect(container.querySelector('img')?.getAttribute('src')).toBe('banner-a.png');
expect(container.textContent).not.toContain('subscriptions_subtitle');
expect(container.textContent).toContain('all_subtitle');
});
it('renders a clickable subscriptions subtitle that navigates to subscription settings', async () => {
+3 -3
View File
@@ -83,7 +83,7 @@ const BoardHeader = () => {
? '/mod/ - Boards You Moderate'
: defaultCommunity?.title || stableCommunity?.title;
const subtitle = isInAllView
? ''
? t('all_subtitle')
: isInSubscriptionsView
? subscriptionsSubtitle
: isInModView
@@ -124,9 +124,9 @@ const BoardHeader = () => {
>
{subtitle}
</button>
) : isInDirectoryListView ? (
) : isInDirectoryListView || isInAllView ? (
<span>{subtitle}</span>
) : !isInAllView && !isInModView && subtitle ? (
) : !isInModView && subtitle ? (
<span title={t('board_address_tooltip')}>{subtitle}</span>
) : (
subtitle
+8 -2
View File
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import { getCommentFlagFlairs, getAuthorFlagFlairs, getAuthorFlagViewModels, TOR_AUTHOR_FLAG_LABEL_KEY } from '../comment-flags';
import { getBoardFlagDefinition } from '../board-flags';
describe('comment-flags', () => {
it('parses the pkc-js challenge flair example for country flags', () => {
@@ -21,8 +22,13 @@ describe('comment-flags', () => {
const flags = getAuthorFlagViewModels([{ text: 'flag:country:DE' }, { text: 'flag:pol:AC' }, { text: 'flag:pony:AJ' }], 1000);
expect(flags.map((flag) => flag.key)).toEqual(['country:de', 'pol:AC', 'pony:AJ']);
expect(flags[1]).toMatchObject({ label: 'Anarcho-Capitalist', x: 0, y: 0 });
expect(flags[2]).toMatchObject({ label: 'Applejack', x: 48, y: 0 });
// Pin the human-readable labels here, but derive the sprite coords from the board-flags source of
// truth so this test can't drift when the sheet is remapped (board-flags.test.ts pins the values).
const politicalFlag = getBoardFlagDefinition('pol', 'AC');
const ponyFlag = getBoardFlagDefinition('pony', 'AJ');
expect(flags[1]).toMatchObject({ label: 'Anarcho-Capitalist', x: politicalFlag?.x, y: politicalFlag?.y });
expect(flags[2]).toMatchObject({ label: 'Applejack', x: ponyFlag?.x, y: ponyFlag?.y });
});
it('labels the xx country flag as Tor traffic', () => {