|
| 1 | +import { MASS_FLAKY_TEST_ISSUE_LABEL } from "lib/flakyBot/aggregateDisableIssue"; |
1 | 2 | import * as flakyBotUtils from "lib/flakyBot/utils";
|
2 | 3 | import { IssueData } from "lib/types";
|
3 | 4 | import nock from "nock";
|
@@ -379,4 +380,48 @@ describe("Disable Flaky Test Bot Utils Unit Tests", () => {
|
379 | 380 | await helper([closedSmall, closedBig], closedBig, []);
|
380 | 381 | await helper([closedSmall, openSmall], openSmall, []);
|
381 | 382 | });
|
| 383 | + |
| 384 | + test("dedupFlakyTestIssues does not touch aggregate issues", async () => { |
| 385 | + const singleIssueToBeClosed: IssueData = { |
| 386 | + number: 1, |
| 387 | + title: "", |
| 388 | + html_url: "", |
| 389 | + state: "open", |
| 390 | + body: "", |
| 391 | + updated_at: "", |
| 392 | + author_association: "MEMBER", |
| 393 | + labels: [], |
| 394 | + }; |
| 395 | + |
| 396 | + const singleIssue: IssueData = { |
| 397 | + ...singleIssueToBeClosed, |
| 398 | + number: 2, |
| 399 | + }; |
| 400 | + |
| 401 | + const aggregateIssue: IssueData = { |
| 402 | + ...singleIssueToBeClosed, |
| 403 | + labels: [MASS_FLAKY_TEST_ISSUE_LABEL], |
| 404 | + }; |
| 405 | + |
| 406 | + // sanity check that it does get closed if its a single issue |
| 407 | + const scope = nock("https://api.github.com"); |
| 408 | + scope |
| 409 | + .patch(`/repos/pytorch/pytorch/issues/${singleIssueToBeClosed.number}`) |
| 410 | + .reply(200); |
| 411 | + expect( |
| 412 | + await flakyBot.dedupFlakyTestIssues(octokit, [ |
| 413 | + singleIssueToBeClosed, |
| 414 | + singleIssue, |
| 415 | + ]) |
| 416 | + ).toEqual([singleIssue]); |
| 417 | + scope.done(); |
| 418 | + |
| 419 | + // Should not make any API calls either |
| 420 | + expect( |
| 421 | + await flakyBot.dedupFlakyTestIssues(octokit, [ |
| 422 | + aggregateIssue, |
| 423 | + singleIssue, |
| 424 | + ]) |
| 425 | + ).toEqual([singleIssue, aggregateIssue]); |
| 426 | + }); |
382 | 427 | });
|
0 commit comments