+53
@@ -32,6 +32,9 @@ const mockOctokit = {
|
||||
pulls: {
|
||||
requestReviewers: jest.fn(),
|
||||
},
|
||||
issues: {
|
||||
addAssignees: jest.fn(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -61,6 +64,7 @@ describe('publish:github:pull-request examples', () => {
|
||||
createPullRequest: jest.Mock;
|
||||
rest: {
|
||||
pulls: { requestReviewers: jest.Mock };
|
||||
issues: { addAssignees: jest.Mock };
|
||||
};
|
||||
};
|
||||
const mockDir = createMockDirectory();
|
||||
@@ -90,6 +94,9 @@ describe('publish:github:pull-request examples', () => {
|
||||
pulls: {
|
||||
requestReviewers: jest.fn(async (_: any) => ({ data: {} })),
|
||||
},
|
||||
issues: {
|
||||
addAssignees: jest.fn(async (_: any) => ({ data: {} })),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -716,4 +723,50 @@ describe('publish:github:pull-request examples', () => {
|
||||
);
|
||||
expect(mockContext.output).toHaveBeenCalledWith('pullRequestNumber', 123);
|
||||
});
|
||||
|
||||
it('Create a pull request with assignees', async () => {
|
||||
const input = yaml.parse(examples[14].example).steps[0].input;
|
||||
|
||||
await action.handler({
|
||||
...mockContext,
|
||||
workspacePath,
|
||||
input,
|
||||
});
|
||||
|
||||
expect(fakeClient.createPullRequest).toHaveBeenCalledWith({
|
||||
owner: 'owner',
|
||||
repo: 'repo',
|
||||
title: 'Create my new app',
|
||||
body: 'This PR is really good',
|
||||
head: 'new-app',
|
||||
draft: undefined,
|
||||
changes: [
|
||||
{
|
||||
commit: 'Create my new app',
|
||||
files: {
|
||||
'file.txt': {
|
||||
content: Buffer.from('Hello there!').toString('base64'),
|
||||
encoding: 'base64',
|
||||
mode: '100644',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(fakeClient.rest.issues.addAssignees).toHaveBeenCalledWith({
|
||||
owner: 'owner',
|
||||
repo: 'repo',
|
||||
issue_number: 123,
|
||||
assignees: ['foobar'],
|
||||
});
|
||||
|
||||
expect(mockContext.output).toHaveBeenCalledTimes(3);
|
||||
expect(mockContext.output).toHaveBeenCalledWith('targetBranchName', 'main');
|
||||
expect(mockContext.output).toHaveBeenCalledWith(
|
||||
'remoteUrl',
|
||||
'https://github.com/myorg/myrepo/pull/123',
|
||||
);
|
||||
expect(mockContext.output).toHaveBeenCalledWith('pullRequestNumber', 123);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -283,4 +283,22 @@ export const examples: TemplateExample[] = [
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
description: 'Create a pull request with assignees',
|
||||
example: yaml.stringify({
|
||||
steps: [
|
||||
{
|
||||
action: 'publish:github:pull-request',
|
||||
name: 'Create a pull request with reviewers',
|
||||
input: {
|
||||
repoUrl: 'github.com?repo=repo&owner=owner',
|
||||
branchName: 'new-app',
|
||||
title: 'Create my new app',
|
||||
description: 'This PR is really good',
|
||||
assignees: ['foobar'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user