Skip to content

Commit

Permalink
Merge pull request #851 from opengovsg/release-4.49.1
Browse files Browse the repository at this point in the history
build: merge Release 4.49.1 into master
  • Loading branch information
karrui authored Dec 14, 2020
2 parents 773fd41 + ec7f0b6 commit 3e5b510
Show file tree
Hide file tree
Showing 138 changed files with 9,119 additions and 3,531 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ tmp/
# =======
.localstack

# @shelf/jest-mongodb generated file
# =======
globalConfig.json

# Tests
# =======
coverage/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ jobs:
workspaces:
use: build
script:
- travis_retry npm run test-backend-jasmine
- npm run test-backend-jasmine
- npm run test-frontend
- name: Typescript tests
workspaces:
use: build
script:
- travis_retry npm run test-backend-jest
- npm run test-backend-jest
after_success:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- name: End-to-end tests
Expand Down
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,74 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v4.49.1](https://github.com/opengovsg/FormSG/compare/v4.49.0...v4.49.1)

- feat: add typeguard for JWT payload [`7169cfb`](https://github.com/opengovsg/FormSG/commit/7169cfbb13aca6913344dcea5d350aa8363315dd)
- feat: enclose createEmailData in try-catch [`96d6399`](https://github.com/opengovsg/FormSG/commit/96d63994f705b5de2589531ad1579fb373c84341)

#### [v4.49.0](https://github.com/opengovsg/FormSG/compare/v4.48.2...v4.49.0)

> 10 December 2020
- fix: tear out response hash [`#837`](https://github.com/opengovsg/FormSG/pull/837)
- feat: add ie11 specific styling for new template forms [`#834`](https://github.com/opengovsg/FormSG/pull/834)
- refactor/core: migrate & rename core controller to HomeController in TypeScript [`#788`](https://github.com/opengovsg/FormSG/pull/788)
- refactor: convert Captcha to service [`#827`](https://github.com/opengovsg/FormSG/pull/827)
- build: merge 4.48.2 into develop [`#836`](https://github.com/opengovsg/FormSG/pull/836)
- chore: log errors from concatResponse [`#817`](https://github.com/opengovsg/FormSG/pull/817)
- fix: Travis Jest test not downloading mongo binary fast enough [`#826`](https://github.com/opengovsg/FormSG/pull/826)
- chore(deps-dev): bump @types/node from 14.14.10 to 14.14.11 [`#829`](https://github.com/opengovsg/FormSG/pull/829)
- fix(deps): bump @sentry/browser from 5.28.0 to 5.29.0 [`#831`](https://github.com/opengovsg/FormSG/pull/831)
- fix(deps): bump libphonenumber-js from 1.9.5 to 1.9.6 [`#832`](https://github.com/opengovsg/FormSG/pull/832)
- feat: misc UX fixes [`#833`](https://github.com/opengovsg/FormSG/pull/833)
- ref: migrate GET adminform/template endpoint to TypeScript [`#823`](https://github.com/opengovsg/FormSG/pull/823)
- refactor: migrate validate- and receiveEmailSubmission to TypeScript [`#755`](https://github.com/opengovsg/FormSG/pull/755)
- feat: improve email mode messaging [`#825`](https://github.com/opengovsg/FormSG/pull/825)
- fix: close create form modal when create form fails [`#824`](https://github.com/opengovsg/FormSG/pull/824)
- refactor: migrate decimal validator to ts [`#750`](https://github.com/opengovsg/FormSG/pull/750)
- refactor: migrate date validator to ts [`#749`](https://github.com/opengovsg/FormSG/pull/749)
- fix: wrap initDate in a new Date object to avoid reference to minDate [`#816`](https://github.com/opengovsg/FormSG/pull/816)
- ref: migrate transfer ownership flow to TypeScript [`#718`](https://github.com/opengovsg/FormSG/pull/718)
- chore(deps-dev): bump @opengovsg/mockpass from 2.5.6 to 2.6.0 [`#821`](https://github.com/opengovsg/FormSG/pull/821)
- fix(deps): bump aws-sdk from 2.802.0 to 2.805.0 [`#818`](https://github.com/opengovsg/FormSG/pull/818)
- chore(deps-dev): bump husky from 4.3.0 to 4.3.5 [`#819`](https://github.com/opengovsg/FormSG/pull/819)
- chore(deps-dev): bump eslint-plugin-simple-import-sort [`#820`](https://github.com/opengovsg/FormSG/pull/820)
- ref: migrate create new form api flow to TypeScript [`#806`](https://github.com/opengovsg/FormSG/pull/806)
- chore(deps-dev): bump @types/jest from 26.0.15 to 26.0.16 [`#812`](https://github.com/opengovsg/FormSG/pull/812)
- ref: migrate copy template form flow to TypeScript [`#793`](https://github.com/opengovsg/FormSG/pull/793)
- fix(deps): bump validator from 13.1.17 to 13.5.1 [`#811`](https://github.com/opengovsg/FormSG/pull/811)
- ref: migrate duplicate admin form endpoint to TypeScript [`#789`](https://github.com/opengovsg/FormSG/pull/789)
- ref: migrate endpoint for getting admin form to TypeScript [`#807`](https://github.com/opengovsg/FormSG/pull/807)
- chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 7.0.0 [`#810`](https://github.com/opengovsg/FormSG/pull/810)
- chore: enhance jest test reliability [`#800`](https://github.com/opengovsg/FormSG/pull/800)
- docs: remove dangling commas from mongo scripts [`#794`](https://github.com/opengovsg/FormSG/pull/794)
- refactor: migrate prepareEmailSubmission to TypeScript [`#752`](https://github.com/opengovsg/FormSG/pull/752)
- chore(deps-dev): bump @types/node from 14.14.7 to 14.14.10 [`#813`](https://github.com/opengovsg/FormSG/pull/813)
- feat: tighten submission validation [`#751`](https://github.com/opengovsg/FormSG/pull/751)
- chore(deps-dev): bump @types/helmet from 0.0.48 to 4.0.0 [`#697`](https://github.com/opengovsg/FormSG/pull/697)
- fix(deps): bump whatwg-fetch from 3.4.1 to 3.5.0 [`#804`](https://github.com/opengovsg/FormSG/pull/804)
- chore(deps-dev): bump @types/express-serve-static-core [`#801`](https://github.com/opengovsg/FormSG/pull/801)
- chore(deps-dev): bump @typescript-eslint/parser from 4.7.0 to 4.9.0 [`#803`](https://github.com/opengovsg/FormSG/pull/803)
- chore(deps-dev): bump prettier from 2.2.0 to 2.2.1 [`#785`](https://github.com/opengovsg/FormSG/pull/785)
- fix(deps): bump libphonenumber-js from 1.7.55 to 1.9.5 [`#798`](https://github.com/opengovsg/FormSG/pull/798)
- fix(deps): bump neverthrow from 2.7.1 to 3.0.0 [`#797`](https://github.com/opengovsg/FormSG/pull/797)
- chore: improve default submission error message [`#796`](https://github.com/opengovsg/FormSG/pull/796)
- test: raise global statement threshold [`#795`](https://github.com/opengovsg/FormSG/pull/795)
- chore(deps-dev): bump type-fest from 0.18.0 to 0.20.2 [`#782`](https://github.com/opengovsg/FormSG/pull/782)
- fix(deps): bump aws-sdk from 2.783.0 to 2.802.0 [`#783`](https://github.com/opengovsg/FormSG/pull/783)
- fix(deps): bump file-saver from 2.0.2 to 2.0.5 [`#784`](https://github.com/opengovsg/FormSG/pull/784)
- chore: merge release v4.48.1 back into `develop` [`#776`](https://github.com/opengovsg/FormSG/pull/776)
- fix(deps): bump @sentry/browser from 5.27.3 to 5.28.0 [`#774`](https://github.com/opengovsg/FormSG/pull/774)
- chore(deps-dev): bump csv-parse from 4.12.0 to 4.14.1 [`#745`](https://github.com/opengovsg/FormSG/pull/745)
- ref: migrate DELETE /{formId}/adminform endpoint flow to TypeScript [`#753`](https://github.com/opengovsg/FormSG/pull/753)
- chore: bump version to 4.49.0 [`49702e3`](https://github.com/opengovsg/FormSG/commit/49702e3ff3e8ff3e9fccfd0adac5f8b6b346428b)

#### [v4.48.2](https://github.com/opengovsg/FormSG/compare/v4.48.1...v4.48.2)

> 9 December 2020
- chore: log errors from concatResponse [`#817`](https://github.com/opengovsg/FormSG/pull/817)
- chore: bump version to 4.48.2 [`5cd7078`](https://github.com/opengovsg/FormSG/commit/5cd70788e6250239a838ba64b7168ff347e26aae)

#### [v4.48.1](https://github.com/opengovsg/FormSG/compare/v4.48.0...v4.48.1)

Expand Down
69 changes: 17 additions & 52 deletions docs/MONGODB.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,12 @@ function unlistFormFromExamples(id) {
if (!ObjectId.isValid(id)) throw new Error('Id is not valid')
const formId = ObjectId(id)
const result = db.forms.update(
{
_id: formId,
},
{
$set: {
isListed: false,
},
},
{ _id: formId },
{ $set: { isListed: false } }
)
if (result.nMatched === 0) throw new Error(`Form ${formId} not found`)

return db.forms.find({
_id: formId,
})
return db.forms.find({ _id: formId })
}
// unlistFormFromExamples("form id")
```
Expand Down Expand Up @@ -75,17 +67,15 @@ function unlistFormArrayFromExamples(ids) {
*/
function createAgency(shortName, fullName, logoUrl, emailDomains) {
if (!(emailDomains instanceof Array))
throw new Error(
`Email domains not in an array, emailDomains: ${emailDomains}`,
)
throw new Error(`Email domains not in an array, emailDomains: ${emailDomains}`)

return db.agencies.insert([
{
shortName: shortName,
fullName: fullName,
logo: logoUrl,
emailDomain: emailDomains,
},
emailDomain: emailDomains
}
])
}

Expand All @@ -103,26 +93,16 @@ function createAgency(shortName, fullName, logoUrl, emailDomains) {
function migrateAllForms(oldAdminEmail, newAdminEmail) {
const oldAdmin = db.users.findOne({ email: oldAdminEmail })
if (oldAdmin === null)
throw new Error(
`Could not find any user with the email address: ${oldAdminEmail}`,
)
throw new Error(`Could not find any user with the email address: ${oldAdminEmail}`)

const newAdmin = db.users.findOne({ email: newAdminEmail })
if (newAdmin === null)
throw new Error(
`Could not find any user with the email address: ${newAdminEmail}`,
)
throw new Error(`Could not find any user with the email address: ${newAdminEmail}`)

return db.forms.update(
{
admin: oldAdmin._id,
},
{
$set: {
admin: newAdmin._id,
},
},
{ multi: true },
{ admin: oldAdmin._id },
{ $set: { admin: newAdmin._id } },
{ multi: true }
)
}
// migrateAllForms("oldAdmin", "newAdmin")
Expand All @@ -142,37 +122,22 @@ function migrateOneForm(id, oldAdminEmail, newAdminEmail) {

const oldAdmin = db.users.findOne({ email: oldAdminEmail })
if (oldAdmin === null)
throw new Error(
`Could not find any user with the email address: ${oldAdminEmail}`,
)
throw new Error(`Could not find any user with the email address: ${oldAdminEmail}`)

const newAdmin = db.users.findOne({ email: newAdminEmail })
if (newAdmin === null)
throw new Error(
`Could not find any user with the email address: ${newAdminEmail}`,
)
throw new Error(`Could not find any user with the email address: ${newAdminEmail}`)

let form = db.forms.findOne({ _id: formId, admin: oldAdmin._id })
if (form === null)
throw new Error(
`Could not find form ${id} that belongs to ${oldAdminEmail}`,
)
throw new Error(`Could not find form ${id} that belongs to ${oldAdminEmail}`)

db.forms.update(
{
_id: formId,
admin: oldAdmin._id,
},
{
$set: {
admin: newAdmin._id,
},
},
{ _id: formId, admin: oldAdmin._id },
{ $set: { admin: newAdmin._id } }
)

return db.forms.find({
_id: formId,
})
return db.forms.find({ _id: formId })
}
// migrateOneForm("form id", "oldAdmin", "newAdmin")
```
11 changes: 0 additions & 11 deletions jest-mongodb-config.js

This file was deleted.

20 changes: 11 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
const { defaults: tsJestPreset } = require('ts-jest/presets')

module.exports = {
preset: '@shelf/jest-mongodb',
preset: 'ts-jest',
testMatch: ['**/?(*.)+(spec|test).[t]s?(x)'],
modulePaths: ['<rootDir>'],
testEnvironment: 'node',
globalSetup: '<rootDir>/tests/jest-global-setup.js',
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/'],
transform: {
// Needed to use @shelf/jest-mongodb preset.
...tsJestPreset.transform,
},
collectCoverageFrom: ['./src/**/*.{ts,js}', '!**/__tests__/**'],
coveragePathIgnorePatterns: ['./node_modules/', './tests'],
coverageReporters: ['lcov', 'text'],
coverageThreshold: {
global: {
statements: 25, // Increase this percentage as test coverage improves
statements: 38, // Increase this percentage as test coverage improves
},
},
globals: {
// Revert when memory leak in ts-jest is fixed.
// See https://github.com/kulshekhar/ts-jest/issues/1967.
'ts-jest': {
isolatedModules: true,
},
},
testEnvironment: 'node',
}
Loading

0 comments on commit 3e5b510

Please sign in to comment.