Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(surveys branching): rename confirmation_message -> end #23121

Merged
merged 3 commits into from
Jun 21, 2024
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
6 changes: 3 additions & 3 deletions frontend/src/scenes/surveys/QuestionBranchingInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export function QuestionBranchingInput({
]
: []),
{
label: 'Confirmation message',
value: SurveyQuestionBranchingType.ConfirmationMessage,
label: survey.appearance.displayThankYouMessage ? 'Confirmation message' : 'End',
value: SurveyQuestionBranchingType.End,
},
...(hasResponseBasedBranching
? [
Expand Down Expand Up @@ -162,7 +162,7 @@ function QuestionResponseBasedBranchingInput({
: []),
{
label: 'Confirmation message',
value: SurveyQuestionBranchingType.ConfirmationMessage,
value: SurveyQuestionBranchingType.End,
},
...availableNextQuestions.map((question) => ({
label: truncate(`${question.questionIndex + 1}. ${question.question}`, 20),
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/scenes/surveys/surveyLogic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ describe('set response-based survey branching', () => {
logic.actions.setResponseBasedBranchingForQuestion(
questionIndex,
0,
SurveyQuestionBranchingType.ConfirmationMessage,
SurveyQuestionBranchingType.End,
undefined
)
logic.actions.setResponseBasedBranchingForQuestion(
Expand All @@ -824,7 +824,7 @@ describe('set response-based survey branching', () => {
...SURVEY.questions[0],
branching: {
type: SurveyQuestionBranchingType.ResponseBased,
responseValues: { 0: SurveyQuestionBranchingType.ConfirmationMessage }, // Branching out to "Next question" is implicit
responseValues: { 0: SurveyQuestionBranchingType.End }, // Branching out to "Next question" is implicit
},
},
{ ...SURVEY.questions[1] },
Expand Down Expand Up @@ -1179,7 +1179,7 @@ describe('set response-based survey branching', () => {
upperBoundLabel: 'Very likely',
branching: {
type: SurveyQuestionBranchingType.ResponseBased,
responseValues: { 2: 1, 5: SurveyQuestionBranchingType.ConfirmationMessage },
responseValues: { 2: 1, 5: SurveyQuestionBranchingType.End },
},
},
{
Expand All @@ -1192,7 +1192,7 @@ describe('set response-based survey branching', () => {
upperBoundLabel: 'Very likely',
branching: {
type: SurveyQuestionBranchingType.ResponseBased,
responseValues: { 3: SurveyQuestionBranchingType.ConfirmationMessage },
responseValues: { 3: SurveyQuestionBranchingType.End },
},
},
]
Expand Down Expand Up @@ -1257,7 +1257,7 @@ describe('set response-based survey branching', () => {
scale: 5,
lowerBoundLabel: 'Unlikely',
upperBoundLabel: 'Very likely',
branching: { type: SurveyQuestionBranchingType.ConfirmationMessage },
branching: { type: SurveyQuestionBranchingType.End },
},
{
type: SurveyQuestionType.Rating,
Expand Down Expand Up @@ -1314,7 +1314,7 @@ describe('set response-based survey branching', () => {
question: '3',
description: '',
branching: {
type: SurveyQuestionBranchingType.ConfirmationMessage,
type: SurveyQuestionBranchingType.End,
},
},
{
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,9 @@ export const surveyLogic = kea<surveyLogicType>([

if (type === SurveyQuestionBranchingType.NextQuestion) {
delete question.branching
} else if (type === SurveyQuestionBranchingType.ConfirmationMessage) {
} else if (type === SurveyQuestionBranchingType.End) {
question.branching = {
type: SurveyQuestionBranchingType.ConfirmationMessage,
type: SurveyQuestionBranchingType.End,
}
} else if (type === SurveyQuestionBranchingType.ResponseBased) {
if (
Expand Down Expand Up @@ -736,9 +736,8 @@ export const surveyLogic = kea<surveyLogicType>([
if ('responseValues' in question.branching) {
if (nextStep === SurveyQuestionBranchingType.NextQuestion) {
delete question.branching.responseValues[responseValue]
} else if (nextStep === SurveyQuestionBranchingType.ConfirmationMessage) {
question.branching.responseValues[responseValue] =
SurveyQuestionBranchingType.ConfirmationMessage
} else if (nextStep === SurveyQuestionBranchingType.End) {
question.branching.responseValues[responseValue] = SurveyQuestionBranchingType.End
} else if (nextStep === SurveyQuestionBranchingType.SpecificQuestion) {
question.branching.responseValues[responseValue] = specificQuestionIndex
}
Expand Down Expand Up @@ -1022,7 +1021,7 @@ export const surveyLogic = kea<surveyLogicType>([
return SurveyQuestionBranchingType.NextQuestion
}

return SurveyQuestionBranchingType.ConfirmationMessage
return SurveyQuestionBranchingType.End
},
],
getResponseBasedBranchingDropdownValue: [
Expand All @@ -1048,7 +1047,7 @@ export const surveyLogic = kea<surveyLogicType>([
return SurveyQuestionBranchingType.NextQuestion
}

return SurveyQuestionBranchingType.ConfirmationMessage
return SurveyQuestionBranchingType.End
},
],
hasCycle: [
Expand All @@ -1060,7 +1059,7 @@ export const surveyLogic = kea<surveyLogicType>([
graph.set(fromIndex, new Set())
}

if (question.branching?.type === SurveyQuestionBranchingType.ConfirmationMessage) {
if (question.branching?.type === SurveyQuestionBranchingType.End) {
return
} else if (
question.branching?.type === SurveyQuestionBranchingType.SpecificQuestion &&
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2720,7 +2720,7 @@ export enum SurveyQuestionType {

export enum SurveyQuestionBranchingType {
NextQuestion = 'next_question',
ConfirmationMessage = 'confirmation_message',
End = 'end',
ResponseBased = 'response_based',
SpecificQuestion = 'specific_question',
}
Expand All @@ -2730,7 +2730,7 @@ interface NextQuestionBranching {
}

interface ConfirmationMessageBranching {
type: SurveyQuestionBranchingType.ConfirmationMessage
type: SurveyQuestionBranchingType.End
}

interface ResponseBasedBranching {
Expand Down
Loading