{"size": 2632, "ext": "js", "max_stars_repo_path": "tests/e2e/specs/single.js", "max_stars_repo_name": "TwilightDirge/Geoguess-Master", "max_stars_repo_stars_event_min_datetime": "2019-10-07T18:43:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-30T23:54:54.000Z", "max_issues_repo_path": "tests/e2e/specs/single.js", "max_issues_repo_name": "TwilightDirge/Geoguess-Master", "max_issues_repo_issues_event_min_datetime": "2020-03-22T00:28:39.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-05T15:28:46.000Z", "max_forks_repo_path": "tests/e2e/specs/single.js", "max_forks_repo_name": "TwilightDirge/Geoguess-Master", "max_forks_repo_forks_event_min_datetime": "2019-10-11T23:00:54.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-02T07:20:51.000Z"}
{"max_stars_count": 50, "max_issues_count": 13, "max_forks_count": 62, "avg_line_length": 29.9090909091, "max_line_length": 85, "alphanum_fraction": 0.5607902736}
describe("Test single player game", () => {
  it("Proceed to game page when clicking start game button", () => {
    cy.visit("/");
    cy.get(".start-game-button").click();
    cy.url().should("include", "/game");
  });

  it("Round should be 1", () => {
    cy.get("#round").should("have.text", "1 / 5");
  });

  it("Score should be 0", () => {
    cy.get("#score").should("have.text", "0");
  });

  it("Guess button should be disabled before selecting a location", () => {
    cy.get("#guess-button").should("be.disabled");
  });

  it("Guess button can be clicked after selecting a location", () => {
    cy.get('#map-container').trigger("mouseover").wait(1000);
    cy.get('#map-container').click();
    cy.get("#guess-button").should("not.be.disabled");
  });

  it("Result dialog shows up when clicking guess button", () => {
    cy.get("#guess-button").click();
    cy.get(".result-modal").should("exist");
  });

  it("Test result text", () => {
    cy.window().its('__store__')
      .then((store) => {
        const distance = store.getters.distance;
        cy.get("#distance").should("have.text", `You are ${distance}km away.`);
      });
  });

  it("Round should be 2", () => {
    cy.get("#next-round-button").click();
    cy.get("#round").should("have.text", "2 / 5");
  });

  it("Round should be 5", () => {
    // Skip some rounds and proceed to round 5
    const roundArr = [2, 3, 4];
    cy.wrap(roundArr).each(() => {
      cy.get('#map-container').trigger("mouseover").wait(1000);
      cy.get('#map-container').click();
      cy.get("#guess-button").click();
      cy.get("#next-round-button").click();
    });

    cy.get("#round").should("have.text", "5 / 5");
  });

  it("View summary button should appear on modal at round 5", () => {
    cy.get('#map-container').trigger("mouseover").wait(1000);
    cy.get('#map-container').click();
    cy.get("#guess-button").click();

    cy.get("#view-summary-button").should("exist");
  });

  it("Test summary text", () => {
    cy.get("#view-summary-button").click();

    cy.window().its('__store__')
      .then((store) => {
        const score = store.state.inGame.score;
        cy.get("#distance").should("have.text", `You are ${score}km away in total.`);
      });
  });

  it("Play again button should appear on modal", () => {
    cy.get("#play-again-button").should("exist");
  });

  it("Exit button should appear on modal", () => {
    cy.get("#exit-button").should("exist");
  });

  it("End single player game and get back to home page", () => {
    cy.get("#exit-button").click();
    cy.url().should("eq", "http://localhost:8080/");
  });
});
