@tiberriver256/mcp-server-azure-devops
Version:
Azure DevOps reference server for the Model Context Protocol (MCP)
98 lines • 4.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const feature_1 = require("./feature");
const feature_2 = require("../create-work-item/feature");
const test_helpers_1 = require("../../../shared/test/test-helpers");
// Note: These tests will be skipped in CI due to missing credentials
// They are meant to be run manually in a dev environment with proper Azure DevOps setup
describe('manageWorkItemLink integration', () => {
let connection = null;
let projectName;
let sourceWorkItemId = null;
let targetWorkItemId = null;
beforeAll(async () => {
// Get a real connection using environment variables
connection = await (0, test_helpers_1.getTestConnection)();
projectName = process.env.AZURE_DEVOPS_DEFAULT_PROJECT || 'DefaultProject';
// Skip setup if integration tests should be skipped
if ((0, test_helpers_1.shouldSkipIntegrationTest)() || !connection) {
return;
}
try {
// Create source work item for link tests
const sourceOptions = {
title: `Source Work Item for Link Tests ${new Date().toISOString()}`,
description: 'Source work item for integration tests of manage-work-item-link',
};
const sourceWorkItem = await (0, feature_2.createWorkItem)(connection, projectName, 'Task', sourceOptions);
// Create target work item for link tests
const targetOptions = {
title: `Target Work Item for Link Tests ${new Date().toISOString()}`,
description: 'Target work item for integration tests of manage-work-item-link',
};
const targetWorkItem = await (0, feature_2.createWorkItem)(connection, projectName, 'Task', targetOptions);
// Store the work item IDs for the tests
if (sourceWorkItem && sourceWorkItem.id !== undefined) {
sourceWorkItemId = sourceWorkItem.id;
}
if (targetWorkItem && targetWorkItem.id !== undefined) {
targetWorkItemId = targetWorkItem.id;
}
}
catch (error) {
console.error('Failed to create work items for link tests:', error);
}
});
test('should add a link between two existing work items', async () => {
// Skip if integration tests should be skipped or if work items weren't created
if ((0, test_helpers_1.shouldSkipIntegrationTest)() ||
!connection ||
!sourceWorkItemId ||
!targetWorkItemId) {
return;
}
// Act & Assert - should not throw
const result = await (0, feature_1.manageWorkItemLink)(connection, projectName, {
sourceWorkItemId,
targetWorkItemId,
operation: 'add',
relationType: 'System.LinkTypes.Related',
comment: 'Link created by integration test',
});
// Assert
expect(result).toBeDefined();
expect(result.id).toBe(sourceWorkItemId);
});
test('should handle non-existent work items gracefully', async () => {
// Skip if integration tests should be skipped or if no connection
if ((0, test_helpers_1.shouldSkipIntegrationTest)() || !connection) {
return;
}
// Use a very large ID that's unlikely to exist
const nonExistentId = 999999999;
// Act & Assert - should throw an error for non-existent work item
await expect((0, feature_1.manageWorkItemLink)(connection, projectName, {
sourceWorkItemId: nonExistentId,
targetWorkItemId: nonExistentId,
operation: 'add',
relationType: 'System.LinkTypes.Related',
})).rejects.toThrow(/[Ww]ork [Ii]tem.*not found|does not exist/);
});
test('should handle non-existent relationship types gracefully', async () => {
// Skip if integration tests should be skipped or if work items weren't created
if ((0, test_helpers_1.shouldSkipIntegrationTest)() ||
!connection ||
!sourceWorkItemId ||
!targetWorkItemId) {
return;
}
// Act & Assert - should throw an error for non-existent relation type
await expect((0, feature_1.manageWorkItemLink)(connection, projectName, {
sourceWorkItemId,
targetWorkItemId,
operation: 'add',
relationType: 'NonExistentLinkType',
})).rejects.toThrow(/[Rr]elation|[Ll]ink|[Tt]ype/); // Error may vary, but should mention relation/link/type
});
});
//# sourceMappingURL=feature.spec.int.js.map