Skip to content

Commit

Permalink
added api test for update users settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Junjiequan committed Apr 4, 2024
1 parent 3eb8295 commit 0151989
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions test/Users.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/* eslint-disable @typescript-eslint/no-var-requires */
"use strict";

const { TestData } = require("./TestData");
const utils = require("./LoginUtils");

let userIdUser1 = null,
accessTokenUser1 = null;

describe("Users: Login with functional accounts", () => {
it("Admin ingestor login fails with incorrect credentials", async () => {
describe("2350: Users: Login with functional accounts", () => {
it("0010: Admin ingestor login fails with incorrect credentials", async () => {
return request(appUrl)
.post("/api/v3/Users/Login?include=user")
.send({
Expand All @@ -15,7 +21,7 @@ describe("Users: Login with functional accounts", () => {
});
});

it("Login should succeed with correct credentials", async () => {
it("0020: Login should succeed with correct credentials", async () => {
return request(appUrl)
.post("/api/v3/Users/Login?include=user")
.send({
Expand All @@ -30,3 +36,34 @@ describe("Users: Login with functional accounts", () => {
});
});
});

describe("2360: Users settings", () => {
beforeEach((done) => {
utils.getIdAndToken(
appUrl,
{
username: "user1",
password: TestData.Accounts["user1"]["password"],
},
(idVal, tokenVal) => {
accessTokenUser1 = tokenVal;
userIdUser1 = idVal;
done();
},
);
});

it("0010: Update users settings with valid value should sucess ", async () => {
return request(appUrl)
.put(`/api/v3/Users/${userIdUser1}/settings`)
.set("Accept", "application/json")
.set({ Authorization: `Bearer ${accessTokenUser1}` })
.expect(TestData.SuccessfulPatchStatusCode)
.expect("Content-Type", /json/)
.then((res) => {
res.body.should.have.property("userId", userIdUser1);
res.body.should.have.property("datasetCount");
res.body.should.have.property("jobCount");
});
});
});

0 comments on commit 0151989

Please sign in to comment.