Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.3 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import { checkWorkspaceName } from "../../../apps/api/src/utils/check-workspace-name";

describe("checkWorkspaceName", () => {
  it("accepts normal workspace names", () => {
    expect(checkWorkspaceName("Acme Inc.").ok).toBe(true);
    expect(checkWorkspaceName("My Team – Project").ok).toBe(true);
    expect(checkWorkspaceName("Crypto Snack").ok).toBe(true);
  });

  it("rejects names with embedded URLs (2026-05-28 phishing pattern)", () => {
    const result = checkWorkspaceName(
      "BANK OPER https://ij5205.craftum.io/page2",
    );
    expect(result.ok).toBe(false);
  });

  it("rejects names longer than 100 characters", () => {
    const result = checkWorkspaceName("a".repeat(101));
    expect(result.ok).toBe(false);
  });

  it("rejects names with HTML / template chars", () => {
    expect(checkWorkspaceName("<!DOCTYPE html><script>").ok).toBe(false);
    expect(checkWorkspaceName("hello {{name}}").ok).toBe(false);
  });

  it("rejects empty / whitespace-only names", () => {
    expect(checkWorkspaceName("").ok).toBe(false);
    expect(checkWorkspaceName("   ").ok).toBe(false);
  });

  it("returns the rejection reason as a string", () => {
    const r = checkWorkspaceName("a".repeat(150));
    expect(r.ok).toBe(false);
    if (!r.ok) expect(typeof r.reason).toBe("string");
  });
});