From 1122735b873bd7999aa529bed83c49bb63afc4b8 Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Fri, 15 Dec 2023 15:37:39 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20returning=20mirage?= =?UTF-8?q?=20data=20from=20client=20daemon=20mock=20(#2050)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/client-daemon-search.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/api/addon-test-support/handlers/client-daemon-search.js b/addons/api/addon-test-support/handlers/client-daemon-search.js index baa34e577..6635fcb70 100644 --- a/addons/api/addon-test-support/handlers/client-daemon-search.js +++ b/addons/api/addon-test-support/handlers/client-daemon-search.js @@ -47,10 +47,16 @@ export default function setupStubs(hooks) { .withArgs('searchClientDaemon') .onCall(i) .returns({ - [type]: this.server.db[type].map((model) => ({ - ...model, - scope: this.server.db.scopes.find(model.scopeId), - })), + [type]: this.server.schema[type]?.all().models.map((model) => { + // Use internal serializer to serialize the model correctly + // according to our mirage serializers + const modelData = + this.server.serializerOrRegistry.serialize(model); + + // Serialize the data properly to standard JSON as that is what + // we're expecting from the client daemon response + return JSON.parse(JSON.stringify(modelData)); + }), }); }); };