diff --git a/tests/api/licenses/licenses-ip-terms.get.spec.ts b/tests/api/licenses/licenses-ip-terms.get.spec.ts index 0f540e0..ea556ba 100644 --- a/tests/api/licenses/licenses-ip-terms.get.spec.ts +++ b/tests/api/licenses/licenses-ip-terms.get.spec.ts @@ -4,45 +4,32 @@ const endpoint = "./licenses/ip/terms"; test.describe("Get LicenseIpTerm @Licenses", () => { test("query with id param", async ({ request, licensesIpTerms }) => { - const params = [ - { licenseIpTermId: licensesIpTerms[1].id, exists: true }, - { licenseIpTermId: "0", exists: false }, - ]; - for (const { licenseIpTermId, exists } of params) { - await test.step(`Query with licenseIpTermId ${licenseIpTermId}`, async () => { - const response = await request.get(endpoint + `/${licenseIpTermId}`); - expect(response.status()).toBe(200); + const licenseIpTermId = licensesIpTerms[1].id; + const response = await request.get(endpoint + `/${licenseIpTermId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(licenseIpTermId); - 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: "", - ipId: "", - licenseTemplate: "", - licenseTermsId: "", - blockNumber: "", - blockTime: "", - }); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(licenseIpTermId); + 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(); + }); + + test("query with non-exist id param", async ({ request }) => { + const response = await request.get(endpoint + "/0"); + expect(response.status()).toBe(404); }); test("query with no param", async ({ request }) => { const response = await request.get(endpoint); expect(response.status()).toBe(404); }); -}); \ No newline at end of file +}); diff --git a/tests/api/licenses/licenses-mintingfees.get.spec.ts b/tests/api/licenses/licenses-mintingfees.get.spec.ts index 09d42c9..7c6c64e 100644 --- a/tests/api/licenses/licenses-mintingfees.get.spec.ts +++ b/tests/api/licenses/licenses-mintingfees.get.spec.ts @@ -1,45 +1,39 @@ import { test, expect } from "../fixtures/base"; -const endpoint = "./licenses/mintingfees"; +const endpoint = "./licenses/mintingfees"; test.describe("Get a Minting Fee @Licenses Minting Fees", async () => { test("Should return Licenses Minting Fees detail", async ({ request, licensesMintingfees, }) => { - const params = [ - { licenseMintingFeeId: licensesMintingfees[1].id, exists: true }, - { licenseMintingFeeId: "0x78b3264eaf8030999", exists: false }, - ]; - for (const { licenseMintingFeeId, exists } of params) { - await test.step(`Query with licenseMintingFeeId ${licenseMintingFeeId}`, async () => { - const response = await request.get( - endpoint + `/${licenseMintingFeeId}` - ); - expect(response.status()).toBe(200); + const licenseMintingFeeId = licensesMintingfees[1].id; + const response = await request.get(endpoint + `/${licenseMintingFeeId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(licenseMintingFeeId); - expect(typeof data.token).toBe("string"); - expect(typeof data.payer).toBe("string"); - expect(typeof data.amount).toBe("string"); - expect(typeof data.receiverIpId).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.token).toBeTruthy(); - expect(data.payer).toBeTruthy(); - expect(data.amount).toBeTruthy(); - expect(data.receiverIpId).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(licenseMintingFeeId); + expect.soft(typeof data.token).toBe("string"); + expect.soft(typeof data.payer).toBe("string"); + expect.soft(typeof data.amount).toBe("string"); + expect.soft(typeof data.receiverIpId).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.token).toBeTruthy(); + expect.soft(data.payer).toBeTruthy(); + expect.soft(data.amount).toBeTruthy(); + expect.soft(data.receiverIpId).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist licenseMintingFeeId", async ({ + request, + }) => { + const response = await request.get(endpoint + "/0x78b3264eaf8030999"); + expect(response.status()).toBe(404); }); test("Should return null for no licenseMintingFeeId", async ({ request }) => { diff --git a/tests/api/licenses/licenses-templates.get.spec.ts b/tests/api/licenses/licenses-templates.get.spec.ts index 3650d6f..1926aa4 100644 --- a/tests/api/licenses/licenses-templates.get.spec.ts +++ b/tests/api/licenses/licenses-templates.get.spec.ts @@ -4,39 +4,27 @@ const endpoint = "./licenses/templates"; test.describe("Get LicenseTemplate @Licenses", () => { test("query with id param", async ({ request, licensesTemplates }) => { - const params = [ - { licenseTemplateId: licensesTemplates[0].id, exists: true }, - { licenseTemplateId: "1", exists: false }, - ]; - for (const { licenseTemplateId, exists } of params) { - await test.step(`Query with licenseTemplateId ${licenseTemplateId}`, async () => { - const response = await request.get(endpoint + `/${licenseTemplateId}`); - expect(response.status()).toBe(200); + const licenseTemplateId = licensesTemplates[0].id; + const response = await request.get(endpoint + `/${licenseTemplateId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(licenseTemplateId); - 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: "", - metadataUri: "", - blockNumber: "", - blockTime: "", - }); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(licenseTemplateId); + 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(); + }); + + test("query with non-exist id param", async ({ request }) => { + const response = await request.get(endpoint + "/0"); + expect(response.status()).toBe(404); }); test("query with no param", async ({ request }) => { diff --git a/tests/api/licenses/licenses-terms.get.spec.ts b/tests/api/licenses/licenses-terms.get.spec.ts index 529ab89..4cfcdd7 100644 --- a/tests/api/licenses/licenses-terms.get.spec.ts +++ b/tests/api/licenses/licenses-terms.get.spec.ts @@ -4,43 +4,31 @@ const endpoint = "./licenses/terms"; test.describe("Get LicenseTerm @Licenses", () => { test("query with id param", async ({ request, licensesTerms }) => { - const params = [ - { licenseTermId: licensesTerms[1].id, exists: true }, - { licenseTermId: "0", exists: false }, - ]; - for (const { licenseTermId, exists } of params) { - await test.step(`Query with licenseTermId ${licenseTermId}`, async () => { - const response = await request.get(endpoint + `/${licenseTermId}`); - expect(response.status()).toBe(200); + const licenseTermId = licensesTerms[1].id; + const response = await request.get(endpoint + `/${licenseTermId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(licenseTermId); - 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: "", - licenseTerms: [], - licenseTemplate: "", - blockNumber: "", - blockTime: "", - }); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(licenseTermId); + 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(); + }); + + test("query with non-exist id param", async ({ request }) => { + const response = await request.get(endpoint + "/0"); + expect(response.status()).toBe(404); }); test("query with no param", async ({ request }) => { const response = await request.get(endpoint); expect(response.status()).toBe(404); }); -}); \ No newline at end of file +}); diff --git a/tests/api/licenses/licenses-tokens.get.spec.ts b/tests/api/licenses/licenses-tokens.get.spec.ts index 3ec471d..439f725 100644 --- a/tests/api/licenses/licenses-tokens.get.spec.ts +++ b/tests/api/licenses/licenses-tokens.get.spec.ts @@ -4,57 +4,39 @@ const endpoint = "./licenses/tokens"; test.describe("Get LicenseToken @Licenses", () => { test("query with id param", async ({ request, licensesTokens }) => { - const params = [ - { licenseTokenId: licensesTokens[1].id, exists: true }, - { licenseTokenId: "-1", exists: false }, - ]; - for (const { licenseTokenId, exists } of params) { - await test.step(`Query with licenseTokenId ${licenseTokenId}`, async () => { - const response = await request.get(endpoint + `/${licenseTokenId}`); - expect(response.status()).toBe(200); + const licenseTokenId = licensesTokens[1].id; + const response = await request.get(endpoint + `/${licenseTokenId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(licenseTokenId); - 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: "", - licensorIpId: "", - licenseTemplate: "", - licenseTermsId: "", - transferable: "", - owner: "", - mintedAt: "", - expiresAt: "", - burntAt: "", - blockNumber: "", - blockTime: "", - }); - } - }); - } + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + expect(data.id).toBe(licenseTokenId); + 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(); + }); + + test("query with non-exist id param", async ({ request }) => { + const response = await request.get(endpoint + "/00"); + expect(response.status()).toBe(404); }); test("query with no param", async ({ request }) => { diff --git a/tests/api/royalties/royalties-payments.get.spec.ts b/tests/api/royalties/royalties-payments.get.spec.ts index 81a62db..45e7509 100644 --- a/tests/api/royalties/royalties-payments.get.spec.ts +++ b/tests/api/royalties/royalties-payments.get.spec.ts @@ -7,39 +7,33 @@ test.describe("Get a RoyaltyPay @Royalties", () => { request, royaltiesPayments, }) => { - const params = [ - { royaltyPayId: royaltiesPayments[0].id, exists: true }, - { royaltyPayId: "0x55ffbb07777249999", exists: false }, - ]; - for (const { royaltyPayId, exists } of params) { - await test.step(`Query with royaltyPayId ${royaltyPayId}`, async () => { - const response = await request.get(endpoint + `/${royaltyPayId}`); - expect(response.status()).toBe(200); + const royaltyPayId = royaltiesPayments[0].id; + const response = await request.get(endpoint + `/${royaltyPayId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(royaltyPayId); - expect(typeof data.payerIpId).toBe("string"); - expect(typeof data.receiverIpId).toBe("string"); - expect(typeof data.sender).toBe("string"); - expect(typeof data.token).toBe("string"); - expect(typeof data.amount).toBe("string"); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.payerIpId).toBeTruthy(); - expect(data.receiverIpId).toBeTruthy(); - expect(data.sender).toBeTruthy(); - expect(data.token).toBeTruthy(); - expect(data.amount).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(royaltyPayId); + expect.soft(typeof data.payerIpId).toBe("string"); + expect.soft(typeof data.receiverIpId).toBe("string"); + expect.soft(typeof data.sender).toBe("string"); + expect.soft(typeof data.token).toBe("string"); + expect.soft(typeof data.amount).toBe("string"); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.payerIpId).toBeTruthy(); + expect.soft(data.receiverIpId).toBeTruthy(); + expect.soft(data.sender).toBeTruthy(); + expect.soft(data.token).toBeTruthy(); + expect.soft(data.amount).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist royaltyPayId", async ({ request }) => { + const response = await request.get(endpoint + "/0x55ffbb07777249999"); + expect(response.status()).toBe(404); }); test("Should return 404 for no royaltyPayId", async ({ request }) => { diff --git a/tests/api/royalties/royalties-policies.get.spec.ts b/tests/api/royalties/royalties-policies.get.spec.ts index b8ac0fe..1b041bd 100644 --- a/tests/api/royalties/royalties-policies.get.spec.ts +++ b/tests/api/royalties/royalties-policies.get.spec.ts @@ -7,38 +7,33 @@ test.describe("Get a Royalties Policy @Royalties", () => { request, royaltiesPolicies, }) => { - const params = [ - { royaltyPolicyId: royaltiesPolicies[1].id, exists: true }, - { - royaltyPolicyId: "0x484c10779f9c5209b371afa029797e76129d9999", - exists: false, - }, - ]; - for (const { royaltyPolicyId, exists } of params) { - await test.step(`Query with royaltyPolicyId ${royaltyPolicyId}`, async () => { - const response = await request.get(endpoint + `/${royaltyPolicyId}`); - expect(response.status()).toBe(200); + const royaltyPolicyId = royaltiesPolicies[1].id; + const response = await request.get(endpoint + `/${royaltyPolicyId}`); + expect(response.status()).toBe(200); - const { errors, data } = await response.json(); - expect(errors).toBeUndefined(); - if (exists) { - expect(data.id).toBe(royaltyPolicyId); - expect(typeof data.royaltyStack).toBe("string"); - expect(typeof data.ipRoyaltyVault).toBe("string"); - expect(Array.isArray(data.targetAncestors ?? [])).toBeTruthy(); - expect(Array.isArray(data.targetRoyaltyAmount ?? [])).toBeTruthy(); - expect(typeof data.blockNumber).toBe("string"); - expect(typeof data.blockTimestamp).toBe("string"); - expect(data.id).toBeTruthy(); - expect(data.royaltyStack).toBeTruthy(); - expect(data.ipRoyaltyVault).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(royaltyPolicyId); + expect.soft(typeof data.royaltyStack).toBe("string"); + expect.soft(typeof data.ipRoyaltyVault).toBe("string"); + expect.soft(Array.isArray(data.targetAncestors ?? [])).toBeTruthy(); + expect.soft(Array.isArray(data.targetRoyaltyAmount ?? [])).toBeTruthy(); + expect.soft(typeof data.blockNumber).toBe("string"); + expect.soft(typeof data.blockTimestamp).toBe("string"); + expect.soft(data.id).toBeTruthy(); + expect.soft(data.royaltyStack).toBeTruthy(); + expect.soft(data.ipRoyaltyVault).toBeTruthy(); + expect.soft(data.blockNumber).toBeTruthy(); + expect.soft(data.blockTimestamp).toBeTruthy(); + }); + + test("Should return 404 for non-exist royaltyPolicyId", async ({ + request, + }) => { + const response = await request.get( + endpoint + "/0x484c10779f9c5209b371afa029797e76129d9999" + ); + expect(response.status()).toBe(404); }); test("Should return 404 for no royaltyPolicyId", async ({ request }) => {