diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b063d7c50f..7d30ce8063 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,97 +1,47 @@ name: ci on: + pull_request: push: branches: - master - pull_request: - types: - - opened - - reopened - - synchronize jobs: - linux-tests: - name: linux tests - runs-on: ubuntu-18.04 + tests: + name: tests + strategy: + matrix: + os: [ubuntu-18.04, macos-latest, windows-2019] + channel: [beta, nightly] + fail-fast: false + runs-on: ${{ matrix.os }} env: - DISPLAY: ":99" ATOM_GITHUB_BABEL_ENV: coverage - ATOM_CHANNEL: nightly - ATOM: /tmp/atom/usr/bin/atom-nightly - APM: /tmp/atom/usr/share/atom-nightly/resources/app/apm/bin/apm MOCHA_TIMEOUT: 60000 UNTIL_TIMEOUT: 30000 steps: - uses: actions/checkout@v1 - name: install Atom - shell: bash - run: | - curl -s -L https://atom.io/download/deb?channel=${ATOM_CHANNEL} \ - -H 'Accept: application/octet-stream' \ - -o /tmp/atom-amd64.deb - /sbin/start-stop-daemon --start --quiet \ - --pidfile /tmp/custom_xvfb_99.pid \ - --make-pidfile --background \ - --exec /usr/bin/Xvfb \ - -- :99 -ac -screen 0 1280x1024x16 - sudo apt-get update - sudo apt-get install -yyq libgconf-2-4 build-essential git libsecret-1-dev gvfs-bin - dpkg-deb -x /tmp/atom-amd64.deb /tmp/atom - - name: install dependencies - shell: bash - run: ${APM} ci - - name: configure git - shell: bash - run: | - git config --global user.name Hubot - git config --global user.email hubot@github.com - - name: run tests - shell: bash - run: ${ATOM} --test test/ - - name: report code coverage - shell: bash - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - SYSTEM_PULLREQUEST_PULLREQUESTNUMBER: ${{ github.event.number }} - SYSTEM_PULLREQUEST_SOURCEBRANCH: ${{ github.head_ref }} - BUILD_SOURCEBRANCH: ${{ github.event.ref }} - run: | - npm run report:coverage - bash <(curl -s https://codecov.io/bash) \ - -n "Linux" \ - -P "${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-}" \ - -B "${SYSTEM_PULLREQUEST_SOURCEBRANCH:-${BUILD_SOURCEBRANCH}}" - if: success() || failure() + uses: UziTech/action-setup-atom@v1 + with: + channel: ${{ matrix.channel }} - macos-tests: - name: macos tests - runs-on: macos-10.14 - env: - ATOM_GITHUB_BABEL_ENV: coverage - ATOM_CHANNEL: nightly - ATOM: /tmp/atom/Atom\ Nightly.app/Contents/Resources/app/atom.sh - APM: /tmp/atom/Atom\ Nightly.app/Contents/Resources/app/apm/bin/apm - MOCHA_TIMEOUT: 60000 - UNTIL_TIMEOUT: 30000 - steps: - - uses: actions/checkout@v1 - - name: install Atom - shell: bash - run: | - curl -s -L https://atom.io/download/mac?channel=${ATOM_CHANNEL} \ - -H 'Accept: application/octet-stream' \ - -o /tmp/atom.zip - sudo unzip -q /tmp/atom.zip -d /tmp/atom - name: install dependencies - shell: bash - run: sh -c "${APM} ci" + run: apm ci + - name: configure git shell: bash run: | git config --global user.name Hubot git config --global user.email hubot@github.com - - name: run tests - shell: bash - run: sh -c "${ATOM} --test test/" + + - name: Run the tests + if: ${{ !contains(matrix.os, 'windows') }} + run: atom --test test + + - name: Run the tests on Windows + if: ${{ contains(matrix.os, 'windows') }} + continue-on-error: true # due to https://github.com/atom/github/pull/2459#issuecomment-624725972 + run: atom --test test + - name: report code coverage shell: bash env: @@ -99,74 +49,44 @@ jobs: SYSTEM_PULLREQUEST_PULLREQUESTNUMBER: ${{ github.event.number }} SYSTEM_PULLREQUEST_SOURCEBRANCH: ${{ github.head_ref }} BUILD_SOURCEBRANCH: ${{ github.event.ref }} + OS_NAME: ${{ matrix.os }} run: | npm run report:coverage + COVERAGE_NAME=$([[ "${OS_NAME}" == macos* ]] && echo "macOS" || echo "Linux") bash <(curl -s https://codecov.io/bash) \ - -n "macOS" \ + -n "${COVERAGE_NAME}" \ -P "${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER:-}" \ -B "${SYSTEM_PULLREQUEST_SOURCEBRANCH:-${BUILD_SOURCEBRANCH}}" - if: success() || failure() - + if: | + !contains(matrix.os, 'windows') && + (success() || failure()) lint: name: lint runs-on: ubuntu-18.04 - env: - DISPLAY: ":99" - ATOM_CHANNEL: nightly - ATOM: /tmp/atom/usr/bin/atom-nightly - APM: /tmp/atom/usr/share/atom-nightly/resources/app/apm/bin/apm steps: - uses: actions/checkout@v1 - name: install Atom - shell: bash - run: | - curl -s -L https://atom.io/download/deb?channel=${ATOM_CHANNEL} \ - -H 'Accept: application/octet-stream' \ - -o /tmp/atom-amd64.deb - /sbin/start-stop-daemon --start --quiet \ - --pidfile /tmp/custom_xvfb_99.pid \ - --make-pidfile --background \ - --exec /usr/bin/Xvfb \ - -- :99 -ac -screen 0 1280x1024x16 - sudo apt-get update - sudo apt-get install -yyq libgconf-2-4 build-essential git libsecret-1-dev gvfs-bin - dpkg-deb -x /tmp/atom-amd64.deb /tmp/atom + uses: UziTech/action-setup-atom@v1 + with: + channel: nightly - name: install dependencies - shell: bash - run: ${APM} ci + run: apm ci - name: lint - shell: bash run: npm run lint snapshot-tests: name: snapshot tests runs-on: ubuntu-18.04 env: - DISPLAY: ":99" - ATOM_CHANNEL: nightly - ATOM: /tmp/atom/usr/bin/atom-nightly - APM: /tmp/atom/usr/share/atom-nightly/resources/app/apm/bin/apm ATOM_GITHUB_BABEL_ENV: coverage ATOM_GITHUB_TEST_SUITE: snapshot steps: - uses: actions/checkout@v1 - name: install Atom - shell: bash - run: | - curl -s -L https://atom.io/download/deb?channel=${ATOM_CHANNEL} \ - -H 'Accept: application/octet-stream' \ - -o /tmp/atom-amd64.deb - /sbin/start-stop-daemon --start --quiet \ - --pidfile /tmp/custom_xvfb_99.pid \ - --make-pidfile --background \ - --exec /usr/bin/Xvfb \ - -- :99 -ac -screen 0 1280x1024x16 - sudo apt-get update - sudo apt-get install -yyq libgconf-2-4 build-essential git libsecret-1-dev gvfs-bin - dpkg-deb -x /tmp/atom-amd64.deb /tmp/atom + uses: UziTech/action-setup-atom@v1 + with: + channel: nightly - name: install dependencies - shell: bash - run: ${APM} ci + run: apm ci - name: run snapshot tests - shell: bash - run: ${ATOM} --test test/ + run: atom --test test/ diff --git a/README.md b/README.md index e43d03aff3..d7d7d2b5ce 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# Atom GitHub Package +##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/) + # Atom GitHub Package | Build | Code Coverage | |-------|---------------| diff --git a/lib/controllers/issueish-list-controller.js b/lib/controllers/issueish-list-controller.js index 94635a6cc6..93ebfa9b61 100644 --- a/lib/controllers/issueish-list-controller.js +++ b/lib/controllers/issueish-list-controller.js @@ -90,15 +90,9 @@ export class BareIssueishListController extends React.Component { return null; } - openOnGitHub = url => { - return new Promise((resolve, reject) => { - shell.openExternal(url, {}, err => { - if (err) { reject(err); } else { - resolve(); - addEvent('open-issueish-in-browser', {package: 'github', component: this.constructor.name}); - } - }); - }); + openOnGitHub = async url => { + await shell.openExternal(url); + addEvent('open-issueish-in-browser', {package: 'github', component: this.constructor.name}); } showActionsMenu = /* istanbul ignore next */ issueish => { diff --git a/lib/controllers/issueish-searches-controller.js b/lib/controllers/issueish-searches-controller.js index 1a9281db88..4d1d79b069 100644 --- a/lib/controllers/issueish-searches-controller.js +++ b/lib/controllers/issueish-searches-controller.js @@ -113,13 +113,8 @@ export default class IssueishSearchesController extends React.Component { }); } - onOpenSearch = search => { + onOpenSearch = async search => { const searchURL = search.getWebURL(this.props.remote); - - return new Promise((resolve, reject) => { - shell.openExternal(searchURL, {}, err => { - if (err) { reject(err); } else { resolve(); } - }); - }); + await shell.openExternal(searchURL); } } diff --git a/lib/controllers/remote-controller.js b/lib/controllers/remote-controller.js index 98f7a255f2..f0a38cc497 100644 --- a/lib/controllers/remote-controller.js +++ b/lib/controllers/remote-controller.js @@ -67,15 +67,7 @@ export default class RemoteController extends React.Component { createPrUrl += '/compare/' + encodeURIComponent(currentBranch.getName()); createPrUrl += '?expand=1'; - return new Promise((resolve, reject) => { - shell.openExternal(createPrUrl, {}, err => { - if (err) { - reject(err); - } else { - incrementCounter('create-pull-request'); - resolve(); - } - }); - }); + await shell.openExternal(createPrUrl); + incrementCounter('create-pull-request'); } } diff --git a/lib/models/discard-history.js b/lib/models/discard-history.js index 3521ae3b81..01a211212e 100644 --- a/lib/models/discard-history.js +++ b/lib/models/discard-history.js @@ -127,7 +127,7 @@ export default class DiscardHistory { await this.expandBlobToFile(path.join(tempFolderPath, `${filePath}-before-discard`), beforeSha); const commonBasePath = !afterSha ? null : await this.expandBlobToFile(path.join(tempFolderPath, `${filePath}-after-discard`), afterSha); - const resultPath = path.join(tempFolderPath, `~${path.basename(filePath)}-merge-result`); + const resultPath = path.join(dir, `~${path.basename(filePath)}-merge-result`); return {filePath, commonBasePath, theirsPath, resultPath, theirsSha: beforeSha, commonBaseSha: afterSha}; }); return await Promise.all(pathPromises); diff --git a/lib/relay-network-layer-manager.js b/lib/relay-network-layer-manager.js index 0d359936b1..db77e0a56d 100644 --- a/lib/relay-network-layer-manager.js +++ b/lib/relay-network-layer-manager.js @@ -18,7 +18,7 @@ function logRatelimitApi(headers) { const resetsIn = moment.unix(parseInt(resets, 10)).from(); // eslint-disable-next-line no-console - console.debug(`GitHub API Rate Limit: ${remaining}/${total} — resets ${resetsIn}`); + console.debug(`GitHub API Rate Limiting Info: ${remaining}/${total} requests left — resets ${resetsIn}`); } export function expectRelayQuery(operationPattern, response) { diff --git a/lib/views/actionable-review-view.js b/lib/views/actionable-review-view.js index aa92696ed1..888837db67 100644 --- a/lib/views/actionable-review-view.js +++ b/lib/views/actionable-review-view.js @@ -124,28 +124,17 @@ export default class ActionableReviewView extends React.Component { } } - reportAbuse = (commentUrl, author) => { - return new Promise((resolve, reject) => { - const url = 'https://github.com/contact/report-content?report=' + - `${encodeURIComponent(author)}&content_url=${encodeURIComponent(commentUrl)}`; - shell.openExternal(url, {}, err => { - if (err) { reject(err); } else { - resolve(); - addEvent('report-abuse', {package: 'github', component: this.constructor.name}); - } - }); - }); + reportAbuse = async (commentUrl, author) => { + const url = 'https://github.com/contact/report-content?report=' + + `${encodeURIComponent(author)}&content_url=${encodeURIComponent(commentUrl)}`; + + await shell.openExternal(url); + addEvent('report-abuse', {package: 'github', component: this.constructor.name}); } - openOnGitHub = url => { - return new Promise((resolve, reject) => { - shell.openExternal(url, {}, err => { - if (err) { reject(err); } else { - resolve(); - addEvent('open-comment-in-browser', {package: 'github', component: this.constructor.name}); - } - }); - }); + openOnGitHub = async url => { + await shell.openExternal(url); + addEvent('open-comment-in-browser', {package: 'github', component: this.constructor.name}); } showActionsMenu = (event, content, author) => { diff --git a/lib/views/directory-select.js b/lib/views/directory-select.js index e22137771f..0f62c24a67 100644 --- a/lib/views/directory-select.js +++ b/lib/views/directory-select.js @@ -45,15 +45,13 @@ export default class DirectorySelect extends React.Component { ); } - chooseDirectory = () => new Promise(resolve => { - this.props.showOpenDialog(this.props.currentWindow, { + chooseDirectory = async () => { + const {filePaths} = await this.props.showOpenDialog(this.props.currentWindow, { defaultPath: this.props.buffer.getText(), properties: ['openDirectory', 'createDirectory', 'promptToCreate'], - }, filePaths => { - if (filePaths !== undefined) { - this.props.buffer.setText(filePaths[0]); - } - resolve(); }); - }); + if (filePaths.length) { + this.props.buffer.setText(filePaths[0]); + } + } } diff --git a/lib/views/git-timings-view.js b/lib/views/git-timings-view.js index 6f1b6b88ce..f689917673 100644 --- a/lib/views/git-timings-view.js +++ b/lib/views/git-timings-view.js @@ -322,16 +322,17 @@ class WaterfallWidget extends React.Component { this.setState(s => ({collapsed: !s.collapsed})); } - handleExportClick(e) { + async handleExportClick(e) { e.preventDefault(); const json = JSON.stringify(this.props.markers.map(m => m.serialize()), null, ' '); const buffer = new TextBuffer({text: json}); - dialog.showSaveDialog({ + const {filePath} = await dialog.showSaveDialog({ defaultPath: 'git-timings.json', - }, filename => { - if (!filename) { return; } - buffer.saveAs(filename); }); + if (!filePath) { + return; + } + buffer.saveAs(filePath); } } @@ -419,22 +420,23 @@ export default class GitTimingsView extends React.Component { ); } - handleImportClick(e) { + async handleImportClick(e) { e.preventDefault(); - dialog.showOpenDialog({ + const {filePaths} = await dialog.showOpenDialog({ properties: ['openFile'], - }, async filenames => { - if (!filenames) { return; } - const filename = filenames[0]; - try { - const contents = await fs.readFile(filename, {encoding: 'utf8'}); - const data = JSON.parse(contents); - const restoredMarkers = data.map(item => Marker.deserialize(item)); - GitTimingsView.restoreGroup(restoredMarkers); - } catch (_err) { - atom.notifications.addError(`Could not import timings from ${filename}`); - } }); + if (!filePaths.length) { + return; + } + const filename = filePaths[0]; + try { + const contents = await fs.readFile(filename, {encoding: 'utf8'}); + const data = JSON.parse(contents); + const restoredMarkers = data.map(item => Marker.deserialize(item)); + GitTimingsView.restoreGroup(restoredMarkers); + } catch (_err) { + atom.notifications.addError(`Could not import timings from ${filename}`); + } } serialize() { diff --git a/lib/views/issueish-link.js b/lib/views/issueish-link.js index 798ce814ea..80571c1bae 100644 --- a/lib/views/issueish-link.js +++ b/lib/views/issueish-link.js @@ -44,17 +44,9 @@ export function openIssueishLinkInNewTab(url, options = {}) { } } -export function openLinkInBrowser(uri) { - return new Promise((resolve, reject) => { - shell.openExternal(uri, {}, err => { - if (err) { - reject(err); - } else { - addEvent('open-issueish-in-browser', {package: 'github', from: 'issueish-link'}); - resolve(); - } - }); - }); +export async function openLinkInBrowser(uri) { + await shell.openExternal(uri); + addEvent('open-issueish-in-browser', {package: 'github', from: 'issueish-link'}); } function getAtomUriForGithubUrl(githubUrl) { diff --git a/lib/worker-manager.js b/lib/worker-manager.js index 409a1085e6..17b9588191 100644 --- a/lib/worker-manager.js +++ b/lib/worker-manager.js @@ -268,7 +268,7 @@ export class RendererProcess { this.onExecStarted = onExecStarted; this.win = new BrowserWindow({show: !!process.env.ATOM_GITHUB_SHOW_RENDERER_WINDOW, - webPreferences: {nodeIntegration: true}}); + webPreferences: {nodeIntegration: true, enableRemoteModule: true}}); this.webContents = this.win.webContents; // this.webContents.openDevTools(); diff --git a/package-lock.json b/package-lock.json index bced7e53f5..cafe6d2056 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "github", - "version": "0.36.6", + "version": "0.36.10", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5062,9 +5062,9 @@ } }, "dompurify": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.0.7.tgz", - "integrity": "sha512-S3O0lk6rFJtO01ZTzMollCOGg+WAtCwS3U5E2WSDY/x/sy7q70RjEC4Dmrih5/UqzLLB9XoKJ8KqwBxaNvBu4A==" + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.0.17.tgz", + "integrity": "sha512-nNwwJfW55r8akD8MSFz6k75bzyT2y6JEa1O3JrZFBf+Y5R9JXXU4OsRl0B9hKoPgHTw2b7ER5yJ5Md97MMUJPg==" }, "domutils": { "version": "1.5.1", diff --git a/package.json b/package.json index 9915593a74..c008cf5d55 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "github", "main": "./lib/index", - "version": "0.36.6", + "version": "0.36.10", "description": "GitHub integration", "repository": "https://github.com/atom/github", "license": "MIT", @@ -41,6 +41,7 @@ "dependencies": { "@atom/babel-plugin-chai-assert-async": "1.0.0", "@atom/babel7-transpiler": "1.0.0-1", + "@babel/core": "7.x <7.12.10", "@babel/generator": "7.8.0", "@babel/plugin-proposal-class-properties": "7.8.0", "@babel/plugin-proposal-object-rest-spread": "7.8.0", @@ -51,7 +52,7 @@ "bytes": "3.1.0", "classnames": "2.2.6", "compare-sets": "1.0.1", - "dompurify": "2.0.7", + "dompurify": "2.0.17", "dugite": "1.92.0", "event-kit": "2.5.3", "fs-extra": "4.0.3", diff --git a/test/controllers/issueish-list-controller.test.js b/test/controllers/issueish-list-controller.test.js index c5b7ab4e3d..13f4ffa07c 100644 --- a/test/controllers/issueish-list-controller.test.js +++ b/test/controllers/issueish-list-controller.test.js @@ -90,7 +90,7 @@ describe('IssueishListController', function() { it('calls shell.openExternal with specified url', async function() { const wrapper = shallow(buildApp()); - sinon.stub(shell, 'openExternal').callsArg(2); + sinon.stub(shell, 'openExternal').callsFake(() => { }); await wrapper.instance().openOnGitHub(url); assert.isTrue(shell.openExternal.calledWith(url)); @@ -98,7 +98,7 @@ describe('IssueishListController', function() { it('fires `open-issueish-in-browser` event upon success', async function() { const wrapper = shallow(buildApp()); - sinon.stub(shell, 'openExternal').callsArg(2); + sinon.stub(shell, 'openExternal').callsFake(() => {}); sinon.stub(reporterProxy, 'addEvent'); await wrapper.instance().openOnGitHub(url); @@ -109,7 +109,7 @@ describe('IssueishListController', function() { it('handles error when openOnGitHub fails', async function() { const wrapper = shallow(buildApp()); - sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('oh noes')); + sinon.stub(shell, 'openExternal').throws(new Error('oh noes')); sinon.stub(reporterProxy, 'addEvent'); try { diff --git a/test/controllers/remote-controller.test.js b/test/controllers/remote-controller.test.js index 36e34cccf1..3028264145 100644 --- a/test/controllers/remote-controller.test.js +++ b/test/controllers/remote-controller.test.js @@ -52,7 +52,7 @@ describe('RemoteController', function() { it('increments a counter when onCreatePr is called', async function() { const wrapper = shallow(createApp()); - sinon.stub(shell, 'openExternal').callsArg(2); + sinon.stub(shell, 'openExternal').callsFake(() => {}); sinon.stub(reporterProxy, 'incrementCounter'); await wrapper.instance().onCreatePr(); @@ -62,7 +62,7 @@ describe('RemoteController', function() { it('handles error when onCreatePr fails', async function() { const wrapper = shallow(createApp()); - sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('oh noes')); + sinon.stub(shell, 'openExternal').throws(new Error('oh noes')); sinon.stub(reporterProxy, 'incrementCounter'); try { diff --git a/test/git-strategies.test.js b/test/git-strategies.test.js index c39b8dca60..3d7ad41b85 100644 --- a/test/git-strategies.test.js +++ b/test/git-strategies.test.js @@ -837,7 +837,7 @@ import * as reporterProxy from '../lib/reporter-proxy'; it('returns an empty diff', async function() { const workingDirPath = await cloneRepository('three-files'); const git = createTestStrategy(workingDirPath); - const data = new Buffer(10); + const data = Buffer.alloc(10); for (let i = 0; i < 10; i++) { data.writeUInt8(i + 200, i); } diff --git a/test/integration/file-patch.test.js b/test/integration/file-patch.test.js index d2d3a0d9e1..f608b1ef51 100644 --- a/test/integration/file-patch.test.js +++ b/test/integration/file-patch.test.js @@ -7,6 +7,10 @@ import {setup, teardown} from './helpers'; import GitShellOutStrategy from '../../lib/git-shell-out-strategy'; describe('integration: file patches', function() { + // NOTE: This test does not pass on VSTS macOS builds. It will be re-enabled + // once the underlying problem is solved. See atom/github#2617 for details. + if (process.env.CI_PROVIDER === 'VSTS') { return; } + let context, wrapper, atomEnv; let workspace; let commands, workspaceElement; diff --git a/test/views/actionable-review-view.test.js b/test/views/actionable-review-view.test.js index 0c5474cec0..598ad362e0 100644 --- a/test/views/actionable-review-view.test.js +++ b/test/views/actionable-review-view.test.js @@ -69,17 +69,17 @@ describe('ActionableReviewView', function() { } it("opens the content object's URL with 'Open on GitHub'", async function() { - sinon.stub(shell, 'openExternal').callsArg(2); + sinon.stub(shell, 'openExternal').callsFake(() => {}); const item = triggerMenu({url: 'https://github.com'}, {}).items.find(i => i.label === 'Open on GitHub'); await item.click(); - assert.isTrue(shell.openExternal.calledWith('https://github.com', {})); + assert.isTrue(shell.openExternal.calledWith('https://github.com')); assert.isTrue(reporterProxy.addEvent.calledWith('open-comment-in-browser')); }); it("rejects the promise when 'Open on GitHub' fails", async function() { - sinon.stub(shell, 'openExternal').callsArgWith(2, new Error("I don't feel like it")); + sinon.stub(shell, 'openExternal').throws(new Error("I don't feel like it")); const item = triggerMenu({url: 'https://github.com'}, {}).items.find(i => i.label === 'Open on GitHub'); await assert.isRejected(item.click()); @@ -87,7 +87,7 @@ describe('ActionableReviewView', function() { }); it('opens a prepopulated abuse-reporting link with "Report abuse"', async function() { - sinon.stub(shell, 'openExternal').callsArg(2); + sinon.stub(shell, 'openExternal').callsFake(() => {}); const item = triggerMenu({url: 'https://github.com/a/b'}, {login: 'tyrion'}) .items.find(i => i.label === 'Report abuse'); @@ -95,13 +95,12 @@ describe('ActionableReviewView', function() { assert.isTrue(shell.openExternal.calledWith( 'https://github.com/contact/report-content?report=tyrion&content_url=https%3A%2F%2Fgithub.com%2Fa%2Fb', - {}, )); assert.isTrue(reporterProxy.addEvent.calledWith('report-abuse')); }); it("rejects the promise when 'Report abuse' fails", async function() { - sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('nah')); + sinon.stub(shell, 'openExternal').throws(new Error('nah')); const item = triggerMenu({url: 'https://github.com/a/b'}, {login: 'tyrion'}) .items.find(i => i.label === 'Report abuse'); diff --git a/test/views/directory-select.test.js b/test/views/directory-select.test.js index 8e27125111..b371ccd426 100644 --- a/test/views/directory-select.test.js +++ b/test/views/directory-select.test.js @@ -24,7 +24,7 @@ describe('DirectorySelect', function() { {}} + showOpenDialog={() => Promise.resolve()} tabGroup={new TabGroup()} {...override} /> @@ -47,7 +47,7 @@ describe('DirectorySelect', function() { describe('clicking the directory button', function() { it('populates the destination path buffer on accept', async function() { - const showOpenDialog = sinon.stub().callsArgWith(2, ['/some/directory/path']); + const showOpenDialog = sinon.stub().returns(Promise.resolve({filePaths: ['/some/directory/path']})); const buffer = new TextBuffer({text: '/original'}); const wrapper = shallow(buildApp({showOpenDialog, buffer})); @@ -58,7 +58,7 @@ describe('DirectorySelect', function() { }); it('leaves the destination path buffer unmodified on cancel', async function() { - const showOpenDialog = sinon.stub().callsArgWith(2, undefined); + const showOpenDialog = sinon.stub().returns(Promise.resolve({filePaths: []})); const buffer = new TextBuffer({text: '/original'}); const wrapper = shallow(buildApp({showOpenDialog, buffer})); diff --git a/test/views/github-dotcom-markdown.test.js b/test/views/github-dotcom-markdown.test.js index d8aa347f7e..a34ad96296 100644 --- a/test/views/github-dotcom-markdown.test.js +++ b/test/views/github-dotcom-markdown.test.js @@ -140,6 +140,7 @@ describe('GithubDotcomMarkdown', function() { }); it('opens item in pane and activates accordingly', async function() { + atom.workspace = {open: () => {}}; sinon.stub(atom.workspace, 'open').returns(Promise.resolve()); const issueishLink = wrapper.getDOMNode().querySelector('a.issue-link'); @@ -213,7 +214,7 @@ describe('GithubDotcomMarkdown', function() { }); it('records event for opening issueish in browser', async function() { - sinon.stub(shell, 'openExternal').callsArg(2); + sinon.stub(shell, 'openExternal').callsFake(() => {}); sinon.stub(reporterProxy, 'addEvent'); const issueishLink = wrapper.getDOMNode().querySelector('a.issue-link'); @@ -228,7 +229,7 @@ describe('GithubDotcomMarkdown', function() { }); it('does not record event if opening issueish in browser fails', function() { - sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('oh noes')); + sinon.stub(shell, 'openExternal').throws(new Error('oh noes')); sinon.stub(reporterProxy, 'addEvent'); // calling `handleClick` directly rather than dispatching event so that we can catch the error thrown and prevent errors in the console diff --git a/test/worker-manager.test.js b/test/worker-manager.test.js index 27932fe8bb..515d54c1d7 100644 --- a/test/worker-manager.test.js +++ b/test/worker-manager.test.js @@ -151,23 +151,25 @@ describe('WorkerManager', function() { it('destroys all the renderer processes that were created', async function() { this.retries(5); // FLAKE - const browserWindow = new BrowserWindow({show: !!process.env.ATOM_GITHUB_SHOW_RENDERER_WINDOW, webPreferences: {nodeIntegration: true}}); + const browserWindow = new BrowserWindow({show: !!process.env.ATOM_GITHUB_SHOW_RENDERER_WINDOW, webPreferences: {nodeIntegration: true, enableRemoteModule: true}}); browserWindow.loadURL('about:blank'); sinon.stub(Worker.prototype, 'getWebContentsId').returns(browserWindow.webContents.id); const script = ` const ipc = require('electron').ipcRenderer; - ipc.on('${Worker.channelName}', function() { - const args = Array.prototype.slice.apply(arguments) - args.shift(); - - args.unshift('${Worker.channelName}'); - args.unshift(${remote.getCurrentWebContents().id}) - ipc.sendTo.apply(ipc, args); - }); + (function() { + ipc.on('${Worker.channelName}', function() { + const args = Array.prototype.slice.apply(arguments) + args.shift(); + + args.unshift('${Worker.channelName}'); + args.unshift(${remote.getCurrentWebContents().id}) + ipc.sendTo.apply(ipc, args); + }); + })() `; - await new Promise(resolve => browserWindow.webContents.executeJavaScript(script, resolve)); + await browserWindow.webContents.executeJavaScript(script); workerManager.destroy(true); workerManager = new WorkerManager();