@cypress/core-desktop-gui
Version:
Desktop GUI for managing Cypress projects.
130 lines (100 loc) • 4.07 kB
text/coffeescript
describe "Project Show", ->
beforeEach ->
cy
.visit("/")
.window().then (win) ->
{, } = win
= cy.agents()
.handle("get:options", null, {})
.fixture("user").then () ->
.handle("get:current:user", null, )
.fixture("projects").then () ->
.handle("get:project:paths", null, )
.get("#projects-container>li").first().click()
describe "begins starting server", ->
it "displays folder name", ->
cy.contains("h3", "My-Fake-Project")
it "displays folder path", ->
cy.contains([0])
it "displays Starting Server... message", ->
cy.contains("Starting server...")
describe "server error", ->
beforeEach ->
= {
name: "Port 2020"
msg: "There is already a port running"
}
it "displays normal error message", ->
.handle("open:project", {name: .name, message: .msg}, {})
cy
.get(".error")
.should("contain", .name)
.and("contain", .msg)
it "displays Port in Use instructions on err", ->
.handle("open:project", {portInUse: true, name: .name, message: .msg}, {})
cy
.get(".error")
.should("contain", .name)
.and("contain", .msg)
.and("contain", "To fix")
it "triggers close:project on dismiss button click", ->
.handle("open:project", {name: .name, message: .msg}, {})
.spy(, "ipc")
cy
.contains(".btn", "Dismiss").click().then ->
expect(.ipc).to.be.calledWith("close:project")
.handle("close:project", null, {})
.then ->
expect(.ipc).to.be.calledWith("get:project:paths")
it "returns to projects on dismiss button click", ->
.handle("open:project", {name: .name, message: .msg}, {})
cy
.contains(".btn", "Dismiss").click().then ->
.handle("close:project", null, {})
.handle("get:project:paths", null, )
.get("#projects-container")
describe "successfully starts server", ->
beforeEach ->
.spy(, "ipc")
= {
clientUrl: "http://localhost:2020",
clientUrlDisplay: "http://localhost:2020"
}
.handle("open:project", null, )
it "displays Server url", ->
cy.contains(.clientUrlDisplay)
it "triggers external:open on click of url", ->
cy
.contains("a", .clientUrlDisplay).click().then ->
expect(.ipc).to.be.calledWith("external:open", "http://localhost:2020")
it "triggers close:project on click of Stop", ->
cy
.contains(".btn", "Stop").click().then ->
expect(.ipc).to.be.calledWith("close:project")
.handle("close:project", null, {})
.then ->
expect(.ipc).to.be.calledWith("get:project:paths")
it "returns to projects on Stop button click", ->
cy
.contains(".btn", "Stop").click().then ->
.handle("close:project", null, {})
.handle("get:project:paths", null, )
.get("#projects-container")
it "attaches 'on:project:settings:change' after project opens", ->
cy.wrap(.ipc).should("be.calledWith", "on:project:settings:change")
it "closes existing server + reopens on 'on:project:settings:change'", ->
.spy(.ipc, "off")
cy
.contains(.clientUrlDisplay)
.then ->
.handle("close:project", null, {})
.handle("open:project", null, {
clientUrl: "http://localhost:8888",
clientUrlDisplay: "http://localhost:8888"
})
## cause a settings change event
.handle("on:project:settings:change")
cy
.contains("http://localhost:8888")
.then ->
expect(.ipc.off).to.be.calledWith("on:project:settings:change")