import { login } from "./helpers";

describe("settings.cy.js", () => {
  beforeEach(() => {
    cy.manageCommand("cypress_reset");
  });

  describe("with circle documents enabled", () => {
    it("student can see circle documents", () => {
      login("test-student1@example.com", "test");
      cy.visit("/course/test-lehrgang/learn/fahrzeug");
      cy.get('[data-cy="circle-document-section"]').should("exist");
    });

    it("trainer can see circle documents", () => {
      login("test-trainer1@example.com", "test");
      cy.visit("/course/test-lehrgang/cockpit");
      cy.get('[data-cy="circle-documents"]').should("exist");
    });
  });

  describe("with circle documents disabled", () => {
    beforeEach(() => {
      cy.manageCommand("cypress_reset --no-enable-circle-documents");
    });

    it("student cannot see circle documents", () => {
      login("test-student1@example.com", "test");
      cy.visit("/course/test-lehrgang/learn/fahrzeug");
      cy.get('[data-cy="circle-title"]').should("contain", "Fahrzeug");
      cy.get('[data-cy="circle-document-section"]').should("not.exist");
    });

    it("trainer cannot see circle documents", () => {
      login("test-trainer1@example.com", "test");
      cy.visit("/course/test-lehrgang/cockpit");
      cy.get('[data-cy="circle-documents"]').should("not.exist");
    });
  });
});
