Skip to content

Commit

Permalink
polls/PollQuestion.jsx: fix missing textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
hom3mad3 authored and goapunk committed Oct 28, 2024
1 parent a40be82 commit e03c69a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
3 changes: 1 addition & 2 deletions adhocracy4/polls/static/PollDetail/PollQuestion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ export const PollQuestion = (props) => {

{choice.is_other_choice &&
<>
<input
<textarea
className="form-control"
type="text"
name="question"
value={otherChoiceAnswer}
id={'id_choice-' + choice.id + '-other'}
Expand Down
26 changes: 13 additions & 13 deletions adhocracy4/polls/static/__tests__/PollQuestion.jest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import { PollQuestion } from '../PollDetail/PollQuestion.jsx'
import { QUESTION_OBJECT } from './__testdata__/QUESTION_OBJECT'

describe('render <PollQuestion> with...', () => {
test('-> single-choice -> non-open-asnwers', () => {
test('-> single-choice -> non-open-answers', () => {
const tree = render(<PollQuestion question={QUESTION_OBJECT} />)
expect(tree).toMatchSnapshot()
})

test('-> single-choice -> open-asnwers', () => {
test('-> single-choice -> open-answers', () => {
const singleOpenQuestion = { ...QUESTION_OBJECT }
singleOpenQuestion.is_open = true
const tree = render(<PollQuestion question={singleOpenQuestion} />)
expect(tree).toMatchSnapshot()
})

test('-> multiple-choice -> non-open-asnwers', () => {
test('-> multiple-choice -> non-open-answers', () => {
const multiQuestion = { ...QUESTION_OBJECT }
multiQuestion.multiple_choice = true
const tree = render(<PollQuestion question={multiQuestion} />)
expect(tree).toMatchSnapshot()
})

test('-> multiple-choice -> open-asnwers', () => {
test('-> multiple-choice -> open-answers', () => {
const multiOpenQuestion = { ...QUESTION_OBJECT }
multiOpenQuestion.multiple_choice = true
multiOpenQuestion.is_open = true
Expand Down Expand Up @@ -65,12 +65,12 @@ describe('calling prop-passed functions...', () => {
onOtherChange={otherChangedFn}
/>
)
const choiceRadio = tree.container.querySelector('#id_choice-1-other')
const choiceTextInput = tree.container.querySelector('#id_choice-1-other')
const choiceRadio = tree.container.querySelector('input[type="radio"][id="id_choice-1-single"]')
const choiceTextArea = tree.container.querySelector('#id_choice-1-other')
expect(choiceRadio.checked).toBe(false)
expect(choiceTextInput.value).toBe('')
expect(choiceTextArea.value).toBe('')
fireEvent.click(choiceRadio)
fireEvent.change(choiceTextInput, { target: { value: 'something' } })
fireEvent.change(choiceTextArea, { target: { value: 'something' } })
expect(otherChangedFn).toHaveBeenCalled()
expect(otherChangedFn).toHaveBeenCalledWith(1, 'something')
})
Expand Down Expand Up @@ -105,11 +105,11 @@ describe('calling prop-passed functions...', () => {
/>
)
const choiceCheckbox = tree.container.querySelector('#id_choice-1-multiple')
const choiceTextInput = tree.container.querySelector('#id_choice-1-other')
const choiceTextArea = tree.container.querySelector('#id_choice-1-other')
expect(choiceCheckbox.checked).toBe(false)
expect(choiceTextInput.value).toBe('')
expect(choiceTextArea.value).toBe('')
fireEvent.click(choiceCheckbox)
fireEvent.change(choiceTextInput, { target: { value: 'something' } })
fireEvent.change(choiceTextArea, { target: { value: 'something' } })
expect(otherChangedFn).toHaveBeenCalled()
expect(otherChangedFn).toHaveBeenCalledWith(1, 'something')
})
Expand All @@ -125,6 +125,6 @@ test('initialize with function getUserAnswer -> with user answer', () => {
question={userAnswerQuestion}
/>
)
const choiceTextInput = tree.container.querySelector('#id_choice-1-other')
expect(choiceTextInput.value).toBe('antwoord')
const choiceTextArea = tree.container.querySelector('#id_choice-1-other')
expect(choiceTextArea.value).toBe('antwoord')
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`render <PollQuestion> with... -> multiple-choice -> non-open-asnwers 1`] = `
exports[`render <PollQuestion> with... -> multiple-choice -> non-open-answers 1`] = `
{
"asFragment": [Function],
"baseElement": <body>
Expand Down Expand Up @@ -167,7 +167,7 @@ exports[`render <PollQuestion> with... -> multiple-choice -> non-open-asnwers 1`
}
`;
exports[`render <PollQuestion> with... -> multiple-choice -> open-asnwers 1`] = `
exports[`render <PollQuestion> with... -> multiple-choice -> open-answers 1`] = `
{
"asFragment": [Function],
"baseElement": <body>
Expand Down Expand Up @@ -334,7 +334,7 @@ exports[`render <PollQuestion> with... -> multiple-choice -> open-asnwers 1`] =
}
`;
exports[`render <PollQuestion> with... -> single-choice -> non-open-asnwers 1`] = `
exports[`render <PollQuestion> with... -> single-choice -> non-open-answers 1`] = `
{
"asFragment": [Function],
"baseElement": <body>
Expand Down Expand Up @@ -491,7 +491,7 @@ exports[`render <PollQuestion> with... -> single-choice -> non-open-asnwers 1`]
}
`;
exports[`render <PollQuestion> with... -> single-choice -> open-asnwers 1`] = `
exports[`render <PollQuestion> with... -> single-choice -> open-answers 1`] = `
{
"asFragment": [Function],
"baseElement": <body>
Expand Down
1 change: 1 addition & 0 deletions changelog/8462.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Changed

- Modified the input type for text inputs PollOpenQuestion.jsx and PollQuestion.jsx to textarea.
- Changed PollQuestion.jest.jsx


0 comments on commit e03c69a

Please sign in to comment.