Skip to content

Commit

Permalink
fix: 400 error on the datasets page when changing the number of items…
Browse files Browse the repository at this point in the history
… per page (#1151)

* fix: datasets page 400 error on changing items per page

* added api test for update users settings
  • Loading branch information
Junjiequan authored Apr 5, 2024
1 parent c97d49a commit d81cbf0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ import { Request } from "express";
import { JWTUser } from "../auth/interfaces/jwt-user.interface";
import { UserSettings } from "./schemas/user-settings.schema";
import { CreateUserSettingsDto } from "./dto/create-user-settings.dto";
import {
PartialUpdateUserSettingsDto,
UpdateUserSettingsDto,
} from "./dto/update-user-settings.dto";
import { PartialUpdateUserSettingsDto } from "./dto/update-user-settings.dto";
import { User } from "./schemas/user.schema";
import { CreateUserSettingsInterceptor } from "./interceptors/create-user-settings.interceptor";
import { AuthService } from "src/auth/auth.service";
Expand Down Expand Up @@ -255,7 +252,7 @@ export class UsersController {
async updateSettings(
@Req() request: Request,
@Param("id") id: string,
@Body() updateUserSettingsDto: UpdateUserSettingsDto,
@Body() updateUserSettingsDto: PartialUpdateUserSettingsDto,
): Promise<UserSettings | null> {
await this.checkUserAuthorization(
request,
Expand Down
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 d81cbf0

Please sign in to comment.