diff --git a/src/eq_schema/schema/Block/index.js b/src/eq_schema/schema/Block/index.js index 383056c9..5e4e7ab0 100644 --- a/src/eq_schema/schema/Block/index.js +++ b/src/eq_schema/schema/Block/index.js @@ -119,7 +119,10 @@ class Block { this.page_title = processPipe(ctx)(page.pageDescription); } if (page.pageType === "CalculatedSummaryPage") { - this.title = processPipe(ctx)(page.title); + this.title = processPipe(ctx)(page.title).endsWith(".") + ? `${processPipe(ctx)(page.title)} Is this correct?` + : `${processPipe(ctx)(page.title)}. Is this correct?`; + this.page_title = processPipe(ctx)(page.pageDescription) || processPipe(ctx)(page.title); diff --git a/src/eq_schema/schema/Block/index.test.js b/src/eq_schema/schema/Block/index.test.js index fd854761..55f3bf46 100644 --- a/src/eq_schema/schema/Block/index.test.js +++ b/src/eq_schema/schema/Block/index.test.js @@ -200,7 +200,7 @@ describe("Block", () => { title: "Bye", }, id: "1", - title: "Hi is your total %(total)s", + title: "Hi is your total %(total)s. Is this correct?", type: "CalculatedSummary", }); }); @@ -728,7 +728,7 @@ describe("Block", () => { id: "summary-page1", type: "CalculatedSummary", page_title: "Summary page1", - title: "Summary1", + title: "Summary1. Is this correct?", calculation: { operation: { "+": [ @@ -754,6 +754,49 @@ describe("Block", () => { }); }); + it("Should not add a full stop after the title if it has been added by the user", () => { + const calculatedPageGraphql = { + totalTitle: "
Summary title1
", + answers: [ + { + label: "Summary title1
", + type: "Number", + id: "9d2b3354-9751-4be4-9523-1f36345c3069", + validation: {}, + properties: {}, + }, + ], + title: "Summary1.
", + type: "Number", + pageType: "CalculatedSummaryPage", + summaryAnswers: ["num-1"], + pageDescription: "Summary page1", + alias: null, + id: "summary-page1", + listId: undefined, + }; + + const block = new Block(calculatedPageGraphql, null, ctx); + + expect(block).toMatchObject({ + id: "summary-page1", + type: "CalculatedSummary", + page_title: "Summary page1", + title: "Summary1. Is this correct?", + calculation: { + operation: { + "+": [ + { + identifier: "answernum-1", + source: "answers", + }, + ], + }, + title: "Summary title1", + }, + }); + }); + it("should build a calculated summary page without skip condition when it contains a normal answer", () => { const calculatedPageGraphql = { totalTitle: "Summary title1
", @@ -782,7 +825,7 @@ describe("Block", () => { id: "summary-page1", type: "CalculatedSummary", page_title: "Summary page1", - title: "Summary1", + title: "Summary1. Is this correct?", calculation: { operation: { "+": [ @@ -829,7 +872,7 @@ describe("Block", () => { id: "grand-summary-1", type: "GrandCalculatedSummary", page_title: "Grand summary", - title: "Grand summary", + title: "Grand summary. Is this correct?", calculation: { operation: { "+": [