-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pull request assignee added done and tested
- Loading branch information
Showing
5 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/ActionHandler/PullRequest/PullRequestAssigneeAddedStrategy.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,45 @@ | ||
import PullRequestStrategy, {OctokitResponsePullRequest} from "./PullRequestStrategy.js"; | ||
import {Emotion} from "../../enums/Emotion.js"; | ||
import {Sentiment} from "../../enums/Sentiment.js"; | ||
import {ActionContextDTO} from "../../DTO/ActionContextDTO.js"; | ||
import {EmitterWebhookEventName} from "@octokit/webhooks/dist-types/types"; | ||
import {CommentFactory} from "../../Comment/CommentFactory.js"; | ||
import Comment from "../../Comment/Comment.js"; | ||
import {CaseSlugs} from "../../enums/CaseSlug.js"; | ||
|
||
|
||
export default class PullRequestAssigneeAddedStrategy extends PullRequestStrategy<'pull_request.assigned'>{ | ||
|
||
|
||
protected getEventName(): EmitterWebhookEventName { | ||
return "pull_request.assigned"; | ||
} | ||
|
||
|
||
protected async executePrStrategy(commentFactory:CommentFactory,_previousPRs:Array<OctokitResponsePullRequest>): Promise<Comment|null> { | ||
|
||
|
||
let tags: Array<string>=['assignment','team','support','backup','reinforce','reinforcement','aid','band','league','join','accompany','assemble','associate','enlist','guide','lead','pair','together','company','team up','stand together','unite','ally','suggest','request','plea','call','duty','demand','appeal','summon','invoke','invitation','invite','prayer','seek','hero','champion','evaluation','new','arrive','arrival','fresh','the one','savior','visitor','task','mission','goal']; | ||
let contextEmotionMatrix: Emotion.EmotionMatrix=[ | ||
{emotion:Emotion.Interest.Trust,temperature:4}, | ||
{emotion:Emotion.Interest.Friendliness,temperature:5}, | ||
{emotion:Emotion.Fear.Fright,temperature:2}, | ||
{emotion:Emotion.Fear.Anxiety,temperature:1}, | ||
{emotion:Emotion.Joy.Relief,temperature:4}, | ||
{emotion:Emotion.Joy.Thrill,temperature:2}, | ||
{emotion:Emotion.Surprise.Amazement,temperature:2}, | ||
{emotion:Emotion.Surprise.Wonder,temperature:3}, | ||
]; | ||
|
||
let caseSlug: CaseSlugs.Types=CaseSlugs.PullRequest.Assignee.Added; | ||
let sentiment :Sentiment=Sentiment.Positive; | ||
|
||
|
||
|
||
const actionContext=new ActionContextDTO(contextEmotionMatrix,sentiment,tags); | ||
const comment = commentFactory.create(caseSlug,actionContext); | ||
return comment; | ||
|
||
} | ||
|
||
} |
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
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,41 @@ | ||
import {describe, test, afterEach, vi, beforeAll} from "vitest"; | ||
import {StrategyTestSetup} from "../strategyTestSetup"; | ||
import PullRequestAssigneeAddedStrategy from "../../../src/ActionHandler/PullRequest/PullRequestAssigneeAddedStrategy"; | ||
|
||
|
||
import prAssigneeAddedPayload from '../../fixtures/events/pull_request/assignee/pull_request.assignee.added.json'; | ||
import {CaseSlugs} from "../../../src/enums/CaseSlug"; | ||
|
||
|
||
|
||
describe("Pull Request assignee added tests", () => { | ||
const strategyTestSetup = new StrategyTestSetup(); | ||
|
||
|
||
beforeAll(() => { | ||
strategyTestSetup.beforeAll(); | ||
strategyTestSetup.actionStrategyHandleSpy = vi.spyOn(PullRequestAssigneeAddedStrategy.prototype as any, 'handle'); | ||
}); | ||
|
||
afterEach(() => { | ||
strategyTestSetup.afterEach(); | ||
}); | ||
|
||
|
||
test("Creates comment", async () => { | ||
|
||
const caseSlug=CaseSlugs.PullRequest.Assignee.Added; | ||
|
||
await strategyTestSetup.probot.receive({ | ||
id: '123', | ||
name: 'pull_request', | ||
payload: prAssigneeAddedPayload as any, | ||
}); | ||
|
||
strategyTestSetup.performCommonAssertions(caseSlug); | ||
|
||
}); | ||
|
||
|
||
|
||
}); |
60 changes: 60 additions & 0 deletions
60
test/fixtures/events/pull_request/assignee/pull_request.assignee.added.json
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,60 @@ | ||
{ | ||
"action": "assigned", | ||
"pull_request": { | ||
"id": 1, | ||
"number": 555444, | ||
"state": "open", | ||
"title": "Test Pull Request", | ||
"user": { | ||
"login": "test-user", | ||
"id": 101, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/101?v=4" | ||
}, | ||
"head": { | ||
"ref": "some-branch" | ||
}, | ||
"base": { | ||
"ref": "master" | ||
}, | ||
"assignees": [ | ||
{ | ||
"login": "existing-user1", | ||
"id": 102, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/102?v=4" | ||
}, | ||
{ | ||
"login": "existing-user2", | ||
"id": 103, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/103?v=4" | ||
}, | ||
{ | ||
"login": "new-assigned-user", | ||
"id": 104, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/104?v=4" | ||
} | ||
] | ||
}, | ||
"repository": { | ||
"id": 202, | ||
"name": "test-repo", | ||
"full_name": "test-owner/test-repo", | ||
"owner": { | ||
"login": "test-owner", | ||
"id": 103, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/103?v=4" | ||
} | ||
}, | ||
"sender": { | ||
"login": "test-user", | ||
"id": 101, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/101?v=4" | ||
}, | ||
"assignee": { | ||
"login": "new-assigned-user", | ||
"id": 104, | ||
"avatar_url": "https://avatars.githubusercontent.com/u/104?v=4" | ||
}, | ||
"installation": { | ||
"id": 1 | ||
} | ||
} |