/// <reference types="cypress" />

describe("Test fetch measurments button in the main page", () => {
  beforeEach(() => {
    cy.visit(Cypress.env("TEST_URL"));
  });

  it("Fetch timeseries with valid user-room-device", () => {
    cy.get('[data-cy="fetch-measurements-button"]').should("be.visible");
    // keep default mulitselector value for the test
    cy.get('[data-cy="fetch-measurements-button"]').click();

    cy.get('[data-cy="main-chart"]').should("be.visible");
    cy.get('[data-cy="no-data-display"]').should("not.exist");
  });

  it("Fetch timeseries with invalid user-room-device", () => {
    //change the defualt user to "Sylvan"
    cy.get('[data-cy="user-mulitselect"]').should("be.visible").click();
    cy.get(
      '[data-cy="user-mulitselect"] .multiselect__content-wrapper .multiselect__element'
    )
      .contains("Sylvan")
      .click();

    cy.get('[data-cy="fetch-measurements-button"]').should("be.visible");
    // keep default mulitselector value for the test
    cy.get('[data-cy="fetch-measurements-button"]').click();

    cy.get('[data-cy="main-chart"]').should("not.exist");
    cy.get('[data-cy="no-data-display"]').should("be.visible");
  });
});
