import { describe, it, expect } from "vitest";
import {
trackProjectHandler,
checkDependenciesHandler,
generateGitHubActionsHandler,
fullStackScaffoldHandler,
developerRulesHandler,
enforceProjectStandardsHandler,
} from "./fullstack.js";
describe("Full Stack Tools", () => {
describe("trackProjectHandler", () => {
it("should track web project", () => {
const result = trackProjectHandler({
projectPath: "/root",
projectName: "MyApp",
techStack: ["React", "Node"],
});
expect(result.content[0].text).toContain("# Project Tracking: MyApp");
expect(result.content[0].text).toContain("React");
expect(result.content[0].text).toContain("components/"); // Web structure
});
it("should track api project", () => {
// The handler prints both structures anyway, but tech stack differs
const result = trackProjectHandler({
projectPath: "/root",
projectName: "API",
techStack: ["Express"],
});
expect(result.content[0].text).toContain("controllers/"); // API structure
});
});
describe("checkDependenciesHandler", () => {
it("should check npm dependencies", () => {
const result = checkDependenciesHandler({
packageManager: "npm",
});
expect(result.content[0].text).toContain("npm audit");
expect(result.content[0].text).toContain("npm outdated");
});
it("should check python dependencies", () => {
const result = checkDependenciesHandler({
packageManager: "pip",
});
expect(result.content[0].text).toContain("pip-audit");
});
});
describe("generateGitHubActionsHandler", () => {
it("should generate node ci", () => {
const result = generateGitHubActionsHandler({
projectType: "node",
features: ["test", "lint"],
});
expect(result.content[0].text).toContain("runs-on: ubuntu-latest");
expect(result.content[0].text).toContain("npm test");
expect(result.content[0].text).toContain("npm run lint");
});
it("should generate security workflow", () => {
const result = generateGitHubActionsHandler({
projectType: "python",
features: ["security"],
});
expect(result.content[0].text).toContain("Security Scan");
expect(result.content[0].text).toContain("pip-audit");
});
});
describe("fullStackScaffoldHandler", () => {
it("should scaffold full stack", () => {
const result = fullStackScaffoldHandler({
projectName: "FullApp",
frontend: "react",
backend: "express",
database: "postgresql",
});
expect(result.content[0].text).toContain(
"# Full Stack Scaffold: FullApp",
);
expect(result.content[0].text).toContain("frontend/");
expect(result.content[0].text).toContain("backend/");
expect(result.content[0].text).toContain("docker-compose.yml");
expect(result.content[0].text).toContain("POSTGRES_PASSWORD");
});
it("should scaffold backend only", () => {
const result = fullStackScaffoldHandler({
projectName: "APIOnly",
frontend: "none",
backend: "fastapi",
database: "none",
});
expect(result.content[0].text).toContain("backend/");
expect(result.content[0].text).toContain("N/A");
expect(result.content[0].text).toContain("fastapi");
});
});
describe("developerRulesHandler", () => {
it("should show security rules", () => {
const result = developerRulesHandler({
category: "security",
});
expect(result.content[0].text).toContain("Security Rules");
expect(result.content[0].text).toContain("SQL injection");
});
});
describe("enforceProjectStandardsHandler", () => {
it("should show enforcement report", () => {
const result = enforceProjectStandardsHandler({
fix: false,
});
expect(result.content[0].text).toContain(
"Project Standards Enforcement Report",
);
expect(result.content[0].text).toContain("Essential Files");
// The handler output structure: "### 1. Essential Files"
expect(result.content[0].text).toContain("Essential Files");
expect(result.content[0].text).toContain("MCP Configuration found"); // Or MISSING
// Wait, logic: if [ -f ... ] in bash script. The handler generates a shell script and a report table.
expect(result.content[0].text).toContain("README.md");
});
});
});