chore: added changes to creating a history in resolvers and service method
This commit is contained in:
parent
a5a14f6c76
commit
ebf236b387
3 changed files with 15 additions and 15 deletions
|
|
@ -22,7 +22,7 @@ export class UserHistoryResolver {
|
|||
description: 'Adds a new REST/GQL request to user history',
|
||||
})
|
||||
@UseGuards(GqlAuthGuard)
|
||||
async addRequestToHistory(
|
||||
async createUserHistory(
|
||||
@GqlUser() user: User,
|
||||
@Args({
|
||||
name: 'reqData',
|
||||
|
|
@ -40,7 +40,7 @@ export class UserHistoryResolver {
|
|||
})
|
||||
reqType: string,
|
||||
): Promise<UserHistory> {
|
||||
const createdHistory = await this.userHistoryService.addRequestToHistory(
|
||||
const createdHistory = await this.userHistoryService.createUserHistory(
|
||||
user.uid,
|
||||
reqData,
|
||||
resMetadata,
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ describe('UserHistoryService', () => {
|
|||
).toEqual(userHistory);
|
||||
});
|
||||
});
|
||||
describe('addRequestToHistory', () => {
|
||||
test('Should resolve right and add a REST request to users history and return a `UserHistory` object', async () => {
|
||||
describe('createUserHistory', () => {
|
||||
test('Should resolve right and create a REST request to users history and return a `UserHistory` object', async () => {
|
||||
userHistoryService.validateReqType('REST');
|
||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||
userUid: 'abc',
|
||||
|
|
@ -160,7 +160,7 @@ describe('UserHistoryService', () => {
|
|||
};
|
||||
|
||||
return expect(
|
||||
await userHistoryService.addRequestToHistory(
|
||||
await userHistoryService.createUserHistory(
|
||||
'abc',
|
||||
JSON.stringify([{}]),
|
||||
JSON.stringify([{}]),
|
||||
|
|
@ -168,7 +168,7 @@ describe('UserHistoryService', () => {
|
|||
),
|
||||
).toEqualRight(userHistory);
|
||||
});
|
||||
test('Should resolve right and add a GQL request to users history and return a `UserHistory` object', async () => {
|
||||
test('Should resolve right and create a GQL request to users history and return a `UserHistory` object', async () => {
|
||||
userHistoryService.validateReqType('GQL');
|
||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||
userUid: 'abc',
|
||||
|
|
@ -191,7 +191,7 @@ describe('UserHistoryService', () => {
|
|||
};
|
||||
|
||||
return expect(
|
||||
await userHistoryService.addRequestToHistory(
|
||||
await userHistoryService.createUserHistory(
|
||||
'abc',
|
||||
JSON.stringify([{}]),
|
||||
JSON.stringify([{}]),
|
||||
|
|
@ -202,7 +202,7 @@ describe('UserHistoryService', () => {
|
|||
test('Should resolve left when invalid ReqType is passed', async () => {
|
||||
userHistoryService.validateReqType('INVALID');
|
||||
return expect(
|
||||
await userHistoryService.addRequestToHistory(
|
||||
await userHistoryService.createUserHistory(
|
||||
'abc',
|
||||
JSON.stringify([{}]),
|
||||
JSON.stringify([{}]),
|
||||
|
|
@ -210,7 +210,7 @@ describe('UserHistoryService', () => {
|
|||
),
|
||||
).toEqualLeft(USER_HISTORY_INVALID_REQ_TYPE);
|
||||
});
|
||||
test('Should add a GQL request to users history and publish a created subscription', async () => {
|
||||
test('Should create a GQL request to users history and publish a created subscription', async () => {
|
||||
userHistoryService.validateReqType('GQL');
|
||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||
userUid: 'abc',
|
||||
|
|
@ -232,7 +232,7 @@ describe('UserHistoryService', () => {
|
|||
isStarred: false,
|
||||
};
|
||||
|
||||
await userHistoryService.addRequestToHistory(
|
||||
await userHistoryService.createUserHistory(
|
||||
'abc',
|
||||
JSON.stringify([{}]),
|
||||
JSON.stringify([{}]),
|
||||
|
|
@ -244,7 +244,7 @@ describe('UserHistoryService', () => {
|
|||
userHistory,
|
||||
);
|
||||
});
|
||||
test('Should add a REST request to users history and publish a created subscription', async () => {
|
||||
test('Should create a REST request to users history and publish a created subscription', async () => {
|
||||
userHistoryService.validateReqType('REST');
|
||||
mockPrisma.userHistory.create.mockResolvedValueOnce({
|
||||
userUid: 'abc',
|
||||
|
|
@ -266,7 +266,7 @@ describe('UserHistoryService', () => {
|
|||
isStarred: false,
|
||||
};
|
||||
|
||||
await userHistoryService.addRequestToHistory(
|
||||
await userHistoryService.createUserHistory(
|
||||
'abc',
|
||||
JSON.stringify([{}]),
|
||||
JSON.stringify([{}]),
|
||||
|
|
|
|||
|
|
@ -46,14 +46,14 @@ export class UserHistoryService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a request to users history.
|
||||
* Creates a user history.
|
||||
* @param uid Users uid
|
||||
* @param reqData the request data
|
||||
* @param resMetadata the response metadata
|
||||
* @param reqType request Type to fetch i.e. GraphQL or REST
|
||||
* @returns a `UserHistory` object
|
||||
*/
|
||||
async addRequestToHistory(
|
||||
async createUserHistory(
|
||||
uid: string,
|
||||
reqData: string,
|
||||
resMetadata: string,
|
||||
|
|
@ -92,7 +92,7 @@ export class UserHistoryService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stars or unstars a request in the history
|
||||
* Toggles star status of a user history
|
||||
* @param uid Users uid
|
||||
* @param id id of the request in the history
|
||||
* @returns an Either of updated `UserHistory` or Error
|
||||
|
|
|
|||
Loading…
Reference in a new issue