diff --git a/tests/api/collections/collections.post.spec.ts b/tests/api/collections/collections.post.spec.ts index 580747e..de32dea 100644 --- a/tests/api/collections/collections.post.spec.ts +++ b/tests/api/collections/collections.post.spec.ts @@ -39,7 +39,7 @@ test.describe("List Collections @Collections", async () => { const pageParams = [ { pagination: { offset: 0, limit: 5 } }, { pagination: { offset: 0, limit: 1 } }, - { pagination: { offset: 1, limit: 20 } }, + { pagination: { offset: 1, limit: 5 } }, ]; for (const { pagination } of pageParams) { test(`Should return Collections list with pagination ${JSON.stringify( @@ -54,7 +54,7 @@ test.describe("List Collections @Collections", 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[pagination.offset]; diff --git a/tests/api/fixtures/base.ts b/tests/api/fixtures/base.ts index 5161608..953bf0a 100644 --- a/tests/api/fixtures/base.ts +++ b/tests/api/fixtures/base.ts @@ -60,9 +60,11 @@ type TestOptions = { }>; licensesIpTerms: Array<{ id: string; + ipId: string; }>; licensesTokens: Array<{ id: string; + licensorIpId: string; }>; }; diff --git a/tests/api/ipassets/assets.post.spec.ts b/tests/api/ipassets/assets.post.spec.ts index 2318f87..4f86dcf 100644 --- a/tests/api/ipassets/assets.post.spec.ts +++ b/tests/api/ipassets/assets.post.spec.ts @@ -54,7 +54,7 @@ test.describe("List IPAssets @IPAssets", 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[pagination.offset]; diff --git a/tests/api/licenses/licenses-ip-terms.post.spec.ts b/tests/api/licenses/licenses-ip-terms.post.spec.ts index 4186618..de7f0cc 100644 --- a/tests/api/licenses/licenses-ip-terms.post.spec.ts +++ b/tests/api/licenses/licenses-ip-terms.post.spec.ts @@ -47,7 +47,7 @@ test.describe("List LicenseIpTerms @Licenses", () => { 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[pagination.offset]; @@ -58,5 +58,36 @@ test.describe("List LicenseIpTerms @Licenses", () => { expect(data[0]).toMatchObject(firstItem); }); } -}); + test("query with filter", async ({ request, licensesIpTerms }) => { + const whereParams = [ + { where: { ipId: licensesIpTerms[1].ipId }, exists: true }, + { + where: { ipId: "0xe7517E0Ee3e255a904BD777961C20566be089999" }, + exists: false, + }, + ]; + for (const { where, exists } of whereParams) { + await test.step(`query with where ${JSON.stringify(where)}`, async () => { + const payload = { + options: { where }, + }; + const response = await request.post(endpoint, { + data: payload, + }); + expect(response.status()).toBe(200); + + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + if (exists) { + expect(data.length).toBeGreaterThan(0); + data.forEach((item: object) => { + expect(item).toMatchObject(where); + }); + } else { + expect(data.length).toBe(0); + } + }); + } + }); +}); diff --git a/tests/api/licenses/licenses-templates.post.spec.ts b/tests/api/licenses/licenses-templates.post.spec.ts index ecb8e91..d18ecc3 100644 --- a/tests/api/licenses/licenses-templates.post.spec.ts +++ b/tests/api/licenses/licenses-templates.post.spec.ts @@ -45,7 +45,7 @@ test.describe("List LicenseTemplates @Licenses", () => { 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[pagination.offset]; diff --git a/tests/api/licenses/licenses-terms.post.spec.ts b/tests/api/licenses/licenses-terms.post.spec.ts index e4f9287..78bee49 100644 --- a/tests/api/licenses/licenses-terms.post.spec.ts +++ b/tests/api/licenses/licenses-terms.post.spec.ts @@ -45,7 +45,7 @@ test.describe("List LicenseTerms @Licenses", () => { 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[pagination.offset]; diff --git a/tests/api/licenses/licenses-tokens.post.spec.ts b/tests/api/licenses/licenses-tokens.post.spec.ts index 69b5edc..77d490c 100644 --- a/tests/api/licenses/licenses-tokens.post.spec.ts +++ b/tests/api/licenses/licenses-tokens.post.spec.ts @@ -68,4 +68,34 @@ test.describe("List LicenseTokens @Licenses", () => { expect(data[0]).toMatchObject(firstItem); }); } -}); \ No newline at end of file + + test("query with filter", async ({ request, licensesTokens }) => { + const whereParams = [ + { where: { licensorIpId: licensesTokens[1].licensorIpId }, exists: true }, + { + where: { licensorIpId: "0x5FCeDadBbDF710Ac3C528F6Aac9D1bD9ac189999" }, + exists: false, + }, + ]; + for (const { where, exists } of whereParams) { + await test.step(`query with where ${JSON.stringify(where)}`, async () => { + const payload = { + options: { where }, + }; + const response = await request.post(endpoint, { + data: payload, + }); + expect(response.status()).toBe(200); + + const { errors, data } = await response.json(); + expect(errors).toBeUndefined(); + if (exists) { + expect(data.length).toBeGreaterThan(0); + expect(data[0].licensorIpId).toBe(licensesTokens[1].licensorIpId); + } else { + expect(data.length).toBe(0); + } + }); + } + }); +}); diff --git a/tests/api/permissions/permissions.post.spec.ts b/tests/api/permissions/permissions.post.spec.ts index 39a33a6..cef6be0 100644 --- a/tests/api/permissions/permissions.post.spec.ts +++ b/tests/api/permissions/permissions.post.spec.ts @@ -50,7 +50,7 @@ test.describe("List Permissions @Permissions", 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[pagination.offset]; diff --git a/tests/api/royalties/royalties-payments.post.spec.ts b/tests/api/royalties/royalties-payments.post.spec.ts index f3942b1..4bc1923 100644 --- a/tests/api/royalties/royalties-payments.post.spec.ts +++ b/tests/api/royalties/royalties-payments.post.spec.ts @@ -52,7 +52,7 @@ test.describe("List RoyaltyPays @Royalties", () => { 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[pagination.offset];