tools.test.ts•37 kB
import { createDHIS2Tools } from '../src/tools/index';
describe('DHIS2 Tools', () => {
let tools: any[];
beforeAll(() => {
tools = createDHIS2Tools();
});
describe('tool registration', () => {
it('should create tools array', () => {
expect(Array.isArray(tools)).toBe(true);
expect(tools.length).toBeGreaterThan(0);
});
it('should include required core tools', () => {
const toolNames = tools.map(tool => tool.name);
const requiredTools = [
'dhis2_configure',
'dhis2_get_system_info',
'dhis2_list_data_elements',
'dhis2_create_data_element',
'dhis2_list_programs',
'dhis2_create_program',
'dhis2_get_analytics',
'dhis2_get_event_analytics'
];
requiredTools.forEach(toolName => {
expect(toolNames).toContain(toolName);
});
});
it('should include Phase 3 Android SDK tools', () => {
const toolNames = tools.map(tool => tool.name);
const androidTools = [
'dhis2_android_init_project',
'dhis2_android_configure_gradle',
'dhis2_android_setup_sync',
'dhis2_android_configure_storage',
'dhis2_android_setup_location_services',
'dhis2_android_configure_camera',
'dhis2_android_setup_authentication',
'dhis2_android_generate_data_models',
'dhis2_android_setup_testing',
'dhis2_android_configure_ui_patterns',
'dhis2_android_setup_offline_analytics',
'dhis2_android_configure_notifications',
'dhis2_android_performance_optimization'
];
androidTools.forEach(toolName => {
expect(toolNames).toContain(toolName);
});
});
it('should include Phase 4 UI Library Integration tools', () => {
const toolNames = tools.map(tool => tool.name);
const uiTools = [
'dhis2_create_ui_components',
'dhis2_generate_ui_form_patterns',
'dhis2_generate_ui_data_display',
'dhis2_generate_ui_navigation_layout',
'dhis2_generate_design_system'
];
uiTools.forEach(toolName => {
expect(toolNames).toContain(toolName);
});
});
it('should have valid tool schemas', () => {
tools.forEach(tool => {
expect(tool).toHaveProperty('name');
expect(tool).toHaveProperty('description');
expect(tool).toHaveProperty('inputSchema');
expect(typeof tool.name).toBe('string');
expect(typeof tool.description).toBe('string');
expect(typeof tool.inputSchema).toBe('object');
});
});
});
describe('dhis2_configure tool', () => {
let configureTool: any;
beforeAll(() => {
configureTool = tools.find(tool => tool.name === 'dhis2_configure');
});
it('should exist and have correct schema', () => {
expect(configureTool).toBeDefined();
expect(configureTool.inputSchema.properties).toHaveProperty('baseUrl');
expect(configureTool.inputSchema.properties).toHaveProperty('username');
expect(configureTool.inputSchema.properties).toHaveProperty('password');
expect(configureTool.inputSchema.required).toEqual(['baseUrl', 'username', 'password']);
});
});
describe('data element tools', () => {
let createTool: any;
let listTool: any;
beforeAll(() => {
createTool = tools.find(tool => tool.name === 'dhis2_create_data_element');
listTool = tools.find(tool => tool.name === 'dhis2_list_data_elements');
});
it('should have create data element tool with proper schema', () => {
expect(createTool).toBeDefined();
expect(createTool.inputSchema.properties).toHaveProperty('name');
expect(createTool.inputSchema.properties).toHaveProperty('valueType');
expect(createTool.inputSchema.properties).toHaveProperty('domainType');
expect(createTool.inputSchema.properties.valueType.enum).toContain('NUMBER');
expect(createTool.inputSchema.properties.valueType.enum).toContain('TEXT');
expect(createTool.inputSchema.properties.domainType.enum).toContain('AGGREGATE');
expect(createTool.inputSchema.properties.domainType.enum).toContain('TRACKER');
});
it('should have list data elements tool with optional filters', () => {
expect(listTool).toBeDefined();
expect(listTool.inputSchema.properties).toHaveProperty('filter');
expect(listTool.inputSchema.properties).toHaveProperty('pageSize');
expect(listTool.inputSchema.required).toBeUndefined(); // All parameters are optional
});
});
describe('program tools', () => {
let createTool: any;
let listTool: any;
beforeAll(() => {
createTool = tools.find(tool => tool.name === 'dhis2_create_program');
listTool = tools.find(tool => tool.name === 'dhis2_list_programs');
});
it('should have create program tool with program type validation', () => {
expect(createTool).toBeDefined();
expect(createTool.inputSchema.properties).toHaveProperty('programType');
expect(createTool.inputSchema.properties.programType.enum).toContain('WITH_REGISTRATION');
expect(createTool.inputSchema.properties.programType.enum).toContain('WITHOUT_REGISTRATION');
});
it('should have list programs tool', () => {
expect(listTool).toBeDefined();
expect(listTool.inputSchema.type).toBe('object');
});
});
describe('analytics tools', () => {
let analyticsTool: any;
let eventAnalyticsTool: any;
beforeAll(() => {
analyticsTool = tools.find(tool => tool.name === 'dhis2_get_analytics');
eventAnalyticsTool = tools.find(tool => tool.name === 'dhis2_get_event_analytics');
});
it('should have basic analytics tool', () => {
expect(analyticsTool).toBeDefined();
expect(analyticsTool.inputSchema.properties).toHaveProperty('dimension');
expect(analyticsTool.inputSchema.properties).toHaveProperty('filter');
});
it('should have event analytics tool with required parameters', () => {
expect(eventAnalyticsTool).toBeDefined();
expect(eventAnalyticsTool.inputSchema.properties).toHaveProperty('program');
expect(eventAnalyticsTool.inputSchema.properties).toHaveProperty('startDate');
expect(eventAnalyticsTool.inputSchema.properties).toHaveProperty('endDate');
expect(eventAnalyticsTool.inputSchema.properties).toHaveProperty('orgUnit');
expect(eventAnalyticsTool.inputSchema.required).toEqual(['program', 'startDate', 'endDate', 'orgUnit']);
});
});
describe('validation tools', () => {
let validationTool: any;
let runValidationTool: any;
beforeAll(() => {
validationTool = tools.find(tool => tool.name === 'dhis2_create_validation_rule');
runValidationTool = tools.find(tool => tool.name === 'dhis2_run_validation');
});
it('should have validation rule creation tool', () => {
expect(validationTool).toBeDefined();
expect(validationTool.inputSchema.properties).toHaveProperty('importance');
expect(validationTool.inputSchema.properties).toHaveProperty('operator');
expect(validationTool.inputSchema.properties.importance.enum).toContain('HIGH');
expect(validationTool.inputSchema.properties.importance.enum).toContain('MEDIUM');
expect(validationTool.inputSchema.properties.importance.enum).toContain('LOW');
});
it('should have run validation tool', () => {
expect(runValidationTool).toBeDefined();
expect(runValidationTool.inputSchema.required).toContain('startDate');
expect(runValidationTool.inputSchema.required).toContain('endDate');
expect(runValidationTool.inputSchema.required).toContain('organisationUnits');
});
});
describe('bulk operations', () => {
let bulkDataValuesTool: any;
let bulkEventsTool: any;
beforeAll(() => {
bulkDataValuesTool = tools.find(tool => tool.name === 'dhis2_bulk_import_data_values');
bulkEventsTool = tools.find(tool => tool.name === 'dhis2_bulk_import_events');
});
it('should have bulk data values import tool', () => {
expect(bulkDataValuesTool).toBeDefined();
expect(bulkDataValuesTool.inputSchema.properties).toHaveProperty('dataValues');
expect(bulkDataValuesTool.inputSchema.properties.dataValues.type).toBe('array');
});
it('should have bulk events import tool', () => {
expect(bulkEventsTool).toBeDefined();
expect(bulkEventsTool.inputSchema.properties).toHaveProperty('events');
expect(bulkEventsTool.inputSchema.properties.events.type).toBe('array');
});
});
describe('Phase 3: Android SDK Integration Tools', () => {
describe('android project initialization', () => {
let androidInitTool: any;
beforeAll(() => {
androidInitTool = tools.find(tool => tool.name === 'dhis2_android_init_project');
});
it('should have android project init tool', () => {
expect(androidInitTool).toBeDefined();
expect(androidInitTool.description).toContain('Android project');
});
it('should require essential project parameters', () => {
expect(androidInitTool.inputSchema.required).toEqual([
'projectName',
'applicationId',
'language'
]);
});
it('should support kotlin and java languages', () => {
expect(androidInitTool.inputSchema.properties.language.enum).toEqual(['kotlin', 'java']);
});
it('should have architecture options', () => {
expect(androidInitTool.inputSchema.properties.architecture.enum).toContain('mvvm');
expect(androidInitTool.inputSchema.properties.architecture.enum).toContain('mvi');
expect(androidInitTool.inputSchema.properties.architecture.enum).toContain('clean_architecture');
});
it('should have feature flags', () => {
expect(androidInitTool.inputSchema.properties.features.type).toBe('array');
expect(androidInitTool.inputSchema.properties.features.items.enum).toContain('offline_sync');
expect(androidInitTool.inputSchema.properties.features.items.enum).toContain('gps_capture');
expect(androidInitTool.inputSchema.properties.features.items.enum).toContain('camera_integration');
});
});
describe('gradle configuration', () => {
let gradleTool: any;
beforeAll(() => {
gradleTool = tools.find(tool => tool.name === 'dhis2_android_configure_gradle');
});
it('should have gradle configuration tool', () => {
expect(gradleTool).toBeDefined();
expect(gradleTool.inputSchema.required).toContain('dhis2SdkVersion');
});
it('should support build features', () => {
expect(gradleTool.inputSchema.properties.buildFeatures.properties).toHaveProperty('compose');
expect(gradleTool.inputSchema.properties.buildFeatures.properties).toHaveProperty('viewBinding');
expect(gradleTool.inputSchema.properties.buildFeatures.properties).toHaveProperty('dataBinding');
});
it('should support additional libraries', () => {
const libsEnum = gradleTool.inputSchema.properties.additionalLibraries.items.enum;
expect(libsEnum).toContain('room');
expect(libsEnum).toContain('retrofit');
expect(libsEnum).toContain('dagger_hilt');
expect(libsEnum).toContain('coroutines');
});
});
describe('sync configuration', () => {
let syncTool: any;
beforeAll(() => {
syncTool = tools.find(tool => tool.name === 'dhis2_android_setup_sync');
});
it('should have sync setup tool', () => {
expect(syncTool).toBeDefined();
expect(syncTool.inputSchema.required).toContain('syncStrategy');
});
it('should support sync strategies', () => {
const strategies = syncTool.inputSchema.properties.syncStrategy.enum;
expect(strategies).toContain('manual');
expect(strategies).toContain('automatic');
expect(strategies).toContain('scheduled');
expect(strategies).toContain('smart');
});
it('should support conflict resolution strategies', () => {
const resolutions = syncTool.inputSchema.properties.conflictResolution.enum;
expect(resolutions).toContain('server_wins');
expect(resolutions).toContain('client_wins');
expect(resolutions).toContain('merge');
expect(resolutions).toContain('user_prompt');
});
it('should have sync scope options', () => {
const syncScope = syncTool.inputSchema.properties.syncScope.properties;
expect(syncScope).toHaveProperty('metadata');
expect(syncScope).toHaveProperty('dataValues');
expect(syncScope).toHaveProperty('events');
expect(syncScope).toHaveProperty('enrollments');
});
});
describe('storage configuration', () => {
let storageTool: any;
beforeAll(() => {
storageTool = tools.find(tool => tool.name === 'dhis2_android_configure_storage');
});
it('should have storage configuration tool', () => {
expect(storageTool).toBeDefined();
expect(storageTool.inputSchema.required).toContain('storageType');
});
it('should support database technologies', () => {
const storageTypes = storageTool.inputSchema.properties.storageType.enum;
expect(storageTypes).toContain('room');
expect(storageTypes).toContain('sqlite');
expect(storageTypes).toContain('realm');
});
it('should support encryption levels', () => {
const encryptionLevels = storageTool.inputSchema.properties.encryptionLevel.enum;
expect(encryptionLevels).toContain('none');
expect(encryptionLevels).toContain('basic');
expect(encryptionLevels).toContain('advanced');
});
it('should have purge policy configuration', () => {
const purgePolicy = storageTool.inputSchema.properties.purgePolicy.properties;
expect(purgePolicy).toHaveProperty('enabled');
expect(purgePolicy).toHaveProperty('retentionDays');
expect(purgePolicy).toHaveProperty('conditions');
const conditions = purgePolicy.conditions.items.enum;
expect(conditions).toContain('storage_full');
expect(conditions).toContain('data_old');
expect(conditions).toContain('user_logout');
});
});
describe('location services', () => {
let locationTool: any;
beforeAll(() => {
locationTool = tools.find(tool => tool.name === 'dhis2_android_setup_location_services');
});
it('should have location services tool', () => {
expect(locationTool).toBeDefined();
expect(locationTool.inputSchema.required).toContain('locationAccuracy');
});
it('should support location accuracy levels', () => {
const accuracyLevels = locationTool.inputSchema.properties.locationAccuracy.enum;
expect(accuracyLevels).toContain('high');
expect(accuracyLevels).toContain('balanced');
expect(accuracyLevels).toContain('low_power');
expect(accuracyLevels).toContain('passive');
});
it('should have geofencing configuration', () => {
const geofencing = locationTool.inputSchema.properties.geofencing.properties;
expect(geofencing).toHaveProperty('enabled');
expect(geofencing).toHaveProperty('radius');
expect(geofencing).toHaveProperty('triggers');
const triggers = geofencing.triggers.items.enum;
expect(triggers).toContain('enter');
expect(triggers).toContain('exit');
expect(triggers).toContain('dwell');
});
it('should have coordinate capture settings', () => {
const capture = locationTool.inputSchema.properties.coordinateCapture.properties;
expect(capture).toHaveProperty('validation');
expect(capture).toHaveProperty('accuracyThreshold');
expect(capture).toHaveProperty('timeoutSeconds');
});
});
describe('camera configuration', () => {
let cameraTool: any;
beforeAll(() => {
cameraTool = tools.find(tool => tool.name === 'dhis2_android_configure_camera');
});
it('should have camera configuration tool', () => {
expect(cameraTool).toBeDefined();
expect(cameraTool.inputSchema.required).toContain('cameraFeatures');
});
it('should support camera features', () => {
const features = cameraTool.inputSchema.properties.cameraFeatures.items.enum;
expect(features).toContain('photo_capture');
expect(features).toContain('video_recording');
expect(features).toContain('barcode_scanning');
expect(features).toContain('document_scanning');
});
it('should support barcode types', () => {
const barcodeTypes = cameraTool.inputSchema.properties.barcodeTypes.items.enum;
expect(barcodeTypes).toContain('qr_code');
expect(barcodeTypes).toContain('barcode_128');
expect(barcodeTypes).toContain('data_matrix');
expect(barcodeTypes).toContain('pdf417');
});
it('should have image compression settings', () => {
const imageSettings = cameraTool.inputSchema.properties.imageSettings.properties;
expect(imageSettings).toHaveProperty('maxResolution');
expect(imageSettings).toHaveProperty('compression');
expect(imageSettings).toHaveProperty('watermark');
});
});
describe('authentication configuration', () => {
let authTool: any;
beforeAll(() => {
authTool = tools.find(tool => tool.name === 'dhis2_android_setup_authentication');
});
it('should have authentication setup tool', () => {
expect(authTool).toBeDefined();
expect(authTool.inputSchema.required).toContain('authMethods');
});
it('should support authentication methods', () => {
const authMethods = authTool.inputSchema.properties.authMethods.items.enum;
expect(authMethods).toContain('basic');
expect(authMethods).toContain('oauth2');
expect(authMethods).toContain('biometric');
expect(authMethods).toContain('pin');
expect(authMethods).toContain('pattern');
});
it('should have biometric settings', () => {
const biometric = authTool.inputSchema.properties.biometricSettings.properties;
expect(biometric).toHaveProperty('fingerprintAuth');
expect(biometric).toHaveProperty('faceAuth');
expect(biometric).toHaveProperty('fallbackToPin');
});
it('should have security features', () => {
const security = authTool.inputSchema.properties.securityFeatures.properties;
expect(security).toHaveProperty('screenShotPrevention');
expect(security).toHaveProperty('rootDetection');
expect(security).toHaveProperty('certificatePinning');
expect(security).toHaveProperty('obfuscation');
});
});
describe('data models generation', () => {
let dataModelsTool: any;
beforeAll(() => {
dataModelsTool = tools.find(tool => tool.name === 'dhis2_android_generate_data_models');
});
it('should have data models tool', () => {
expect(dataModelsTool).toBeDefined();
expect(dataModelsTool.inputSchema.required).toEqual(['entities', 'architecture']);
});
it('should support DHIS2 entities', () => {
const entities = dataModelsTool.inputSchema.properties.entities.items.enum;
expect(entities).toContain('data_element');
expect(entities).toContain('program');
expect(entities).toContain('tracked_entity');
expect(entities).toContain('event');
expect(entities).toContain('enrollment');
expect(entities).toContain('organisation_unit');
expect(entities).toContain('user');
});
it('should support architecture patterns', () => {
const architectures = dataModelsTool.inputSchema.properties.architecture.enum;
expect(architectures).toContain('repository_pattern');
expect(architectures).toContain('use_cases');
expect(architectures).toContain('clean_architecture');
});
it('should support serialization libraries', () => {
const serialization = dataModelsTool.inputSchema.properties.serialization.enum;
expect(serialization).toContain('gson');
expect(serialization).toContain('moshi');
expect(serialization).toContain('kotlinx_serialization');
});
});
describe('testing configuration', () => {
let testingTool: any;
beforeAll(() => {
testingTool = tools.find(tool => tool.name === 'dhis2_android_setup_testing');
});
it('should have testing setup tool', () => {
expect(testingTool).toBeDefined();
expect(testingTool.inputSchema.required).toEqual(['testingFrameworks', 'testTypes']);
});
it('should support testing frameworks', () => {
const frameworks = testingTool.inputSchema.properties.testingFrameworks.items.enum;
expect(frameworks).toContain('junit');
expect(frameworks).toContain('mockito');
expect(frameworks).toContain('espresso');
expect(frameworks).toContain('robolectric');
expect(frameworks).toContain('compose_test');
});
it('should support test types', () => {
const testTypes = testingTool.inputSchema.properties.testTypes.items.enum;
expect(testTypes).toContain('unit');
expect(testTypes).toContain('integration');
expect(testTypes).toContain('ui');
expect(testTypes).toContain('sync');
expect(testTypes).toContain('offline');
});
});
describe('UI patterns', () => {
let uiTool: any;
beforeAll(() => {
uiTool = tools.find(tool => tool.name === 'dhis2_android_configure_ui_patterns');
});
it('should have UI patterns tool', () => {
expect(uiTool).toBeDefined();
expect(uiTool.inputSchema.required).toEqual(['uiFramework', 'components']);
});
it('should support UI frameworks', () => {
const frameworks = uiTool.inputSchema.properties.uiFramework.enum;
expect(frameworks).toContain('jetpack_compose');
expect(frameworks).toContain('xml_layouts');
expect(frameworks).toContain('hybrid');
});
it('should support UI components', () => {
const components = uiTool.inputSchema.properties.components.items.enum;
expect(components).toContain('data_entry_form');
expect(components).toContain('list_adapter');
expect(components).toContain('navigation_drawer');
expect(components).toContain('bottom_sheet');
expect(components).toContain('sync_indicator');
expect(components).toContain('offline_banner');
});
it('should have material design settings', () => {
const designSystem = uiTool.inputSchema.properties.designSystem.properties;
expect(designSystem.materialDesign.enum).toContain('material2');
expect(designSystem.materialDesign.enum).toContain('material3');
});
});
describe('offline analytics', () => {
let analyticsTool: any;
beforeAll(() => {
analyticsTool = tools.find(tool => tool.name === 'dhis2_android_setup_offline_analytics');
});
it('should have offline analytics tool', () => {
expect(analyticsTool).toBeDefined();
expect(analyticsTool.inputSchema.required).toContain('analyticsFeatures');
});
it('should support analytics features', () => {
const features = analyticsTool.inputSchema.properties.analyticsFeatures.items.enum;
expect(features).toContain('charts');
expect(features).toContain('tables');
expect(features).toContain('maps');
expect(features).toContain('indicators');
expect(features).toContain('dashboards');
});
it('should support chart types', () => {
const chartTypes = analyticsTool.inputSchema.properties.chartTypes.items.enum;
expect(chartTypes).toContain('line');
expect(chartTypes).toContain('bar');
expect(chartTypes).toContain('pie');
expect(chartTypes).toContain('column');
expect(chartTypes).toContain('area');
});
});
describe('notifications', () => {
let notificationsTool: any;
beforeAll(() => {
notificationsTool = tools.find(tool => tool.name === 'dhis2_android_configure_notifications');
});
it('should have notifications tool', () => {
expect(notificationsTool).toBeDefined();
expect(notificationsTool.inputSchema.required).toContain('notificationTypes');
});
it('should support notification types', () => {
const types = notificationsTool.inputSchema.properties.notificationTypes.items.enum;
expect(types).toContain('push');
expect(types).toContain('local');
expect(types).toContain('in_app');
});
it('should support push providers', () => {
const providers = notificationsTool.inputSchema.properties.pushProvider.enum;
expect(providers).toContain('fcm');
expect(providers).toContain('hms');
expect(providers).toContain('custom');
});
});
describe('performance optimization', () => {
let perfTool: any;
beforeAll(() => {
perfTool = tools.find(tool => tool.name === 'dhis2_android_performance_optimization');
});
it('should have performance optimization tool', () => {
expect(perfTool).toBeDefined();
expect(perfTool.inputSchema.required).toContain('optimizationAreas');
});
it('should support optimization areas', () => {
const areas = perfTool.inputSchema.properties.optimizationAreas.items.enum;
expect(areas).toContain('database_queries');
expect(areas).toContain('image_loading');
expect(areas).toContain('network_requests');
expect(areas).toContain('ui_rendering');
expect(areas).toContain('memory_usage');
});
it('should have monitoring configuration', () => {
const monitoring = perfTool.inputSchema.properties.monitoring.properties;
expect(monitoring.crashReporting.enum).toContain('crashlytics');
expect(monitoring.analytics.enum).toContain('firebase');
});
});
});
describe('Phase 4: UI Library Integration Tools', () => {
describe('DHIS2 UI components', () => {
let uiComponentsTool: any;
beforeAll(() => {
uiComponentsTool = tools.find(tool => tool.name === 'dhis2_create_ui_components');
});
it('should have UI components creation tool', () => {
expect(uiComponentsTool).toBeDefined();
expect(uiComponentsTool.description).toContain('DHIS2 UI library');
});
it('should support various component types', () => {
const componentTypes = uiComponentsTool.inputSchema.properties.componentType.enum;
expect(componentTypes).toContain('form');
expect(componentTypes).toContain('table');
expect(componentTypes).toContain('dashboard');
expect(componentTypes).toContain('modal');
expect(componentTypes).toContain('navigation');
expect(componentTypes).toContain('chart');
expect(componentTypes).toContain('list');
});
it('should have feature flags for components', () => {
const features = uiComponentsTool.inputSchema.properties.features.properties;
expect(features).toHaveProperty('validation');
expect(features).toHaveProperty('pagination');
expect(features).toHaveProperty('search');
expect(features).toHaveProperty('export');
expect(features).toHaveProperty('responsive');
});
it('should support data integration options', () => {
const dataIntegration = uiComponentsTool.inputSchema.properties.dataIntegration.properties;
expect(dataIntegration).toHaveProperty('useDataQuery');
expect(dataIntegration).toHaveProperty('useDataMutation');
expect(dataIntegration).toHaveProperty('apiEndpoint');
});
it('should support styling options', () => {
const styling = uiComponentsTool.inputSchema.properties.styling.properties;
expect(styling.theme.enum).toContain('default');
expect(styling.theme.enum).toContain('dark');
expect(styling.theme.enum).toContain('light');
expect(styling.theme.enum).toContain('custom');
});
});
describe('UI form patterns', () => {
let formPatternsTool: any;
beforeAll(() => {
formPatternsTool = tools.find(tool => tool.name === 'dhis2_generate_ui_form_patterns');
});
it('should have form patterns tool', () => {
expect(formPatternsTool).toBeDefined();
expect(formPatternsTool.description).toContain('@dhis2/ui form patterns');
});
it('should support form component options', () => {
const properties = formPatternsTool.inputSchema.properties;
expect(properties).toHaveProperty('componentName');
expect(properties).toHaveProperty('includeValidation');
expect(properties).toHaveProperty('includeDatePicker');
expect(properties).toHaveProperty('includeFileUpload');
expect(properties).toHaveProperty('includeMultiSelect');
expect(properties).toHaveProperty('includeSelects');
});
it('should support internationalization and accessibility', () => {
const properties = formPatternsTool.inputSchema.properties;
expect(properties).toHaveProperty('i18n');
expect(properties).toHaveProperty('rtl');
expect(properties).toHaveProperty('accessibility');
});
it('should support density options', () => {
const density = formPatternsTool.inputSchema.properties.density;
expect(density.enum).toContain('comfortable');
expect(density.enum).toContain('compact');
});
});
describe('UI data display patterns', () => {
let dataDisplayTool: any;
beforeAll(() => {
dataDisplayTool = tools.find(tool => tool.name === 'dhis2_generate_ui_data_display');
});
it('should have data display tool', () => {
expect(dataDisplayTool).toBeDefined();
expect(dataDisplayTool.description).toContain('@dhis2/ui data display patterns');
});
it('should support data display components', () => {
const properties = dataDisplayTool.inputSchema.properties;
expect(properties).toHaveProperty('componentName');
expect(properties).toHaveProperty('includeTable');
expect(properties).toHaveProperty('includeCards'); // Note: plural
expect(properties).toHaveProperty('includeLists'); // Note: plural
expect(properties).toHaveProperty('includeModal');
expect(properties).toHaveProperty('includeLoading'); // Note: different name
});
it('should support table features', () => {
const properties = dataDisplayTool.inputSchema.properties;
expect(properties).toHaveProperty('includePagination'); // Actual property name
expect(properties).toHaveProperty('sorting'); // Actual property name
expect(properties).toHaveProperty('selection'); // Actual property name for row selection
});
});
describe('UI navigation and layout', () => {
let navigationTool: any;
beforeAll(() => {
navigationTool = tools.find(tool => tool.name === 'dhis2_generate_ui_navigation_layout');
});
it('should have navigation and layout tool', () => {
expect(navigationTool).toBeDefined();
expect(navigationTool.description).toContain('@dhis2/ui navigation and layout patterns');
});
it('should support navigation components', () => {
const properties = navigationTool.inputSchema.properties;
expect(properties).toHaveProperty('componentName');
expect(properties).toHaveProperty('includeHeaderBar');
expect(properties).toHaveProperty('includeSidebar');
expect(properties).toHaveProperty('includeBreadcrumbs');
expect(properties).toHaveProperty('includeTabs');
});
it('should support responsive options', () => {
const properties = navigationTool.inputSchema.properties;
expect(properties).toHaveProperty('includeResponsive'); // Actual property name
expect(properties).toHaveProperty('rtl'); // RTL support instead of mobileCollapse
});
});
describe('design system integration', () => {
let designSystemTool: any;
beforeAll(() => {
designSystemTool = tools.find(tool => tool.name === 'dhis2_generate_design_system');
});
it('should have design system tool', () => {
expect(designSystemTool).toBeDefined();
expect(designSystemTool.description).toContain('design system'); // More flexible check
});
it('should support theme configuration', () => {
const properties = designSystemTool.inputSchema.properties;
expect(properties).toHaveProperty('theme');
expect(properties).toHaveProperty('palette'); // Actual property name
expect(properties).toHaveProperty('typography');
expect(properties).toHaveProperty('spacing');
expect(properties).toHaveProperty('density'); // Has density instead of breakpoints
});
it('should support customization options', () => {
const properties = designSystemTool.inputSchema.properties;
expect(properties).toHaveProperty('theme'); // Has theme instead of customBranding
expect(properties).toHaveProperty('rtl'); // RTL support
expect(properties).toHaveProperty('enableDarkMode'); // Actual property name
});
it('should support density and theming', () => {
const properties = designSystemTool.inputSchema.properties;
expect(properties).toHaveProperty('density');
expect(properties).toHaveProperty('enableDarkMode'); // Dark mode support instead of accessibility
});
});
describe('cross-platform UI consistency', () => {
it('should maintain consistent patterns across web and mobile', () => {
const webUITool = tools.find(tool => tool.name === 'dhis2_create_ui_components');
const androidUITool = tools.find(tool => tool.name === 'dhis2_android_configure_ui_patterns');
expect(webUITool).toBeDefined();
expect(androidUITool).toBeDefined();
// Both should support similar component types
const webComponents = webUITool.inputSchema.properties.componentType.enum;
const androidComponents = androidUITool.inputSchema.properties.components.items.enum;
expect(webComponents).toContain('form');
expect(androidComponents).toContain('data_entry_form');
expect(webComponents).toContain('navigation');
expect(androidComponents).toContain('navigation_drawer');
});
});
describe('responsive design patterns', () => {
it('should include responsive design considerations in UI tools', () => {
const uiComponentsTool = tools.find(tool => tool.name === 'dhis2_create_ui_components');
const navigationTool = tools.find(tool => tool.name === 'dhis2_generate_ui_navigation_layout');
expect(uiComponentsTool.inputSchema.properties.features.properties).toHaveProperty('responsive');
expect(navigationTool.inputSchema.properties).toHaveProperty('includeResponsive'); // Correct property name
});
});
describe('accessibility support', () => {
it('should include accessibility features in UI tools', () => {
const formTool = tools.find(tool => tool.name === 'dhis2_generate_ui_form_patterns');
const designTool = tools.find(tool => tool.name === 'dhis2_generate_design_system');
const androidUITool = tools.find(tool => tool.name === 'dhis2_android_configure_ui_patterns');
expect(formTool.inputSchema.properties).toHaveProperty('accessibility');
expect(designTool.inputSchema.properties).toHaveProperty('rtl'); // RTL is accessibility feature
expect(androidUITool.inputSchema.properties.accessibility).toBeDefined();
});
});
describe('internationalization support', () => {
it('should support i18n and RTL in UI tools', () => {
const formTool = tools.find(tool => tool.name === 'dhis2_generate_ui_form_patterns');
const androidUITool = tools.find(tool => tool.name === 'dhis2_android_configure_ui_patterns');
expect(formTool.inputSchema.properties).toHaveProperty('i18n');
expect(formTool.inputSchema.properties).toHaveProperty('rtl');
expect(androidUITool.inputSchema.properties.localization).toBeDefined();
expect(androidUITool.inputSchema.properties.localization.properties).toHaveProperty('rtlSupport');
});
});
});
});