From 5f35043a7f7cf7a89b4eead3b496883b3a556ce3 Mon Sep 17 00:00:00 2001 From: Celiant Date: Thu, 20 Jun 2024 16:55:55 +0400 Subject: [PATCH] update tests with modules and profiles (#3810) --- .../api-tests/analytics/compareModules.cy.js | 130 ++++++++---------- .../userCreateAndSetHederaCreds.cy.js | 65 ++++----- 2 files changed, 80 insertions(+), 115 deletions(-) diff --git a/e2e-tests/cypress/e2e/api-tests/analytics/compareModules.cy.js b/e2e-tests/cypress/e2e/api-tests/analytics/compareModules.cy.js index e5067656a6..ecdd97dbc5 100644 --- a/e2e-tests/cypress/e2e/api-tests/analytics/compareModules.cy.js +++ b/e2e-tests/cypress/e2e/api-tests/analytics/compareModules.cy.js @@ -1,8 +1,9 @@ import { METHOD, STATUS_CODE } from "../../../support/api/api-const"; import API from "../../../support/ApiUrls"; -context("Analytics", { tags: '@analytics' },() => { +context("Analytics", { tags: '@analytics' }, () => { const authorization = Cypress.env("authorization"); + let moduleId1, moduleId2 before(() => { cy.fixture("displayDocuments.module", "binary").then((binary) => Cypress.Blob.binaryStringToBlob(binary)) .then((file) => { @@ -17,6 +18,8 @@ context("Analytics", { tags: '@analytics' },() => { timeout: 180000, }).then((response) => { expect(response.status).to.eq(STATUS_CODE.SUCCESS); + let json = JSON.parse(new TextDecoder("utf-8").decode(response.body)) + moduleId1 = json.id; }); }); cy.request({ @@ -31,40 +34,30 @@ context("Analytics", { tags: '@analytics' },() => { timeout: 180000 }).then((response) => { expect(response.status).eql(STATUS_CODE.SUCCESS); + moduleId2 = response.body.id; }); }) it("Compare modules", () => { - let moduleId1, moduleId2 cy.request({ - method: METHOD.GET, - url: API.ApiServer + API.ListOfAllModules, + method: METHOD.POST, + url: API.ApiServer + API.ModuleCompare, + body: { + moduleId1: moduleId1, + moduleId2: moduleId2, + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 + }, headers: { authorization, } }).then((response) => { - moduleId1 = response.body.at(1)._id - moduleId2 = response.body.at(0)._id - cy.request({ - method: METHOD.POST, - url: API.ApiServer + API.ModuleCompare, - body: { - moduleId1: moduleId1, - moduleId2: moduleId2, - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" - }, - headers: { - authorization, - } - }).then((response) => { - expect(response.status).to.eq(STATUS_CODE.OK); - expect(response.body.left.id).to.eq(moduleId1); - expect(response.body.right.id).to.eq(moduleId2); - expect(response.body.total).not.null; - }) + expect(response.status).to.eq(STATUS_CODE.OK); + expect(response.body.left.id).to.eq(moduleId1); + expect(response.body.right.id).to.eq(moduleId2); + expect(response.body.total).not.null; }) }); @@ -75,10 +68,10 @@ context("Analytics", { tags: '@analytics' },() => { body: { moduleId1: "6419853a31fe4fd0e741b3a9", moduleId2: "641983a931fe4fd0e741b399", - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 }, headers: { }, @@ -96,10 +89,10 @@ context("Analytics", { tags: '@analytics' },() => { body: { moduleId1: "6419853a31fe4fd0e741b3a9", moduleId2: "641983a931fe4fd0e741b399", - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 }, headers: { authorization: auth, @@ -118,10 +111,10 @@ context("Analytics", { tags: '@analytics' },() => { body: { moduleId1: "6419853a31fe4fd0e741b3a9", moduleId2: "641983a931fe4fd0e741b399", - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 }, headers: { authorization: auth, @@ -133,34 +126,23 @@ context("Analytics", { tags: '@analytics' },() => { }); it("Compare modules(Export)", () => { - let moduleId1, moduleId2 cy.request({ - method: METHOD.GET, - url: API.ApiServer + API.ListOfAllModules, + method: METHOD.POST, + url: API.ApiServer + API.ModuleCompare + API.ExportCSV, + body: { + moduleId1: moduleId1, + moduleId2: moduleId2, + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 + }, headers: { authorization, } }).then((response) => { - moduleId1 = response.body.at(1)._id - moduleId2 = response.body.at(0)._id - cy.request({ - method: METHOD.POST, - url: API.ApiServer + API.ModuleCompare + API.ExportCSV, - body: { - moduleId1: moduleId1, - moduleId2: moduleId2, - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" - }, - headers: { - authorization, - } - }).then((response) => { - expect(response.status).to.eq(STATUS_CODE.OK); - expect(response.body).to.include("data:text/csv"); - }) + expect(response.status).to.eq(STATUS_CODE.OK); + expect(response.body).to.include("data:text/csv"); }) }); @@ -171,10 +153,10 @@ context("Analytics", { tags: '@analytics' },() => { body: { moduleId1: "6419853a31fe4fd0e741b3a9", moduleId2: "641983a931fe4fd0e741b399", - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 }, headers: { }, @@ -192,10 +174,10 @@ context("Analytics", { tags: '@analytics' },() => { body: { moduleId1: "6419853a31fe4fd0e741b3a9", moduleId2: "641983a931fe4fd0e741b399", - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 }, headers: { authorization: auth, @@ -214,10 +196,10 @@ context("Analytics", { tags: '@analytics' },() => { body: { moduleId1: "6419853a31fe4fd0e741b3a9", moduleId2: "641983a931fe4fd0e741b399", - eventsLvl: "1", - propLvl: "2", - childrenLvl: "2", - idLvl: "0" + eventsLvl: 1, + propLvl: 2, + childrenLvl: 2, + idLvl: 0 }, headers: { authorization: auth, @@ -227,4 +209,4 @@ context("Analytics", { tags: '@analytics' },() => { expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED); }) }); -}); +}); \ No newline at end of file diff --git a/e2e-tests/cypress/e2e/api-tests/profiles/userCreateAndSetHederaCreds.cy.js b/e2e-tests/cypress/e2e/api-tests/profiles/userCreateAndSetHederaCreds.cy.js index 48d3262b18..c2fca985f6 100644 --- a/e2e-tests/cypress/e2e/api-tests/profiles/userCreateAndSetHederaCreds.cy.js +++ b/e2e-tests/cypress/e2e/api-tests/profiles/userCreateAndSetHederaCreds.cy.js @@ -1,8 +1,8 @@ -import { METHOD, STATUS_CODE } from "../../../support/api/api-const"; +import {METHOD, STATUS_CODE} from "../../../support/api/api-const"; import API from "../../../support/ApiUrls"; -context('Profiles', { tags: '@profiles' }, () => { +context('Profiles', {tags: '@profiles'}, () => { const authorization = Cypress.env("authorization"); let did @@ -13,8 +13,8 @@ context('Profiles', { tags: '@profiles' }, () => { headers: { authorization, }, - }).then((resp) => { - did = resp.body[0].did + }).then((response) => { + did = response.body[0].did }); }); @@ -33,8 +33,9 @@ context('Profiles', { tags: '@profiles' }, () => { }; cy.request(options) .then((response) => { - expect(response.status).to.eq(201) + expect(response.status).to.eq(STATUS_CODE.SUCCESS) expect(response.body.username).to.equal(name) + expect(response.body.permissionsGroup.at(0).roleName).to.equal('Default policy user') cy.request({ method: 'POST', url: API.ApiServer + 'accounts/login', @@ -53,35 +54,18 @@ context('Profiles', { tags: '@profiles' }, () => { }).then((response) => { let accessToken = 'Bearer ' + response.body.accessToken cy.request({ - method: METHOD.GET, - url: API.ApiServer + API.RandomKey, - headers: { authorization }, - }).then((resp) => { - expect(resp.status).eql(STATUS_CODE.OK); - expect(resp.body).to.have.property("id"); - expect(resp.body).to.have.property("key"); - cy.request({ - method: 'PUT', - url: API.ApiServer + 'profiles/' + name, - headers: { - authorization: accessToken - }, - body: { - fireblocksConfig: { - fireBlocksVaultId: "", - fireBlocksAssetId: "", - fireBlocksApiKey: "", - fireBlocksPrivateiKey: "" - }, - hederaAccountId: resp.body.id, - hederaAccountKey: resp.body.key, - parent: did, - useFireblocksSigning: false, - vcDocument: { field0: "" } - }, - timeout: 200000 - }) - }); + method: 'PUT', + url: API.ApiServer + 'profiles/' + name, + headers: { + authorization: accessToken + }, + body: { + hederaAccountId: "0.0.2954463", + hederaAccountKey: "3030020100300706052b8104000a042204200501fd610df433a7dd202faa6864d5f270dbb129ccc6455ab5cb1ee44838cab8", + parent: did + }, + timeout: 200000 + }) }) }) }) @@ -102,11 +86,12 @@ context('Profiles', { tags: '@profiles' }, () => { }; cy.request(options) .then((response) => { - let role = response.body.role + let role = response.body.permissionsGroup.at(0).roleName let username = response.body.username - expect(response.status).to.eq(201) + expect(response.status).to.eq(STATUS_CODE.SUCCESS) expect(username).to.equal(name) + expect(role).to.equal('Default policy user') cy.request({ method: 'POST', @@ -118,7 +103,7 @@ context('Profiles', { tags: '@profiles' }, () => { } }) .then((response) => { - expect(response.status).to.eq(200) + expect(response.status).to.eq(STATUS_CODE.OK) let accessToken = 'bearer ' + response.body.accessToken cy.request({ method: 'PUT', @@ -141,11 +126,9 @@ context('Profiles', { tags: '@profiles' }, () => { timeout: 200000 }) .then((response) => { - expect(response.status).to.eq(401) + expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED) }) }) }) }) -}) - - +}) \ No newline at end of file