describe("Smoke Tests", () => {
  it("should load the application", () => {
    cy.visit("/login");
    cy.contains("ورود به پنل مدیریت").should("be.visible");
  });

  it("should complete basic user flow", () => {
    // Login
    cy.login();

    // Navigate to dashboard
    cy.visit("/");
    cy.contains("داشبورد").should("be.visible");

    // Check navigation works
    cy.visit("/products");
    cy.url().should("include", "/products");

    cy.visit("/discount-codes");
    cy.url().should("include", "/discount-codes");

    cy.visit("/orders");
    cy.url().should("include", "/orders");

    cy.visit("/users-admin");
    cy.url().should("include", "/users-admin");

    cy.visit("/admin-users");
    cy.url().should("include", "/admin-users");

    cy.visit("/roles");
    cy.url().should("include", "/roles");

    // Check logout works by visiting login page
    cy.visit("/login");
    cy.url().should("include", "/login");
  });

  it("should handle API errors gracefully", () => {
    cy.intercept("GET", "**/api/**", { statusCode: 500 }).as("apiError");

    cy.login();
    cy.visit("/products");

    cy.wait("@apiError");
    // Check for loading or error state
    cy.get("body").should("be.visible");
  });

  it("should work in different browsers", () => {
    cy.login();
    cy.visit("/");

    // Basic functionality should work
    cy.contains("داشبورد").should("be.visible");
    cy.get("header").should("be.visible");
  });
});
