Skip to content

Commit

Permalink
Merge pull request #1563 from opengovsg/release-5.4.1
Browse files Browse the repository at this point in the history
build: merge Release 5.4.1 into master
  • Loading branch information
liangyuanruo authored Apr 6, 2021
2 parents 3006bdc + 7fb57ad commit 4556b00
Show file tree
Hide file tree
Showing 81 changed files with 3,042 additions and 3,851 deletions.
4 changes: 3 additions & 1 deletion .github/.mergify.yml → .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pull_request_rules:
- name: Merge dependency upgrades when tests pass
- name: Approve and merge non-major dependency upgrades
conditions:
- 'author=dependabot[bot]'
- '#check-failure=0'
- 'title~=bump [^\s]+ from ([\d]+)\..+ to \1\.'
actions:
review:
type: APPROVE
merge:
method: squash
112 changes: 97 additions & 15 deletions CHANGELOG.md

Large diffs are not rendered by default.

770 changes: 461 additions & 309 deletions package-lock.json

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FormSG",
"description": "Form Manager for Government",
"version": "5.3.0",
"version": "5.4.1",
"homepage": "https://form.gov.sg",
"authors": [
"FormSG <[email protected]>"
Expand Down Expand Up @@ -64,7 +64,7 @@
"@opengovsg/myinfo-gov-client": "=4.0.0-beta.0",
"@opengovsg/ng-file-upload": "^12.2.15",
"@opengovsg/spcp-auth-client": "^1.4.4",
"@sentry/browser": "^6.2.2",
"@sentry/browser": "^6.2.3",
"@sentry/integrations": "^6.2.3",
"@stablelib/base64": "^1.0.0",
"JSONStream": "^1.3.5",
Expand All @@ -84,7 +84,7 @@
"angular-ui-bootstrap": "~2.5.6",
"angular-ui-router": "~1.0.29",
"aws-info": "^1.2.0",
"aws-sdk": "^2.866.0",
"aws-sdk": "^2.874.0",
"axios": "^0.21.1",
"bcrypt": "^5.0.1",
"bluebird": "^3.5.2",
Expand All @@ -95,7 +95,7 @@
"busboy": "^0.3.1",
"celebrate": "^14.0.0",
"compression": "~1.7.2",
"connect-mongo": "^4.4.0",
"connect-mongo": "^4.4.1",
"convict": "^6.0.1",
"convict-format-with-validator": "^6.0.1",
"cookie-parser": "~1.4.0",
Expand Down Expand Up @@ -147,7 +147,7 @@
"toastr": "^2.1.4",
"triple-beam": "^1.3.0",
"tweetnacl": "^1.0.1",
"twilio": "^3.58.0",
"twilio": "^3.59.0",
"ui-select": "^0.19.8",
"uid-generator": "^2.0.0",
"uuid": "^8.3.2",
Expand All @@ -158,9 +158,9 @@
"winston-cloudwatch": "^2.5.0"
},
"devDependencies": {
"@babel/core": "^7.13.10",
"@babel/core": "^7.13.13",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@babel/preset-env": "^7.13.12",
"@opengovsg/mockpass": "^2.6.8",
"@types/bcrypt": "^3.0.0",
"@types/bluebird": "^3.5.33",
Expand All @@ -178,11 +178,11 @@
"@types/has-ansi": "^3.0.0",
"@types/helmet": "4.0.0",
"@types/ip": "^1.1.0",
"@types/jest": "^26.0.21",
"@types/jest": "^26.0.22",
"@types/json-stringify-safe": "^5.0.0",
"@types/mongodb": "^3.6.10",
"@types/mongodb-uri": "^0.9.0",
"@types/node": "^14.14.35",
"@types/node": "^14.14.37",
"@types/nodemailer": "^6.4.1",
"@types/nodemailer-direct-transport": "^1.0.31",
"@types/opossum": "^4.1.1",
Expand All @@ -194,8 +194,8 @@
"@types/uid-generator": "^2.0.2",
"@types/uuid": "^8.3.0",
"@types/validator": "^13.1.3",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"auto-changelog": "^2.2.1",
"axios-mock-adapter": "^1.19.0",
"babel-loader": "^8.2.2",
Expand All @@ -205,8 +205,9 @@
"coveralls": "^3.1.0",
"css-loader": "^2.1.1",
"csv-parse": "^4.15.3",
"date-fns": "^2.19.0",
"env-cmd": "^10.1.0",
"eslint": "^7.22.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-angular": "^4.0.1",
"eslint-plugin-import": "^2.22.1",
Expand All @@ -218,7 +219,7 @@
"google-fonts-plugin": "4.1.0",
"html-loader": "~0.5.5",
"htmlhint": "^0.14.2",
"husky": "^5.1.3",
"husky": "^5.2.0",
"jasmine": "^3.7.0",
"jasmine-core": "^3.7.1",
"jasmine-sinon": "^0.4.0",
Expand All @@ -229,7 +230,7 @@
"lint-staged": "^10.5.4",
"maildev": "^1.1.0",
"mini-css-extract-plugin": "^0.5.0",
"mockdate": "^3.0.3",
"mockdate": "^3.0.5",
"mockingoose": "^2.13.2",
"mongodb-memory-server-core": "^6.9.6",
"ngrok": "^3.4.1",
Expand All @@ -238,15 +239,15 @@
"proxyquire": "^2.1.3",
"regenerator": "^0.14.4",
"rimraf": "^3.0.2",
"sinon": "^9.2.4",
"sinon": "^10.0.0",
"stylelint": "^13.12.0",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^21.0.0",
"stylelint-prettier": "^1.2.0",
"supertest": "^6.1.3",
"supertest-session": "^4.1.0",
"terser-webpack-plugin": "^1.2.3",
"testcafe": "^1.12.0",
"testcafe": "^1.13.0",
"ts-jest": "^26.5.4",
"ts-loader": "^7.0.5",
"ts-mock-imports": "^1.3.3",
Expand Down
23 changes: 0 additions & 23 deletions src/app/controllers/admin-forms.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,6 @@ function makeModule(connection) {
}
return next()
},
/**
* Submit feedback when previewing forms
* Preview feedback is not stored
* @param {Object} req - Express request object
* @param {Object} res - Express response object
*/
passThroughFeedback: function (req, res) {
if (
!req.params ||
!('formId' in req.params) ||
!req.body ||
!('rating' in req.body) ||
!('comment' in req.body)
) {
return res
.status(StatusCodes.BAD_REQUEST)
.json({ message: 'Form feedback data not passed in' })
} else {
return res
.status(StatusCodes.OK)
.json({ message: 'Successfully received feedback' })
}
},
/**
* Pass through save new Submission object to db
* Simply create and pass forward a submissions object w/o saving to db
Expand Down
3 changes: 2 additions & 1 deletion src/app/controllers/frontend.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module.exports.datalayer = function (req, res) {
gtag('js', new Date());
gtag('config', '<%= GATrackingID%>', {
'send_page_view': false,
'app_name': '<%= appName%>'
'app_name': '<%= appName%>',
'cookie_flags': 'samesite=none;secure',
});
`
try {
Expand Down
118 changes: 0 additions & 118 deletions src/app/modules/analytics/__tests__/analytics.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,124 +11,6 @@ describe('analytics.controller', () => {
const MOCK_REQ = expressHandler.mockRequest()
afterEach(() => jest.clearAllMocks())

describe('handleGetUserCount', () => {
it('should return 200 with number of users on success', async () => {
// Arrange
const mockRes = expressHandler.mockResponse()
const mockUserCount = 21
const getUserSpy = jest
.spyOn(AnalyticsService, 'getUserCount')
.mockReturnValueOnce(TE.of(mockUserCount))

// Act
await AnalyticsController.handleGetUserCount(MOCK_REQ, mockRes, jest.fn())

// Assert
expect(getUserSpy).toHaveBeenCalledTimes(1)
expect(mockRes.status).not.toHaveBeenCalled()
expect(mockRes.json).toHaveBeenCalledWith(mockUserCount)
})

it('should return 500 when error occurs whilst retrieving user count', async () => {
const mockRes = expressHandler.mockResponse()
const getUserSpy = jest
.spyOn(AnalyticsService, 'getUserCount')
.mockReturnValueOnce(TE.fromEither(E.left(new DatabaseError())))

// Act
await AnalyticsController.handleGetUserCount(MOCK_REQ, mockRes, jest.fn())

// Assert
expect(getUserSpy).toHaveBeenCalledTimes(1)
expect(mockRes.status).toHaveBeenCalledWith(500)
expect(mockRes.json).toHaveBeenCalledWith(
'Unable to retrieve number of users from the database',
)
})
})

describe('handleGetSubmissionCount', () => {
it('should return 200 with number of submissions on success', async () => {
// Arrange
const mockSubmissionCount = 1234
const mockRes = expressHandler.mockResponse()
const getSubsSpy = jest
.spyOn(AnalyticsService, 'getSubmissionCount')
.mockReturnValueOnce(TE.of(mockSubmissionCount))

// Act
await AnalyticsController.handleGetSubmissionCount(
MOCK_REQ,
mockRes,
jest.fn(),
)

// Assert
expect(getSubsSpy).toHaveBeenCalledTimes(1)
expect(mockRes.status).not.toHaveBeenCalled()
expect(mockRes.json).toHaveBeenCalledWith(mockSubmissionCount)
})

it('should return 500 when error occurs whilst retrieving submission count', async () => {
// Arrange
const mockRes = expressHandler.mockResponse()
const getSubsSpy = jest
.spyOn(AnalyticsService, 'getSubmissionCount')
.mockReturnValueOnce(TE.fromEither(E.left(new DatabaseError())))

// Act
await AnalyticsController.handleGetSubmissionCount(
MOCK_REQ,
mockRes,
jest.fn(),
)

// Assert
expect(getSubsSpy).toHaveBeenCalledTimes(1)
expect(mockRes.status).toHaveBeenCalledWith(500)
expect(mockRes.json).toHaveBeenCalledWith(
'Unable to retrieve number of submissions from the database',
)
})
})

describe('handleGetFormCount', () => {
it('should return 200 with number of forms on success', async () => {
// Arrange
const mockFormCount = 99543
const mockRes = expressHandler.mockResponse()
const getFormSpy = jest
.spyOn(AnalyticsService, 'getFormCount')
.mockReturnValueOnce(TE.of(mockFormCount))

// Act
await AnalyticsController.handleGetFormCount(MOCK_REQ, mockRes, jest.fn())

// Assert
expect(getFormSpy).toHaveBeenCalledTimes(1)
expect(mockRes.status).not.toHaveBeenCalled()
expect(mockRes.json).toHaveBeenCalledWith(mockFormCount)
})

it('should return 500 when error occurs whilst retrieving form count', async () => {
// Arrange
const mockRes = expressHandler.mockResponse()
const getFormSpy = jest
.spyOn(AnalyticsService, 'getFormCount')
.mockReturnValueOnce(TE.fromEither(E.left(new DatabaseError())))

// Act
await AnalyticsController.handleGetFormCount(MOCK_REQ, mockRes, jest.fn())

// Assert
expect(getFormSpy).toHaveBeenCalledTimes(1)
expect(mockRes.status).toHaveBeenCalledWith(500)
expect(mockRes.json).toHaveBeenCalledWith(
'Unable to retrieve number of forms from the database',
)
})
})

describe('handleGetStatistics', () => {
it('should return HTTP 200 when calls to AnalyticsService do not return any errors', async () => {
// Arrange
Expand Down
Loading

0 comments on commit 4556b00

Please sign in to comment.