-
Notifications
You must be signed in to change notification settings - Fork 3
fix: remove debug console.log statements from conversionHelpers #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,9 +85,8 @@ export class HouseholdAdapter { | |
| // Convert snake_case to camelCase for internal representation | ||
| const camelKey = key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()); | ||
| householdData[camelKey] = value as any; | ||
| } catch (error) { | ||
| // If entity not found in metadata, still include it but log warning | ||
| console.warn(`Entity "${key}" not found in metadata, including anyway`); | ||
| } catch { | ||
| // If entity not found in metadata, still include it | ||
| const camelKey = key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()); | ||
| householdData[camelKey] = value as any; | ||
| } | ||
|
|
@@ -125,7 +124,6 @@ export class HouseholdAdapter { | |
| } else { | ||
| // If not found in metadata, try snake_case conversion | ||
| const snakeKey = key.replace(/([A-Z])/g, '_$1').toLowerCase(); | ||
| console.warn(`Entity "${key}" not found in metadata, using snake_case "${snakeKey}"`); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue, blocking: Here, too, let's keep the |
||
| household_json[snakeKey] = value as any; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,14 +19,6 @@ export class SimulationAdapter { | |
| * Converts SimulationMetadata from API GET response to Simulation type | ||
| */ | ||
| static fromMetadata(metadata: SimulationMetadata): Simulation { | ||
| console.log('[SimulationAdapter.fromMetadata] RAW API METADATA:', { | ||
| id: metadata.id, | ||
| status: metadata.status, | ||
| hasOutput: !!metadata.output, | ||
| outputType: typeof metadata.output, | ||
| metadataKeys: Object.keys(metadata), | ||
| }); | ||
|
|
||
| if (!metadata.population_id) { | ||
| throw new Error('Simulation metadata missing population_id'); | ||
| } | ||
|
|
@@ -45,13 +37,7 @@ export class SimulationAdapter { | |
| if (metadata.output && typeof metadata.output === 'string') { | ||
| try { | ||
| parsedOutput = JSON.parse(metadata.output); | ||
| console.log('[SimulationAdapter.fromMetadata] Parsed stringified output:', { | ||
| originalType: 'string', | ||
| parsedType: typeof parsedOutput, | ||
| parsedKeys: parsedOutput ? Object.keys(parsedOutput) : [], | ||
| }); | ||
| } catch (error) { | ||
| console.error('[SimulationAdapter.fromMetadata] Failed to parse output:', error); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue, blocking: Let's keep this |
||
| } catch { | ||
| // Keep original value if parsing fails | ||
| parsedOutput = metadata.output; | ||
| } | ||
|
|
@@ -70,14 +56,6 @@ export class SimulationAdapter { | |
| status: metadata.status, | ||
| }; | ||
|
|
||
| console.log('[SimulationAdapter.fromMetadata] TRANSFORMED SIMULATION:', { | ||
| id: simulation.id, | ||
| status: simulation.status, | ||
| hasOutput: !!simulation.output, | ||
| outputType: typeof simulation.output, | ||
| simulationKeys: Object.keys(simulation), | ||
| }); | ||
|
|
||
| return simulation; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,12 +66,9 @@ describe('HouseholdAdapter', () => { | |
| expect(result.householdData.maritalUnits).toEqual(metadata.household_json.marital_units); | ||
| }); | ||
|
|
||
| test('given entity not in metadata then logs warning but includes it anyway', () => { | ||
| test('given entity not in metadata then includes it anyway', () => { | ||
| const result = HouseholdAdapter.fromMetadata(mockHouseholdMetadataWithUnknownEntity); | ||
|
|
||
| expect(console.warn).toHaveBeenCalledWith( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue, non-blocking: Perhaps better to keep this, since we'd be looking to keep the |
||
| 'Entity "unknown_entity" not found in metadata, including anyway' | ||
| ); | ||
| expect(result.householdData).toHaveProperty('unknownEntity'); | ||
| expect(result.householdData.unknownEntity).toEqual( | ||
| // @ts-expect-error | ||
|
|
@@ -179,12 +176,9 @@ describe('HouseholdAdapter', () => { | |
| }); | ||
| }); | ||
|
|
||
| test('given entity not in metadata then toCreationPayload logs warning and uses snake_case', () => { | ||
| test('given entity not in metadata then toCreationPayload uses snake_case', () => { | ||
| const result = HouseholdAdapter.toCreationPayload(mockHouseholdDataWithUnknownEntity, 'uk'); | ||
|
|
||
| expect(console.warn).toHaveBeenCalledWith( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue, non-blocking: Better to keep |
||
| 'Entity "customEntity" not found in metadata, using snake_case "custom_entity"' | ||
| ); | ||
| expect(result.data).toHaveProperty('custom_entity'); | ||
| // @ts-expect-error | ||
| expect(result.data.custom_entity).toEqual(mockHouseholdDataWithUnknownEntity.customEntity); | ||
|
|
@@ -253,7 +247,7 @@ describe('HouseholdAdapter', () => { | |
| const result = HouseholdAdapter.fromMetadata(metadata as any); | ||
|
|
||
| expect(result.householdData.people).toBeDefined(); | ||
| expect(console.warn).toHaveBeenCalled(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue, non-blocking: Here, too |
||
| expect(result.householdData.taxUnits).toBeDefined(); | ||
| }); | ||
|
|
||
| test('given complex nested snake_case then converts correctly to camelCase', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue, blocking: We do want
console.warnstatements. We'll use these with RUM monitoring down the road to diagnose bugs.