-
Notifications
You must be signed in to change notification settings - Fork 39
Add unit tests for issues and PRs #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bipplane
wants to merge
10
commits into
CATcher-org:main
Choose a base branch
from
bipplane:issue-model-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2b580e0
Add mock issue and pull request data for testing
bipplane 64f6458
Fix: Update headRepository structure
bipplane db5e1ac
Update test constants
bipplane 2e41654
Refactor createPhaseBugReportingIssue to createFromGithubIssue
bipplane cc7678d
Update default string for WATcher logic
bipplane 9d25f22
Default author to 'ghost'
bipplane 3513b8d
Add pull request unit tests
bipplane d5c9004
Add createFromGithubIssue unit tests
bipplane 41ebf9c
Fix lint issues
bipplane 9b748e5
Refine docs and tests
bipplane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -10,12 +10,12 @@ import { | |
|
|
||
| describe('issuer-sorter', () => { | ||
| describe('applySort()', () => { | ||
| const dummyIssue: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION); | ||
| const otherDummyIssue: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_ASSIGNEES); | ||
| const dummyIssue: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION); | ||
| const otherDummyIssue: Issue = Issue.createFromGithubIssue(ISSUE_WITH_ASSIGNEES); | ||
| const issuesList: Issue[] = [dummyIssue, otherDummyIssue]; | ||
|
|
||
| const issueUpdatedEarlier: Issue = Issue.createPhaseBugReportingIssue(ISSUE_UPDATED_EARLIER); | ||
| const issueUpdatedLater: Issue = Issue.createPhaseBugReportingIssue(ISSUE_UPDATED_LATER); | ||
| const issueUpdatedEarlier: Issue = Issue.createFromGithubIssue(ISSUE_UPDATED_EARLIER); | ||
| const issueUpdatedLater: Issue = Issue.createFromGithubIssue(ISSUE_UPDATED_LATER); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, the naming might cause merge conflicts with #499 . |
||
| const issuesWithDifferentUpdatedDate: Issue[] = [issueUpdatedEarlier, issueUpdatedLater]; | ||
|
|
||
| const matSort: MatSort = new MatSort(); | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,69 @@ | ||
| import { IssueState } from '../../graphql/graphql-types'; | ||
| import { GithubIssue } from '../../src/app/core/models/github/github-issue.model'; | ||
| import { ReviewDecision } from '../../src/app/core/models/issue.model'; | ||
| import { PullrequestReviewState } from '../../src/app/core/models/pullrequest-review.model'; | ||
| import { USER_ANUBHAV, USER_JUNWEI } from './data.constants'; | ||
| import { MILESTONE_ONE, USER_ANUBHAV_DETAILS } from './githubissue.constants'; | ||
| import { GITHUB_LABEL_FUNCTIONALITY_BUG, GITHUB_LABEL_TEAM_LABEL } from './githublabel.constants'; | ||
|
|
||
| export const MOCK_PR_DATA = new GithubIssue({ | ||
| id: '123456789', | ||
| number: 101, | ||
| assignees: [USER_ANUBHAV_DETAILS], | ||
| body: 'This is a mock PR description', | ||
| created_at: '2025-01-15T10:30:00Z', | ||
| updated_at: '2025-01-16T14:45:00Z', | ||
| closed_at: '', | ||
| labels: [GITHUB_LABEL_TEAM_LABEL, GITHUB_LABEL_FUNCTIONALITY_BUG], | ||
| state: IssueState.Open, | ||
| stateReason: null, | ||
| title: 'Add new feature', | ||
| url: 'https://github.com/CATcher-org/WATcher-test/pulls/101', | ||
| user: { login: 'testuser' }, | ||
| milestone: MILESTONE_ONE, | ||
| comments: [], | ||
| issueOrPr: 'PullRequest', | ||
| isDraft: false, | ||
| headRepository: { | ||
| nameWithOwner: 'testuser/WATcher-test' | ||
| }, | ||
| reviewDecision: ReviewDecision.REVIEW_REQUIRED, | ||
| reviews: [ | ||
| { | ||
| state: PullrequestReviewState.APPROVED, | ||
| author: USER_JUNWEI | ||
| } | ||
| ] | ||
| }); | ||
|
|
||
| export const MOCK_DRAFT_PR_DATA = new GithubIssue({ | ||
| ...MOCK_PR_DATA, | ||
| id: '123456790', | ||
| number: 102, | ||
| title: 'Draft feature', | ||
| url: 'https://github.com/CATcher-org/WATcher-test/pulls/102', | ||
| isDraft: true, | ||
| reviewDecision: null, | ||
| reviews: [] | ||
| }); | ||
|
|
||
| export const MOCK_MERGED_PR_DATA = new GithubIssue({ | ||
| ...MOCK_PR_DATA, | ||
| id: '123456791', | ||
| number: 103, | ||
| title: 'Merged pull request', | ||
| url: 'https://github.com/CATcher-org/WATcher-test/pulls/103', | ||
| state: IssueState.Closed, | ||
| closed_at: '2025-01-20T16:00:00Z', | ||
| reviewDecision: ReviewDecision.APPROVED, | ||
| reviews: [ | ||
| { | ||
| state: PullrequestReviewState.APPROVED, | ||
| author: USER_ANUBHAV | ||
| }, | ||
| { | ||
| state: PullrequestReviewState.APPROVED, | ||
| author: USER_JUNWEI | ||
| } | ||
| ] | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the effort to rename this method and make it more independent of CATcher. Take note that this may result in merge conflict with PR #499 .