mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Merge branch 'codex/fix/flag-verification-scope'
This commit is contained in:
@@ -936,9 +936,6 @@ describe('PostForm', () => {
|
|||||||
|
|
||||||
expect(testState.publishPostMock).toHaveBeenCalledWith({
|
expect(testState.publishPostMock).toHaveBeenCalledWith({
|
||||||
content: 'memeflag post',
|
content: 'memeflag post',
|
||||||
challengeRequest: {
|
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pol:AC'],
|
|
||||||
},
|
|
||||||
flairs: [{ type: 'pol', code: 'AC', text: 'flag:pol:AC' }],
|
flairs: [{ type: 'pol', code: 'AC', text: 'flag:pol:AC' }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -601,9 +601,6 @@ describe('ReplyModal', () => {
|
|||||||
|
|
||||||
expect(testState.publishReplyMock).toHaveBeenCalledWith({
|
expect(testState.publishReplyMock).toHaveBeenCalledWith({
|
||||||
content: 'reply body',
|
content: 'reply body',
|
||||||
challengeRequest: {
|
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pol:AC'],
|
|
||||||
},
|
|
||||||
flairs: [{ type: 'pol', code: 'AC', text: 'flag:pol:AC' }],
|
flairs: [{ type: 'pol', code: 'AC', text: 'flag:pol:AC' }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -231,9 +231,9 @@ describe('usePublishReply', () => {
|
|||||||
latestValue.setPublishReplyOptions({
|
latestValue.setPublishReplyOptions({
|
||||||
content: 'Flag reply',
|
content: 'Flag reply',
|
||||||
challengeRequest: {
|
challengeRequest: {
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pol:AC'],
|
challengeAnswers: ['bitsocial-flags:5chan:flag:country:auto'],
|
||||||
},
|
},
|
||||||
flairs: [{ text: 'flag:pol:AC', type: 'pol', code: 'AC' }],
|
flairs: [{ text: 'flag:country:auto', type: 'country', code: 'auto' }],
|
||||||
} as never);
|
} as never);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -126,17 +126,18 @@ describe('comment-flag-selection', () => {
|
|||||||
expect(getCommentFlagRequestFromSelection('none')).toBeUndefined();
|
expect(getCommentFlagRequestFromSelection('none')).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes selected flags as signed comment flairs and challenge answers', () => {
|
it('publishes geographic flags as challenge-backed comment flairs', () => {
|
||||||
expect(getCommentFlagPublishOptionsFromSelection('country:auto')).toEqual({
|
expect(getCommentFlagPublishOptionsFromSelection('country:auto')).toEqual({
|
||||||
challengeRequest: {
|
challengeRequest: {
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:country:auto'],
|
challengeAnswers: ['bitsocial-flags:5chan:flag:country:auto'],
|
||||||
},
|
},
|
||||||
flairs: [{ type: 'country', code: 'auto', text: 'flag:country:auto' }],
|
flairs: [{ type: 'country', code: 'auto', text: 'flag:country:auto' }],
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('publishes board-choice flags as regular comment flairs without a challenge request', () => {
|
||||||
expect(getCommentFlagPublishOptionsFromSelection('pony:AJ')).toEqual({
|
expect(getCommentFlagPublishOptionsFromSelection('pony:AJ')).toEqual({
|
||||||
challengeRequest: {
|
challengeRequest: undefined,
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pony:AJ'],
|
|
||||||
},
|
|
||||||
flairs: [{ type: 'pony', code: 'AJ', text: 'flag:pony:AJ' }],
|
flairs: [{ type: 'pony', code: 'AJ', text: 'flag:pony:AJ' }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -133,9 +133,12 @@ export const getCommentFlagPublishOptionsFromSelection = (value: string | undefi
|
|||||||
const flag = getCommentFlagRequestFromSelection(value);
|
const flag = getCommentFlagRequestFromSelection(value);
|
||||||
return flag
|
return flag
|
||||||
? {
|
? {
|
||||||
challengeRequest: {
|
challengeRequest:
|
||||||
challengeAnswers: [`${FLAG_CHALLENGE_ANSWER_PREFIX}${flag.text}`],
|
flag.type === 'country'
|
||||||
},
|
? {
|
||||||
|
challengeAnswers: [`${FLAG_CHALLENGE_ANSWER_PREFIX}${flag.text}`],
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
flairs: [flag],
|
flairs: [flag],
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ describe('publish stores', () => {
|
|||||||
spoiler: false,
|
spoiler: false,
|
||||||
communityAddress: 'music-posting.eth',
|
communityAddress: 'music-posting.eth',
|
||||||
challengeRequest: {
|
challengeRequest: {
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pol:AC'],
|
challengeAnswers: ['bitsocial-flags:5chan:flag:country:auto'],
|
||||||
},
|
},
|
||||||
flairs: [{ text: 'flag:pol:AC', type: 'pol', code: 'AC' }],
|
flairs: [{ text: 'flag:country:auto', type: 'country', code: 'auto' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
usePublishReplyStore.getState().setPublishReplyStore(comment);
|
usePublishReplyStore.getState().setPublishReplyStore(comment);
|
||||||
@@ -111,9 +111,9 @@ describe('publish stores', () => {
|
|||||||
expect(state.publishCommentOptions['parent-1']?.parentCid).toBe('parent-1');
|
expect(state.publishCommentOptions['parent-1']?.parentCid).toBe('parent-1');
|
||||||
expect(state.publishCommentOptions['parent-1']?.postCid).toBe('parent-1');
|
expect(state.publishCommentOptions['parent-1']?.postCid).toBe('parent-1');
|
||||||
expect(state.publishCommentOptions['parent-1']?.challengeRequest).toEqual({
|
expect(state.publishCommentOptions['parent-1']?.challengeRequest).toEqual({
|
||||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pol:AC'],
|
challengeAnswers: ['bitsocial-flags:5chan:flag:country:auto'],
|
||||||
});
|
});
|
||||||
expect(state.publishCommentOptions['parent-1']?.flairs).toEqual([{ text: 'flag:pol:AC', type: 'pol', code: 'AC' }]);
|
expect(state.publishCommentOptions['parent-1']?.flairs).toEqual([{ text: 'flag:country:auto', type: 'country', code: 'auto' }]);
|
||||||
|
|
||||||
state.publishCommentOptions['parent-1']?.onChallengeVerification?.({ token: 'challenge' } as never, comment);
|
state.publishCommentOptions['parent-1']?.onChallengeVerification?.({ token: 'challenge' } as never, comment);
|
||||||
expect(testState.alertChallengeVerificationFailedMock).toHaveBeenCalledWith({ token: 'challenge' }, comment);
|
expect(testState.alertChallengeVerificationFailedMock).toHaveBeenCalledWith({ token: 'challenge' }, comment);
|
||||||
|
|||||||
Reference in New Issue
Block a user