UNPKG

@tiberriver256/mcp-server-azure-devops

Version:

Azure DevOps reference server for the Model Context Protocol (MCP)

119 lines 5.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const feature_1 = require("./feature"); const test_helpers_1 = require("@/shared/test/test-helpers"); const shouldSkip = (0, test_helpers_1.shouldSkipIntegrationTest)(); const describeOrSkip = shouldSkip ? describe.skip : describe; describeOrSkip('getRepositoryDetails integration', () => { let connection; let projectName; beforeAll(async () => { // Get a real connection using environment variables const testConnection = await (0, test_helpers_1.getTestConnection)(); if (!testConnection) { throw new Error('Connection should be available when integration tests are enabled'); } connection = testConnection; projectName = process.env.AZURE_DEVOPS_DEFAULT_PROJECT || 'DefaultProject'; }); test('should retrieve repository details from Azure DevOps', async () => { // First, get a list of repos to find one to test with const gitApi = await connection.getGitApi(); const repos = await gitApi.getRepositories(projectName); expect(repos.length).toBeGreaterThan(0); // Use the first repo as a test subject const testRepo = repos[0]; // Act - make an actual API call to Azure DevOps const result = await (0, feature_1.getRepositoryDetails)(connection, { projectId: projectName, repositoryId: testRepo.name || testRepo.id || '', }); // Assert on the actual response expect(result).toBeDefined(); expect(result.repository).toBeDefined(); expect(result.repository.id).toBe(testRepo.id); expect(result.repository.name).toBe(testRepo.name); expect(result.repository.project).toBeDefined(); if (result.repository.project) { expect(result.repository.project.name).toBe(projectName); } }); test('should retrieve repository details with statistics', async () => { // First, get a list of repos to find one to test with const gitApi = await connection.getGitApi(); const repos = await gitApi.getRepositories(projectName); expect(repos.length).toBeGreaterThan(0); // Use the first repo as a test subject const testRepo = repos[0]; // Act - make an actual API call to Azure DevOps const result = await (0, feature_1.getRepositoryDetails)(connection, { projectId: projectName, repositoryId: testRepo.name || testRepo.id || '', includeStatistics: true, }); // Assert on the actual response expect(result).toBeDefined(); expect(result.repository).toBeDefined(); expect(result.repository.id).toBe(testRepo.id); expect(result.statistics).toBeDefined(); expect(Array.isArray(result.statistics?.branches)).toBe(true); }); test('should retrieve repository details with refs', async () => { // First, get a list of repos to find one to test with const gitApi = await connection.getGitApi(); const repos = await gitApi.getRepositories(projectName); expect(repos.length).toBeGreaterThan(0); // Use the first repo as a test subject const testRepo = repos[0]; // Act - make an actual API call to Azure DevOps const result = await (0, feature_1.getRepositoryDetails)(connection, { projectId: projectName, repositoryId: testRepo.name || testRepo.id || '', includeRefs: true, }); // Assert on the actual response expect(result).toBeDefined(); expect(result.repository).toBeDefined(); expect(result.repository.id).toBe(testRepo.id); expect(result.refs).toBeDefined(); expect(result.refs?.value).toBeDefined(); expect(Array.isArray(result.refs?.value)).toBe(true); expect(typeof result.refs?.count).toBe('number'); }); test('should retrieve repository details with refs filtered by heads/', async () => { // First, get a list of repos to find one to test with const gitApi = await connection.getGitApi(); const repos = await gitApi.getRepositories(projectName); expect(repos.length).toBeGreaterThan(0); // Use the first repo as a test subject const testRepo = repos[0]; // Act - make an actual API call to Azure DevOps const result = await (0, feature_1.getRepositoryDetails)(connection, { projectId: projectName, repositoryId: testRepo.name || testRepo.id || '', includeRefs: true, refFilter: 'heads/', }); // Assert on the actual response expect(result).toBeDefined(); expect(result.repository).toBeDefined(); expect(result.refs).toBeDefined(); expect(result.refs?.value).toBeDefined(); // All refs should start with refs/heads/ if (result.refs && result.refs.value.length > 0) { result.refs.value.forEach((ref) => { expect(ref.name).toMatch(/^refs\/heads\//); }); } }); test('should throw error when repository is not found', async () => { // Use a non-existent repository name const nonExistentRepoName = 'non-existent-repo-' + Date.now(); // Act & Assert - should throw an error for non-existent repo await expect((0, feature_1.getRepositoryDetails)(connection, { projectId: projectName, repositoryId: nonExistentRepoName, })).rejects.toThrow(/not found|Failed to get repository/); }); }); //# sourceMappingURL=feature.spec.int.js.map