-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fixes #324 Use branch name from config when creating PR #353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import AssetProxy from "../../../valueObjects/AssetProxy"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fantastic - mocking the GH API is an existing issue (#330). This is a great step towards that, which will let us add a test suite for the editorial workflow. |
||
import API from "../API"; | ||
|
||
describe('github API', () => { | ||
const mockAPI = (api, responses) => { | ||
api.request = (path, options = {}) => { | ||
const normalizedPath = path.indexOf('?') !== -1 ? path.substr(0, path.indexOf('?')) : path; | ||
const response = responses[normalizedPath]; | ||
return typeof response === 'function' | ||
? Promise.resolve(response(options)) | ||
: Promise.reject(new Error(`No response for path '${normalizedPath}'`)) | ||
}; | ||
} | ||
|
||
it('should create PR with correct base branch name when publishing with editorial workflow', () => { | ||
let prBaseBranch = null; | ||
const api = new API({ branch: 'gh-pages', repo: 'my-repo' }); | ||
const responses = { | ||
'/repos/my-repo/branches/gh-pages': () => ({ commit: { sha: 'def' } }), | ||
'/repos/my-repo/git/trees/def': () => ({ tree: [] }), | ||
'/repos/my-repo/git/trees': () => ({}), | ||
'/repos/my-repo/git/commits': () => ({}), | ||
'/repos/my-repo/git/refs': () => ({}), | ||
'/repos/my-repo/pulls': (pullRequest) => { | ||
prBaseBranch = JSON.parse(pullRequest.body).base; | ||
return { head: { sha: 'cbd' } }; | ||
}, | ||
'/user': () => ({}), | ||
'/repos/my-repo/git/blobs': () => ({}), | ||
'/repos/my-repo/git/refs/meta/_netlify_cms': () => ({ 'object': {} }) | ||
}; | ||
mockAPI(api, responses); | ||
|
||
return expect( | ||
api.editorialWorkflowGit(null, { slug: 'entry', sha: 'abc' }, null, {}) | ||
.then(() => prBaseBranch) | ||
).resolves.toEqual('gh-pages') | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
exports[`EntryEditorToolbar should disable and update label of Save button when persisting 1`] = `"<div><button disabled=\"\" class=\"\" type=\"button\" data-react-toolbox=\"button\">Saving...</button> <button class=\"\" type=\"button\" data-react-toolbox=\"button\">Cancel</button></div>"`; | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These snapshot changes shouldn't be a part of this PR - it looks like these are due to either the |
||
|
||
exports[`EntryEditorToolbar should have both buttons enabled initially 1`] = `"<div><button class=\"\" type=\"button\" data-react-toolbox=\"button\">Save</button> <button class=\"\" type=\"button\" data-react-toolbox=\"button\">Cancel</button></div>"`; | ||
exports[`EntryEditorToolbar should disable and update label of Save button when persisting 1`] = `"<div><button disabled=\\"\\" class=\\"\\" type=\\"button\\" data-react-toolbox=\\"button\\">Saving...</button> <button class=\\"\\" type=\\"button\\" data-react-toolbox=\\"button\\">Cancel</button></div>"`; | ||
|
||
exports[`EntryEditorToolbar should have both buttons enabled initially 1`] = `"<div><button class=\\"\\" type=\\"button\\" data-react-toolbox=\\"button\\">Save</button> <button class=\\"\\" type=\\"button\\" data-react-toolbox=\\"button\\">Cancel</button></div>"`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if that
Super expression
error you saw was related to this use ofthis
. The fact that we didn't get to the bottom of that error, and that the preceding import mysteriously stopped it, gives me pause. We should dig a little deeper.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested -- I still get the error if I change it back to
base = "master"
and usethis.createPR(options.commitMessage, branchName, this.branch)
, so it seems not