Files
cypress/scripts/unit/github-actions/create-pull-request-spec.js
Ryan Manuel 56bebb109e feat: set up auto prs for snapshot metafile changes (#25052)
Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-13 08:29:22 -06:00

87 lines
2.4 KiB
JavaScript

const { expect } = require('chai')
const {
createPullRequest,
} = require('../../github-actions/create-pull-request')
const sinon = require('sinon')
describe('pull requests', () => {
context('.createPullRequest', () => {
it('creates pull request with correct properties', async () => {
const github = {
pulls: {
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
},
}
const context = {
repo: {
owner: 'cypress-io',
repo: 'cypress',
},
}
await createPullRequest({
context,
github,
baseBranch: 'develop',
branchName: 'some-branch-name',
description: 'Update Chrome',
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
})
expect(github.pulls.create).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
base: 'develop',
head: 'some-branch-name',
title: 'chore: Update Chrome',
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
maintainer_can_modify: true,
})
})
it('creates pull request with correct properties including reviewers', async () => {
const github = {
pulls: {
create: sinon.stub().returns(Promise.resolve({ data: { number: 123 } })),
requestReviewers: sinon.stub().returns(Promise.resolve()),
},
}
const context = {
repo: {
owner: 'cypress-io',
repo: 'cypress',
},
}
await createPullRequest({
context,
github,
baseBranch: 'develop',
branchName: 'some-branch-name',
description: 'Update Chrome',
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
reviewers: ['ryanthemanuel'],
})
expect(github.pulls.create).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
base: 'develop',
head: 'some-branch-name',
title: 'chore: Update Chrome',
body: 'This PR was auto-generated to update the version(s) of Chrome for driver tests',
maintainer_can_modify: true,
})
expect(github.pulls.requestReviewers).to.be.calledWith({
owner: 'cypress-io',
repo: 'cypress',
pull_number: 123,
reviewers: ['ryanthemanuel'],
})
})
})
})