diff --git a/packages/desktop-gui/cypress/integration/global_mode_spec.coffee b/packages/desktop-gui/cypress/integration/global_mode_spec.coffee index 3d0d8a4244..e8b1ffac94 100644 --- a/packages/desktop-gui/cypress/integration/global_mode_spec.coffee +++ b/packages/desktop-gui/cypress/integration/global_mode_spec.coffee @@ -58,7 +58,7 @@ describe "Global Mode", -> it "opens link to docs on click 'installing...'", -> cy.contains("a", "installing it via").click().then -> - expect(@ipc.externalOpen).to.be.calledWith("https://on.cypress.io/adding-new-project") + expect(@ipc.externalOpen).to.be.calledWith("https://on.cypress.io/installing-via-npm") it "dismisses notice when close is clicked", -> cy.get(".local-install-notice .close").click() @@ -79,25 +79,35 @@ describe "Global Mode", -> cy.get(".project-drop p:first").should("contain", "Drag your project here") cy.get(".project-drop a").should("have.text", "select manually") + it "handles drops of non-files gracefully", (done) -> + cy.window().then (win) -> + win.onerror = (message) -> + done("Should not cause error but threw: #{message}") + ## user could drag and drop a link or text, not a file + @dropEvent.dataTransfer.files = [] + cy.get(".project-drop").trigger("drop", @dropEvent) + cy.wait(300).then -> + done() + describe "dragging and dropping project", -> it "highlights/unhighlights drop area when dragging over it/leaving it", -> cy .get(".project-drop") - .ttrigger("dragover") + .trigger("dragover") .should("have.class", "is-dragging-over") - .ttrigger("dragleave") + .trigger("dragleave") .should("not.have.class", "is-dragging-over") it "unhighlights drop area when dropping a project on it", -> cy .get(".project-drop") - .ttrigger("dragover") + .trigger("dragover") .should("have.class", "is-dragging-over") - .ttrigger("drop", @dropEvent) + .trigger("drop", @dropEvent) .should("not.have.class", "is-dragging-over") it "adds project and opens it when dropped", -> - cy.get(".project-drop").ttrigger("drop", @dropEvent) + cy.get(".project-drop").trigger("drop", @dropEvent) cy.shouldBeOnProjectSpecs() describe "selecting project", -> @@ -119,7 +129,7 @@ describe "Global Mode", -> describe "going to project", -> beforeEach -> - cy.get(".project-drop").ttrigger("drop", @dropEvent) + cy.get(".project-drop").trigger("drop", @dropEvent) it "displays Back button", -> cy.get('.left-nav a').invoke("text").should("include", "Back") diff --git a/packages/desktop-gui/cypress/integration/projects_list_spec.coffee b/packages/desktop-gui/cypress/integration/projects_list_spec.coffee index 8fd6e0acd9..c797e90a64 100644 --- a/packages/desktop-gui/cypress/integration/projects_list_spec.coffee +++ b/packages/desktop-gui/cypress/integration/projects_list_spec.coffee @@ -134,12 +134,12 @@ describe "Global Mode", -> @getProjects.resolve(@aCoupleProjects) it "puts project at start when dropped", -> - cy.get(".project-drop").ttrigger("drop", @dropEvent).should => + cy.get(".project-drop").trigger("drop", @dropEvent).should => @assertOrder(["id-bar", "id-a", "id-b"]) it "puts project at start when dropped and it already exists", -> @dropEvent.dataTransfer.files[0].path = "/project/b" - cy.get(".project-drop").ttrigger("drop", @dropEvent).then => + cy.get(".project-drop").trigger("drop", @dropEvent).then => @assertOrder(["id-b", "id-a"]) it "puts project at start when selected", -> diff --git a/packages/desktop-gui/src/app/intro.jsx b/packages/desktop-gui/src/app/intro.jsx index 49d7c7189d..58b3191a25 100644 --- a/packages/desktop-gui/src/app/intro.jsx +++ b/packages/desktop-gui/src/app/intro.jsx @@ -1,3 +1,4 @@ +import _ from 'lodash' import cs from 'classnames' import React, { Component } from 'react' import { action, observable } from 'mobx' @@ -103,7 +104,9 @@ class Default extends Component { e.preventDefault() this._setDragging(false) - const file = e.dataTransfer.files[0] + const file = _.get(e, 'dataTransfer.files[0]') + if (!file) return false + this._addProject(file.path) return false