@@ -275,7 +275,7 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
275275 }
276276
277277 // publish wrong challenge answer, verification should be success false
278- const publishCommentOptions = {
278+ let publishCommentOptions = {
279279 subplebbitAddress : subplebbit . address ,
280280 title : 'some title' ,
281281 content : 'some content' ,
@@ -295,14 +295,23 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
295295 await waitFor ( ( ) => ! ! challengeVerification )
296296 expect ( challengeVerification . type ) . to . equal ( 'CHALLENGEVERIFICATION' )
297297 // verification should be success false
298- // NOTE RINSE: uncomment below, challengeVerification.challengeSuccess should be false if the challenge fails
299- // expect(challengeVerification.challengeSuccess).to.equal(false)
298+ expect ( challengeVerification . challengeSuccess ) . to . equal ( false )
299+ expect ( challengeVerification . commentUpdate ?. pendingApproval ) . to . equal ( undefined )
300+ expect ( rendered . result . current . modQueue . feed . length ) . to . equal ( 0 )
300301 console . log ( 'after onChallengeVerification wrong challenge answer' )
301302
302303 // reset
303- challenge = undefined
304- comment = undefined
305- challengeVerification = undefined
304+ let challenge2 , comment2 , challengeVerification2
305+ publishCommentOptions = { ...publishCommentOptions }
306+ publishCommentOptions . onChallenge = ( _challenge , _comment ) => {
307+ logChallenge ( 'onChallenge' , _challenge )
308+ challenge2 = _challenge
309+ comment2 = _comment
310+ }
311+ publishCommentOptions . onChallengeVerification = ( _challengeVerification ) => {
312+ logChallenge ( 'onChallengeVerification' , _challengeVerification )
313+ challengeVerification2 = _challengeVerification
314+ }
306315 publishCommentOptions . content += ' 2'
307316
308317 // publish correct challenge answer, verification should be success true, but pending approval
@@ -312,26 +321,25 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
312321 console . log ( 'after publishComment' )
313322 } )
314323 // wait for challenge
315- await waitFor ( ( ) => ! ! challenge )
316- expect ( challenge . type ) . to . equal ( 'CHALLENGE' )
317- let challengeAnswer = String ( eval ( challenge . challenges [ 0 ] . challenge ) )
318- // NOTE RINSE: delete line below, the correct challengeAnswer above should trigger a pendingApproval, wrong challengeAnswer should fail without pendingApproval
319- challengeAnswer = 'wrong answer'
320- comment . publishChallengeAnswers ( [ challengeAnswer ] ) // publish correct challenge answer
324+ await waitFor ( ( ) => ! ! challenge2 )
325+ expect ( challenge2 . type ) . to . equal ( 'CHALLENGE' )
326+ let challengeAnswer = String ( eval ( challenge2 . challenges [ 0 ] . challenge ) )
327+ // challengeAnswer = 'wrong answer'
328+ comment2 . publishChallengeAnswers ( [ challengeAnswer ] ) // publish correct challenge answer
321329 // wait for challenge verification
322- await waitFor ( ( ) => ! ! challengeVerification )
323- expect ( challengeVerification . type ) . to . equal ( 'CHALLENGEVERIFICATION' )
324- expect ( challengeVerification . challengeSuccess ) . to . equal ( true )
325- expect ( challengeVerification . commentUpdate . pendingApproval ) . to . equal ( true )
326- const pendingApprovalCommentCid = challengeVerification . commentUpdate . cid
330+ await waitFor ( ( ) => ! ! challengeVerification2 )
331+ expect ( challengeVerification2 . type ) . to . equal ( 'CHALLENGEVERIFICATION' )
332+ expect ( challengeVerification2 . challengeSuccess ) . to . equal ( true )
333+ expect ( challengeVerification2 . commentUpdate . pendingApproval ) . to . equal ( true )
334+ const pendingApprovalCommentCid = challengeVerification2 . commentUpdate . cid
327335 expect ( typeof pendingApprovalCommentCid ) . to . equal ( 'string' )
328336 console . log ( 'after onChallengeVerification' )
329337
330338 // wait for pending approval in modQueue
331339 console . log ( `before useFeed({modQueue: ['pendingApproval']})` )
332340 await waitFor ( ( ) => rendered . result . current . modQueue . feed . length > 0 )
333- // NOTE RINSE: uncomment below, if the first challenge fails, should only have 1 comment in modQueue
334- // expect(rendered.result.current.modQueue.feed.length).to.equal(1)
341+ console . log ( rendered . result . current . modQueue . feed )
342+ expect ( rendered . result . current . modQueue . feed . length ) . to . equal ( 1 )
335343 expect ( rendered . result . current . modQueue . feed [ 0 ] . pendingApproval ) . to . equal ( true )
336344 expect ( rendered . result . current . modQueue . feed [ 0 ] . content ) . to . equal ( publishCommentOptions . content )
337345 console . log ( `after useFeed({modQueue: ['pendingApproval']})` )
0 commit comments