import { screen } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement } from "react";

import { APP } from "../../src/shared/app";
import { App } from "../../src/web/app";
import { installFetchMock, mockMetaResponse, renderWithProviders } from "./test-utils";

describe("App", () => {
  test("渲染管理台入口、品牌和主题切换项", () => {
    installFetchMock(() => mockMetaResponse());

    renderWithProviders(createElement(App));

    expect(screen.getByText(APP.title)).not.toBeNull();
    expect(screen.getByText("管理台")).not.toBeNull();
    expect(screen.getByText("系统")).not.toBeNull();
    expect(screen.getByText("明亮")).not.toBeNull();
    expect(screen.getByText("黑暗")).not.toBeNull();
  });

  test("渲染 Admin 导航菜单项", () => {
    installFetchMock(() => mockMetaResponse());

    renderWithProviders(createElement(App));

    expect(screen.getAllByText("总览").length).toBeGreaterThan(0);
    expect(screen.getAllByText("项目管理").length).toBeGreaterThan(0);
  });
});
