n8n-nodes-awx
Version:
n8n node to interact with Ansible AWX/Tower with improved type safety
131 lines • 5.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
describe('AWX Project Operations - Data Structures', () => {
test('should have the correct project data structure', () => {
const projectData = {
id: 456,
name: 'Web Application',
description: 'Infrastructure as code project',
scm_type: 'git',
scm_url: 'https://github.com/example/project.git',
scm_branch: 'main',
status: 'successful',
last_updated: '2023-04-15T10:30:00Z',
summary_fields: {
last_job: {
id: 123,
status: 'successful',
finished: '2023-04-15T10:35:00Z'
},
created_by: { username: 'admin', id: 1 },
organization: { name: 'Default', id: 1 }
},
related: {
last_update: '/api/v2/project_updates/123/'
}
};
expect(projectData).toEqual(expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
description: expect.any(String),
scm_type: expect.any(String),
scm_url: expect.any(String),
scm_branch: expect.any(String),
status: expect.any(String)
}));
expect(projectData.id).toBe(456);
expect(projectData.name).toBe('Web Application');
expect(projectData.scm_type).toBe('git');
expect(projectData.scm_url).toBe('https://github.com/example/project.git');
expect(projectData).toHaveProperty('summary_fields');
expect(projectData.summary_fields).toHaveProperty('last_job');
expect(projectData.summary_fields.last_job).toHaveProperty('status', 'successful');
});
test('should have the correct project list response format', () => {
const projectListResponse = {
count: 2,
next: null,
previous: null,
results: [
{
id: 456,
name: 'Web Application',
description: 'Infrastructure as code project',
scm_type: 'git',
status: 'successful'
},
{
id: 457,
name: 'Database Schema',
description: 'Database migration scripts',
scm_type: 'git',
status: 'successful'
}
]
};
expect(projectListResponse).toHaveProperty('count');
expect(projectListResponse).toHaveProperty('next');
expect(projectListResponse).toHaveProperty('previous');
expect(projectListResponse).toHaveProperty('results');
expect(Array.isArray(projectListResponse.results)).toBe(true);
expect(projectListResponse.results).toHaveLength(2);
const firstProject = projectListResponse.results[0];
expect(firstProject).toEqual(expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
scm_type: expect.any(String),
status: expect.any(String)
}));
expect(firstProject.id).toBe(456);
expect(firstProject.name).toBe('Web Application');
expect(firstProject.scm_type).toBe('git');
expect(firstProject.status).toBe('successful');
});
it('should have the correct AI-friendly project format', () => {
const aiFriendlyProject = {
id: 456,
name: 'Web Application',
description: 'Infrastructure as code project',
scm_type: 'git',
scm_url: 'https://github.com/example/project.git',
scm_branch: 'main',
status: 'successful',
last_updated: '2023-04-15T10:30:00Z',
last_job_status: 'successful',
last_job_id: 123,
organization_name: 'Default',
created_by: 'admin',
ui_url: 'https://awx.example.com/#/projects/456'
};
expect(aiFriendlyProject).toHaveProperty('id');
expect(aiFriendlyProject).toHaveProperty('name');
expect(aiFriendlyProject).toHaveProperty('last_job_status');
expect(aiFriendlyProject).toHaveProperty('organization_name');
expect(aiFriendlyProject).toHaveProperty('ui_url');
expect(aiFriendlyProject.name).toBe('Web Application');
expect(aiFriendlyProject.last_job_status).toBe('successful');
expect(aiFriendlyProject.organization_name).toBe('Default');
});
test('should have the correct project sync response format', () => {
const projectSyncResponse = {
id: 789,
type: 'project_update',
url: '/api/v2/project_updates/789/',
related: {
project: '/api/v2/projects/456/'
},
status: 'pending',
name: 'Web Application',
project: 456,
started: null,
finished: null,
elapsed: 0
};
expect(Object.keys(projectSyncResponse)).toEqual(expect.arrayContaining(['id', 'type', 'status', 'project']));
expect(projectSyncResponse.id).toBe(789);
expect(projectSyncResponse.type).toBe('project_update');
expect(projectSyncResponse.status).toBe('pending');
expect(projectSyncResponse.project).toBe(456);
});
});
//# sourceMappingURL=ProjectStandalone.test.js.map