|
| 1 | +// src/__mocks__/configMocks.ts |
| 2 | + |
| 3 | +// Happy Path Mocks |
| 4 | +export const validFullClinicalConfig = { |
| 5 | + patientInformation: { |
| 6 | + displayPatientIdentifiers: true, |
| 7 | + showPatientPhoto: true, |
| 8 | + additionalAttributes: ['caste', 'education', 'occupation'], |
| 9 | + }, |
| 10 | + actions: [ |
| 11 | + { |
| 12 | + name: 'Start Visit', |
| 13 | + url: '/openmrs/ws/rest/v1/visit', |
| 14 | + icon: 'fa fa-stethoscope', |
| 15 | + requiredPrivilege: 'Start Visit', |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'Add Diagnosis', |
| 19 | + url: '/openmrs/ws/rest/v1/diagnosis', |
| 20 | + icon: 'fa fa-heartbeat', |
| 21 | + requiredPrivilege: 'Add Diagnosis', |
| 22 | + }, |
| 23 | + { |
| 24 | + name: 'Record Allergy', |
| 25 | + url: '/openmrs/ws/rest/v1/allergy', |
| 26 | + icon: 'fa fa-exclamation-triangle', |
| 27 | + requiredPrivilege: 'Record Allergy', |
| 28 | + }, |
| 29 | + ], |
| 30 | + dashboards: [ |
| 31 | + { |
| 32 | + name: 'Patient Information', |
| 33 | + url: 'patient-information', |
| 34 | + requiredPrivileges: ['View Patient Information'], |
| 35 | + icon: 'fa fa-user', |
| 36 | + default: true, |
| 37 | + }, |
| 38 | + { |
| 39 | + name: 'Conditions', |
| 40 | + url: 'conditions', |
| 41 | + requiredPrivileges: ['View Conditions'], |
| 42 | + icon: 'fa fa-heartbeat', |
| 43 | + }, |
| 44 | + { |
| 45 | + name: 'Allergies', |
| 46 | + url: 'allergies', |
| 47 | + requiredPrivileges: ['View Allergies'], |
| 48 | + icon: 'fa fa-exclamation-triangle', |
| 49 | + }, |
| 50 | + ], |
| 51 | +}; |
| 52 | + |
| 53 | +export const minimalClinicalConfig = { |
| 54 | + patientInformation: {}, |
| 55 | + actions: [], |
| 56 | + dashboards: [ |
| 57 | + { |
| 58 | + name: 'Basic Information', |
| 59 | + url: 'basic-information', |
| 60 | + requiredPrivileges: ['View Patient Dashboard'], |
| 61 | + }, |
| 62 | + ], |
| 63 | +}; |
| 64 | + |
| 65 | +export const mixedClinicalConfig = { |
| 66 | + patientInformation: { |
| 67 | + displayPatientIdentifiers: true, |
| 68 | + }, |
| 69 | + actions: [ |
| 70 | + { |
| 71 | + name: 'Start Visit', |
| 72 | + url: '/openmrs/ws/rest/v1/visit', |
| 73 | + requiredPrivilege: 'Start Visit', |
| 74 | + }, |
| 75 | + ], |
| 76 | + dashboards: [ |
| 77 | + { |
| 78 | + name: 'Required Section', |
| 79 | + url: 'required-section', |
| 80 | + requiredPrivileges: ['View Patient Dashboard'], |
| 81 | + }, |
| 82 | + { |
| 83 | + name: 'Optional Section', |
| 84 | + url: 'optional-section', |
| 85 | + requiredPrivileges: ['View Optional Dashboard'], |
| 86 | + icon: 'fa fa-plus', |
| 87 | + default: false, |
| 88 | + }, |
| 89 | + ], |
| 90 | +}; |
| 91 | + |
| 92 | +// Sad Path Mocks |
| 93 | +export const invalidClinicalConfig = { |
| 94 | + // Missing required properties |
| 95 | + patientInformation: {}, |
| 96 | + // Missing actions array |
| 97 | + // Missing dashboards array |
| 98 | + otherProperty: 'value', |
| 99 | +}; |
| 100 | + |
| 101 | +export const emptyResponse = null; |
| 102 | + |
| 103 | +export const malformedJsonResponse = '{invalid-json}'; |
| 104 | + |
| 105 | +// Edge Case Mocks |
| 106 | +export const largeConfig = { |
| 107 | + patientInformation: { |
| 108 | + displayPatientIdentifiers: true, |
| 109 | + showPatientPhoto: true, |
| 110 | + additionalAttributes: Array(50) |
| 111 | + .fill(0) |
| 112 | + .map((_, i) => `attribute${i}`), |
| 113 | + }, |
| 114 | + actions: Array(20) |
| 115 | + .fill(0) |
| 116 | + .map((_, i) => ({ |
| 117 | + name: `Action ${i}`, |
| 118 | + url: `/openmrs/ws/rest/v1/action${i}`, |
| 119 | + icon: 'fa fa-cog', |
| 120 | + requiredPrivilege: `Privilege ${i}`, |
| 121 | + })), |
| 122 | + dashboards: generateLargeDashboards(50), // Generates 50 dashboards |
| 123 | +}; |
| 124 | + |
| 125 | +export const allOptionalFieldsConfig = { |
| 126 | + patientInformation: { |
| 127 | + displayPatientIdentifiers: true, |
| 128 | + showPatientPhoto: true, |
| 129 | + additionalAttributes: ['caste', 'education', 'occupation'], |
| 130 | + customSections: [ |
| 131 | + { |
| 132 | + name: 'Demographics', |
| 133 | + attributes: ['birthdate', 'gender', 'address'], |
| 134 | + }, |
| 135 | + { |
| 136 | + name: 'Contact Information', |
| 137 | + attributes: ['phoneNumber', 'email'], |
| 138 | + }, |
| 139 | + ], |
| 140 | + }, |
| 141 | + actions: [ |
| 142 | + { |
| 143 | + name: 'Comprehensive Action', |
| 144 | + url: '/openmrs/ws/rest/v1/comprehensive', |
| 145 | + icon: 'fa fa-th-large', |
| 146 | + requiredPrivilege: 'Comprehensive Privilege', |
| 147 | + order: 1, |
| 148 | + type: 'standard', |
| 149 | + additionalParams: { |
| 150 | + color: 'blue', |
| 151 | + size: 'large', |
| 152 | + showInHeader: true, |
| 153 | + }, |
| 154 | + }, |
| 155 | + ], |
| 156 | + dashboards: [ |
| 157 | + { |
| 158 | + name: 'Comprehensive Dashboard', |
| 159 | + url: 'comprehensive-dashboard', |
| 160 | + requiredPrivileges: ['View Comprehensive Dashboard'], |
| 161 | + icon: 'fa fa-th-large', |
| 162 | + default: true, |
| 163 | + order: 1, |
| 164 | + displayName: 'Comprehensive View', |
| 165 | + description: 'A dashboard with all possible controls and features', |
| 166 | + config: { |
| 167 | + refreshInterval: 60, |
| 168 | + layout: 'grid', |
| 169 | + maxItems: 10, |
| 170 | + }, |
| 171 | + }, |
| 172 | + ], |
| 173 | +}; |
| 174 | + |
| 175 | +// Helper function to generate large config |
| 176 | +function generateLargeDashboards(count: number) { |
| 177 | + const dashboards = []; |
| 178 | + const icons = [ |
| 179 | + 'fa fa-user', |
| 180 | + 'fa fa-heartbeat', |
| 181 | + 'fa fa-hospital', |
| 182 | + 'fa fa-medkit', |
| 183 | + ]; |
| 184 | + |
| 185 | + for (let i = 0; i < count; i++) { |
| 186 | + dashboards.push({ |
| 187 | + name: `Dashboard ${i}`, |
| 188 | + url: `dashboard-${i}`, |
| 189 | + requiredPrivileges: [`View Dashboard ${i}`], |
| 190 | + icon: icons[i % icons.length], |
| 191 | + default: i === 0, // First one is default |
| 192 | + }); |
| 193 | + } |
| 194 | + |
| 195 | + return dashboards; |
| 196 | +} |
0 commit comments