github-issue-tower-defence-management 1.146.17 → 1.146.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>TDPM Console</title>
7
- <script type="module" crossorigin src="/assets/index-Cuitqkoc.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-Dj5NvMDZ.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-CDLgAfIB.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-issue-tower-defence-management",
3
- "version": "1.146.17",
3
+ "version": "1.146.18",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {
@@ -266,6 +266,33 @@ describe('consoleOperationApi', () => {
266
266
  expectRecordedAcrossTabs('PVTI_unnecessary');
267
267
  });
268
268
 
269
+ it('tells the linked issue that the unnecessary pull request must not be created again', async () => {
270
+ issueRepository.getIssueByUrl.mockResolvedValue({
271
+ ...issue,
272
+ url: 'https://github.com/o/r/issues/9',
273
+ org: 'o',
274
+ repo: 'r',
275
+ number: 9,
276
+ labels: ['bug'],
277
+ });
278
+ const issueCommentBody =
279
+ 'The pull request for this issue was unnecessary and has been closed: https://github.com/o/r/pull/3\n\nDo not create it again.';
280
+ const response = await handleReview(context, {
281
+ pjcode: 'acme',
282
+ action: 'unnecessary',
283
+ prUrl: 'https://github.com/o/r/pull/3',
284
+ issueUrl: 'https://github.com/o/r/issues/9',
285
+ projectItemId: 'PVTI_unnecessary_issue_comment',
286
+ commentBody: 'This pull request is unnecessary.',
287
+ issueCommentBody,
288
+ });
289
+ expect(response.statusCode).toBe(200);
290
+ expect(issueRepository.createCommentByUrl).toHaveBeenCalledWith(
291
+ 'https://github.com/o/r/issues/9',
292
+ issueCommentBody,
293
+ );
294
+ });
295
+
269
296
  it('keeps the chore label once when the unnecessary item already carries it', async () => {
270
297
  issueRepository.getIssueByUrl.mockResolvedValue({
271
298
  ...issue,
@@ -260,6 +260,11 @@ export const handleReview = async (
260
260
  .resolveIssueRepository(prUrl)
261
261
  .createCommentByUrl(prUrl, body.commentBody);
262
262
  }
263
+ if (isNonEmptyString(body.issueCommentBody)) {
264
+ await context
265
+ .resolveIssueRepository(issueUrl)
266
+ .createCommentByUrl(issueUrl, body.issueCommentBody);
267
+ }
263
268
  const labelFailure = await addChoreLabel(
264
269
  context.resolveIssueRepository(issueUrl),
265
270
  issueUrl,
@@ -89,6 +89,21 @@ describe('useConsoleOperations', () => {
89
89
  });
90
90
  });
91
91
 
92
+ it('posts an unnecessary review carrying the comment the linked issue receives', async () => {
93
+ const fetchMock = captureFetch();
94
+ const { result } = setup();
95
+ await act(async () => {
96
+ await result.current.operations.reviewPullRequest(
97
+ prItem,
98
+ prItem.url,
99
+ 'unnecessary',
100
+ );
101
+ });
102
+ expect(lastBody(fetchMock)).toMatchObject({
103
+ issueCommentBody: `The pull request for this issue was unnecessary and has been closed: ${prItem.url}\n\nDo not create it again.`,
104
+ });
105
+ });
106
+
92
107
  it('posts an approve review and marks the item done in the overlay', async () => {
93
108
  captureFetch();
94
109
  const { result } = setup();
@@ -12,6 +12,7 @@ import {
12
12
  } from '../lib/consoleApi';
13
13
  import {
14
14
  buildRequestChangesBody,
15
+ buildUnnecessaryIssueCommentBody,
15
16
  type ConsoleCloseAction,
16
17
  type ConsoleNextActionDateAction,
17
18
  type ConsolePendingReviewComment,
@@ -119,6 +120,7 @@ const reviewRequest = (
119
120
  projectItemId: item.projectItemId,
120
121
  issueUrl: item.url,
121
122
  commentBody: UNNECESSARY_COMMENT_BODY,
123
+ issueCommentBody: buildUnnecessaryIssueCommentBody(prUrl),
122
124
  };
123
125
  };
124
126
 
@@ -25,6 +25,7 @@ export type ConsoleReviewRequest = {
25
25
  projectItemId: string;
26
26
  issueUrl?: string;
27
27
  commentBody?: string;
28
+ issueCommentBody?: string;
28
29
  changedFilePath?: string;
29
30
  line?: number;
30
31
  side?: ConsoleReviewCommentSide;
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  buildRequestChangesBody,
3
+ buildUnnecessaryIssueCommentBody,
3
4
  IN_TMUX_BY_HUMAN_NAME,
4
5
  isManualTriageTab,
5
6
  STATUS_BUTTON_NAMES,
@@ -16,6 +17,14 @@ describe('operation constants', () => {
16
17
  expect(UNNECESSARY_COMMENT_BODY).toBe('This pull request is unnecessary.');
17
18
  });
18
19
 
20
+ it('builds an issue comment body that names the closed pull request and forbids creating it again', () => {
21
+ expect(
22
+ buildUnnecessaryIssueCommentBody('https://github.com/o/r/pull/1'),
23
+ ).toBe(
24
+ 'The pull request for this issue was unnecessary and has been closed: https://github.com/o/r/pull/1\n\nDo not create it again.',
25
+ );
26
+ });
27
+
19
28
  it('lists the status buttons left to right', () => {
20
29
  expect(STATUS_BUTTON_NAMES).toEqual([
21
30
  'In Tmux by agent',
@@ -4,6 +4,9 @@ import type { ConsoleFieldOption, ConsoleTabName } from './types';
4
4
  export const TOTALLY_WRONG_COMMENT_BODY = 'totally wrong';
5
5
  export const UNNECESSARY_COMMENT_BODY = 'This pull request is unnecessary.';
6
6
 
7
+ export const buildUnnecessaryIssueCommentBody = (prUrl: string): string =>
8
+ `The pull request for this issue was unnecessary and has been closed: ${prUrl}\n\nDo not create it again.`;
9
+
7
10
  export type ConsolePendingReviewComment = {
8
11
  path: string;
9
12
  line: number;