diff --git a/frontend/src/scenes/surveys/SurveyAppearance.tsx b/frontend/src/scenes/surveys/SurveyAppearance.tsx
index 8b78e2aa90d93..ed3fc50036ce0 100644
--- a/frontend/src/scenes/surveys/SurveyAppearance.tsx
+++ b/frontend/src/scenes/surveys/SurveyAppearance.tsx
@@ -269,7 +269,7 @@ export function BaseAppearance({
)}
-
{question}
+
{/* Using dangerouslySetInnerHTML is safe here, because it's taking the user's input and showing it to the same user.
They can try passing in arbitrary scripts, but it would show up only for them, so it's like trying to XSS yourself, where
you already have all the data. Furthermore, sanitization should catch all obvious attempts */}
@@ -638,8 +638,14 @@ export function SurveyThankYou({ appearance }: { appearance: SurveyAppearanceTyp
{cancel}
- {appearance?.thankYouMessageHeader || 'Thank you!'}
- {appearance?.thankYouMessageDescription || ''}
+
+
undefined}>
Close
diff --git a/frontend/src/scenes/surveys/SurveyEdit.tsx b/frontend/src/scenes/surveys/SurveyEdit.tsx
index 63f20619f7a2e..1db795f0b0d36 100644
--- a/frontend/src/scenes/surveys/SurveyEdit.tsx
+++ b/frontend/src/scenes/surveys/SurveyEdit.tsx
@@ -158,93 +158,16 @@ export default function SurveyEdit(): JSX.Element {
label="Description (optional)"
>
{({ value, onChange }) => (
- <>
-
- setWritingHTMLDescription(
- key === 'html'
- )
- }
- tabs={[
- {
- key: 'text',
- label: (
-
- Text
-
- ),
- content: (
-
- onChange(v)
- }
- />
- ),
- },
- {
- key: 'html',
- label: (
-
- HTML
-
- ),
- content: (
-
-
- onChange(
- v ?? ''
- )
- }
- height={150}
- options={{
- minimap: {
- enabled:
- false,
- },
- wordWrap: 'on',
- scrollBeyondLastLine:
- false,
- automaticLayout:
- true,
- fixedOverflowWidgets:
- true,
- lineNumbers:
- 'off',
- glyphMargin:
- false,
- folding: false,
- }}
- />
-
- ),
- },
- ]}
- />
- {question.description &&
- question.description
- ?.toLowerCase()
- .includes('",
+ },
},
format="json",
)
@@ -702,6 +706,10 @@ def test_create_basic_survey_question_validation(self):
"question": "What do you think of the new notebooks feature?",
},
]
+ assert response_data["appearance"] == {
+ "thankYouMessageHeader": "Thanks for your feedback!",
+ "thankYouMessageDescription": "We'll use it to make notebooks better. ",
+ }
assert response_data["created_by"]["id"] == self.user.id
def test_update_basic_survey_question_validation(self):
@@ -728,6 +736,9 @@ def test_update_basic_survey_question_validation(self):
"question": "What do you think of the new notebooks feature?",
},
],
+ "appearance": {
+ "thankYouMessageDescription": "We'll use it to make notebooks better.",
+ },
},
format="json",
)
@@ -745,6 +756,9 @@ def test_update_basic_survey_question_validation(self):
"question": "What do you think of the new notebooks feature?",
},
]
+ assert response_data["appearance"] == {
+ "thankYouMessageDescription": "We'll use it to make notebooks better. ",
+ }
assert response_data["created_by"]["id"] == self.user.id
def test_cleaning_empty_questions(self):
@@ -755,6 +769,10 @@ def test_cleaning_empty_questions(self):
"description": "Get feedback on the new notebooks feature",
"type": "popover",
"questions": [],
+ "appearance": {
+ "thankYouMessageHeader": " ",
+ "thankYouMessageDescription": "",
+ },
},
format="json",
)
@@ -763,6 +781,25 @@ def test_cleaning_empty_questions(self):
assert Survey.objects.filter(id=response_data["id"]).exists()
assert response_data["name"] == "Notebooks beta release survey"
assert response_data["questions"] == []
+ assert response_data["appearance"] == {
+ "thankYouMessageHeader": " ",
+ "thankYouMessageDescription": "",
+ }
+
+ def test_validate_thank_you_with_invalid_type(self):
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/surveys/",
+ data={
+ "name": "Notebooks beta release survey",
+ "description": "Get feedback on the new notebooks feature",
+ "type": "popover",
+ "appearance": "invalid",
+ },
+ format="json",
+ )
+ response_data = response.json()
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response_data
+ assert response_data["detail"] == "Appearance must be an object"
def test_validate_question_with_missing_text(self):
response = self.client.post(