Skip to content

Commit

Permalink
Merge branch 'master' into EAR-2311-moving-page-repeating-section-int…
Browse files Browse the repository at this point in the history
…o-list-collector-folder
  • Loading branch information
sudeepkunhis authored May 30, 2024
2 parents a4ee676 + 5b54c44 commit 6e3bf65
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cloudbuild-author-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ steps:
exit $(( 1 - $result ))
id: unit_tests
entrypoint: /bin/ash
timeout: 1200s
timeout: 1800s
options:
machineType: E2_HIGHCPU_8
1 change: 1 addition & 0 deletions eq-author-api/constants/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const THEME_SHORT_NAMES = [
"ukhsa-ons",
"desnz",
"desnz-ni",
"ons-nhs",
];

module.exports = { THEME_SHORT_NAMES };
13 changes: 13 additions & 0 deletions eq-author-api/db/baseQuestionnaireSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,20 @@ const baseQuestionnaireFields = {
locked,
};

const saveQuestionnaireFields = {
id,
isPublic,
title,
type,
shortTitle,
publishStatus,
introduction,
editors,
locked,
};

module.exports = {
baseQuestionnaireFields,
...baseQuestionnaireFields,
saveQuestionnaireFields,
};
18 changes: 14 additions & 4 deletions eq-author-api/db/datastore/datastore-firestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const { logger } = require("../../utils/logger");
const { pick } = require("lodash/fp");
const { omit } = require("lodash");
const { removeEmpty } = require("../../utils/removeEmpty");
const { baseQuestionnaireFields } = require("../baseQuestionnaireSchema");
const {
baseQuestionnaireFields,
saveQuestionnaireFields,
} = require("../baseQuestionnaireSchema");
const {
questionnaireCreationEvent,
historyCreationForImport,
Expand Down Expand Up @@ -32,6 +35,14 @@ const BASE_FIELDS = [

const justListFields = pick(BASE_FIELDS);

const SAVE_FIELDS = [
...Object.keys(saveQuestionnaireFields),
"updatedAt",
"history",
];

const justListSaveFields = pick(SAVE_FIELDS);

const saveSections = (parentDoc, sections) =>
Promise.all(
sections.map((section, position) =>
Expand Down Expand Up @@ -271,8 +282,7 @@ const saveQuestionnaire = async (changedQuestionnaire) => {
"Unable to save questionnaire; cannot find required field: ID (from saveQuestionnaire)"
);
}
const createdAt = new Date();
const updatedAt = createdAt;
const updatedAt = new Date();

const originalQuestionnaire = await getQuestionnaire(id);

Expand All @@ -297,7 +307,7 @@ const saveQuestionnaire = async (changedQuestionnaire) => {

const baseDoc = db.collection("questionnaires").doc(id);
await baseDoc.update({
...justListFields(updatedQuestionnaire),
...justListSaveFields(updatedQuestionnaire),
updatedAt,
});

Expand Down
10 changes: 10 additions & 0 deletions eq-author-api/db/datastore/datastore-firestore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ describe("Firestore Datastore", () => {
});
expect(updatedAt !== savedQuestionnaire.updatedAt).toBeTruthy();
});

it("Should not update the 'createdAt' property", async () => {
const createdAt = questionnaire.createdAt;
const savedQuestionnaire = await saveQuestionnaire({
id: "123",
title: "Updated questionnaire title",
...questionnaire,
});
expect(createdAt === savedQuestionnaire.createdAt).toBeTruthy();
});
});

describe("Getting a list of questionnaires", () => {
Expand Down
6 changes: 6 additions & 0 deletions eq-author/src/constants/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ const THEMES = [
title: "Office of Rail and Road",
description: "Header includes the Office of Rail and Road logo",
},
{
id: "ons-nhs",
title: "NHS England",
description:
"Header includes the logos for NHS England and the Office for National Statistics but does not include the links for 'Help', 'My account' or 'Sign out' ",
},
];

export default THEMES;

0 comments on commit 6e3bf65

Please sign in to comment.