-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sources): add call to feedback endpoint
[CTCORE-10099]
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import API from '../../../APICore.js'; | ||
import {FeedbackConsumerType} from '../../Enums.js'; | ||
import Resource from '../../Resource.js'; | ||
import {FeedbackPayload} from './SourcesFeedbackInterfaces.js'; | ||
|
||
export default class SourcesFeedback extends Resource { | ||
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/sources/feedback`; | ||
|
||
sendFeedback(feedbackConsumerType: FeedbackConsumerType, feedbackPayload: FeedbackPayload) { | ||
return this.api.post(this.buildPath(SourcesFeedback.baseUrl, {feedbackConsumerType}), feedbackPayload); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/resources/Sources/SourcesFeedback/SourcesFeedbackInterfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface FeedbackPayload { | ||
message: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './SourcesFeedback.js'; | ||
export * from './SourcesFeedbackInterfaces.js'; |
31 changes: 31 additions & 0 deletions
31
src/resources/Sources/SourcesFeedback/tests/SourcesFeedback.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import API from '../../../../APICore.js'; | ||
import {FeedbackConsumerType} from '../../../Enums.js'; | ||
import SourcesFeedback from '../SourcesFeedback.js'; | ||
import {FeedbackPayload} from '../SourcesFeedbackInterfaces.js'; | ||
|
||
jest.mock('../../../../APICore.js'); | ||
|
||
const APIMock: jest.Mock<API> = API as any; | ||
|
||
describe('SourcesFeedback', () => { | ||
let sourceFeedback: SourcesFeedback; | ||
const api = new APIMock() as jest.Mocked<API>; | ||
const serverlessApi = new APIMock() as jest.Mocked<API>; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
sourceFeedback = new SourcesFeedback(api, serverlessApi); | ||
}); | ||
|
||
describe('sendFeedback', () => { | ||
it('should make a POST call to the specific feedback url', () => { | ||
const feedback = {message: 'allo!'} as FeedbackPayload; | ||
sourceFeedback.sendFeedback(FeedbackConsumerType.SOURCE_MANAGEMENT_IMPROVEMENTS, feedback); | ||
expect(api.post).toHaveBeenCalledTimes(1); | ||
expect(api.post).toHaveBeenCalledWith( | ||
`${SourcesFeedback.baseUrl}?feedbackConsumerType=SOURCE_MANAGEMENT_IMPROVEMENTS`, | ||
feedback, | ||
); | ||
}); | ||
}); | ||
}); |