Skip to content

Commit 37dff87

Browse files
committed
bugfix-309-setup-crash: Add publicUrl method to ProjectDetail class and update related use cases to utilize it. Enhance tests to verify correct URL generation when project URL is absent.
1 parent 45a4b87 commit 37dff87

7 files changed

Lines changed: 107 additions & 6 deletions

File tree

build/cli/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48725,6 +48725,17 @@ class ProjectDetail {
4872548725
this.url = data[`url`] ?? '';
4872648726
this.number = data[`number`] ?? -1;
4872748727
}
48728+
/**
48729+
* Returns the full public URL to the project (board).
48730+
* Uses the URL from the API when present and valid; otherwise builds it from owner, type and number.
48731+
*/
48732+
get publicUrl() {
48733+
if (this.url && typeof this.url === 'string' && this.url.startsWith('https://')) {
48734+
return this.url;
48735+
}
48736+
const path = this.type === 'organization' ? 'orgs' : 'users';
48737+
return `https://github.com/${path}/${this.owner}/projects/${this.number}`;
48738+
}
4872848739
}
4872948740
exports.ProjectDetail = ProjectDetail;
4873048741

@@ -57948,7 +57959,7 @@ class CheckPriorityIssueSizeUseCase {
5794857959
success: true,
5794957960
executed: true,
5795057961
steps: [
57951-
`Priority set to \`${priorityLabel}\` in [${project.title}](https://github.com/${param.owner}/${param.repo}/projects/${project.id}).`,
57962+
`Priority set to \`${priorityLabel}\` in [${project.title}](${project.publicUrl}).`,
5795257963
],
5795357964
}));
5795457965
}
@@ -58389,7 +58400,7 @@ class MoveIssueToInProgressUseCase {
5838958400
success: true,
5839058401
executed: true,
5839158402
steps: [
58392-
`Moved issue to \`${columnName}\` in [${project.title}](https://github.com/${param.owner}/${param.repo}/projects/${project.id}).`,
58403+
`Moved issue to \`${columnName}\` in [${project.title}](${project.publicUrl}).`,
5839358404
],
5839458405
}));
5839558406
}
@@ -59141,7 +59152,7 @@ class CheckPriorityPullRequestSizeUseCase {
5914159152
success: true,
5914259153
executed: true,
5914359154
steps: [
59144-
`Priority set to \`${priorityLabel}\` in [${project.title}](https://github.com/${param.owner}/${param.repo}/projects/${project.id}).`,
59155+
`Priority set to \`${priorityLabel}\` in [${project.title}](${project.publicUrl}).`,
5914559156
],
5914659157
}));
5914759158
}

build/cli/src/data/model/project_detail.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ export declare class ProjectDetail {
66
url: string;
77
number: number;
88
constructor(data: any);
9+
/**
10+
* Returns the full public URL to the project (board).
11+
* Uses the URL from the API when present and valid; otherwise builds it from owner, type and number.
12+
*/
13+
get publicUrl(): string;
914
}

build/github_action/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43814,6 +43814,17 @@ class ProjectDetail {
4381443814
this.url = data[`url`] ?? '';
4381543815
this.number = data[`number`] ?? -1;
4381643816
}
43817+
/**
43818+
* Returns the full public URL to the project (board).
43819+
* Uses the URL from the API when present and valid; otherwise builds it from owner, type and number.
43820+
*/
43821+
get publicUrl() {
43822+
if (this.url && typeof this.url === 'string' && this.url.startsWith('https://')) {
43823+
return this.url;
43824+
}
43825+
const path = this.type === 'organization' ? 'orgs' : 'users';
43826+
return `https://github.com/${path}/${this.owner}/projects/${this.number}`;
43827+
}
4381743828
}
4381843829
exports.ProjectDetail = ProjectDetail;
4381943830

@@ -53238,7 +53249,7 @@ class CheckPriorityIssueSizeUseCase {
5323853249
success: true,
5323953250
executed: true,
5324053251
steps: [
53241-
`Priority set to \`${priorityLabel}\` in [${project.title}](https://github.com/${param.owner}/${param.repo}/projects/${project.id}).`,
53252+
`Priority set to \`${priorityLabel}\` in [${project.title}](${project.publicUrl}).`,
5324253253
],
5324353254
}));
5324453255
}
@@ -53679,7 +53690,7 @@ class MoveIssueToInProgressUseCase {
5367953690
success: true,
5368053691
executed: true,
5368153692
steps: [
53682-
`Moved issue to \`${columnName}\` in [${project.title}](https://github.com/${param.owner}/${param.repo}/projects/${project.id}).`,
53693+
`Moved issue to \`${columnName}\` in [${project.title}](${project.publicUrl}).`,
5368353694
],
5368453695
}));
5368553696
}
@@ -54431,7 +54442,7 @@ class CheckPriorityPullRequestSizeUseCase {
5443154442
success: true,
5443254443
executed: true,
5443354444
steps: [
54434-
`Priority set to \`${priorityLabel}\` in [${project.title}](https://github.com/${param.owner}/${param.repo}/projects/${project.id}).`,
54445+
`Priority set to \`${priorityLabel}\` in [${project.title}](${project.publicUrl}).`,
5443554446
],
5443654447
}));
5443754448
}

build/github_action/src/data/model/project_detail.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ export declare class ProjectDetail {
66
url: string;
77
number: number;
88
constructor(data: any);
9+
/**
10+
* Returns the full public URL to the project (board).
11+
* Uses the URL from the API when present and valid; otherwise builds it from owner, type and number.
12+
*/
13+
get publicUrl(): string;
914
}

src/usecase/steps/issue/__tests__/check_priority_issue_size_use_case.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ProjectDetail } from '../../../../data/model/project_detail';
12
import { CheckPriorityIssueSizeUseCase } from '../check_priority_issue_size_use_case';
23

34
jest.mock('../../../../utils/logger', () => ({
@@ -144,4 +145,26 @@ describe('CheckPriorityIssueSizeUseCase', () => {
144145
expect(results[0].executed).toBe(true);
145146
expect(mockSetTaskPriority).toHaveBeenCalled();
146147
});
148+
149+
it('step message contains built project URL when project has no url', async () => {
150+
mockSetTaskPriority.mockResolvedValue(true);
151+
const projectNoUrl = new ProjectDetail({
152+
id: 'p1',
153+
title: 'Board',
154+
type: 'user',
155+
owner: 'jane',
156+
url: '',
157+
number: 2,
158+
});
159+
const param = baseParam({
160+
project: { getProjects: () => [projectNoUrl] },
161+
});
162+
163+
const results = await useCase.invoke(param);
164+
165+
const builtUrl = 'https://github.com/users/jane/projects/2';
166+
expect(results[0].success).toBe(true);
167+
expect(results[0].steps?.some((s) => s.includes(builtUrl))).toBe(true);
168+
expect(results[0].steps?.some((s) => s.includes('[Board]'))).toBe(true);
169+
});
147170
});

src/usecase/steps/issue/__tests__/move_issue_to_in_progress_use_case.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ProjectDetail } from '../../../../data/model/project_detail';
12
import { MoveIssueToInProgressUseCase } from '../move_issue_to_in_progress';
23

34
jest.mock('../../../../utils/logger', () => ({
@@ -72,4 +73,26 @@ describe('MoveIssueToInProgressUseCase', () => {
7273
expect(results[0].success).toBe(false);
7374
expect(results[0].steps?.some((s) => s.includes('problem'))).toBe(true);
7475
});
76+
77+
it('step message contains built project URL when project has no url', async () => {
78+
const projectNoUrl = new ProjectDetail({
79+
id: 'p1',
80+
title: 'Backlog',
81+
type: 'organization',
82+
owner: 'acme',
83+
url: '',
84+
number: 3,
85+
});
86+
const param = baseParam({
87+
project: {
88+
getProjects: () => [projectNoUrl],
89+
getProjectColumnIssueInProgress: () => 'In Progress',
90+
},
91+
});
92+
const results = await useCase.invoke(param);
93+
const builtUrl = 'https://github.com/orgs/acme/projects/3';
94+
expect(results[0].success).toBe(true);
95+
expect(results[0].steps?.some((s) => s.includes(builtUrl))).toBe(true);
96+
expect(results[0].steps?.some((s) => s.includes('[Backlog]'))).toBe(true);
97+
});
7598
});

src/usecase/steps/pull_request/__tests__/check_priority_pull_request_size_use_case.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ProjectDetail } from '../../../../data/model/project_detail';
12
import { CheckPriorityPullRequestSizeUseCase } from '../check_priority_pull_request_size_use_case';
23

34
jest.mock('../../../../utils/logger', () => ({
@@ -158,4 +159,26 @@ describe('CheckPriorityPullRequestSizeUseCase', () => {
158159
expect(results[0].executed).toBe(true);
159160
expect(results[0].steps).toContain('Tried to check the priority of the issue, but there was a problem.');
160161
});
162+
163+
it('step message contains built project URL when project has no url', async () => {
164+
mockSetTaskPriority.mockResolvedValue(true);
165+
const projectNoUrl = new ProjectDetail({
166+
id: 'p1',
167+
title: 'Sprint',
168+
type: 'organization',
169+
owner: 'acme',
170+
url: '',
171+
number: 5,
172+
});
173+
const param = baseParam({
174+
project: { getProjects: () => [projectNoUrl] },
175+
});
176+
177+
const results = await useCase.invoke(param);
178+
179+
const builtUrl = 'https://github.com/orgs/acme/projects/5';
180+
expect(results[0].success).toBe(true);
181+
expect(results[0].steps?.some((s) => s.includes(builtUrl))).toBe(true);
182+
expect(results[0].steps?.some((s) => s.includes('[Sprint]'))).toBe(true);
183+
});
161184
});

0 commit comments

Comments
 (0)