/**
 * Unit tests for AccessDenied. Ported from webapp/js/ui.test.js showAccessDenied.
 */

import { describe, it, expect, beforeEach } from "vitest";
import { render, screen } from "@testing-library/react";
import { AccessDenied } from "./AccessDenied";
import { resetAppStore } from "@/test/test-utils";

describe("AccessDenied", () => {
  beforeEach(() => {
    resetAppStore();
  });

  it("renders translated access denied message", () => {
    render(<AccessDenied serverDetail={null} />);
    expect(screen.getByText(/Access denied|Доступ запрещён/i)).toBeInTheDocument();
  });

  it("appends serverDetail when provided", () => {
    render(<AccessDenied serverDetail="Custom 403 message" />);
    expect(screen.getByText("Custom 403 message")).toBeInTheDocument();
  });
});
