Skip to content

Commit

Permalink
fix: Items consolidation without urn (#397)
Browse files Browse the repository at this point in the history
* fix: Items consolidation without urn

* feat: Add test to verify that the URN gets filled if it's not published
  • Loading branch information
LautaroPetaccio committed Feb 4, 2022
1 parent 0431186 commit acdd374
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
33 changes: 32 additions & 1 deletion src/Item/Item.router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ import {
import { buildTPItemURN } from './utils'
import { hasPublicAccess } from './access'
import { Item } from './Item.model'
import { FullItem, ItemAttributes, ItemRarity } from './Item.types'
import {
FullItem,
ItemAttributes,
ItemRarity,
ThirdPartyItemAttributes,
} from './Item.types'

jest.mock('./Item.model')
jest.mock('../ethereum/api/collection')
Expand Down Expand Up @@ -211,11 +216,25 @@ describe('Item router', () => {
})

describe('when getting all the items', () => {
let dbTPItemNotPublishedMock: ThirdPartyItemAttributes
let dbTPItemNotPublishedUrn: string

beforeEach(() => {
dbTPItemNotPublishedMock = {
...dbTPItemMock,
urn_suffix: '2',
}

dbTPItemNotPublishedUrn = buildTPItemURN(
dbTPCollectionMock.third_party_id,
dbTPCollectionMock.urn_suffix,
dbTPItemNotPublishedMock.urn_suffix!
)
;(isCommitteeMember as jest.Mock).mockResolvedValueOnce(true)
;(Item.find as jest.Mock).mockResolvedValueOnce([
dbItem,
dbTPItemMock,
dbTPItemNotPublishedMock,
dbItemNotPublished,
])
;(collectionAPI.fetchItems as jest.Mock).mockResolvedValueOnce([
Expand Down Expand Up @@ -259,6 +278,18 @@ describe('Item router', () => {
blockchain_item_id: thirdPartyItemFragmentMock.blockchainItemId,
urn: thirdPartyItemFragmentMock.urn,
},
{
...resultingItem,
in_catalyst: false,
is_approved: false,
is_published: false,
beneficiary: '',
price: '',
total_supply: 0,
collection_id: dbTPItemNotPublishedMock.collection_id,
blockchain_item_id: '0',
urn: dbTPItemNotPublishedUrn,
},
],
ok: true,
})
Expand Down
5 changes: 4 additions & 1 deletion src/ethereum/api/Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export class Bridge {

fullItem = Bridge.mergeTPItem(item, remoteItem, catalystItem)
} else {
fullItem = Bridge.toFullItem(item)
fullItem = Bridge.toFullItem(
item,
dbTPCollectionsIndex[item.collection_id!]
)
}

fullItems.push(fullItem)
Expand Down

0 comments on commit acdd374

Please sign in to comment.