From 2561dc5bcc6b2c639fb2ae4ef55cafbf38423b7e Mon Sep 17 00:00:00 2001 From: Tina-57blocks Date: Tue, 7 May 2024 17:20:34 +0800 Subject: [PATCH] update tests --- tests/api/collections/collections.get.spec.ts | 67 ++++++++---------- tests/api/disputes/disputes.get.spec.ts | 64 ++++++++--------- tests/api/disputes/disputes.post.spec.ts | 4 +- tests/api/ipassets/assets.get.spec.ts | 69 +++++++++---------- tests/api/ipassets/assets.post.spec.ts | 3 +- .../licenses/licenses-ip-terms.get.spec.ts | 31 ++++----- .../licenses/licenses-ip-terms.post.spec.ts | 24 +++---- .../licenses-mintingfees.post.spec.ts | 2 +- .../licenses/licenses-templates.get.spec.ts | 24 +++---- .../licenses/licenses-templates.post.spec.ts | 16 ++--- tests/api/licenses/licenses-terms.get.spec.ts | 23 ++++--- .../api/licenses/licenses-terms.post.spec.ts | 18 ++--- .../api/licenses/licenses-tokens.get.spec.ts | 58 ++++++++-------- .../api/licenses/licenses-tokens.post.spec.ts | 36 +++++----- tests/api/modules/modules.get.spec.ts | 50 +++++++------- tests/api/permissions/permissions.get.spec.ts | 54 +++++++-------- .../api/transactions/transactions.get.spec.ts | 59 +++++++--------- 17 files changed, 285 insertions(+), 317 deletions(-) diff --git a/tests/api/collections/collections.get.spec.ts b/tests/api/collections/collections.get.spec.ts index b99191d..9e30485 100644 --- a/tests/api/collections/collections.get.spec.ts +++ b/tests/api/collections/collections.get.spec.ts @@ -7,44 +7,37 @@ test.describe("Get a Collection @Collections", async () => { request, collections, }) => { - const params = [ - { collectionId: collections[0].id, exists: true }, - { - collectionId: "0x6456cba1cf7189a5e51a207fe232574e1fc21999", - exists: false, - }, - ]; - for (const { collectionId, exists } of params) { - await test.step(`Should return the Collection detail with collectionId ${collectionId}`, async () => { - const response = await request.get(endpoint + `/${collectionId}`); - expect(response.status()).toBe(200); + const collectionId = collections[0].id; + const response = await request.get(endpoint + `/${collectionId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(collectionId); - expect(typeof data.assetCount).toBe("string"); - expect(typeof data.licensesCount).toBe("string"); - expect(typeof data.raisedDisputeCount).toBe("string"); - expect(typeof data.judgedDisputeCount).toBe("string"); - expect(typeof data.resolvedDisputeCount).toBe("string"); - expect(typeof data.cancelledDisputeCount).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.assetCount).toBeTruthy(); - expect(data.licensesCount).toBeTruthy(); - expect(data.raisedDisputeCount).toBeTruthy(); - expect(data.judgedDisputeCount).toBeTruthy(); - expect(data.resolvedDisputeCount).toBeTruthy(); - expect(data.cancelledDisputeCount).toBeTruthy(); - expect(data.blockNumber).toBeTruthy(); - expect(data.blockTimestamp).toBeTruthy(); - } else { - expect(data.id).toBeFalsy(); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(collectionId); + expect.soft(typeof data.assetCount).toBe("string"); + expect.soft(typeof data.licensesCount).toBe("string"); + expect.soft(typeof data.raisedDisputeCount).toBe("string"); + expect.soft(typeof data.judgedDisputeCount).toBe("string"); + expect.soft(typeof data.resolvedDisputeCount).toBe("string"); + expect.soft(typeof data.cancelledDisputeCount).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.assetCount).toBeTruthy(); + expect.soft(data.licensesCount).toBeTruthy(); + expect.soft(data.raisedDisputeCount).toBeTruthy(); + expect.soft(data.judgedDisputeCount).toBeTruthy(); + expect.soft(data.resolvedDisputeCount).toBeTruthy(); + expect.soft(data.cancelledDisputeCount).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist collectionId", async ({ request }) => { + const response = await request.get( + endpoint + "/0x6456cba1cf7189a5e51a207fe232574e1fc21999" + ); + expect(response.status()).toBe(404); }); test("Should return 404 for no collectionId", async ({ request }) => { diff --git a/tests/api/disputes/disputes.get.spec.ts b/tests/api/disputes/disputes.get.spec.ts index f0d33f9..a8f2e99 100644 --- a/tests/api/disputes/disputes.get.spec.ts +++ b/tests/api/disputes/disputes.get.spec.ts @@ -1,44 +1,38 @@ import { test, expect } from "../fixtures/base"; -const endpoint = "./disputes"; +const endpoint = "./disputes"; test.describe("Get a Dispute @Disputes", async () => { test("Should return the Dispute detail", async ({ request, disputes }) => { - const params = [ - { disputeId: disputes[1].id, exists: true }, - { disputeId: "0", exists: false }, - ]; - for (const { disputeId, exists } of params) { - await test.step(`Should return the Dispute detail with disputeId ${disputeId}`, async () => { - const response = await request.get(endpoint + `/${disputeId}`); - expect(response.status()).toBe(200); + const disputeId = disputes[1].id; + const response = await request.get(endpoint + `/${disputeId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(disputeId); - expect(typeof data.targetIpId).toBe("string"); - expect(typeof data.targetTag).toBe("string"); - expect(typeof data.currentTag).toBe("string"); - expect(typeof data.arbitrationPolicy).toBe("string"); - expect(typeof data.evidenceLink).toBe("string"); - expect(typeof data.initiator).toBe("string"); - expect(typeof data.data).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.targetIpId).toBeTruthy(); - expect(data.targetTag).toBeTruthy(); - expect(data.arbitrationPolicy).toBeTruthy(); - expect(data.evidenceLink).toBeTruthy(); - expect(data.initiator).toBeTruthy(); - expect(data.blockNumber).toBeTruthy(); - expect(data.blockTimestamp).toBeTruthy(); - } else { - expect(data.id).toBeFalsy(); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(disputeId); + expect.soft(typeof data.targetIpId).toBe("string"); + expect.soft(typeof data.targetTag).toBe("string"); + expect.soft(typeof data.currentTag).toBe("string"); + expect.soft(typeof data.arbitrationPolicy).toBe("string"); + expect.soft(typeof data.evidenceLink).toBe("string"); + expect.soft(typeof data.initiator).toBe("string"); + expect.soft(typeof data.data).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.targetIpId).toBeTruthy(); + expect.soft(data.targetTag).toBeTruthy(); + expect.soft(data.arbitrationPolicy).toBeTruthy(); + expect.soft(data.evidenceLink).toBeTruthy(); + expect.soft(data.initiator).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist disputeId", async ({ request }) => { + const response = await request.get(endpoint + "/0"); + expect(response.status()).toBe(404); }); test("Should return 404 for no disputeId", async ({ request }) => { diff --git a/tests/api/disputes/disputes.post.spec.ts b/tests/api/disputes/disputes.post.spec.ts index f5e0dc0..67d56b4 100644 --- a/tests/api/disputes/disputes.post.spec.ts +++ b/tests/api/disputes/disputes.post.spec.ts @@ -54,7 +54,7 @@ test.describe("List Disputes @Disputes", async () => { expect(response.status()).toBe(200); const offsetResponse = await request.post(endpoint, { - data: { options: { pagination: { limit: 20 } } }, + data: { options: { pagination: { limit: 5 } } }, }); const offsetJson = await offsetResponse.json(); const firstItem = offsetJson.data[pagination.offset]; @@ -266,7 +266,7 @@ test.describe("List Disputes @Disputes", async () => { }, }, { - pagination: { offset: 1, limit: 3 }, + pagination: { offset: 0, limit: 3 }, orderBy: "targetIpId", orderDirection: "asc", where: { diff --git a/tests/api/ipassets/assets.get.spec.ts b/tests/api/ipassets/assets.get.spec.ts index 5c2a13f..3794ebf 100644 --- a/tests/api/ipassets/assets.get.spec.ts +++ b/tests/api/ipassets/assets.get.spec.ts @@ -1,46 +1,41 @@ import { test, expect } from "../fixtures/base"; -const endpoint = "./assets"; +const endpoint = "./assets"; test.describe("Get an IPAsset @IPAssets", () => { test("Should return the IPAsset detail", async ({ request, assets }) => { - const params = [ - { assetId: assets[1].id, exists: true }, - { assetId: "0xac05ed0d029e2441067df38da387ea5b5e6d6999", exists: false }, - ]; - for (const { assetId, exists } of params) { - await test.step(`Should return the IPAsset detail with assetId ${assetId}`, async () => { - const response = await request.get(endpoint + `/${assetId}`); - expect(response.status()).toBe(200); + const assetId = assets[1].id; + const response = await request.get(endpoint + `/${assetId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(assetId); - expect(Array.isArray(data.parentIpIds ?? [])).toBeTruthy(); - expect(Array.isArray(data.childIpIds ?? [])).toBeTruthy(); - expect(Array.isArray(data.rootIpIds ?? [])).toBeTruthy(); - expect(typeof data.nftMetadata.name).toBe("string"); - expect(typeof data.nftMetadata.chainId).toBe("string"); - expect(typeof data.nftMetadata.tokenId).toBe("string"); - expect(typeof data.nftMetadata.tokenUri).toBe("string"); - expect(typeof data.nftMetadata.imageUrl).toBe("string"); - expect(typeof data.nftMetadata.tokenContract).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.nftMetadata.name).toBeTruthy(); - expect(data.nftMetadata.chainId).toBeTruthy(); - expect(data.nftMetadata.tokenId).toBeTruthy(); - expect(data.nftMetadata.tokenUri).toBeTruthy(); - expect(data.nftMetadata.tokenContract).toBeTruthy(); - expect(data.blockNumber).toBeTruthy(); - expect(data.blockTimestamp).toBeTruthy(); - } else { - expect(data.id).toBeFalsy(); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(assetId); + expect.soft(Array.isArray(data.parentIpIds ?? [])).toBeTruthy(); + expect.soft(Array.isArray(data.childIpIds ?? [])).toBeTruthy(); + expect.soft(Array.isArray(data.rootIpIds ?? [])).toBeTruthy(); + expect.soft(typeof data.nftMetadata.name).toBe("string"); + expect.soft(typeof data.nftMetadata.chainId).toBe("string"); + expect.soft(typeof data.nftMetadata.tokenId).toBe("string"); + expect.soft(typeof data.nftMetadata.tokenUri).toBe("string"); + expect.soft(typeof data.nftMetadata.imageUrl).toBe("string"); + expect.soft(typeof data.nftMetadata.tokenContract).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.nftMetadata.name).toBeTruthy(); + expect.soft(data.nftMetadata.chainId).toBeTruthy(); + expect.soft(data.nftMetadata.tokenId).toBeTruthy(); + expect.soft(data.nftMetadata.tokenContract).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist assetId", async ({ request }) => { + const response = await request.get( + endpoint + "/0xac05ed0d029e2441067df38da387ea5b5e6d9999" + ); + expect(response.status()).toBe(404); }); test("Should return 404 for no assetId", async ({ request }) => { diff --git a/tests/api/ipassets/assets.post.spec.ts b/tests/api/ipassets/assets.post.spec.ts index d9d8308..2318f87 100644 --- a/tests/api/ipassets/assets.post.spec.ts +++ b/tests/api/ipassets/assets.post.spec.ts @@ -27,7 +27,6 @@ test.describe("List IPAssets @IPAssets", async () => { expect(data[0].nftMetadata.name).toBeTruthy(); expect(data[0].nftMetadata.chainId).toBeTruthy(); expect(data[0].nftMetadata.tokenId).toBeTruthy(); - expect(data[0].nftMetadata.tokenUri).toBeTruthy(); expect(data[0].nftMetadata.tokenContract).toBeTruthy(); expect(data[0].blockNumber).toBeTruthy(); expect(data[0].blockTimestamp).toBeTruthy(); @@ -187,7 +186,7 @@ test.describe("List IPAssets @IPAssets", async () => { }, }, { - pagination: { offset: 2, limit: 15 }, + pagination: { offset: 0, limit: 3 }, orderBy: "id", orderDirection: "desc", where: { diff --git a/tests/api/licenses/licenses-ip-terms.get.spec.ts b/tests/api/licenses/licenses-ip-terms.get.spec.ts index 9315a93..0f540e0 100644 --- a/tests/api/licenses/licenses-ip-terms.get.spec.ts +++ b/tests/api/licenses/licenses-ip-terms.get.spec.ts @@ -17,25 +17,24 @@ test.describe("Get LicenseIpTerm @Licenses", () => { expect(errors).toBeUndefined(); if (exists) { expect(data.id).toBe(licenseIpTermId); - expect(typeof data.ip_id).toBe("string"); - expect(typeof data.license_template).toBe("string"); - expect(typeof data.license_terms_id).toBe("string"); - expect(typeof data.block_number).toBe("string"); - expect(typeof data.block_time).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.ip_id).toBeTruthy(); - expect(data.license_template).toBeTruthy(); - expect(data.license_terms_id).toBeTruthy(); - expect(data.block_number).toBeTruthy(); - expect(data.block_time).toBeTruthy(); + expect.soft(typeof data.ipId).toBe("string"); + expect.soft(typeof data.licenseTemplate).toBe("string"); + expect.soft(typeof data.licenseTermsId).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTime).toBe("string"); + expect.soft(data.ipId).toBeTruthy(); + expect.soft(data.licenseTemplate).toBeTruthy(); + expect.soft(data.licenseTermsId).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTime).toBeTruthy(); } else { expect(data).toMatchObject({ id: "", - ip_id: "", - license_template: "", - license_terms_id: "", - block_number: "", - block_time: "", + ipId: "", + licenseTemplate: "", + licenseTermsId: "", + blockNumber: "", + blockTime: "", }); } }); diff --git a/tests/api/licenses/licenses-ip-terms.post.spec.ts b/tests/api/licenses/licenses-ip-terms.post.spec.ts index 6af919f..4186618 100644 --- a/tests/api/licenses/licenses-ip-terms.post.spec.ts +++ b/tests/api/licenses/licenses-ip-terms.post.spec.ts @@ -12,20 +12,20 @@ test.describe("List LicenseIpTerms @Licenses", () => { expect(Array.isArray(data)).toBeTruthy(); expect(data.length).toBeGreaterThan(0); expect(typeof data[0].id).toBe("string"); - expect(typeof data[0].ip_id).toBe("string"); - expect(typeof data[0].license_template).toBe("string"); - expect(typeof data[0].license_terms_id).toBe("string"); - expect(typeof data[0].block_number).toBe("string"); - expect(typeof data[0].block_time).toBe("string"); + expect(typeof data[0].ipId).toBe("string"); + expect(typeof data[0].licenseTemplate).toBe("string"); + expect(typeof data[0].licenseTermsId).toBe("string"); + expect(typeof data[0].blockNumber).toBe("string"); + expect(typeof data[0].blockTime).toBe("string"); expect(data[0].id).toBeTruthy(); - expect(data[0].ip_id).toBeTruthy(); - expect(data[0].license_template).toBeTruthy(); - expect(data[0].license_terms_id).toBeTruthy(); - expect(data[0].block_number).toBeTruthy(); - expect(data[0].block_time).toBeTruthy(); + expect(data[0].ipId).toBeTruthy(); + expect(data[0].licenseTemplate).toBeTruthy(); + expect(data[0].licenseTermsId).toBeTruthy(); + expect(data[0].blockNumber).toBeTruthy(); + expect(data[0].blockTime).toBeTruthy(); for (let i = 0; i < data.length - 1; i++) { - const item = parseInt(data[i].block_time); - const nextItem = parseInt(data[i + 1].block_time); + const item = parseInt(data[i].blockTime); + const nextItem = parseInt(data[i + 1].blockTime); expect(item).toBeGreaterThanOrEqual(nextItem); } }); diff --git a/tests/api/licenses/licenses-mintingfees.post.spec.ts b/tests/api/licenses/licenses-mintingfees.post.spec.ts index dd41faa..5232ce8 100644 --- a/tests/api/licenses/licenses-mintingfees.post.spec.ts +++ b/tests/api/licenses/licenses-mintingfees.post.spec.ts @@ -50,7 +50,7 @@ test.describe("List Minting Fees @Licenses Minting Fees", async () => { expect(response.status()).toBe(200); const offsetResponse = await request.post(endpoint, { - data: { options: { pagination: { limit: 30 } } }, + data: { options: { pagination: { limit: 5 } } }, }); const offsetJson = await offsetResponse.json(); const firstItem = offsetJson.data[payload.options.pagination.offset]; diff --git a/tests/api/licenses/licenses-templates.get.spec.ts b/tests/api/licenses/licenses-templates.get.spec.ts index 5258e9d..3650d6f 100644 --- a/tests/api/licenses/licenses-templates.get.spec.ts +++ b/tests/api/licenses/licenses-templates.get.spec.ts @@ -17,22 +17,22 @@ test.describe("Get LicenseTemplate @Licenses", () => { expect(errors).toBeUndefined(); if (exists) { expect(data.id).toBe(licenseTemplateId); - expect(typeof data.name).toBe("string"); - expect(typeof data.metadata_uri).toBe("string"); - expect(typeof data.block_number).toBe("string"); - expect(typeof data.block_time).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.name).toBeTruthy(); - expect(data.metadata_uri).toBeTruthy(); - expect(data.block_number).toBeTruthy(); - expect(data.block_time).toBeTruthy(); + expect.soft(typeof data.name).toBe("string"); + expect.soft(typeof data.metadataUri).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTime).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.name).toBeTruthy(); + expect.soft(data.metadataUri).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTime).toBeTruthy(); } else { expect(data).toMatchObject({ id: "", name: "", - metadata_uri: "", - block_number: "", - block_time: "", + metadataUri: "", + blockNumber: "", + blockTime: "", }); } }); diff --git a/tests/api/licenses/licenses-templates.post.spec.ts b/tests/api/licenses/licenses-templates.post.spec.ts index fabab15..ecb8e91 100644 --- a/tests/api/licenses/licenses-templates.post.spec.ts +++ b/tests/api/licenses/licenses-templates.post.spec.ts @@ -13,17 +13,17 @@ test.describe("List LicenseTemplates @Licenses", () => { expect(data.length).toBeGreaterThan(0); expect(typeof data[0].id).toBe("string"); expect(typeof data[0].name).toBe("string"); - expect(typeof data[0].metadata_uri).toBe("string"); - expect(typeof data[0].block_number).toBe("string"); - expect(typeof data[0].block_time).toBe("string"); + expect(typeof data[0].metadataUri).toBe("string"); + expect(typeof data[0].blockNumber).toBe("string"); + expect(typeof data[0].blockTime).toBe("string"); expect(data[0].id).toBeTruthy(); expect(data[0].name).toBeTruthy(); - expect(data[0].metadata_uri).toBeTruthy(); - expect(data[0].block_number).toBeTruthy(); - expect(data[0].block_time).toBeTruthy(); + expect(data[0].metadataUri).toBeTruthy(); + expect(data[0].blockNumber).toBeTruthy(); + expect(data[0].blockTime).toBeTruthy(); for (let i = 0; i < data.length - 1; i++) { - const item = parseInt(data[i].block_time); - const nextItem = parseInt(data[i + 1].block_time); + const item = parseInt(data[i].blockTime); + const nextItem = parseInt(data[i + 1].blockTime); expect(item).toBeGreaterThanOrEqual(nextItem); } }); diff --git a/tests/api/licenses/licenses-terms.get.spec.ts b/tests/api/licenses/licenses-terms.get.spec.ts index 14b6398..529ab89 100644 --- a/tests/api/licenses/licenses-terms.get.spec.ts +++ b/tests/api/licenses/licenses-terms.get.spec.ts @@ -17,19 +17,22 @@ test.describe("Get LicenseTerm @Licenses", () => { expect(errors).toBeUndefined(); if (exists) { expect(data.id).toBe(licenseTermId); - expect(typeof data.json).toBe("string"); - expect(typeof data.license_template).toBe("string"); - expect(typeof data.block_time).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.json).toBeTruthy(); - expect(data.license_template).toBeTruthy(); - expect(data.block_time).toBeTruthy(); + expect.soft(Array.isArray(data.licenseTerms)).toBeTruthy(); + expect.soft(typeof data.licenseTemplate).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTime).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.licenseTerms).toBeTruthy(); + expect.soft(data.licenseTemplate).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTime).toBeTruthy(); } else { expect(data).toMatchObject({ id: "", - json: "", - license_template: "", - block_time: "", + licenseTerms: [], + licenseTemplate: "", + blockNumber: "", + blockTime: "", }); } }); diff --git a/tests/api/licenses/licenses-terms.post.spec.ts b/tests/api/licenses/licenses-terms.post.spec.ts index 93f8e09..e4f9287 100644 --- a/tests/api/licenses/licenses-terms.post.spec.ts +++ b/tests/api/licenses/licenses-terms.post.spec.ts @@ -12,16 +12,18 @@ test.describe("List LicenseTerms @Licenses", () => { expect(Array.isArray(data)).toBeTruthy(); expect(data.length).toBeGreaterThan(0); expect(typeof data[0].id).toBe("string"); - expect(typeof data[0].json).toBe("string"); - expect(typeof data[0].license_template).toBe("string"); - expect(typeof data[0].block_time).toBe("string"); + expect(Array.isArray(data[0].licenseTerms)).toBeTruthy(); + expect(typeof data[0].licenseTemplate).toBe("string"); + expect(typeof data[0].blockNumber).toBe("string"); + expect(typeof data[0].blockTime).toBe("string"); expect(data[0].id).toBeTruthy(); - expect(data[0].json).toBeTruthy(); - expect(data[0].license_template).toBeTruthy(); - expect(data[0].block_time).toBeTruthy(); + expect(data[0].licenseTerms).toBeTruthy(); + expect(data[0].licenseTemplate).toBeTruthy(); + expect(data[0].blockNumber).toBeTruthy(); + expect(data[0].blockTime).toBeTruthy(); for (let i = 0; i < data.length - 1; i++) { - const item = parseInt(data[i].block_time); - const nextItem = parseInt(data[i + 1].block_time); + const item = parseInt(data[i].blockTime); + const nextItem = parseInt(data[i + 1].blockTime); expect(item).toBeGreaterThanOrEqual(nextItem); } }); diff --git a/tests/api/licenses/licenses-tokens.get.spec.ts b/tests/api/licenses/licenses-tokens.get.spec.ts index 7c6d907..3ec471d 100644 --- a/tests/api/licenses/licenses-tokens.get.spec.ts +++ b/tests/api/licenses/licenses-tokens.get.spec.ts @@ -17,40 +17,40 @@ test.describe("Get LicenseToken @Licenses", () => { expect(errors).toBeUndefined(); if (exists) { expect(data.id).toBe(licenseTokenId); - expect(typeof data.licensor_ip_id).toBe("string"); - expect(typeof data.license_template).toBe("string"); - expect(typeof data.license_terms_id).toBe("string"); - expect(typeof data.transferable).toBe("string"); - expect(typeof data.owner).toBe("string"); - expect(typeof data.minted_at).toBe("string"); - expect(typeof data.expires_at).toBe("string"); - expect(typeof data.burnt_at).toBe("string"); - expect(typeof data.block_number).toBe("string"); - expect(typeof data.block_time).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.licensor_ip_id).toBeTruthy(); - expect(data.license_template).toBeTruthy(); - expect(data.license_terms_id).toBeTruthy(); - expect(data.transferable).toBeTruthy(); - expect(data.owner).toBeTruthy(); - expect(data.minted_at).toBeTruthy(); - expect(data.expires_at).toBeTruthy(); - expect(data.burnt_at).toBeTruthy(); - expect(data.block_number).toBeTruthy(); - expect(data.block_time).toBeTruthy(); + expect.soft(typeof data.licensorIpId).toBe("string"); + expect.soft(typeof data.licenseTemplate).toBe("string"); + expect.soft(typeof data.licenseTermsId).toBe("string"); + expect.soft(typeof data.transferable).toBe("string"); + expect.soft(typeof data.owner).toBe("string"); + expect.soft(typeof data.mintedAt).toBe("string"); + expect.soft(typeof data.expiresAt).toBe("string"); + expect.soft(typeof data.burntAt).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTime).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.licensorIpId).toBeTruthy(); + expect.soft(data.licenseTemplate).toBeTruthy(); + expect.soft(data.licenseTermsId).toBeTruthy(); + expect.soft(data.transferable).toBeTruthy(); + expect.soft(data.owner).toBeTruthy(); + expect.soft(data.mintedAt).toBeTruthy(); + expect.soft(data.expiresAt).toBeTruthy(); + expect.soft(data.burntAt).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTime).toBeTruthy(); } else { expect(data).toMatchObject({ id: "", - licensor_ip_id: "", - license_template: "", - license_terms_id: "", + licensorIpId: "", + licenseTemplate: "", + licenseTermsId: "", transferable: "", owner: "", - minted_at: "", - expires_at: "", - burnt_at: "", - block_number: "", - block_time: "", + mintedAt: "", + expiresAt: "", + burntAt: "", + blockNumber: "", + blockTime: "", }); } }); diff --git a/tests/api/licenses/licenses-tokens.post.spec.ts b/tests/api/licenses/licenses-tokens.post.spec.ts index aab649b..69b5edc 100644 --- a/tests/api/licenses/licenses-tokens.post.spec.ts +++ b/tests/api/licenses/licenses-tokens.post.spec.ts @@ -12,30 +12,30 @@ test.describe("List LicenseTokens @Licenses", () => { expect(Array.isArray(data)).toBeTruthy(); expect(data.length).toBeGreaterThan(0); expect(typeof data[0].id).toBe("string"); - expect(typeof data[0].licensor_ip_id).toBe("string"); - expect(typeof data[0].license_template).toBe("string"); - expect(typeof data[0].license_terms_id).toBe("string"); + expect(typeof data[0].licensorIpId).toBe("string"); + expect(typeof data[0].licenseTemplate).toBe("string"); + expect(typeof data[0].licenseTermsId).toBe("string"); expect(typeof data[0].transferable).toBe("string"); expect(typeof data[0].owner).toBe("string"); - expect(typeof data[0].minted_at).toBe("string"); - expect(typeof data[0].expires_at).toBe("string"); - expect(typeof data[0].burnt_at).toBe("string"); - expect(typeof data[0].block_number).toBe("string"); - expect(typeof data[0].block_time).toBe("string"); + expect(typeof data[0].mintedAt).toBe("string"); + expect(typeof data[0].expiresAt).toBe("string"); + expect(typeof data[0].burntAt).toBe("string"); + expect(typeof data[0].blockNumber).toBe("string"); + expect(typeof data[0].blockTime).toBe("string"); expect(data[0].id).toBeTruthy(); - expect(data[0].licensor_ip_id).toBeTruthy(); - expect(data[0].license_template).toBeTruthy(); - expect(data[0].license_terms_id).toBeTruthy(); + expect(data[0].licensorIpId).toBeTruthy(); + expect(data[0].licenseTemplate).toBeTruthy(); + expect(data[0].licenseTermsId).toBeTruthy(); expect(data[0].transferable).toBeTruthy(); expect(data[0].owner).toBeTruthy(); - expect(data[0].minted_at).toBeTruthy(); - expect(data[0].expires_at).toBeTruthy(); - expect(data[0].burnt_at).toBeTruthy(); - expect(data[0].block_number).toBeTruthy(); - expect(data[0].block_time).toBeTruthy(); + expect(data[0].mintedAt).toBeTruthy(); + expect(data[0].expiresAt).toBeTruthy(); + expect(data[0].burntAt).toBeTruthy(); + expect(data[0].blockNumber).toBeTruthy(); + expect(data[0].blockTime).toBeTruthy(); for (let i = 0; i < data.length - 1; i++) { - const item = parseInt(data[i].block_time); - const nextItem = parseInt(data[i + 1].block_time); + const item = parseInt(data[i].blockTime); + const nextItem = parseInt(data[i + 1].blockTime); expect(item).toBeGreaterThanOrEqual(nextItem); } }); diff --git a/tests/api/modules/modules.get.spec.ts b/tests/api/modules/modules.get.spec.ts index 5d2ec66..ee38fe8 100644 --- a/tests/api/modules/modules.get.spec.ts +++ b/tests/api/modules/modules.get.spec.ts @@ -4,34 +4,30 @@ const endpoint = "./modules"; test.describe("Get a Module @Modules", async () => { test("Should return Modules detail", async ({ request, modules }) => { - const params = [ - { moduleId: modules[1].id, exists: true }, - { moduleId: "0x950d766a1a0afdc33c3e653c861a8765cb42d999", exists: false }, - ]; - for (const { moduleId, exists } of params) { - await test.step(`Query with moduleId ${moduleId}`, async () => { - const response = await request.get(endpoint + `/${moduleId}`); - expect(response.status()).toBe(200); + const moduleId = modules[1].id; + const response = await request.get(endpoint + `/${moduleId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(moduleId); - expect(typeof data.name).toBe("string"); - expect(typeof data.module).toBe("string"); - expect(typeof data.deletedAt).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.name).toBeTruthy(); - expect(data.module).toBeTruthy(); - expect(data.blockNumber).toBeTruthy(); - expect(data.blockTimestamp).toBeTruthy(); - } else { - expect(data.id).toBeFalsy(); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(moduleId); + expect.soft(typeof data.name).toBe("string"); + expect.soft(typeof data.module).toBe("string"); + expect.soft(typeof data.deletedAt).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.name).toBeTruthy(); + expect.soft(data.module).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist moduleId", async ({ request }) => { + const response = await request.get( + endpoint + "/0x950d766a1a0afdc33c3e653c861a8765cb42d999" + ); + expect(response.status()).toBe(404); }); test("Should return 404 for no moduleId", async ({ request }) => { diff --git a/tests/api/permissions/permissions.get.spec.ts b/tests/api/permissions/permissions.get.spec.ts index de57939..fbe7587 100644 --- a/tests/api/permissions/permissions.get.spec.ts +++ b/tests/api/permissions/permissions.get.spec.ts @@ -7,37 +7,31 @@ test.describe("Get a Permission @Permissions", async () => { request, permissionsList, }) => { - const params = [ - { permissionId: permissionsList[1].id, exists: true }, - { permissionId: "0x93c5f4a647d060x55", exists: false }, - ]; - for (const { permissionId, exists } of params) { - await test.step(`Query with permissionId ${permissionId}`, async () => { - const response = await request.get(endpoint + `/${permissionId}`); - expect(response.status()).toBe(200); + const permissionId = permissionsList[1].id; + const response = await request.get(endpoint + `/${permissionId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(permissionId); - expect(typeof data.permission).toBe("string"); - expect(typeof data.signer).toBe("string"); - expect(typeof data.to).toBe("string"); - expect(typeof data.func).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.permission).toBeTruthy(); - expect(data.signer).toBeTruthy(); - expect(data.to).toBeTruthy(); - expect(data.func).toBeTruthy(); - expect(data.blockNumber).toBeTruthy(); - expect(data.blockTimestamp).toBeTruthy(); - } else { - expect(data).toBeNull(); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(permissionId); + expect.soft(typeof data.permission).toBe("string"); + expect.soft(typeof data.signer).toBe("string"); + expect.soft(typeof data.to).toBe("string"); + expect.soft(typeof data.func).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.permission).toBeTruthy(); + expect.soft(data.signer).toBeTruthy(); + expect.soft(data.to).toBeTruthy(); + expect.soft(data.func).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist permissionId", async ({ request }) => { + const response = await request.get(endpoint + "/0x93c5f4a647d060x55"); + expect(response.status()).toBe(404); }); test("Should return 404 for no permissionId", async ({ request }) => { diff --git a/tests/api/transactions/transactions.get.spec.ts b/tests/api/transactions/transactions.get.spec.ts index f545adb..910455d 100644 --- a/tests/api/transactions/transactions.get.spec.ts +++ b/tests/api/transactions/transactions.get.spec.ts @@ -7,40 +7,33 @@ test.describe("Get a Transaction @Transactions", async () => { request, transactions, }) => { - const params = [ - { transactionId: transactions[1].id, exists: true }, - { - transactionId: - "0xffc3262a1bdcf0c2dca55874eeccc85deb54f887b072a58775ae9a508d049999", - exists: false, - }, - ]; - for (const { transactionId, exists } of params) { - await test.step(`Query with transactionId ${transactionId}`, async () => { - const response = await request.get(endpoint + `/${transactionId}`); - expect(response.status()).toBe(200); + const transactionId = transactions[1].id; + const response = await request.get(endpoint + `/${transactionId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(transactionId); - expect(typeof data.initiator).toBe("string"); - expect(typeof data.ipId).toBe("string"); - expect(typeof data.resourceId).toBe("string"); - expect(typeof data.resourceType).toBe("string"); - expect(typeof data.actionType).toBe("string"); - expect(typeof data.createdAt).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.initiator).toBeTruthy(); - expect(data.resourceId).toBeTruthy(); - expect(data.resourceType).toBeTruthy(); - expect(data.actionType).toBeTruthy(); - expect(data.createdAt).toBeTruthy(); - } else { - expect(data.id).toBeFalsy(); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(transactionId); + expect.soft(typeof data.initiator).toBe("string"); + expect.soft(typeof data.ipId).toBe("string"); + expect.soft(typeof data.resourceId).toBe("string"); + expect.soft(typeof data.resourceType).toBe("string"); + expect.soft(typeof data.actionType).toBe("string"); + expect.soft(typeof data.createdAt).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.initiator).toBeTruthy(); + expect.soft(data.resourceId).toBeTruthy(); + expect.soft(data.resourceType).toBeTruthy(); + expect.soft(data.actionType).toBeTruthy(); + expect.soft(data.createdAt).toBeTruthy(); + }); + + test("Should return 404 for non-exist transactionId", async ({ request }) => { + const response = await request.get( + endpoint + + "/0xffc3262a1bdcf0c2dca55874eeccc85deb54f887b072a58775ae9a508d049999" + ); + expect(response.status()).toBe(404); }); test("Should return 404 for no transactionId", async ({ request }) => {