Skip to main content
Glama

Placid MCP Server

generate_creative.test.ts2.63 kB
import { handleGenerateCreative } from "../../../src/tools/generate_creative/index"; import { PlacidClient } from "../../../src/services/placid/client"; // Mock the PlacidClient jest.mock("../../../src/services/placid/client.js"); describe("handleGenerateCreative", () => { const mockConfig = { placidApiToken: "test-token", apiBaseUrl: "https://api.placid.app/api/rest", }; beforeEach(() => { jest.clearAllMocks(); }); it("should generate creative successfully with immediate completion", async () => { const mockResponse = { id: 1, status: "finished", image_url: "https://placid.app/u/test.jpg", polling_url: null, }; (PlacidClient.prototype.generateCreative as jest.Mock).mockResolvedValue(mockResponse); const result = await handleGenerateCreative( { template_id: "template-1", layers: { title: { text: "Test Title" }, image: { image: "https://example.com/image.jpg" }, }, }, mockConfig ); expect(result.content).toHaveLength(1); expect(result.content[0].text).toContain("https://placid.app/u/test.jpg"); }); it("should handle queued generation with polling", async () => { const mockQueuedResponse = { id: 1, status: "queued", image_url: null, polling_url: "https://api.placid.app/api/rest/images/1", }; const mockFinishedResponse = { id: 1, status: "finished", image_url: "https://placid.app/u/test.jpg", polling_url: null, }; (PlacidClient.prototype.generateCreative as jest.Mock).mockResolvedValue(mockQueuedResponse); (PlacidClient.prototype.getCreativeStatus as jest.Mock) .mockResolvedValueOnce({ ...mockQueuedResponse }) .mockResolvedValueOnce(mockFinishedResponse); const result = await handleGenerateCreative( { template_id: "template-1", layers: { title: { text: "Test Title" }, }, }, mockConfig ); expect(result.content[0].text).toContain("https://placid.app/u/test.jpg"); expect(PlacidClient.prototype.getCreativeStatus).toHaveBeenCalledTimes(2); }); it("should handle generation errors", async () => { (PlacidClient.prototype.generateCreative as jest.Mock).mockRejectedValue( new Error("Generation failed") ); const result = await handleGenerateCreative( { template_id: "template-1", layers: { title: { text: "Test Title" }, }, }, mockConfig ); expect(result.content[0].text).toContain("Error generating creative"); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/felores/placid-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server