import { login } from "./helpers";

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

    login("test-student1@example.com", "test");
  });

  it("should be accessible via link in header", () => {
    cy.visit("/course/test-lehrgang/learn");
    cy.get('[data-cy="medialibrary-link"]').click();
    cy.get('[data-cy="Handlungsfelder-link"]').click();
    cy.get('[data-cy="Fahrzeug-link"]').click();
    cy.get('[data-cy="hf-title"]').should("contain", "Fahrzeug");
  });

  it("should be accessible via direct url", () => {
    cy.visit("/course/test-lehrgang/media");
    cy.get('[data-cy="Handlungsfelder-link"]').click();
    cy.get('[data-cy="Fahrzeug-link"]').click();
    cy.get('[data-cy="hf-title"]').should("contain", "Fahrzeug");
  });

  it("handlungsfeld should be accessible via direct url", () => {
    cy.visit("/course/test-lehrgang/media/category/fahrzeug");
    cy.get('[data-cy="hf-title"]').should("contain", "Fahrzeug");
  });

  it("should be accessible via learning path circle", () => {
    cy.visit("/course/test-lehrgang/learn/fahrzeug/handlungsfeld-fahrzeug");
    cy.get('[data-cy="media-library-link"]')
      .invoke("attr", "href")
      .should("contain", "/media/category/fahrzeug");
  });
});
