describe("Our app", () => {
  beforeEach(() => {
    cy.intercept(
      { pathname: "/api/getTopicList" },
      {
        fixture: "topics",
      }
    ).as("getTopicList");

    cy.intercept(
      { pathname: "/api/getTopic" },
      {
        fixture: "article",
      }
    ).as("getTopic");

    cy.viewport("iphone-x");
    cy.visit("/");
  });

  it("shows the home page", () => {
    cy.visit("/");
    cy.contains("Bienvenidos");
  });

  it("shows a video in the home page", () => {
    cy.visit("/");
    cy.get("iframe").should("be.visible");
  });

  it("shows the about page", () => {
    cy.visit("/about");
    cy.contains("Renacer Social");
  });

  it("shows the individual service pages", () => {
    cy.visit("/about");
    cy.get(".item").first().click();
    cy.contains("Casita de Paz");
  });

  it("shows the advice pages", () => {
    cy.visit("/advice");
    // Wait until the request to the intercept is completed.
    cy.wait("@getTopicList");
    cy.get(".item").first().click();
    cy.wait("@getTopic");
  });

  it("allows exiting the individual service pages", () => {
    cy.visit("/about");
    cy.get(".item").first().click();
    cy.get(".back-button-has-icon-only").first().click();
    cy.contains("Servicios");
  });
});