-
Notifications
You must be signed in to change notification settings - Fork 147
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: make callback on confirmation message instead #1845
base: main
Are you sure you want to change the base?
fix: make callback on confirmation message instead #1845
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: -342 B (-0.01%) Total Size: 3.63 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR fixes a bug where feedback survey confirmation messages were closing prematurely by moving the survey reset functionality to trigger on confirmation message close instead of survey submission.
- Added new test in
src/__tests__/extensions/surveys/survey-popup.test.tsx
to verifyonCloseConfirmationMessage
callback behavior - Removed
onPopupSurveySent
fromSurveyContext
insrc/extensions/surveys/surveys-utils.tsx
in favor of confirmation message close handler - Added comprehensive end-to-end test in
playwright/surveys/feedback-widget.spec.ts
for multiple survey submissions with thank you messages - Improved accessibility in
BottomSection.tsx
andQuestionHeader.tsx
with proper ARIA attributes
7 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
previewPageIndex={mockSurvey.questions.length} | ||
/> | ||
) | ||
const cancelButton2 = screen.getByRole('button', { name: 'Close survey', hidden: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The button name 'Close survey' doesn't match the actual button text 'Close' defined in mockSurvey.appearance.thankYouMessageCloseButtonText
const cancelButton2 = screen.getByRole('button', { name: 'Close survey', hidden: true }) | |
const cancelButton2 = screen.getByRole('button', { name: mockSurvey.appearance.thankYouMessageCloseButtonText, hidden: true }) |
// Click the cancel button | ||
fireEvent.click(cancelButton2) | ||
// Verify that onCloseConfirmationMessage was called | ||
expect(mockOnCloseConfirmationMessage).toHaveBeenCalledTimes(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Should also verify mockRemoveSurveyFromFocus was called to ensure proper cleanup
if (nextStep === SurveyQuestionBranchingType.End) { | ||
sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog) | ||
onPopupSurveySent() | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Survey sent event is triggered but confirmation state is not set. Add setIsSurveySent(true)
here to ensure confirmation message shows.
if (nextStep === SurveyQuestionBranchingType.End) { | |
sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog) | |
onPopupSurveySent() | |
} else { | |
if (nextStep === SurveyQuestionBranchingType.End) { | |
sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog) | |
window.dispatchEvent(new Event('PHSurveySent')) | |
} else { |
// ... existing code ... | ||
test('auto contrasts text color for feedback tab', async ({ page, context }) => { | ||
const surveysAPICall = page.route('**/surveys/**', async (route) => { | ||
await route.fulfill({ | ||
json: { | ||
surveys: [ | ||
{ | ||
id: '123', | ||
name: 'Test survey', | ||
type: 'widget', | ||
start_date: '2021-01-01T00:00:00Z', | ||
questions: [openTextQuestion], | ||
appearance: { | ||
widgetLabel: 'white widget', | ||
widgetType: 'tab', | ||
widgetColor: 'white', | ||
}, | ||
}, | ||
], | ||
}, | ||
}) | ||
}) | ||
|
||
await start(startOptions, page, context) | ||
await surveysAPICall | ||
|
||
await expect(page.locator('.PostHogWidget123').locator('.ph-survey-widget-tab')).toBeVisible() | ||
|
||
await expect(page.locator('.PostHogWidget123').locator('.ph-survey-widget-tab')).toHaveCSS('color', black) | ||
await expect(page.locator('.PostHogWidget123').locator('.ph-survey-widget-tab')).toHaveCSS( | ||
'background-color', | ||
white | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This test is a duplicate of the previous 'auto contrasts text color for feedback tab' test. Should be removed to avoid redundant test coverage.
Changes
after I fix I did for this issue, it introduced a bug for feedback surveys where the confirmation message is not shown for feedback survey since it's being closed in the same instant.
so, this PR does two things:
reset
for the feedback widget popup happens when the survey is closedChecklist