Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Management Automation: Support adding milestones for fork PRs. #20058

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Project Management Automation: Update tests.
epiqueras committed Feb 6, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 4b005c6f85780e76b23a4bbcb7522e5dac132ed6
73 changes: 13 additions & 60 deletions packages/project-management-automation/lib/test/add-milestone.js
Original file line number Diff line number Diff line change
@@ -3,42 +3,10 @@
*/
import addMilestone from '../add-milestone';

describe( 'addFirstTimeContributorLabel', () => {
it( 'does nothing if PR is not merged', async () => {
const payload = {
pull_request: {
merged: false,
},
};
const octokit = {
issues: {
get: jest.fn(),
createMilestone: jest.fn(),
listMilestonesForRepo: jest.fn(),
update: jest.fn(),
},
repos: {
getContents: jest.fn(),
},
};

await addMilestone( payload, octokit );

expect( octokit.issues.get ).not.toHaveBeenCalled();
expect( octokit.issues.createMilestone ).not.toHaveBeenCalled();
expect( octokit.issues.listMilestonesForRepo ).not.toHaveBeenCalled();
expect( octokit.issues.update ).not.toHaveBeenCalled();
expect( octokit.repos.getContents ).not.toHaveBeenCalled();
} );

describe( 'addMilestone', () => {
it( 'does nothing if base is not master', async () => {
const payload = {
pull_request: {
merged: true,
base: {
ref: 'release/5.0',
},
},
ref: 'refs/heads/not-master',
};
const octokit = {
issues: {
@@ -63,13 +31,8 @@ describe( 'addFirstTimeContributorLabel', () => {

it( 'does nothing if PR already has a milestone', async () => {
const payload = {
pull_request: {
merged: true,
base: {
ref: 'master',
},
number: 123,
},
ref: 'refs/heads/master',
commits: [ { message: '(#123)' } ],
repository: {
owner: {
login: 'WordPress',
@@ -100,7 +63,7 @@ describe( 'addFirstTimeContributorLabel', () => {
expect( octokit.issues.get ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
issue_number: '123',
} );
expect( octokit.issues.createMilestone ).not.toHaveBeenCalled();
expect( octokit.issues.listMilestonesForRepo ).not.toHaveBeenCalled();
@@ -110,13 +73,8 @@ describe( 'addFirstTimeContributorLabel', () => {

it( 'correctly milestones PRs when `package.json` has a `*.[1-8]` version', async () => {
const payload = {
pull_request: {
merged: true,
base: {
ref: 'master',
},
number: 123,
},
ref: 'refs/heads/master',
commits: [ { message: '(#123)' } ],
repository: {
owner: {
login: 'WordPress',
@@ -166,7 +124,7 @@ describe( 'addFirstTimeContributorLabel', () => {
expect( octokit.issues.get ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
issue_number: '123',
} );
expect( octokit.repos.getContents ).toHaveBeenCalledWith( {
owner: 'WordPress',
@@ -186,20 +144,15 @@ describe( 'addFirstTimeContributorLabel', () => {
expect( octokit.issues.update ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
issue_number: '123',
milestone: 12,
} );
} );

it( 'correctly milestones PRs when `package.json` has a `*.9` version', async () => {
const payload = {
pull_request: {
merged: true,
base: {
ref: 'master',
},
number: 123,
},
ref: 'refs/heads/master',
commits: [ { message: '(#123)' } ],
repository: {
owner: {
login: 'WordPress',
@@ -249,7 +202,7 @@ describe( 'addFirstTimeContributorLabel', () => {
expect( octokit.issues.get ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
issue_number: '123',
} );
expect( octokit.repos.getContents ).toHaveBeenCalledWith( {
owner: 'WordPress',
@@ -269,7 +222,7 @@ describe( 'addFirstTimeContributorLabel', () => {
expect( octokit.issues.update ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
issue_number: '123',
milestone: 12,
} );
} );