Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/core/models/issue.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class Issue {
* Processes and cleans a raw issue description obtained from user input.
*/
static updateDescription(description: string): string {
const defaultString = 'No details provided by bug reporter.';
const defaultString = '';
return Issue.orDefaultString(Issue.formatText(description), defaultString);
}

Expand Down Expand Up @@ -95,7 +95,7 @@ export class Issue {
this.state = githubIssue.state;
this.stateReason = githubIssue.stateReason;
this.issueOrPr = githubIssue.issueOrPr;
this.author = githubIssue.user.login;
this.author = githubIssue.user?.login || 'ghost';
// this.githubIssue = githubIssue;
this.isDraft = githubIssue.isDraft;
this.reviewDecision = githubIssue.reviewDecision;
Expand All @@ -112,7 +112,7 @@ export class Issue {
this.reviews = githubIssue.reviews?.map((review) => new PullrequestReview(review));
}

public static createPhaseBugReportingIssue(githubIssue: GithubIssue): Issue {
public static createFromGithubIssue(githubIssue: GithubIssue): Issue {
Copy link
Copy Markdown
Contributor

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 .

return new Issue(githubIssue);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/issue.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class IssueService {
private createIssueModel(githubIssue: GithubIssue): Issue {
switch (this.viewService.currentView) {
case View.issuesViewer:
return Issue.createPhaseBugReportingIssue(githubIssue);
return Issue.createFromGithubIssue(githubIssue);
default:
return;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/app/shared/issue-tables/issue-paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ describe('issue-paginator', () => {
describe('paginateData()', () => {
let dataSet_7: Issue[];
let paginator: MatPaginator;
const mediumSeverityIssueWithResponse: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION);
const mediumSeverityIssueWithAssigneee: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_ASSIGNEES);
const lowSeverityFeatureFlawIssue: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION_LOW_SEVERITY);
const highSeverityDocumentationBugIssue: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION_HIGH_SEVERITY);
const mediumSeverityIssueWithResponse: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION);
const mediumSeverityIssueWithAssigneee: Issue = Issue.createFromGithubIssue(ISSUE_WITH_ASSIGNEES);
const lowSeverityFeatureFlawIssue: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION_LOW_SEVERITY);
const highSeverityDocumentationBugIssue: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION_HIGH_SEVERITY);

beforeEach(() => {
dataSet_7 = [
Expand Down
8 changes: 4 additions & 4 deletions tests/app/shared/issue-tables/issue-sorter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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();
Expand Down
8 changes: 4 additions & 4 deletions tests/app/shared/issue-tables/search-filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { GITHUB_LABEL_FEATURE_FLAW } from '../../../constants/githublabel.consta
describe('search-filter', () => {
describe('applySearchFilter()', () => {
let searchKey: string;
const mediumSeverityIssueWithResponse: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION);
const mediumSeverityIssueWithAssigneee: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_ASSIGNEES);
const lowSeverityFeatureFlawIssue: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION_LOW_SEVERITY);
const highSeverityDocumentationBugIssue: Issue = Issue.createPhaseBugReportingIssue(ISSUE_WITH_EMPTY_DESCRIPTION_HIGH_SEVERITY);
const mediumSeverityIssueWithResponse: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION);
const mediumSeverityIssueWithAssigneee: Issue = Issue.createFromGithubIssue(ISSUE_WITH_ASSIGNEES);
const lowSeverityFeatureFlawIssue: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION_LOW_SEVERITY);
const highSeverityDocumentationBugIssue: Issue = Issue.createFromGithubIssue(ISSUE_WITH_EMPTY_DESCRIPTION_HIGH_SEVERITY);

const issuesList: Issue[] = [
mediumSeverityIssueWithResponse,
Expand Down
22 changes: 21 additions & 1 deletion tests/constants/githubissue.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const randomISODate: (startDate?: Date, endDate?: Date) => string = (
return new Date(startDate.getTime() + Math.random() * (startDate.getTime() - endDate.getTime())).toISOString();
};

const USER_ANUBHAV_DETAILS = {
export const USER_ANUBHAV_DETAILS = {
login: USER_ANUBHAV.loginId
};

Expand Down Expand Up @@ -198,6 +198,26 @@ export const ISSUE_WITH_ASSIGNEES = new GithubIssue({
isDraft: false
});

export const ISSUE_WITH_MOCK_DATA = new GithubIssue({
id: '987654321',
number: 201,
assignees: [],
body: 'This is a mock issue description',
created_at: '2025-01-10T09:00:00Z',
updated_at: '2025-01-11T10:30:00Z',
closed_at: '',
labels: [GITHUB_LABEL_TEAM_LABEL],
state: IssueState.Open,
stateReason: null,
title: 'Bug report example',
url: 'https://github.com/CATcher-org/WATcher-test/issues/201',
user: { login: 'bugReporter' },
milestone: MILESTONE_ONE,
comments: [],
issueOrPr: 'Issue',
isDraft: false
});

export const generateIssueWithRandomData: () => GithubIssue = () => {
const created_and_updated_date: string = randomISODate();
const issueNumber: number = randomIssueNumber();
Expand Down
69 changes: 69 additions & 0 deletions tests/constants/githubpullrequest.constants.ts
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
}
]
});
Loading
Loading