Skip to content

Commit

Permalink
Merge pull request #3128 from ONSdigital/EAR-2344-Console-Error-House…
Browse files Browse the repository at this point in the history
…keeping

EAR 2344 Console Error Housekeeping
  • Loading branch information
sanjeevz3009 authored Oct 3, 2024
2 parents 46a0ad5 + 0093c73 commit 3481592
Show file tree
Hide file tree
Showing 29 changed files with 144 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ const CollapsiblesContent = styled.div`
padding: 0.2em 0 0.2em 1em;
`;

const DummyLink = styled.text`
const DummyLink = styled.span`
color: ${colors.blue};
text-decoration: underline;
`;

const MissingText = styled.text`
const MissingText = styled.span`
font-weight: bold;
background-color: ${colors.errorSecondary};
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ exports[`Answer Editor should render Checkbox 1`] = `
"label": "",
},
],
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -240,6 +243,9 @@ exports[`Answer Editor should render Currency 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -371,6 +377,9 @@ exports[`Answer Editor should render Date 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -504,6 +513,9 @@ exports[`Answer Editor should render DateRange 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -633,6 +645,9 @@ exports[`Answer Editor should render Duration 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {
"unit": "YearsMonths",
},
Expand Down Expand Up @@ -775,6 +790,9 @@ exports[`Answer Editor should render Mutually Exclusive 1`] = `
"label": "",
},
],
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -905,6 +923,9 @@ exports[`Answer Editor should render Number 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -1036,6 +1057,9 @@ exports[`Answer Editor should render Percentage 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -1174,6 +1198,9 @@ exports[`Answer Editor should render Radio 1`] = `
"label": "",
},
],
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -1313,6 +1340,9 @@ exports[`Answer Editor should render Select 1`] = `
"label": "",
},
],
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -1444,6 +1474,9 @@ exports[`Answer Editor should render TextArea 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -1574,6 +1607,9 @@ exports[`Answer Editor should render TextField 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": "",
Expand Down Expand Up @@ -1705,6 +1741,9 @@ exports[`Answer Editor should render Unit 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "1",
},
"properties": Object {
"unit": "Centimetres",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class AnswerEditor extends React.Component {
if (type === DATE_RANGE) {
return <DateRange {...this.props} />;
}
// Only option left is Date as validation done in prop types

return (
<DateSingle
{...this.props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe("Answer Editor", () => {
mockAnswer = {
id: "1",
title: "",
page: { id: "1" },
description: "",
type: TEXTFIELD,
guidance: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const StatelessAdditionalInfo = ({
StatelessAdditionalInfo.propTypes = {
onChange: PropTypes.func.isRequired,
onUpdate: PropTypes.func.isRequired,
fetchAnswers: PropTypes.func.isRequired,
fetchAnswers: PropTypes.func,
page: propType(pageFragment).isRequired,
onChangeUpdate: PropTypes.func.isRequired,
option: PropTypes.string.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ exports[`DateRange should render 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "Page 1",
},
"properties": Object {
"required": false,
},
Expand Down Expand Up @@ -42,6 +45,9 @@ exports[`DateRange should render 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "Page 1",
},
"properties": Object {
"required": false,
},
Expand Down Expand Up @@ -71,6 +77,9 @@ exports[`DateRange should render 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "Page 1",
},
"properties": Object {
"required": false,
},
Expand All @@ -94,6 +103,9 @@ exports[`DateRange should render 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "Page 1",
},
"properties": Object {
"required": false,
},
Expand All @@ -118,6 +130,9 @@ exports[`DateRange should render 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "Page 1",
},
"properties": Object {
"required": false,
},
Expand All @@ -140,6 +155,9 @@ exports[`DateRange should render 1`] = `
"guidance": "",
"id": "1",
"label": "",
"page": Object {
"id": "Page 1",
},
"properties": Object {
"required": false,
},
Expand Down
3 changes: 3 additions & 0 deletions eq-author/src/App/page/Design/answers/DateRange/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ describe("DateRange", () => {
id: "1",
label: "",
type: "DateRange",
page: {
id: "Page 1",
},
description: "test",
guidance: "",
secondaryLabel: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exports[`Date should render 1`] = `
"mutuallyExclusive": false,
},
],
"page": Object {
"id": "Page 1",
},
"properties": Object {},
"qCode": "",
"secondaryLabel": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ describe("Date", () => {
answer = {
id: "ansID1",
title: "Date title",
page: {
id: "Page 1",
},
description: "date description",
label: "",
type: "Date",
Expand Down
5 changes: 3 additions & 2 deletions eq-author/src/App/page/Logic/BinaryExpressionEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ export const UnwrappedBinaryExpressionEditor = ({
const MetadataEditor =
METADATA_TYPE_TO_RIGHT_EDITOR[expression?.left?.metadataType];

const shouldRenderEditor =
const shouldRenderEditor = Boolean(
(AnswerEditor && !expression.left.reason && !answerPickerError) ||
MetadataEditor;
MetadataEditor
);

const isLastExpression =
expressionIndex === expressionGroup.expressions.length - 1;
Expand Down
3 changes: 3 additions & 0 deletions eq-author/src/App/page/Preview/QuestionPagePreview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ describe("QuestionPagePreview", () => {
additionalInfoLabel: "<p>Additional Info Label</p>",
additionalInfoContent: "<p>Additional Info Content</p>",
additionalInfoEnabled: true,
confirmation: {
id: "confirmation-1",
},
validationErrorInfo: { totalCount: 0, errors: [] },
answers: [{ id: "1", type: TEXTFIELD }],
comments: [],
Expand Down
3 changes: 3 additions & 0 deletions eq-author/src/App/page/Preview/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ describe("page previews", () => {
additionalInfoLabel: "<p>Additional Info Label</p>",
additionalInfoContent: "<p>Additional Info Content</p>",
additionalInfoEnabled: true,
confirmation: {
id: "confirmation-1",
},
validationErrorInfo: [],
comments: [],
answers: [],
Expand Down
6 changes: 3 additions & 3 deletions eq-author/src/App/qcodes/QCodesTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const Row = memo((props) => {
data-test={`${id}${secondary ? "-secondary" : ""}${
listAnswerType === DRIVING ? "-driving" : ""
}${listAnswerType === ANOTHER ? "-another" : ""}-test-input`}
value={qCode}
value={qCode || ""} // Ensure the input always has a value (empty string if qCode is null or undefined)
onChange={(e) => setQcode(e.value)}
onBlur={() => handleBlur(qCode)}
hasError={Boolean(errorMessage)}
Expand Down Expand Up @@ -271,7 +271,7 @@ export const QCodeTable = () => {
(dataVersion === "3" || item.type !== "CheckboxOption")
) {
return (
<>
<React.Fragment key={`${item.id}-${index}`}>
<Row
key={`${item.id}-${index}`}
dataVersion={dataVersion}
Expand All @@ -284,7 +284,7 @@ export const QCodeTable = () => {
{...item.additionalAnswer}
errorMessage={getErrorMessage(item.additionalAnswer.qCode)}
/>
</>
</React.Fragment>
);
} else {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("Editor", () => {
displayName: "My question",
answers: [],
},
pageDescription: "Page description 1",
positive: {
id: "1",
label: "Positive label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exports[`Editor Editor Component should autoFocus the title when there is not on
marginless={true}
onChange={[MockFunction]}
onUpdate={[MockFunction]}
pageDescription="Page description 1"
/>
<Editor__HorizontalRule />
<Editor__OptionsWrapper>
Expand Down Expand Up @@ -108,6 +109,7 @@ exports[`Editor Editor Component should render 1`] = `
marginless={true}
onChange={[MockFunction]}
onUpdate={[MockFunction]}
pageDescription="Page description 1"
/>
<Editor__HorizontalRule />
<Editor__OptionsWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports[`QuestionConfirmationRoute should render 1`] = `
"displayName": "My question",
"id": "1",
},
"pageDescription": "Page description 1",
"positive": Object {
"description": "Positive description",
"id": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe("QuestionConfirmationRoute", () => {
id: "1",
displayName: "My first displayname",
title: "My first confirmation",
pageDescription: "Page description 1",
qCode: "",
page: {
id: "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe("Question Confirmation Preview", () => {
id: "1",
displayName: "Hello world",
title: "<p>Hello world</p>",
pageDescription: "Page description 1",
qCode: "",
positive: {
id: "1",
Expand Down
Loading

0 comments on commit 3481592

Please sign in to comment.