@cypress/core-desktop-gui
Version:
Desktop GUI for managing Cypress projects.
118 lines (92 loc) • 3.32 kB
text/coffeescript
describe "Debug Console", ->
beforeEach ->
cy
.viewport(800, 400)
.visit("/debug")
.window().then (win) ->
{, } = win
= cy.agents()
.spy(, "ipc")
.handle("get:options", null, {})
it "has debug console title", ->
cy.title().should("include", "Debug Console")
it "triggers get:logs", ->
expect(.ipc).to.be.calledWith("get:logs")
it "triggers on:log", ->
expect(.ipc).to.be.calledWith("on:log")
context "no logs", ->
beforeEach ->
.handle("get:logs", null, [])
it "displays empty logs", ->
cy.get(".empty").should("contain", "Can't find any logs")
context "logs list", ->
beforeEach ->
cy
.fixture("logs").then () ->
.handle("get:logs", null, )
it "lists all logs", ->
cy
.get("#code").find("tbody>tr")
.should("have.length", ?.length)
describe "log detail", ->
beforeEach ->
cy.get("#code").find("tbody>tr").first().as("log")
it "lists most recent log first", ->
cy
.get("@log").find("td")
.contains([0].message)
it "displays type of log", ->
cy.get("@log").should("contain", [0].type)
it "displays data of log", ->
cy.get("@log").should("contain", "{\"foo\":\"bar\"}")
it "displays timestamp", ->
cy
.get("@log").find("td").first()
.should("not.be.empty")
.and("contain", "ago")
context "err on log list", ->
beforeEach ->
.handle("get:logs", "something bad happened", null)
it "handles err gracefully", ->
cy.get("table").find(".empty")
context "on new log", ->
beforeEach ->
cy
.fixture("logs").then () ->
.handle("get:logs", null, )
.fixture("log").then () ->
.handle("on:log", null, )
it "adds new log to table", ->
cy
.get("#code").find("tbody>tr").first()
.should("contain", .message)
context "clear log", ->
it "triggers clear:logs on click", ->
cy
.fixture("logs").then () ->
.handle("get:logs", null, )
.contains(".btn", "Clear").click().then ->
expect(.ipc).to.be.calledWith("clear:logs")
it "clears log on click", ->
cy
.fixture("logs").then () ->
.handle("get:logs", null, )
.get("#code").find(".empty").should("not.exist")
.contains(".btn", "Clear").click().then ->
.handle("clear:logs")
.get("#code").find(".empty").should("be.visible")
context "refresh log", ->
it "triggers get:logs again on click", ->
cy
.fixture("logs").then () ->
.handle("get:logs", null, )
.contains(".btn", "Refresh").click().then ->
expect(.ipc).to.be.calledWith("get:logs")
it "renders new logs on refresh", ->
cy
.fixture("logs").then () ->
.handle("get:logs", null, )
.contains(".btn", "Refresh").click()
.fixture("log").then () ->
.handle("get:logs", null, [])
.get("#code").should("contain", "there was an info")