Skip to content

Commit da37016

Browse files
authored
Merge pull request #208 from ONSdigital/EAR-2291-update-content-for-calculated-summary-question
EAR 2291 update content for calculated summary question
2 parents f8e3d0d + 4853762 commit da37016

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

src/eq_schema/schema/Block/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ class Block {
119119
this.page_title = processPipe(ctx)(page.pageDescription);
120120
}
121121
if (page.pageType === "CalculatedSummaryPage") {
122-
this.title = processPipe(ctx)(page.title);
122+
this.title = processPipe(ctx)(page.title).endsWith(".")
123+
? `${processPipe(ctx)(page.title)} Is this correct?`
124+
: `${processPipe(ctx)(page.title)}. Is this correct?`;
125+
123126
this.page_title =
124127
processPipe(ctx)(page.pageDescription) || processPipe(ctx)(page.title);
125128

src/eq_schema/schema/Block/index.test.js

+47-4
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe("Block", () => {
200200
title: "Bye",
201201
},
202202
id: "1",
203-
title: "Hi is your total %(total)s",
203+
title: "Hi is your total %(total)s. Is this correct?",
204204
type: "CalculatedSummary",
205205
});
206206
});
@@ -728,7 +728,7 @@ describe("Block", () => {
728728
id: "summary-page1",
729729
type: "CalculatedSummary",
730730
page_title: "Summary page1",
731-
title: "Summary1",
731+
title: "Summary1. Is this correct?",
732732
calculation: {
733733
operation: {
734734
"+": [
@@ -754,6 +754,49 @@ describe("Block", () => {
754754
});
755755
});
756756

757+
it("Should not add a full stop after the title if it has been added by the user", () => {
758+
const calculatedPageGraphql = {
759+
totalTitle: "<p>Summary title1</p>",
760+
answers: [
761+
{
762+
label: "<p>Summary title1</p>",
763+
type: "Number",
764+
id: "9d2b3354-9751-4be4-9523-1f36345c3069",
765+
validation: {},
766+
properties: {},
767+
},
768+
],
769+
title: "<p>Summary1.</p>",
770+
type: "Number",
771+
pageType: "CalculatedSummaryPage",
772+
summaryAnswers: ["num-1"],
773+
pageDescription: "Summary page1",
774+
alias: null,
775+
id: "summary-page1",
776+
listId: undefined,
777+
};
778+
779+
const block = new Block(calculatedPageGraphql, null, ctx);
780+
781+
expect(block).toMatchObject({
782+
id: "summary-page1",
783+
type: "CalculatedSummary",
784+
page_title: "Summary page1",
785+
title: "Summary1. Is this correct?",
786+
calculation: {
787+
operation: {
788+
"+": [
789+
{
790+
identifier: "answernum-1",
791+
source: "answers",
792+
},
793+
],
794+
},
795+
title: "Summary title1",
796+
},
797+
});
798+
});
799+
757800
it("should build a calculated summary page without skip condition when it contains a normal answer", () => {
758801
const calculatedPageGraphql = {
759802
totalTitle: "<p>Summary title1</p>",
@@ -782,7 +825,7 @@ describe("Block", () => {
782825
id: "summary-page1",
783826
type: "CalculatedSummary",
784827
page_title: "Summary page1",
785-
title: "Summary1",
828+
title: "Summary1. Is this correct?",
786829
calculation: {
787830
operation: {
788831
"+": [
@@ -829,7 +872,7 @@ describe("Block", () => {
829872
id: "grand-summary-1",
830873
type: "GrandCalculatedSummary",
831874
page_title: "Grand summary",
832-
title: "Grand summary",
875+
title: "Grand summary. Is this correct?",
833876
calculation: {
834877
operation: {
835878
"+": [

0 commit comments

Comments
 (0)