Skip to content

Commit

Permalink
Merge pull request #208 from ONSdigital/EAR-2291-update-content-for-c…
Browse files Browse the repository at this point in the history
…alculated-summary-question

EAR 2291 update content for calculated summary question
  • Loading branch information
Farhanam76 authored Feb 22, 2024
2 parents f8e3d0d + 4853762 commit da37016
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/eq_schema/schema/Block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
51 changes: 47 additions & 4 deletions src/eq_schema/schema/Block/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
});
Expand Down Expand Up @@ -728,7 +728,7 @@ describe("Block", () => {
id: "summary-page1",
type: "CalculatedSummary",
page_title: "Summary page1",
title: "Summary1",
title: "Summary1. Is this correct?",
calculation: {
operation: {
"+": [
Expand All @@ -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: "<p>Summary title1</p>",
answers: [
{
label: "<p>Summary title1</p>",
type: "Number",
id: "9d2b3354-9751-4be4-9523-1f36345c3069",
validation: {},
properties: {},
},
],
title: "<p>Summary1.</p>",
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: "<p>Summary title1</p>",
Expand Down Expand Up @@ -782,7 +825,7 @@ describe("Block", () => {
id: "summary-page1",
type: "CalculatedSummary",
page_title: "Summary page1",
title: "Summary1",
title: "Summary1. Is this correct?",
calculation: {
operation: {
"+": [
Expand Down Expand Up @@ -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: {
"+": [
Expand Down

0 comments on commit da37016

Please sign in to comment.