mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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:
@@ -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();
|
||||
|
||||
|
||||
@@ -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: () => {
|
||||
|
||||
Reference in New Issue
Block a user