fix(badges): return processed data from all badge API functions
CRITICAL FIX (same pattern as event_file fix): - search__event_badge(): Now returns processed_obj_li instead of unprocessed result_li - load_ae_obj_id__event_badge(): Returns processed object after IDB save - load_ae_obj_li__event_badge(): Returns processed list after IDB save - create_ae_obj__event_badge(): Returns processed object after IDB save - update_ae_obj__event_badge(): Returns processed object after IDB save Pattern: All functions now return what was actually saved to IDB (processed data) This ensures consistency between API return values and IDB cached data. TEST IMPROVEMENTS: - Add full_name field to badge mock data (not just full_name_override) - Ensures mock data matches real API structure
This commit is contained in:
@@ -65,6 +65,8 @@ export async function load_ae_obj_id__event_badge({
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
// Return the processed object (matches what was saved to IDB)
|
||||
ae_promises.load__event_badge_obj = processed_obj_li[0];
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
@@ -161,6 +163,8 @@ export async function load_ae_obj_li__event_badge({
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
// Return the processed list (matches what was saved to IDB)
|
||||
ae_promises.load__event_badge_obj_li = processed_obj_li;
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
@@ -245,6 +249,8 @@ export async function create_ae_obj__event_badge({
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
// Return the processed object (matches what was saved to IDB)
|
||||
return processed_obj_li[0];
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -336,6 +342,8 @@ export async function update_ae_obj__event_badge({
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
// Return the processed object (matches what was saved to IDB)
|
||||
return processed_obj_li[0];
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -471,8 +479,9 @@ export async function search__event_badge({
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
return processed_obj_li; // Return processed data (matches saved IDB data)
|
||||
}
|
||||
return result_li;
|
||||
return result_li; // No cache: return raw API results
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -140,6 +140,7 @@ test.describe('Cold-start: Event Badges List (IndexedDB empty)', () => {
|
||||
event_badge_id: event_badge_id,
|
||||
event_id: event_id,
|
||||
event_badge_template_id: 'jgfixEpYp1B', // Per README test data
|
||||
full_name: 'Scott Idem', // Computed from given_name + family_name
|
||||
full_name_override: 'Scott Idem',
|
||||
given_name: 'Scott',
|
||||
family_name: 'Idem',
|
||||
|
||||
@@ -78,6 +78,7 @@ test.describe('Badge Data Integrity & Field Mapping', () => {
|
||||
event_badge_id: event_badge_id,
|
||||
event_id: event_id,
|
||||
event_badge_template_id: event_badge_template_id,
|
||||
full_name: 'Jane Smith', // Computed from given_name + family_name
|
||||
full_name_override: 'Jane Smith',
|
||||
given_name: 'Jane',
|
||||
family_name: 'Smith',
|
||||
|
||||
Reference in New Issue
Block a user