From 8173db0dddf18e7e8ed629f7b4597e2fb737c258 Mon Sep 17 00:00:00 2001 From: Maria Vatasoiu Date: Tue, 26 Nov 2024 14:28:33 +0100 Subject: [PATCH] fix(form): showing of field value in case of calculated questions --- .../form/addon/components/cf-field-value.hbs | 2 +- .../components/cf-field-value-test.js | 17 +++++++++++++++++ .../components/cf-field/input/table-test.js | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/form/addon/components/cf-field-value.hbs b/packages/form/addon/components/cf-field-value.hbs index 1e18dc0bc..fee2d9dc0 100644 --- a/packages/form/addon/components/cf-field-value.hbs +++ b/packages/form/addon/components/cf-field-value.hbs @@ -24,5 +24,5 @@ {{else if (and @field.answer.value @field.question.useNumberSeparatorWidget)}} {{format-number @field.answer.value maximumFractionDigits=20}} {{else}} - {{@field.answer.value}} + {{@field.value}} {{/if}} \ No newline at end of file diff --git a/packages/form/tests/integration/components/cf-field-value-test.js b/packages/form/tests/integration/components/cf-field-value-test.js index c142ca6fe..23a4daf8f 100644 --- a/packages/form/tests/integration/components/cf-field-value-test.js +++ b/packages/form/tests/integration/components/cf-field-value-test.js @@ -106,6 +106,7 @@ module("Integration | Component | cf-field-value", function (hooks) { answer: { value: "foo", }, + value: "foo", }; await render(hbs``); @@ -113,6 +114,22 @@ module("Integration | Component | cf-field-value", function (hooks) { assert.dom(this.element).hasText("foo"); }); + test("it renders calculated float questions", async function (assert) { + this.field = { + questionType: "CalculatedFloatQuestion", + question: { + raw: { + __typename: "CalculatedFloatQuestion", + }, + }, + value: 1111111.111111, + }; + + await render(hbs``); + + assert.dom(this.element).hasText("1111111.111111"); + }); + test("it renders file questions", async function (assert) { const file = this.server.create("file"); diff --git a/packages/form/tests/integration/components/cf-field/input/table-test.js b/packages/form/tests/integration/components/cf-field/input/table-test.js index 8cf32f3a2..cc265a55e 100644 --- a/packages/form/tests/integration/components/cf-field/input/table-test.js +++ b/packages/form/tests/integration/components/cf-field/input/table-test.js @@ -23,6 +23,7 @@ module("Integration | Component | cf-field/input/table", function (hooks) { slug: "first-name", }, answer: { value: "Max" }, + value: "Max", }, { question: { @@ -30,6 +31,7 @@ module("Integration | Component | cf-field/input/table", function (hooks) { slug: "last-name", }, answer: { value: "Muster" }, + value: "Muster", }, ], },