refactor: migrate 5chan to the community hooks API (#1073)

* refactor(community-api): migrate 5chan to community hooks

* fix(review): address PR feedback

* fix(review): preserve legacy board context fallbacks

* fix(review): address latest bot feedback

* fix(review): use communityAddress in edit menu privileges
This commit is contained in:
Tommaso Casaburi
2026-03-13 13:25:10 +08:00
committed by GitHub
parent 9dc4d96d27
commit d7703953fb
105 changed files with 2659 additions and 1491 deletions
@@ -0,0 +1,68 @@
import * as React from 'react';
import { createElement } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import BlotterMessage from '../blotter-message';
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
const act = (React as { act?: (cb: () => void | Promise<void>) => void | Promise<void> }).act as (cb: () => void | Promise<void>) => void | Promise<void>;
vi.mock('../blotter-message.module.css', () => ({
default: {
versionLink: 'versionLink',
},
}));
let container: HTMLDivElement;
let root: Root;
describe('BlotterMessage', () => {
beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
root = createRoot(container);
});
afterEach(() => {
act(() => root.unmount());
container.remove();
});
it('normalizes legacy subplebbit wording without rewriting plain community text', async () => {
await act(async () => {
root.render(
createElement(BlotterMessage, {
entry: {
id: 'manual-1',
kind: 'manual',
message: 'Moved a subplebbit into a community spotlight',
timestamp: 1_710_000_000,
},
}),
);
});
expect(container.textContent).toContain('Moved a board into a community spotlight');
expect(container.textContent).not.toContain('subplebbit');
expect(container.textContent).not.toContain('board spotlight');
});
it('normalizes release one-liners after the version prefix', async () => {
await act(async () => {
root.render(
createElement(BlotterMessage, {
entry: {
id: 'release-1',
kind: 'release',
message: 'v0.7.0: Fix subplebbit loading in plebchan',
timestamp: 1_710_000_000,
version: '0.7.0',
},
}),
);
});
expect(container.querySelector('a')?.getAttribute('href')).toBe('https://github.com/bitsocialnet/5chan/releases/tag/v0.7.0');
expect(container.textContent).toContain('Fix board loading in 5chan');
});
});