@cypress/core-desktop-gui
Version:
Desktop GUI for managing Cypress projects.
187 lines (147 loc) • 6.75 kB
text/coffeescript
describe "Projects List", ->
beforeEach ->
cy
.visit("/")
.window().then (win) ->
{, } = win
= cy.agents()
.spy(, "ipc")
.handle("get:options", null, {})
context "with a current user", ->
describe "username in header", ->
it "displays user name", ->
cy
.fixture("user").then () ->
.handle("get:current:user", null, )
.handle("get:project:paths", null, [])
.get("header a").should ($a) ->
expect($a).to.contain(.name)
it "displays email instead of name", ->
cy
.fixture("user").then () ->
.name = null
.handle("get:current:user", null, )
.handle("get:project:paths", null, [])
.get("header a").should ($a) ->
expect($a).to.contain(.email)
describe "logout of user", ->
beforeEach ->
cy
.fixture("user").then () ->
.handle("get:current:user", null, )
.handle("get:project:paths", null, [])
it "shows dropdown on click of user name", ->
cy.contains("Jane Lane").click()
cy.contains("Logout").should("be.visible")
it.skip "triggers logout on click of logout", ->
cy.contains("Jane Lane").click()
cy.contains("a", "Logout").click().then ->
expect(.ipc).to.be.calledWith("log:out")
it.skip "displays login screen on logout", ->
cy.contains("Jane Lane").click()
cy.contains("a", "Logout").click()
cy.contains(".btn", "Login with GitHub")
describe "no projects", ->
beforeEach ->
cy
.fixture("user").then () ->
.handle("get:current:user", null, )
.handle("get:project:paths", null, [])
it "displays empty view when no projects", ->
cy.get(".empty").contains("Add Project")
it "displays help link", ->
cy.contains("a", "Need help?")
it "opens link to docs on click of help link", ->
cy.contains("a", "Need help?").click().then ->
expect(.ipc).to.be.calledWith("external:open", "https://on.cypress.io/guides/installing-and-running/#section-adding-projects")
describe "lists projects", ->
beforeEach ->
cy
.fixture("user").then () ->
.handle("get:current:user", null, )
.fixture("projects").then () ->
.handle("get:project:paths", null, )
it "displays projects in list", ->
cy
.get(".empty").should("not.be.visible")
.get("#projects-container>li").should("have.length", .length)
it "each project shows it's project path", ->
cy
.get("#projects-container>li").first()
.should("contain", [0])
it "each project has it's folder name", ->
cy.contains("h4", "My-Fake-Project")
it "trigger 'open:project' on click of project", ->
cy
.get("#projects-container>li").first().click().should ->
expect(.ipc).to.be.calledWith("open:project")
describe "add project", ->
beforeEach ->
cy
.fixture("user").then () ->
.handle("get:current:user", null, )
.handle("get:project:paths", null, [])
.get(".empty").contains("Add Project")
it "add button has tooltip attrs", ->
cy
.get("header").find("[data-js='add-project']")
.should("have.attr", "data-original-title")
it "triggers ipc 'show:directory:dialog on header +", ->
cy.get("header").find("[data-js='add-project']").click().then ->
expect(.ipc).to.be.calledWith("show:directory:dialog")
it "triggers ipc 'show:directory:dialog on empty view +", ->
cy.get(".empty").find(".btn[data-js='add-project']").click().then ->
expect(.ipc).to.be.calledWith("show:directory:dialog")
describe "error thrown", ->
beforeEach ->
cy
.get("header").find("[data-js='add-project']").click().then ->
.handle("show:directory:dialog", {message: "something bad happened"}, null)
it "displays error", ->
cy
.get(".error")
.should("be.visible")
.and("contain", "something bad happened")
it "goes back to projects view on dismiss", ->
cy
.contains(".btn", "Dismiss").click().then ->
.handle("get:project:paths", null, [])
.get(".empty").should("be.visible")
describe "directory dialog dismissed", ->
beforeEach ->
cy.get("header").find("[data-js='add-project']").click()
it "does no action", ->
.handle("show:directory:dialog", null, null)
cy.get(".empty").should("exist").then ->
expect(.ipc).to.not.be.calledWith("add:project")
describe "directory chosen", ->
beforeEach ->
cy.get("header").find("[data-js='add-project']").click()
it "triggers ipc 'add:project' with directory", ->
.handle("show:directory:dialog", null, "/Users/Jane/Projects/My-Fake-Project")
cy.get("#projects-container>li:not(.empty)").should("have.length", 1).then ->
expect(.ipc).to.be.calledWith("add:project")
it "displays project row with spinner", ->
.handle("show:directory:dialog", null, "/Users/Jane/Projects/My-Fake-Project")
cy.get(".project.loading").find(".fa-spin").should("be.visible")
describe "remove project", ->
beforeEach ->
cy
.fixture("user").then () ->
.handle("get:current:user", null, )
.fixture("projects").then () ->
.handle("get:project:paths", null, )
.get("#projects-container>li").first()
.invoke("trigger", "contextmenu")
it "displays 'remove' link on right click", ->
cy
.get("a").contains("Remove project").should("be.visible")
it "triggers remove:project with path on right click", ->
cy
.get("a").contains("Remove project").click().then ->
expect(.ipc).to.be.calledWith("remove:project", [0])
it "removes the project from the list", ->
cy
.get("#projects-container>li").should("have.length", .length)
.get("a").contains("Remove project").click()
.get("#projects-container>li").should("have.length", .length - 1)