Skip to content

Commit 3a300f9

Browse files
committed
fix(test): wait for parent comment indexing before publishing reply
The "publish reply" e2e test was failing for the plebbit rpc client variant because the reply was sent before the subplebbit finished indexing the parent comment. Wait for useComment to resolve the parent before publishing.
1 parent b26c1c7 commit 3a300f9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

test/browser-e2e/accounts.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
460460
const notifications = useNotifications()
461461
const comment = useComment({commentCid})
462462
const replies = useReplies({comment})
463-
return {account, accountVotes, accountComments, notifications, replies, ...accountsActions}
463+
return {account, accountVotes, accountComments, notifications, comment, replies, ...accountsActions}
464464
})
465465
waitFor = testUtils.createWaitFor(rendered, {timeout})
466466

@@ -571,6 +571,11 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
571571
console.log(challengeVerification)
572572
replyChallengeVerification = challengeVerification
573573
}
574+
// wait for the parent comment to be indexed by the subplebbit before publishing a reply
575+
rendered.rerender(publishedCid)
576+
await waitFor(() => typeof rendered.result.current.comment?.timestamp === 'number')
577+
console.log('parent comment indexed, publishing reply')
578+
574579
const publishCommentOptions = {
575580
subplebbitAddress,
576581
parentCid: publishedCid,
@@ -592,7 +597,6 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
592597

593598
// wait for useReplies
594599
expect(typeof publishedCid).to.equal('string')
595-
rendered.rerender(publishedCid)
596600
await waitFor(() => rendered.result.current.replies.replies.length > 0)
597601
expect(rendered.result.current.replies.replies.length).to.equal(1)
598602
console.log('after useReplies')

0 commit comments

Comments
 (0)