Skip to content

Commit

Permalink
Merge pull request #66 from atlp-rwanda/fix-Login
Browse files Browse the repository at this point in the history
Fix-#Login: removed UserInfo field when user logs in
  • Loading branch information
teerenzo authored May 24, 2024
2 parents 3d86200 + cd8a730 commit 9b8d8e4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
5 changes: 4 additions & 1 deletion __test__/cart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import User from "../src/sequelize/models/users";
import bcrypt from "bcrypt";
import { Role } from "../src/sequelize/models/roles";
import { dummy } from "./prod";
import * as userServices from "../src/services/user.service"
import { number } from "joi";

const queryInterface = sequelize.getQueryInterface();

Expand Down Expand Up @@ -86,7 +88,8 @@ describe("testing cart", () => {
// console.log("response 3--->", res3);

sellerToken = res3.body.token;
sellerId = res3.body.userInfo?.id;
const seller = await userServices.getUserByEmail("[email protected]");
const sellerId = seller?.id;

await request(app)
.patch(`/api/v1/users/${sellerId}/role`)
Expand Down
8 changes: 6 additions & 2 deletions __test__/payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import User from "../src/sequelize/models/users";
import bcrypt from "bcryptjs";
import { Role } from "../src/sequelize/models/roles";
import { dummy } from "./prod";
import * as userServive from "../src/services/user.service"

let buyerToken: any;
let adminToken: any;
let sellerToken: any;
let sellerId: number;


describe("test stripe api payment", () => {
beforeAll(async () => {
Expand Down Expand Up @@ -79,8 +80,11 @@ describe("test stripe api payment", () => {
email: "[email protected]",
password: "password",
});

const seller = await userServive.getUserByEmail("[email protected]");
sellerToken = sellerResponse.body.token;
sellerId = sellerResponse.body.userInfo?.id;

let sellerId = seller?.id;

await request(app)
.patch(`/api/v1/users/${sellerId}/role`)
Expand Down
5 changes: 4 additions & 1 deletion __test__/product.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { placeOrder } from "../src/services/payment.service";
import Cart from "../src/sequelize/models/Cart";
import CartItem from "../src/sequelize/models/CartItem";
import OrderItem from "../src/sequelize/models/orderItems";
import * as userService from "../src/services/user.service"

const userData: any = {
name: "yvanna",
Expand Down Expand Up @@ -137,7 +138,9 @@ describe("Testing product Routes", () => {
});
expect(logDummySeller.status).toBe(200);
token = logDummySeller.body.token;
const dummySellerId = logDummySeller.body.userInfo.id;

const seller = await userService.getUserByEmail(dummySeller.email)
const dummySellerId = seller?.id;

const response = await request(app)
.patch(`/api/v1/users/${dummySellerId}/role`)
Expand Down
3 changes: 2 additions & 1 deletion __test__/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ describe("Testing user Routes", () => {
password: dummySeller.password,
});
expect(logDummySeller.status).toBe(200);
const dummySellerId = logDummySeller.body.userInfo.id;
const seller = await userServices.getUserByEmail(dummySeller.email);
const dummySellerId = seller?.id;

const response = await request(app)
.patch(`/api/v1/users/${dummySellerId}/role`)
Expand Down
1 change: 0 additions & 1 deletion src/controllers/userControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const userLogin = async (req: Request, res: Response) => {
return res.status(200).json({
status: 200,
message: "Logged in",
userInfo: userInfo,
token: accessToken
});
}
Expand Down

0 comments on commit 9b8d8e4

Please sign in to comment.