Skip to content

Commit

Permalink
Merge pull request #6773 from opengovsg/release_v6.80.0
Browse files Browse the repository at this point in the history
build: release v6.80.0
  • Loading branch information
wanlingt authored Oct 4, 2023
2 parents 9153ccb + 7777b7b commit 23e1dad
Show file tree
Hide file tree
Showing 29 changed files with 1,396 additions and 338 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ 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).

#### [v6.80.0](https://github.com/opengovsg/FormSG/compare/v6.79.0...v6.80.0)

- feat: add index to myinfo child email response [`#6745`](https://github.com/opengovsg/FormSG/pull/6745)
- build: merge v6.79.0 into develop [`#6765`](https://github.com/opengovsg/FormSG/pull/6765)
- feat: add range validation to number field [`#6575`](https://github.com/opengovsg/FormSG/pull/6575)
- fix: missing errors in error mapper [`#6764`](https://github.com/opengovsg/FormSG/pull/6764)
- build: release v6.79.0 [`#6762`](https://github.com/opengovsg/FormSG/pull/6762)

#### [v6.79.0](https://github.com/opengovsg/FormSG/compare/v6.78.2...v6.79.0)

> 3 October 2023

- feat: rename NRIC field to NRIC/FIN [`#6759`](https://github.com/opengovsg/FormSG/pull/6759)
- chore: fix snyk vulnerabilities [`#6728`](https://github.com/opengovsg/FormSG/pull/6728)
- chore: update hydrogen alpine [`#6752`](https://github.com/opengovsg/FormSG/pull/6752)
Expand All @@ -23,6 +33,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: merge v6.78.2 back into develop [`#6742`](https://github.com/opengovsg/FormSG/pull/6742)
- fix: hotfix for 500 errors thrown on email bounce notification endpoint [`#6741`](https://github.com/opengovsg/FormSG/pull/6741)
- build: merge v6.78.1 into develop [`#6738`](https://github.com/opengovsg/FormSG/pull/6738)
- chore: bump version to v6.79.0 [`5ff86cd`](https://github.com/opengovsg/FormSG/commit/5ff86cdb1d281865229de52aa1085c73a2fee426)

#### [v6.78.2](https://github.com/opengovsg/FormSG/compare/v6.78.1...v6.78.2)

Expand Down
43 changes: 42 additions & 1 deletion __tests__/e2e/constants/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
MyInfoAttribute,
NricFieldBase,
NumberFieldBase,
NumberSelectedLengthValidation,
NumberSelectedValidation,
RadioFieldBase,
RatingFieldBase,
RatingShape,
Expand Down Expand Up @@ -246,10 +248,49 @@ export const ALL_FIELDS: E2eFieldMetadata[] = [
fieldType: BasicField.Number,
ValidationOptions: {
selectedValidation: null,
customVal: null,
LengthValidationOptions: {
selectedLengthValidation: null,
customVal: null,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
},
val: '42',
},
{
title: 'Number field character length validation',
fieldType: BasicField.Number,
ValidationOptions: {
selectedValidation: NumberSelectedValidation.Length,
LengthValidationOptions: {
selectedLengthValidation: NumberSelectedLengthValidation.Exact,
customVal: 5,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
},
val: '12345',
},
{
title: 'Number field range validation',
fieldType: BasicField.Number,
ValidationOptions: {
selectedValidation: NumberSelectedValidation.Range,
LengthValidationOptions: {
selectedLengthValidation: null,
customVal: null,
},
RangeValidationOptions: {
customMin: 2,
customMax: 4,
},
},
val: '3',
},
{
title: 'Mother Tongue Language',
fieldType: BasicField.Radio,
Expand Down
9 changes: 8 additions & 1 deletion __tests__/e2e/constants/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ const TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC_FORMFIELDS: E2eFieldMetadata[] =
fieldType: BasicField.Number,
ValidationOptions: {
selectedValidation: null,
customVal: null,
LengthValidationOptions: {
selectedLengthValidation: null,
customVal: null,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
},
val: '10',
},
Expand Down
56 changes: 55 additions & 1 deletion __tests__/e2e/helpers/createForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
LogicConditionState,
LogicType,
MyInfoAttribute,
NumberSelectedValidation,
} from 'shared/types'

import { IFormModel, IFormSchema } from 'src/types'
Expand Down Expand Up @@ -559,7 +560,6 @@ const addBasicField = async (
await page.setInputFiles('input[type="file"]', field.path)
break
case BasicField.LongText:
case BasicField.Number:
case BasicField.ShortText:
if (field.ValidationOptions.selectedValidation) {
// Select from dropdown
Expand All @@ -584,6 +584,60 @@ const addBasicField = async (
await page.getByText('Allow international numbers').click()
}
break
case BasicField.Number:
if (field.ValidationOptions.selectedValidation) {
// We need to transform the backend values to frontend input values
const selectedValidationInput =
field.ValidationOptions.selectedValidation ===
NumberSelectedValidation.Length
? 'Number of characters allowed'
: 'Range of values allowed'

await fillDropdown(
page,
page.getByRole('combobox', { name: 'Field restriction' }),
selectedValidationInput,
)

if (
field.ValidationOptions.selectedValidation ===
NumberSelectedValidation.Length &&
field.ValidationOptions.LengthValidationOptions
.selectedLengthValidation
) {
await fillDropdown(
page,
page.getByPlaceholder('Length restriction'),
field.ValidationOptions.LengthValidationOptions
.selectedLengthValidation,
)

if (field.ValidationOptions.LengthValidationOptions.customVal) {
await page
.getByPlaceholder('Number of characters')
.nth(1)
.fill(
field.ValidationOptions.LengthValidationOptions.customVal.toString(),
)
}
}

if (
field.ValidationOptions.selectedValidation ===
NumberSelectedValidation.Range
) {
const customMin =
field.ValidationOptions.RangeValidationOptions.customMin?.toString() ??
('' as const)
const customMax =
field.ValidationOptions.RangeValidationOptions.customMax?.toString() ??
('' as const)

await page.getByPlaceholder('Minimum value').nth(1).fill(customMin)
await page.getByPlaceholder('Maximum value').nth(1).fill(customMax)
}
}
break
case BasicField.Rating:
await fillDropdown(
page,
Expand Down
18 changes: 18 additions & 0 deletions __tests__/unit/backend/helpers/generate-form-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
IHomenoFieldSchema,
IImageFieldSchema,
IMobileFieldSchema,
INumberFieldSchema,
IRatingFieldSchema,
IShortTextFieldSchema,
ITableFieldSchema,
Expand Down Expand Up @@ -165,6 +166,23 @@ export const generateDefaultField = (
getQuestion: () => defaultParams.title,
...customParams,
} as IDateFieldSchema
case BasicField.Number:
return {
...defaultParams,
ValidationOptions: {
selectedValidation: null,
LengthValidationOptions: {
selectedLengthValidation: null,
customVal: null,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
},
getQuestion: () => defaultParams.title,
...customParams,
} as INumberFieldSchema
default:
return {
...defaultParams,
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-frontend",
"version": "6.79.0",
"version": "6.80.0",
"homepage": ".",
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Meta, Story } from '@storybook/react'
import {
BasicField,
NumberFieldBase,
NumberSelectedLengthValidation,
NumberSelectedValidation,
} from '~shared/types'

Expand All @@ -14,8 +15,15 @@ const DEFAULT_NUMBER_FIELD: NumberFieldBase = {
title: 'Storybook Number',
description: 'Some description',
ValidationOptions: {
customVal: null,
selectedValidation: null,
LengthValidationOptions: {
selectedLengthValidation: null,
customVal: null,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
},
required: true,
disabled: false,
Expand Down Expand Up @@ -60,8 +68,15 @@ WithCustomVal.args = {
field: {
...DEFAULT_NUMBER_FIELD,
ValidationOptions: {
customVal: 3,
selectedValidation: NumberSelectedValidation.Exact,
selectedValidation: NumberSelectedValidation.Length,
LengthValidationOptions: {
selectedLengthValidation: NumberSelectedLengthValidation.Exact,
customVal: 3,
},
RangeValidationOptions: {
customMin: null,
customMax: null,
},
},
},
}
Loading

0 comments on commit 23e1dad

Please sign in to comment.