Skip to content
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

Add new plugin events 'before:spec', 'after:spec', 'before:run', and 'after:run' #2331

Merged
merged 33 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fdb6d20
implement before:spec, after:spec, and after:run plugin events
chrisbreiding Aug 10, 2018
bee55d4
ensure server events only executed if registered
chrisbreiding Aug 10, 2018
b550ba4
don’t execute plugin event if plugins process has been killed
chrisbreiding Aug 10, 2018
daa001c
call default preprocessor directly instead of registering it as plugin
chrisbreiding Aug 13, 2018
3c99444
fix unit tests
chrisbreiding Aug 13, 2018
5138e59
Merge branch 'develop' into issue-2286-new-plugin-events
chrisbreiding Aug 14, 2018
317dc2a
Merge branch 'develop' into issue-2286-new-plugin-events
brian-mann Aug 16, 2018
c68cc4b
Merge branch 'develop' into issue-2286-new-plugin-events
chrisbreiding Aug 29, 2018
6c2d174
await server events before proceeding
chrisbreiding Aug 29, 2018
eab692f
add before:run plugin event
chrisbreiding Aug 29, 2018
494f029
Merge branch 'develop' into issue-2286-new-plugin-events
chrisbreiding Sep 7, 2018
b1cc859
pass run details to before:run event
chrisbreiding Sep 10, 2018
e6bbb74
handle and report errors thrown in server event handlers
chrisbreiding Sep 10, 2018
1fa27ac
wrap plugin execution in promise
chrisbreiding Sep 10, 2018
17e782c
Merge branch 'develop' into v4.0
chrisbreiding Dec 13, 2018
6017fb1
Merge branch 'v4.0' of github.com:cypress-io/cypress into v4.0
chrisbreiding Dec 13, 2018
1581860
Merge branch 'v4.0' into issue-2286-new-plugin-events
chrisbreiding Dec 13, 2018
47c3ee6
rename instances of plugin
chrisbreiding Dec 13, 2018
d951df6
more rename fixes
chrisbreiding Dec 13, 2018
c027a57
fix tests
chrisbreiding Dec 14, 2018
bf78da4
fix test
chrisbreiding Dec 14, 2018
d7449ce
rename events to use ‘start’ instead of ‘before’ and ‘end’ instead of…
chrisbreiding Dec 17, 2018
cf5652f
Merge branch 'v4.0' into issue-2286-new-plugin-events
chrisbreiding Jan 11, 2019
ed440b7
bump zunder to 6.3.2
chrisbreiding Jan 18, 2019
aca5a67
await run & spec events in interactive mode
chrisbreiding Jan 18, 2019
349b0ba
fix server unit tests
chrisbreiding Jan 18, 2019
b6badd2
fix desktop-gui tests
chrisbreiding Jan 18, 2019
367dda8
fix e2e specs
chrisbreiding Jan 18, 2019
91edac1
fix desktop-gui specs
chrisbreiding Jan 18, 2019
1a4add8
fix desktop-gui specs
chrisbreiding Jan 18, 2019
0337476
add server unit tests for run/spec events in interactive mode
chrisbreiding Jan 22, 2019
e011e33
add/update desktop-gui integration tests for run/spec events
chrisbreiding Jan 22, 2019
1ec7074
remove console.log
chrisbreiding Jan 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions packages/desktop-gui/cypress/integration/global_mode_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,10 @@ describe "Global Mode", ->

describe "going back", ->
beforeEach ->
cy.contains("Back").click()

it "returns to intro on click of back button", ->
cy.shouldBeOnIntro()
@closeProject = @util.deferred()
@ipc.closeProject.returns(@closeProject.promise)

it "removes project name from title", ->
cy.title().should("equal", "Cypress")
cy.contains("Back").click()

it "removes ipc listeners", ->
expect(@ipc.offOpenProject).to.be.called
Expand All @@ -148,3 +145,17 @@ describe "Global Mode", ->

it "closes project", ->
expect(@ipc.closeProject).to.be.called

it "shows loader", ->
cy.get(".loader")
cy.contains("Closing project...")

describe "when finished closing", ->
beforeEach ->
@closeProject.resolve()

it "goes to intro", ->
cy.shouldBeOnIntro()

it "removes project name from title", ->
cy.title().should("equal", "Cypress")
41 changes: 30 additions & 11 deletions packages/desktop-gui/cypress/integration/project_nav_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe "Project Nav", ->
cy.stub(@ipc, "getRuns").resolves(@runs)
cy.stub(@ipc, "getSpecs").yields(null, @specs)
cy.stub(@ipc, "getRecordKeys").resolves([])
cy.stub(@ipc, "launchBrowser")
cy.stub(@ipc, "closeBrowser").resolves(null)
cy.stub(@ipc, "onBrowserClose")
cy.stub(@ipc, "pingApiServer").resolves()
cy.stub(@ipc, "closeProject")
cy.stub(@ipc, "externalOpen")
Expand All @@ -26,6 +26,9 @@ describe "Project Nav", ->
@openProject = @util.deferred()
cy.stub(@ipc, "openProject").returns(@openProject.promise)

@launchBrowser = @util.deferred()
cy.stub(@ipc, "launchBrowser").returns(@launchBrowser.promise)

start()

context "project nav", ->
Expand Down Expand Up @@ -134,8 +137,8 @@ describe "Project Nav", ->

context "browser opened after choosing spec", ->
beforeEach ->
@ipc.launchBrowser.yields(null, {browserOpened: true})
cy.contains(".file", "app_spec").click()
@launchBrowser.resolve()

it "displays browser icon as opened", ->
cy.get(".browsers-list>a").first().find("i")
Expand All @@ -150,25 +153,41 @@ describe "Project Nav", ->

describe "stop browser", ->
beforeEach ->
@closeBrowser = @util.deferred()
@ipc.closeBrowser.returns(@closeBrowser.promise)

cy.get(".close-browser").click()

it "calls close:browser on click of stop button", ->
it "calls ipc close:browser", ->
expect(@ipc.closeBrowser).to.be.called

it "hides close button on click of stop", ->
it "hides close button", ->
cy.get(".close-browser").should("not.exist")

it "re-enables browser dropdown", ->
cy.get(".browsers-list>a").first()
.should("not.have.class", "disabled")
it "blocks the UI and shows closing loader while browser is closing", ->
cy.get(".ui-blocker")
cy.get(".browsers-list").find(".fa-refresh.fa-spin")
cy.contains("Closing Chrome 50")

it "displays default browser icon", ->
cy.get(".browsers-list>a").first()
.find(".fa-chrome")
describe "when browser is finished closing", ->
beforeEach ->
@closeBrowser.resolve()

it "re-enables browser dropdown", ->
cy.get(".browsers-list>a").first()
.should("not.have.class", "disabled")

it "displays default browser icon", ->
cy.get(".browsers-list>a").first()
.find(".fa-chrome")

it "unblocks the UI", ->
cy.get(".ui-blocker").should("not.exist")

describe "browser is closed manually", ->
beforeEach ->
@ipc.launchBrowser.yield(null, {browserClosed: true})
cy.stub(@ipc, "awaitBrowserClose").resolves()
@ipc.onBrowserClose.yield()

it "hides close browser button", ->
cy.get(".close-browser").should("not.be.visible")
Expand Down
14 changes: 12 additions & 2 deletions packages/desktop-gui/cypress/integration/project_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,20 @@ describe "Project", ->
it "re-opens project if config changes", ->
cy.shouldBeOnProjectSpecs().then =>
@ipc.onConfigChanged.yield()
expect(@ipc.closeProject).to.be.called
expect(@ipc.openProject).to.be.called
cy.wrap(@ipc.closeProject).should("be.called")
cy.wrap(@ipc.openProject).should("be.called")
cy.shouldBeOnProjectSpecs()

describe "opening", ->
beforeEach ->
@openProject = @util.deferred()
@ipc.openProject.returns(@openProject.promise)
@start()

it "shows loader", ->
cy.get(".loader")
cy.contains("Opening project...")

describe "warnings", ->
beforeEach ->
@start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ describe "Projects List", ->
@start()

it "loads projects and shows loader", ->
cy.get(".projects-list .loader").then =>
cy.get(".projects-list .loader")
.should("have.text", "Loading projects...")
.then =>
expect(@ipc.getProjects).to.be.called

describe "when loaded", ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe "Runs List", ->
it "pings api server", ->
expect(@ipc.pingApiServer).to.be.called
cy.get(".loader")
cy.contains("Loading runs...")

describe "success", ->
beforeEach ->
Expand Down Expand Up @@ -425,6 +426,7 @@ describe "Runs List", ->

it "shows loading spinner", ->
cy.get(".loader")
cy.contains("Loading runs...")

it "shows runs when getting runs succeeds", ->
@getRuns.resolve(@runs)
Expand Down
23 changes: 15 additions & 8 deletions packages/desktop-gui/cypress/integration/settings_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,23 @@ describe "Settings", ->
newConfig.browsers = @browsers
@openProject.resolve(newConfig)

@goToSettings()
cy.contains("Configuration").click()
@goToSettings().then =>
@openProject2ndCall = @util.deferred()
@ipc.openProject.onCall(1).returns(@openProject2ndCall.promise)
@ipc.onConfigChanged.yield()

it "displays updated config", ->
newConfig = @util.deepClone(@config)
newConfig.resolved.baseUrl.value = "http://localhost:7777"
@ipc.openProject.onCall(1).resolves(newConfig)
@ipc.onConfigChanged.yield()
it "re-opens the project", ->
cy.wrap(@ipc.openProject).should("be.calledTwice")

cy.contains("http://localhost:7777")
describe "when project re-opens", ->
beforeEach ->
newConfig = @util.deepClone(@config)
newConfig.resolved.baseUrl.value = "http://localhost:7777"
@openProject2ndCall.resolve(newConfig)

it "displays updated config", ->
cy.contains("Configuration").click()
cy.contains("http://localhost:7777")

describe "errors", ->
beforeEach ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe "Set Up Project", ->
beforeEach ->
@getCurrentUser.resolve(@user)

it "shows loader while orgs load", ->
cy.get(".btn").contains("Set up project").click()
cy.get(".loader")

describe "general behavior", ->
beforeEach ->
@getOrgs.resolve(@orgs)
Expand Down Expand Up @@ -343,6 +347,7 @@ describe "Set Up Project", ->
beforeEach ->
cy.stub(@ipc, "windowOpen").resolves()
cy.stub(@ipc, "logIn").resolves(@user)
@getOrgs.resolve()
cy.contains("button", "Log In with GitHub").click()

it "shows setup", ->
Expand Down
30 changes: 18 additions & 12 deletions packages/desktop-gui/cypress/integration/specs_list_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe "Specs List", ->

cy.stub(@ipc, "getOptions").resolves({projectRoot: "/foo/bar"})
cy.stub(@ipc, "getCurrentUser").resolves(@user)
cy.stub(@ipc, "getSpecs").yields(null, @specs)
cy.stub(@ipc, "getSpecs")
cy.stub(@ipc, "closeBrowser").resolves(null)
cy.stub(@ipc, "launchBrowser")
cy.stub(@ipc, "launchBrowser").resolves()
cy.stub(@ipc, "openFinder")
cy.stub(@ipc, "externalOpen")
cy.stub(@ipc, "onboardingClosed")
Expand All @@ -23,6 +23,11 @@ describe "Specs List", ->

start()

it "shows loader", ->
@openProject.resolve(@config)
cy.get(".loader")
cy.contains("Loading specs...")

describe "no specs", ->
beforeEach ->
@ipc.getSpecs.yields(null, [])
Expand All @@ -47,6 +52,7 @@ describe "Specs List", ->

describe "first time onboarding specs", ->
beforeEach ->
@ipc.getSpecs.yields(null, @specs)
@config.isNewProject = true
@openProject.resolve(@config)

Expand Down Expand Up @@ -123,10 +129,11 @@ describe "Specs List", ->
cy
.contains(".btn", "Run all specs").click()
.then ->
launchArgs = @ipc.launchBrowser.lastCall.args
expect(@ipc.launchBrowser).to.be.called

expect(launchArgs[0].browser.name).to.eq "chrome"
expect(launchArgs[0].spec.name).to.eq "All Specs"
launchArgs = @ipc.launchBrowser.lastCall.args[0]
expect(launchArgs.browser.name).to.eq "chrome"
expect(launchArgs.spec.name).to.eq "All Specs"

describe "all specs running in browser", ->
beforeEach ->
Expand Down Expand Up @@ -266,16 +273,15 @@ describe "Specs List", ->
@openProject.resolve(@config)
cy.contains(".file a", "app_spec.coffee").as("firstSpec")

it "closes then launches browser on click of file", ->
it "launches browser on click of file", ->
cy.get("@firstSpec")
.click()
.then ->
expect(@ipc.closeBrowser).to.be.called
expect(@ipc.launchBrowser).to.be.called

launchArgs = @ipc.launchBrowser.lastCall.args

expect(launchArgs[0].browser.name).to.equal("chrome")
expect(launchArgs[0].spec.relative).to.equal("cypress/integration/app_spec.coffee")
launchArgs = @ipc.launchBrowser.lastCall.args[0]
expect(launchArgs.browser.name).to.equal("chrome")
expect(launchArgs.spec.relative).to.equal("cypress/integration/app_spec.coffee")

it "adds 'active' class on click", ->
cy.get("@firstSpec")
Expand Down Expand Up @@ -315,9 +321,9 @@ describe "Specs List", ->
cy.get("@deepSpec").should("have.class", "active")

context "switching specs", ->

beforeEach ->
@ipc.getSpecs.yields(null, @specs)
@ipc.launchBrowser
@openProject.resolve(@config)
cy
.get(".file").contains("a", "app_spec.coffee").as("firstSpec")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe "Update Banner", ->
{ @start, @ipc } = win.App

cy.stub(@ipc, "getCurrentUser").resolves(@user)
cy.stub(@ipc, "openProject").resolves(@config)
cy.stub(@ipc, "windowOpen")
cy.stub(@ipc, "externalOpen")

Expand Down Expand Up @@ -98,7 +99,6 @@ describe "Update Banner", ->
describe "in specs list", ->
beforeEach ->
cy.stub(@ipc, "getOptions").resolves({version: OLD_VERSION, projectRoot: "/foo/bar"})
cy.stub(@ipc, "openProject").resolves(@config)
cy.stub(@ipc, "getSpecs").yields(null, @specs)
@start()
@updaterCheck.resolve(NEW_VERSION)
Expand Down
3 changes: 1 addition & 2 deletions packages/desktop-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"rebuild-node-sass": "1.1.0",
"react-bootstrap-modal": "4.2.0",
"react-dom": "^16.7.0",
"react-loader": "^2.4.5",
"zunder": "6.3.0"
"zunder": "6.3.2"
}
}
4 changes: 2 additions & 2 deletions packages/desktop-gui/src/app/app.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import _ from 'lodash'
import { observer } from 'mobx-react'
import React, { Component } from 'react'
import Loader from 'react-loader'

import appApi from '../lib/app-api'
import C from '../lib/constants'
Expand All @@ -12,6 +11,7 @@ import viewStore from '../lib/view-store'

import Intro from './intro'
import Layout from './layout'
import Loader from '../lib/loader'
import Project from '../project/project'

@observer
Expand All @@ -30,7 +30,7 @@ class App extends Component {
render () {
switch (viewStore.currentView.name) {
case C.LOADING:
return <Loader color='#888' scale={0.5} />
return <Loader fullscreen />
case C.INTRO:
return (
<Layout>
Expand Down
2 changes: 2 additions & 0 deletions packages/desktop-gui/src/app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import GlobalError from './global-error'
import Footer from '../footer/footer'
import LoginModal from '../auth/login-modal'
import UpdateBanner from '../update/update-banner'
import UiBlocker from './ui-blocker'

export default ({ children }) => {
return (
Expand All @@ -15,6 +16,7 @@ export default ({ children }) => {
<Footer />
<LoginModal />
<GlobalError />
<UiBlocker />
</div>
)
}
9 changes: 7 additions & 2 deletions packages/desktop-gui/src/app/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import viewStore from '../lib/view-store'
import ipc from '../lib/ipc'
import { gravatarUrl } from '../lib/utils'
import { Link, routes } from '../lib/routing'
import projectsApi from '../projects/projects-api'

import Dropdown from '../dropdown/dropdown'

Expand Down Expand Up @@ -51,7 +52,7 @@ export default class Nav extends Component {
// global mode, on project page
if (appStore.isGlobalMode && project) {
return (
<Link to={routes.intro()}>
<Link to={routes.intro()} onClick={this._unloadProject}>
<i className='fa fa-chevron-left'></i> Back
</Link>
)
Expand Down Expand Up @@ -122,12 +123,16 @@ export default class Nav extends Component {

}

_select = (item) => {
_select (item) {
if (item.id === 'logout') {
authApi.logOut()
}
}

_unloadProject () {
return projectsApi.closeProject(viewStore.currentView.project)
}

_showLogin () {
authStore.setShowingLogin(true)
}
Expand Down
Loading