1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {itSub, usingPlaygrounds, expect} from './util';19import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';2021describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;2425 before(async () => {26 await usingPlaygrounds(async (helper, privateKey) => {27 const donor = await privateKey({url: import.meta.url});28 [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);29 });30 });3132 itSub('Remove collection admin', async ({helper}) => {33 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionAdmin-1', tokenPrefix: 'RCA'});34 const collectionInfo = await collection.getData();35 expect(collectionInfo?.raw.owner.toString()).to.be.deep.eq(alice.address);36 37 await collection.addAdmin(alice, {Substrate: bob.address});3839 const adminListAfterAddAdmin = await collection.getAdmins();40 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});4142 43 await collection.removeAdmin(alice, {Substrate: bob.address});4445 const adminListAfterRemoveAdmin = await collection.getAdmins();46 expect(adminListAfterRemoveAdmin).not.to.be.deep.contains({Substrate: bob.address});47 });4849 itSub('Remove admin from collection that has no admins', async ({helper}) => {50 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionAdmin-2', tokenPrefix: 'RCA'});5152 const adminListBeforeAddAdmin = await collection.getAdmins();53 expect(adminListBeforeAddAdmin).to.have.lengthOf(0);5455 await expect(collection.removeAdmin(alice, {Substrate: alice.address})).to.be.rejectedWith('common.UserIsNotCollectionAdmin');56 });57});5859describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {60 let alice: IKeyringPair;61 let bob: IKeyringPair;62 let charlie: IKeyringPair;6364 before(async () => {65 await usingPlaygrounds(async (helper, privateKey) => {66 const donor = await privateKey({url: import.meta.url});67 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);68 });69 });7071 itSub('Can\'t remove collection admin from not existing collection', async ({helper}) => {72 const collectionId = NON_EXISTENT_COLLECTION_ID;7374 await expect(helper.collection.removeAdmin(alice, collectionId, {Substrate: bob.address}))75 .to.be.rejectedWith(/common\.CollectionNotFound/);76 });7778 itSub('Can\'t remove collection admin from deleted collection', async ({helper}) => {79 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionAdmin-Neg-2', tokenPrefix: 'RCA'});8081 expect(await collection.burn(alice)).to.be.true;8283 await expect(helper.collection.removeAdmin(alice, collection.collectionId, {Substrate: bob.address}))84 .to.be.rejectedWith(/common\.CollectionNotFound/);85 });8687 itSub('Regular user can\'t remove collection admin', async ({helper}) => {88 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionAdmin-Neg-3', tokenPrefix: 'RCA'});8990 await collection.addAdmin(alice, {Substrate: bob.address});9192 await expect(collection.removeAdmin(charlie, {Substrate: bob.address}))93 .to.be.rejectedWith(/common\.NoPermission/);94 });9596 itSub('Admin can\'t remove collection admin.', async ({helper}) => {97 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionAdmin-Neg-4', tokenPrefix: 'RCA'});9899 await collection.addAdmin(alice, {Substrate: bob.address});100 await collection.addAdmin(alice, {Substrate: charlie.address});101102 const adminListAfterAddAdmin = await collection.getAdmins();103 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});104 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: charlie.address});105106 await expect(collection.removeAdmin(charlie, {Substrate: bob.address}))107 .to.be.rejectedWith(/common\.NoPermission/);108109 const adminListAfterRemoveAdmin = await collection.getAdmins();110 expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: bob.address});111 expect(adminListAfterRemoveAdmin).to.be.deep.contains({Substrate: charlie.address});112 });113});