UNPKG

mcp-planes-server

Version:

Plane API client and server

110 lines (109 loc) 5.02 kB
import { PlanesClient } from '../client.js'; import dotenv from 'dotenv'; // Load test environment variables dotenv.config({ path: '.env.test' }); const { PLANE_API_URL, PLANE_API_KEY, PLANE_WORKSPACE_SLUG } = process.env; // Validate environment variables if (!PLANE_API_URL || !PLANE_API_KEY || !PLANE_WORKSPACE_SLUG) { throw new Error('Please set all required environment variables in .env.test file'); } describe('PlanesClient Integration Tests', () => { let client; let testProjectId; beforeAll(() => { client = new PlanesClient(PLANE_API_URL, PLANE_API_KEY, PLANE_WORKSPACE_SLUG); }); describe('Project Operations', () => { // it('should create a new project', async () => { // const projectData = { // name: `Test Project ${Date.now()}`, // description: 'Test project created by integration tests', // identifier: `TP${Date.now()}` // }; // const response = await client.createProject(projectData) as Project; // testProjectId = response.id; // expect(response).toBeDefined(); // expect(response.name).toBe(projectData.name); // expect(response.description).toBe(projectData.description); // }, 10000); it('should get all projects', async () => { const projects = await client.getProjects(); console.log(projects); expect(Array.isArray(projects.results)).toBe(true); expect(projects.results.length).toBeGreaterThan(0); // const testProject = projects.find(p => p.id === testProjectId); // expect(testProject).toBeDefined(); }, 10000); // it('should get a specific project', async () => { // const project = await client.getProject(testProjectId) as Project; // expect(project).toBeDefined(); // expect(project.id).toBe(testProjectId); // }, 10000); // it('should update a project', async () => { // const updateData = { // name: `Updated Project ${Date.now()}`, // description: 'Updated project description' // }; // const response = await client.updateProject(testProjectId, updateData) as Project; // expect(response).toBeDefined(); // expect(response.name).toBe(updateData.name); // expect(response.description).toBe(updateData.description); // }, 10000); // }); // describe('Issue Operations', () => { // let testIssueId: string; // interface Issue { // id: string; // name: string; // description: string; // } // it('should create a new issue', async () => { // const issueData = { // name: `Test Issue ${Date.now()}`, // description: 'Test issue created by integration tests', // priority: 'high', // state: 'backlog' // }; // const response = await client.createIssue(testProjectId, issueData) as Issue; // testIssueId = response.id; // expect(response).toBeDefined(); // expect(response.name).toBe(issueData.name); // expect(response.description).toBe(issueData.description); // }, 10000); // it('should get all issues for a project', async () => { // const issues = await client.getIssues(testProjectId) as Issue[]; // expect(Array.isArray(issues)).toBe(true); // expect(issues.length).toBeGreaterThan(0); // const testIssue = issues.find(i => i.id === testIssueId); // expect(testIssue).toBeDefined(); // }, 10000); // it('should get a specific issue', async () => { // const issue = await client.getIssue(testProjectId, testIssueId) as Issue; // expect(issue).toBeDefined(); // expect(issue.id).toBe(testIssueId); // }, 10000); // it('should update an issue', async () => { // const updateData = { // name: `Updated Issue ${Date.now()}`, // description: 'Updated issue description', // priority: 'medium' // }; // const response = await client.updateIssue(testProjectId, testIssueId, updateData) as Issue; // expect(response).toBeDefined(); // expect(response.name).toBe(updateData.name); // expect(response.description).toBe(updateData.description); // }, 10000); // afterAll(async () => { // // Clean up test issue // if (testIssueId) { // await client.deleteIssue(testProjectId, testIssueId); // } // }); }); // Clean up test data after all tests afterAll(async () => { // if (testProjectId) { // await client.deleteProject(testProjectId); // } }); });