Skip to content

Commit

Permalink
update tests with modules and profiles (#3810)
Browse files Browse the repository at this point in the history
  • Loading branch information
Celiant authored Jun 20, 2024
1 parent 22711df commit 5f35043
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 115 deletions.
130 changes: 56 additions & 74 deletions e2e-tests/cypress/e2e/api-tests/analytics/compareModules.cy.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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({
Expand All @@ -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;
})
});

Expand All @@ -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: {
},
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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");
})
});

Expand All @@ -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: {
},
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -227,4 +209,4 @@ context("Analytics", { tags: '@analytics' },() => {
expect(response.status).to.eq(STATUS_CODE.UNAUTHORIZED);
})
});
});
});
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -13,8 +13,8 @@ context('Profiles', { tags: '@profiles' }, () => {
headers: {
authorization,
},
}).then((resp) => {
did = resp.body[0].did
}).then((response) => {
did = response.body[0].did
});
});

Expand All @@ -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',
Expand All @@ -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
})
})
})
})
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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)
})
})
})
})
})


})

0 comments on commit 5f35043

Please sign in to comment.