fix(fortune): scope s5s fortune markup (#1150)

* fix(markdown): scope fortune markup to fortune boards

* fix(fortune): store fortune output as bbcode

* fix(fortune): keep legacy fortune rendering

* fix(tests): resolve catalog button mock merge

* fix(fortune): validate hidden fortune length
This commit is contained in:
Tommaso Casaburi
2026-06-03 13:49:35 +07:00
committed by GitHub
parent 84f357cba1
commit d09d2d05d1
16 changed files with 439 additions and 93 deletions
@@ -177,6 +177,24 @@ describe('interaction stores', () => {
expect(useChallengesStore.getState().challenges).toEqual([]);
});
it('redacts generated fortune content before storing challenge publications', async () => {
const publishChallengeAnswers = vi.fn();
const publication = {
content: 'body[fortune color=#fd4d32]Excellent Luck[/fortune]',
publishChallengeAnswers,
};
useChallengesStore.getState().addChallenge([{ challenges: [] }, publication] as never);
const storedChallenge = useChallengesStore.getState().challenges[0]?.challenge as unknown[] | undefined;
const storedPublication = storedChallenge?.[1] as typeof publication | undefined;
expect(storedPublication?.content).toBe('body');
expect(storedPublication?.content).not.toContain('Excellent Luck');
await storedPublication?.publishChallengeAnswers(['4']);
expect(publishChallengeAnswers).toHaveBeenCalledWith(['4']);
});
it('shows the disclaimer modal until accepted, then navigates directly on later opens', () => {
const navigate = vi.fn();
+2 -1
View File
@@ -1,5 +1,6 @@
import { create } from 'zustand';
import { Challenge } from '@bitsocial/bitsocial-react-hooks';
import { redactGeneratedFortuneFromChallenge } from '../lib/utils/challenge-utils';
let nextChallengeId = 0;
@@ -14,7 +15,7 @@ const useChallengesStore = create<State>((set, get) => ({
challenges: [],
addChallenge: (challenge: Challenge, onAbandon?: () => Promise<void> | void) => {
set((state) => ({
challenges: [...state.challenges, { challenge, id: nextChallengeId++, onAbandon }],
challenges: [...state.challenges, { challenge: redactGeneratedFortuneFromChallenge(challenge), id: nextChallengeId++, onAbandon }],
}));
},
removeChallenge: () => {