Skip to content

Commit c0416b6

Browse files
committed
Fix tests
1 parent cb5ec77 commit c0416b6

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

src/reporter/github/index.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ describe('GitHub', function () {
1010

1111
let MANAGED_LABELS;
1212
let github;
13-
const EXISTING_OPEN_ISSUE = { number: 1, title: 'Opened issue', description: 'Issue description', state: GitHub.ISSUE_STATE_OPEN, labels: [{ name: 'page access restriction' }, { name: 'server error' }] };
14-
const EXISTING_CLOSED_ISSUE = { number: 2, title: 'Closed issue', description: 'Issue description', state: GitHub.ISSUE_STATE_CLOSED, labels: [{ name: 'empty content' }] };
13+
const EXISTING_OPEN_ISSUE = { number: 1, title: 'Opened issue', description: 'Issue description', state: GitHub.ISSUE_STATE_OPEN, labels: [{ name: LABELS.HTTP_403.name }] };
14+
const EXISTING_CLOSED_ISSUE = { number: 2, title: 'Closed issue', description: 'Issue description', state: GitHub.ISSUE_STATE_CLOSED, labels: [{ name: LABELS.EMPTY_CONTENT.name }] };
1515

1616
before(async () => {
1717
MANAGED_LABELS = Object.values(LABELS);
@@ -368,7 +368,7 @@ describe('GitHub', function () {
368368
const ISSUE_TO_CREATE = {
369369
title: 'New Issue',
370370
description: 'Description of the new issue',
371-
labels: ['empty response'],
371+
labels: [LABELS.EMPTY_RESPONSE.name],
372372
};
373373

374374
before(async () => {
@@ -399,14 +399,14 @@ describe('GitHub', function () {
399399

400400
before(async () => {
401401
updateIssueScope = nock('https://api.github.com')
402-
.patch(`/repos/owner/repo/issues/${EXISTING_CLOSED_ISSUE.number}`, { state: GitHub.ISSUE_STATE_OPEN, labels: ['page access restriction'] })
402+
.patch(`/repos/owner/repo/issues/${EXISTING_CLOSED_ISSUE.number}`, { state: GitHub.ISSUE_STATE_OPEN, labels: [LABELS.HTTP_403.name] })
403403
.reply(200);
404404

405405
addCommentScope = nock('https://api.github.com')
406406
.post(`/repos/owner/repo/issues/${EXISTING_CLOSED_ISSUE.number}/comments`, { body: EXISTING_CLOSED_ISSUE.description })
407407
.reply(200);
408408

409-
await github.createOrUpdateIssue({ title: EXISTING_CLOSED_ISSUE.title, description: EXISTING_CLOSED_ISSUE.description, labels: ['page access restriction'] });
409+
await github.createOrUpdateIssue({ title: EXISTING_CLOSED_ISSUE.title, description: EXISTING_CLOSED_ISSUE.description, labels: [LABELS.HTTP_403.name] });
410410
});
411411

412412
after(() => {
@@ -430,14 +430,14 @@ describe('GitHub', function () {
430430

431431
before(async () => {
432432
updateIssueScope = nock('https://api.github.com')
433-
.patch(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}`, { state: GitHub.ISSUE_STATE_OPEN, labels: ['empty content'] })
433+
.patch(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}`, { state: GitHub.ISSUE_STATE_OPEN, labels: [LABELS.EMPTY_CONTENT.name] })
434434
.reply(200);
435435

436436
addCommentScope = nock('https://api.github.com')
437437
.post(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}/comments`, { body: EXISTING_OPEN_ISSUE.description })
438438
.reply(200);
439439

440-
await github.createOrUpdateIssue({ title: EXISTING_OPEN_ISSUE.title, description: EXISTING_OPEN_ISSUE.description, labels: ['empty content'] });
440+
await github.createOrUpdateIssue({ title: EXISTING_OPEN_ISSUE.title, description: EXISTING_OPEN_ISSUE.description, labels: [LABELS.EMPTY_CONTENT.name] });
441441
});
442442

443443
after(() => {
@@ -467,7 +467,7 @@ describe('GitHub', function () {
467467
.post(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}/comments`)
468468
.reply(200);
469469

470-
await github.createOrUpdateIssue({ title: EXISTING_OPEN_ISSUE.title, description: EXISTING_OPEN_ISSUE.description, labels: [ 'page access restriction', 'server error' ] });
470+
await github.createOrUpdateIssue({ title: EXISTING_OPEN_ISSUE.title, description: EXISTING_OPEN_ISSUE.description, labels: [LABELS.HTTP_403.name] });
471471
});
472472

473473
after(() => {
@@ -491,14 +491,14 @@ describe('GitHub', function () {
491491

492492
before(async () => {
493493
updateIssueScope = nock('https://api.github.com')
494-
.patch(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}`, { state: GitHub.ISSUE_STATE_OPEN, labels: [ 'page access restriction', 'empty content' ] })
494+
.patch(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}`, { state: GitHub.ISSUE_STATE_OPEN, labels: [ LABELS.HTTP_403.name, LABELS.NEEDS_INTERVENTION.name ] })
495495
.reply(200);
496496

497497
addCommentScope = nock('https://api.github.com')
498498
.post(`/repos/owner/repo/issues/${EXISTING_OPEN_ISSUE.number}/comments`, { body: EXISTING_OPEN_ISSUE.description })
499499
.reply(200);
500500

501-
await github.createOrUpdateIssue({ title: EXISTING_OPEN_ISSUE.title, description: EXISTING_OPEN_ISSUE.description, labels: [ 'page access restriction', 'empty content' ] });
501+
await github.createOrUpdateIssue({ title: EXISTING_OPEN_ISSUE.title, description: EXISTING_OPEN_ISSUE.description, labels: [ LABELS.HTTP_403.name, LABELS.NEEDS_INTERVENTION.name ] });
502502
});
503503

504504
after(() => {

src/reporter/gitlab/index.test.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,16 @@ describe('GitLab', function () {
118118
nock(gitlab.apiBaseURL)
119119
.persist()
120120
.get(`/projects/${PROJECT_ID}/labels?with_counts=true`)
121-
.reply(200, [ ...MANAGED_LABELS.slice(0, -2), ...testLabels ].map(label => ({
122-
...label,
123-
description: `${label.description} ${MANAGED_BY_OTA_MARKER}`,
124-
})));
121+
.reply(200, [
122+
...MANAGED_LABELS.slice(0, -2).map(label => ({
123+
...label,
124+
description: `${label.description} ${MANAGED_BY_OTA_MARKER}`,
125+
})),
126+
...testLabels.map(label => ({
127+
...label,
128+
description: `${label.description} ${MANAGED_BY_OTA_MARKER}`,
129+
})),
130+
]);
125131

126132
for (const label of originalTestLabels) {
127133
updateScopes.push(nock(gitlab.apiBaseURL)
@@ -499,7 +505,7 @@ describe('GitLab', function () {
499505
const ISSUE_TO_CREATE = {
500506
title: 'New Issue',
501507
description: 'Description of the new issue',
502-
labels: ['empty response'],
508+
labels: [LABELS.EMPTY_RESPONSE.name],
503509
};
504510

505511
before(async () => {
@@ -530,7 +536,7 @@ describe('GitLab', function () {
530536
const ISSUE = {
531537
title: 'Existing Issue',
532538
description: 'New comment',
533-
labels: ['page access restriction'],
539+
labels: [LABELS.HTTP_403.name],
534540
};
535541

536542
context('when issue is closed', () => {
@@ -542,15 +548,15 @@ describe('GitLab', function () {
542548
iid: 123,
543549
title: ISSUE.title,
544550
description: ISSUE.description,
545-
labels: [{ name: 'empty content' }],
551+
labels: [{ name: LABELS.EMPTY_CONTENT.name }],
546552
state: GitLab.ISSUE_STATE_CLOSED,
547553
};
548554

549555
const EXPECTED_REQUEST_BODY = { state_event: 'reopen' };
550556
const responseIssuereopened = { iid: 123 };
551557
const responseSetLabels = {
552558
iid: 123,
553-
labels: ['page access restriction'],
559+
labels: [LABELS.HTTP_403.name],
554560
};
555561
const responseAddcomment = { iid: 123, id: 23, body: ISSUE.description };
556562
const { iid } = GITLAB_RESPONSE_FOR_EXISTING_ISSUE;
@@ -565,7 +571,7 @@ describe('GitLab', function () {
565571
.reply(200, responseIssuereopened);
566572

567573
setIssueLabelsScope = nock(gitlab.apiBaseURL)
568-
.put(`/projects/${PROJECT_ID}/issues/${iid}`, { labels: ['page access restriction'] })
574+
.put(`/projects/${PROJECT_ID}/issues/${iid}`, { labels: [LABELS.HTTP_403.name] })
569575
.reply(200, responseSetLabels);
570576

571577
addCommentScope = nock(gitlab.apiBaseURL)
@@ -598,15 +604,15 @@ describe('GitLab', function () {
598604
iid: 123,
599605
title: ISSUE.title,
600606
description: ISSUE.description,
601-
labels: [{ name: 'empty content' }],
607+
labels: [{ name: LABELS.EMPTY_CONTENT.name }],
602608
state: GitLab.ISSUE_STATE_OPEN,
603609
};
604610

605611
const EXPECTED_REQUEST_BODY = { state_event: 'reopen' };
606612
const responseIssuereopened = { iid: 123 };
607613
const responseSetLabels = {
608614
iid: 123,
609-
labels: ['page access restriction'],
615+
labels: [LABELS.HTTP_403.name],
610616
};
611617
const responseAddcomment = { iid: 123, id: 23, body: ISSUE.description };
612618
const { iid } = GITLAB_RESPONSE_FOR_EXISTING_ISSUE;
@@ -621,7 +627,7 @@ describe('GitLab', function () {
621627
.reply(200, responseIssuereopened);
622628

623629
setIssueLabelsScope = nock(gitlab.apiBaseURL)
624-
.put(`/projects/${PROJECT_ID}/issues/${iid}`, { labels: ['page access restriction'] })
630+
.put(`/projects/${PROJECT_ID}/issues/${iid}`, { labels: [LABELS.HTTP_403.name] })
625631
.reply(200, responseSetLabels);
626632

627633
addCommentScope = nock(gitlab.apiBaseURL)
@@ -653,7 +659,7 @@ describe('GitLab', function () {
653659
iid: 123,
654660
title: ISSUE.title,
655661
description: ISSUE.description,
656-
labels: [{ name: 'page access restriction' }, { name: 'server error' }],
662+
labels: [{ name: LABELS.HTTP_403.name }],
657663
state: GitLab.ISSUE_STATE_OPEN,
658664
};
659665

@@ -679,7 +685,7 @@ describe('GitLab', function () {
679685
await gitlab.createOrUpdateIssue({
680686
title: ISSUE.title,
681687
description: ISSUE.description,
682-
labels: [ 'page access restriction', 'server error' ],
688+
labels: [LABELS.HTTP_403.name],
683689
});
684690
});
685691

@@ -709,15 +715,15 @@ describe('GitLab', function () {
709715
iid: 123,
710716
title: ISSUE.title,
711717
description: ISSUE.description,
712-
labels: [{ name: 'page access restriction' }],
718+
labels: [{ name: LABELS.HTTP_403.name }],
713719
state: GitLab.ISSUE_STATE_OPEN,
714720
};
715721

716722
const EXPECTED_REQUEST_BODY = { state_event: 'reopen' };
717723
const responseIssuereopened = { iid: 123 };
718724
const responseSetLabels = {
719725
iid: 123,
720-
labels: [ 'page access restriction', 'empty content' ],
726+
labels: [ LABELS.HTTP_403.name, LABELS.EMPTY_CONTENT.name ],
721727
};
722728
const responseAddcomment = { iid: 123, id: 23, body: ISSUE.description };
723729
const { iid } = GITLAB_RESPONSE_FOR_EXISTING_ISSUE;
@@ -732,7 +738,7 @@ describe('GitLab', function () {
732738
.reply(200, responseIssuereopened);
733739

734740
setIssueLabelsScope = nock(gitlab.apiBaseURL)
735-
.put(`/projects/${PROJECT_ID}/issues/${iid}`, { labels: [ 'page access restriction', 'empty content' ] })
741+
.put(`/projects/${PROJECT_ID}/issues/${iid}`, { labels: [ LABELS.HTTP_403.name, LABELS.EMPTY_CONTENT.name ] })
736742
.reply(200, responseSetLabels);
737743

738744
addCommentScope = nock(gitlab.apiBaseURL)
@@ -742,7 +748,7 @@ describe('GitLab', function () {
742748
await gitlab.createOrUpdateIssue({
743749
title: ISSUE.title,
744750
description: ISSUE.description,
745-
labels: [ 'page access restriction', 'empty content' ],
751+
labels: [ LABELS.HTTP_403.name, LABELS.EMPTY_CONTENT.name ],
746752
});
747753
});
748754

0 commit comments

Comments
 (0)