Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test adding someone back into the group #111

Merged
merged 18 commits into from
May 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions test/add-member.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,60 @@ test('addMembers too many members', async (t) => {

await p(alice.close)(true)
})

test.only('can or cannot add someone back into a group', async (t) => {
const alice = Testbot({
keys: ssbKeys.generate(null, 'alice'),
mfSeed: Buffer.from(
'000000000000000000000000000000000000000000000000000000000000a1ce',
'hex'
),
})
const bob = Testbot({
keys: ssbKeys.generate(null, 'bob'),
mfSeed: Buffer.from(
'0000000000000000000000000000000000000000000000000000000000000b0b',
'hex'
),
})

await Promise.all([alice.tribes2.start(), bob.tribes2.start()])

const bobRoot = await p(bob.metafeeds.findOrCreate)()

await replicate(alice, bob).catch(t.error)

const { id: groupId } = await alice.tribes2
.create()
.catch((err) => t.error(err, 'alice failed to create group'))

await alice.tribes2
.addMembers(groupId, [bobRoot.id])
.then(() => t.pass('added bob'))
.catch((err) => t.error(err, 'add bob fail'))

await replicate(alice, bob).catch(t.error)

await bob.tribes2.acceptInvite(groupId)

await replicate(alice, bob).catch(t.error)

await alice.tribes2
.excludeMembers(groupId, [bobRoot.id])
.then(() => t.pass('alice excluded bob'))
.catch((err) => t.error(err, 'remove member fail'))

await replicate(alice, bob).catch(t.error)

await alice.tribes2
.addMembers(groupId, [bobRoot.id])
.then(() => t.pass('added bob back in again'))
.catch((err) => t.error(err, 'add bob back fail'))

await replicate(alice, bob).catch(t.error)

await bob.tribes2.acceptInvite(groupId).catch(t.error)
Powersource marked this conversation as resolved.
Show resolved Hide resolved

await p(alice.close)(true)
await p(bob.close)(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await p(alice.close)(true)
await p(bob.close)(true)
await Promise.all([p(alice.close)(true), p(bob.close)(true)])

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

})