molecule-core/canvas/e2e/org-template-import.spec.ts
Hongming Wang 24fec62d7f initial commit — Molecule AI platform
Forked clean from public hackathon repo (Starfire-AgentTeam, BSL 1.1)
with full rebrand to Molecule AI under github.com/Molecule-AI/molecule-monorepo.

Brand: Starfire → Molecule AI.
Slug: starfire / agent-molecule → molecule.
Env vars: STARFIRE_* → MOLECULE_*.
Go module: github.com/agent-molecule/platform → github.com/Molecule-AI/molecule-monorepo/platform.
Python packages: starfire_plugin → molecule_plugin, starfire_agent → molecule_agent.
DB: agentmolecule → molecule.

History truncated; see public repo for prior commits and contributor
attribution. Verified green: go test -race ./... (platform), pytest
(workspace-template 1129 + sdk 132), vitest (canvas 352), build (mcp).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:55:37 -07:00

53 lines
2.4 KiB
TypeScript

import { test, expect } from "@playwright/test";
const API = process.env.E2E_API_URL ?? "http://localhost:8080";
test.describe("Org template import (PLAN.md §20.3)", () => {
test("org templates section renders inside the palette", async ({ page }) => {
// Sanity: platform must serve /org/templates
const res = await page.request.get(`${API}/org/templates`);
expect(res.ok()).toBeTruthy();
const orgs: { dir: string; name: string; workspaces: number }[] = await res.json();
test.skip(orgs.length === 0, "No org templates configured");
await page.goto("/", { waitUntil: "networkidle" });
// The Org Templates section lives in TWO places: inside the EmptyState
// (visible only when there are 0 workspaces) and inside the
// TemplatePalette sidebar. Open the palette so the section is reachable
// regardless of workspace count.
const paletteToggle = page.getByTitle("Template Palette");
if (await paletteToggle.isVisible()) {
await paletteToggle.click({ force: true });
}
const section = page.getByTestId("org-templates-section").first();
await expect(section).toBeVisible({ timeout: 15000 });
await expect(section.getByText("Org Templates")).toBeVisible();
// Wait for the API fetch to populate (auto-waits via toBeVisible)
const first = orgs[0];
const label = first.name || first.dir;
await expect(section.getByText(label, { exact: false })).toBeVisible({ timeout: 15000 });
await expect(section.getByText(`${first.workspaces}w`)).toBeVisible();
await expect(section.getByRole("button", { name: /Import org/i }).first()).toBeVisible();
});
test("import button exists for every org template returned by the API", async ({ page }) => {
const res = await page.request.get(`${API}/org/templates`);
const orgs: { dir: string }[] = await res.json();
test.skip(orgs.length === 0, "No org templates configured");
await page.goto("/", { waitUntil: "networkidle" });
const paletteToggle = page.getByTitle("Template Palette");
if (await paletteToggle.isVisible()) {
await paletteToggle.click({ force: true });
}
const section = page.getByTestId("org-templates-section").first();
await expect(section).toBeVisible({ timeout: 15000 });
// Wait for the API result to render (one Import button per org)
const buttons = section.getByRole("button", { name: /Import org/i });
await expect(buttons).toHaveCount(orgs.length, { timeout: 15000 });
});
});