Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@defra/forms-model": "^3.0.432",
"@defra/forms-model": "^3.0.438",
"@defra/hapi-tracing": "^1.0.0",
"@elastic/ecs-pino-format": "^1.5.0",
"@hapi/boom": "^10.0.1",
Expand Down
10 changes: 5 additions & 5 deletions src/server/plugins/engine/components/AutocompleteField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe.each([

describe('State', () => {
it.each([...options.examples])('returns text from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const answer1 = getAnswer(field, state1)
Expand All @@ -183,7 +183,7 @@ describe.each([
})

it.each([...options.examples])('returns payload from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const payload1 = field.getFormDataFromState(state1)
Expand All @@ -194,7 +194,7 @@ describe.each([
})

it.each([...options.examples])('returns value from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const value1 = field.getFormValueFromState(state1)
Expand All @@ -207,7 +207,7 @@ describe.each([
it.each([...options.examples])(
'returns context for conditions and form submission',
(item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const value1 = field.getContextValueFromState(state1)
Expand All @@ -225,7 +225,7 @@ describe.each([
const value1 = field.getStateFromValidForm(payload1)
const value2 = field.getStateFromValidForm(payload2)

expect(value1).toEqual(getFormState(item.state))
expect(value1).toEqual(getFormState(item.value))
expect(value2).toEqual(getFormState(null))
})
})
Expand Down
14 changes: 7 additions & 7 deletions src/server/plugins/engine/components/CheckboxesField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe.each([
it.each([...options.examples])(
'returns text from state (single)',
(item) => {
const state1 = getFormState([item.state])
const state1 = getFormState([item.value])
const state2 = getFormState(null)

const answer1 = getAnswer(field, state1)
Expand All @@ -260,7 +260,7 @@ describe.each([
const item1 = options.examples[0]
const item2 = options.examples[2]

const state = getFormState([item1.state, item2.state])
const state = getFormState([item1.value, item2.value])
const answer = getAnswer(field, state)

expect(answer).toBe(outdent`
Expand All @@ -272,7 +272,7 @@ describe.each([
})

it.each([...options.examples])('returns payload from state', (item) => {
const state1 = getFormState([item.state])
const state1 = getFormState([item.value])
const state2 = getFormState(null)

const payload1 = field.getFormDataFromState(state1)
Expand All @@ -283,7 +283,7 @@ describe.each([
})

it.each([...options.examples])('returns value from state', (item) => {
const state1 = getFormState([item.state])
const state1 = getFormState([item.value])
const state2 = getFormState(null)

const value1 = field.getFormValueFromState(state1)
Expand All @@ -296,13 +296,13 @@ describe.each([
it.each([...options.examples])(
'returns context for conditions and form submission',
(item) => {
const state1 = getFormState([item.state])
const state1 = getFormState([item.value])
const state2 = getFormState(null)

const value1 = field.getContextValueFromState(state1)
const value2 = field.getContextValueFromState(state2)

expect(value1).toEqual([item.state])
expect(value1).toEqual([item.value])
expect(value2).toEqual([])
}
)
Expand All @@ -314,7 +314,7 @@ describe.each([
const value1 = field.getStateFromValidForm(payload1)
const value2 = field.getStateFromValidForm(payload2)

expect(value1).toEqual(getFormState([item.state]))
expect(value1).toEqual(getFormState([item.value]))
expect(value2).toEqual(getFormState(null))
})
})
Expand Down
3 changes: 3 additions & 0 deletions src/server/plugins/engine/components/List.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,21 @@ describe('List', () => {
it('returns list items', () => {
expect(guidance).toHaveProperty('items', [
{
id: '52fc51fc-c75a-4b08-9c9e-6bd99b9bc49b',
text: '1 day',
value: 1,
description:
'Valid for 24 hours from the start time that you select'
},
{
id: '56b7b34f-23b3-4446-ac8e-b2443d18588e',
text: '8 day',
value: 8,
description:
'Valid for 8 consecutive days from the start time that you select'
},
{
id: '1af54fbc-eec2-4e1e-bd53-2415abf62677',
text: '12 months',
value: 365,
description:
Expand Down
10 changes: 5 additions & 5 deletions src/server/plugins/engine/components/RadiosField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe.each([

describe('State', () => {
it.each([...options.examples])('returns text from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const answer1 = getAnswer(field, state1)
Expand All @@ -181,7 +181,7 @@ describe.each([
})

it.each([...options.examples])('returns payload from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const payload1 = field.getFormDataFromState(state1)
Expand All @@ -192,7 +192,7 @@ describe.each([
})

it.each([...options.examples])('returns value from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const value1 = field.getFormValueFromState(state1)
Expand All @@ -205,7 +205,7 @@ describe.each([
it.each([...options.examples])(
'returns context for conditions and form submission',
(item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const value1 = field.getContextValueFromState(state1)
Expand All @@ -223,7 +223,7 @@ describe.each([
const value1 = field.getStateFromValidForm(payload1)
const value2 = field.getStateFromValidForm(payload2)

expect(value1).toEqual(getFormState(item.state))
expect(value1).toEqual(getFormState(item.value))
expect(value2).toEqual(getFormState(null))
})
})
Expand Down
10 changes: 5 additions & 5 deletions src/server/plugins/engine/components/SelectField.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe.each([

describe('State', () => {
it.each([...options.examples])('returns text from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const answer1 = getAnswer(field, state1)
Expand All @@ -182,7 +182,7 @@ describe.each([
})

it.each([...options.examples])('returns payload from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const payload1 = field.getFormDataFromState(state1)
Expand All @@ -193,7 +193,7 @@ describe.each([
})

it.each([...options.examples])('returns value from state', (item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const value1 = field.getFormValueFromState(state1)
Expand All @@ -206,7 +206,7 @@ describe.each([
it.each([...options.examples])(
'returns context for conditions and form submission',
(item) => {
const state1 = getFormState(item.state)
const state1 = getFormState(item.value)
const state2 = getFormState(null)

const value1 = field.getContextValueFromState(state1)
Expand All @@ -224,7 +224,7 @@ describe.each([
const value1 = field.getStateFromValidForm(payload1)
const value2 = field.getStateFromValidForm(payload2)

expect(value1).toEqual(getFormState(item.state))
expect(value1).toEqual(getFormState(item.value))
expect(value2).toEqual(getFormState(null))
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,15 @@ describe('QuestionPageController', () => {
expect(filtered[1].model.label?.text).toBe('Select from the list')
expect(filtered[1].model.items).toEqual([
{
id: expect.any(String),
checked: false,
condition: 'isBarnOwl',
selected: false,
text: 'Option 1',
value: '1'
},
{
id: expect.any(String),
checked: false,
condition: 'isBarnOwl',
selected: false,
Expand Down Expand Up @@ -499,13 +501,15 @@ describe('QuestionPageController', () => {
expect(filtered[1].model.label?.text).toBe('Select from the list')
expect(filtered[1].model.items).toEqual([
{
id: expect.any(String),
checked: false,
condition: 'notBarnOwl',
selected: false,
text: 'Option 3',
value: '3'
},
{
id: expect.any(String),
checked: false,
condition: 'notBarnOwl',
selected: false,
Expand Down
2 changes: 1 addition & 1 deletion test/condition/checkboxes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Checkboxes based conditions', () => {
})

expect($checkbox).toBeInTheDocument()
expect($checkbox).toHaveAttribute('id', example.id)
expect($checkbox).toHaveAttribute('id', expect.any(String)) // id is now a uuid
expect($checkbox).toHaveAttribute('name', example.name)
expect($checkbox).toHaveAttribute('value', example.value)
expect($checkbox).toHaveClass('govuk-checkboxes__input')
Expand Down
2 changes: 1 addition & 1 deletion test/condition/radios.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Radio based conditions', () => {
})

expect($radio).toBeInTheDocument()
expect($radio).toHaveAttribute('id', example.id)
expect($radio).toHaveAttribute('id', expect.any(String)) // is now a uuid
expect($radio).toHaveAttribute('name', example.name)
expect($radio).toHaveAttribute('value', example.value)
expect($radio).toHaveClass('govuk-radios__input')
Expand Down
Loading