From a3b01c2dd24ccf1d2a4fa8c89df7c4c861fc52ac Mon Sep 17 00:00:00 2001 From: 0xCmdrKeen <98132670+0xCmdrKeen@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:58:51 -0700 Subject: Fix bugs in data import from Ferdium app (#82) * Fixed misspelled field names * Fixed broken tests * Ensure service.settings and workspace.data are not JSON encoded twice * Accept both snake_case and camelCase input files * More tests for JSON fields * Add filename to assertion messages --- app/Controllers/Http/Dashboard/TransferController.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/Http/Dashboard/TransferController.ts b/app/Controllers/Http/Dashboard/TransferController.ts index a005c1b..b113e50 100644 --- a/app/Controllers/Http/Dashboard/TransferController.ts +++ b/app/Controllers/Http/Dashboard/TransferController.ts @@ -68,12 +68,16 @@ export default class TransferController { userId: auth.user?.id, serviceId, name: service.name, - recipeId: service.recipe_id, - settings: JSON.stringify(service.settings), + recipeId: service.recipe_id || service.recipeId, + settings: + typeof service.settings === 'string' + ? service.settings + : JSON.stringify(service.settings), }); // @ts-expect-error Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}' - serviceIdTranslation[service.service_id] = serviceId; + serviceIdTranslation[service.service_id || service.serviceId] = + serviceId; } } catch (error) { // eslint-disable-next-line no-console @@ -109,7 +113,10 @@ export default class TransferController { name: workspace.name, order: workspace.order, services: JSON.stringify(services), - data: JSON.stringify(workspace.data), + data: + typeof workspace.data === 'string' + ? workspace.data + : JSON.stringify(workspace.data), }); } } catch (error) { -- cgit v1.2.3-54-g00ecf