+ const singleOrMultiSelectString = `
${checkSVG}
`
return singleOrMultiSelectString
})
From 30a49dc86f38b5fba1a89609fccd629b58b467d5 Mon Sep 17 00:00:00 2001
From: Li Yi Yu
Date: Wed, 8 Nov 2023 15:42:42 -0500
Subject: [PATCH 3/3] add test and fix auto text color for thank you box
---
src/__tests__/extensions/surveys.js | 35 +++++++++++++++++++++++++++++
src/extensions/surveys.ts | 16 ++++++-------
2 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/src/__tests__/extensions/surveys.js b/src/__tests__/extensions/surveys.js
index 414f0060b..1052fb58b 100644
--- a/src/__tests__/extensions/surveys.js
+++ b/src/__tests__/extensions/surveys.js
@@ -191,4 +191,39 @@ describe('survey display logic', () => {
})
expect(uniqueIds.size).toBe(allSelectOptions.length)
})
+
+ test('single choice question type radio input elements are grouped correctly by question index', () => {
+ mockSurveys = [
+ {
+ id: 'testSurvey2',
+ name: 'Test survey 2',
+ appearance: null,
+ questions: [
+ {
+ question: 'Which types of content would you like to see more of?',
+ description: 'This is a question description',
+ type: 'single_choice',
+ choices: ['Tutorials', 'Product Updates', 'Events', 'Other'],
+ },
+ {
+ question: 'Which features do you use the most?',
+ description: 'This is a question description',
+ type: 'single_choice',
+ choices: ['Surveys', 'Feature flags', 'Analytics'],
+ },
+ ],
+ },
+ ]
+ const multipleQuestionSurveyForm = createMultipleQuestionSurvey(mockPostHog, mockSurveys[0])
+ const firstQuestionRadioInputs = multipleQuestionSurveyForm
+ .querySelectorAll('.tab.question-0')[0]
+ .querySelectorAll('input[type=radio]')
+ const mappedInputNames1 = [...firstQuestionRadioInputs].map((input) => input.name)
+ expect(mappedInputNames1.every((name) => name === 'question0')).toBe(true)
+ const secondQuestionRadioInputs = multipleQuestionSurveyForm
+ .querySelectorAll('.tab.question-1')[0]
+ .querySelectorAll('input[type=radio]')
+ const mappedInputNames2 = [...secondQuestionRadioInputs].map((input) => input.name)
+ expect(mappedInputNames2.every((name) => name === 'question1')).toBe(true)
+ })
})
diff --git a/src/extensions/surveys.ts b/src/extensions/surveys.ts
index 8eaac4a3d..3f6d32922 100644
--- a/src/extensions/surveys.ts
+++ b/src/extensions/surveys.ts
@@ -287,16 +287,14 @@ const style = (id: string, appearance: SurveyAppearance | null) => {
width: 100%;
${positions[appearance?.position || 'right'] || 'right: 30px;'}
}
- .thank-you-message {
- color: ${appearance?.textColor || 'black'};
- }
.thank-you-message-body {
margin-top: 6px;
font-size: 14px;
- color: ${appearance?.descriptionTextColor || '#4b4b52'};
+ background: ${appearance?.backgroundColor || '#eeeded'};
}
.thank-you-message-header {
margin: 10px 0px 0px;
+ background: ${appearance?.backgroundColor || '#eeeded'};
}
.thank-you-message-container .form-submit {
margin-top: 20px;
@@ -429,8 +427,10 @@ export const createThankYouMessage = (survey: Survey) => {
-
- ${survey.appearance?.thankYouMessageDescription || ''}
+
+ ${survey.appearance?.thankYouMessageDescription || ''}
${
survey.appearance?.whiteLabel
@@ -605,8 +605,8 @@ export const createMultipleChoicePopup = (
${surveyQuestionChoices
.map((option, idx) => {
const inputType = singleOrMultiSelect === 'single_choice' ? 'radio' : 'checkbox'
- const singleOrMultiSelectString = `
- ${checkSVG}
`
+ const singleOrMultiSelectString = `
+ ${checkSVG}
`
return singleOrMultiSelectString
})
.join(' ')}