-
Notifications
You must be signed in to change notification settings - Fork 624
feat(cloud): redesign the cloud onboarding survey #13518
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
Open
MaanilVerma
wants to merge
14
commits into
main
Choose a base branch
from
feat/onboarding-survey-redesign
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cc1cd01
feat(cloud): redesign onboarding survey questions
MaanilVerma b48fa5e
feat(cloud): card-based onboarding survey with single-click advance
MaanilVerma c83b916
feat(telemetry): extend SurveyResponses for the new survey fields
MaanilVerma 5595f8b
test(cloud): cover the redesigned onboarding survey
MaanilVerma f7d2f02
chore(cloud): temporarily force the onboarding survey for preview
MaanilVerma cff7bfb
chore(cloud): restore onboarding survey flag default to false
MaanilVerma fd4c729
refactor(cloud): export hasNonEmptyValue as the shared survey emptine…
MaanilVerma 11dff52
feat(cloud): polish onboarding survey layout and branching
MaanilVerma d4c58da
fix(cloud): add rel=noopener to onboarding footer links
MaanilVerma f3e5edb
fix(cloud): void floating onFieldChange promises in survey handlers
MaanilVerma 06334d8
fix(cloud): harden survey validity and other-answer handling
MaanilVerma 4d238ea
Merge branch 'main' into feat/onboarding-survey-redesign
MaanilVerma 963024e
fix(cloud): cap onboarding survey free-text length
MaanilVerma b3bdaa0
Merge branch 'feat/onboarding-survey-redesign' of https://github.com/…
MaanilVerma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
src/platform/cloud/onboarding/survey/DynamicSurveyField.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| import userEvent from '@testing-library/user-event' | ||
| import { render, screen } from '@testing-library/vue' | ||
| import { describe, expect, it } from 'vitest' | ||
| import { createI18n } from 'vue-i18n' | ||
|
|
||
| import enMessages from '@/locales/en/main.json' | ||
| import type { OnboardingSurveyField } from '@/platform/remoteConfig/types' | ||
|
|
||
| import DynamicSurveyField from './DynamicSurveyField.vue' | ||
|
|
||
| const renderField = ( | ||
| field: OnboardingSurveyField, | ||
| props: { | ||
| modelValue?: string | string[] | ||
| otherValue?: string | ||
| errorMessage?: string | ||
| } = {}, | ||
| locale = 'en' | ||
| ) => | ||
| render(DynamicSurveyField, { | ||
| global: { | ||
| plugins: [ | ||
| createI18n({ legacy: false, locale, messages: { en: enMessages } }) | ||
| ] | ||
| }, | ||
| props: { field, modelValue: undefined, ...props } | ||
| }) | ||
|
|
||
| const optionButton = (label: string) => | ||
| screen.getByRole('button', { name: label }) | ||
|
|
||
| describe('DynamicSurveyField', () => { | ||
| const singleField: OnboardingSurveyField = { | ||
| id: 'intent', | ||
| type: 'single', | ||
| label: 'What do you want to make?', | ||
| required: true, | ||
| options: [ | ||
| { value: 'images', label: 'Images', icon: 'icon-[lucide--image]' }, | ||
| { value: 'video', label: 'Video' } | ||
| ] | ||
| } | ||
|
|
||
| it('renders the label and one card per option', () => { | ||
| renderField(singleField) | ||
| expect(screen.getByText('What do you want to make?')).toBeVisible() | ||
| expect(screen.getByText('Images')).toBeInTheDocument() | ||
| expect(screen.getByText('Video')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('emits the chosen value for a single-select card', async () => { | ||
| const user = userEvent.setup() | ||
| const { emitted } = renderField(singleField) | ||
|
|
||
| await user.click(screen.getByText('Images')) | ||
| expect(emitted()['update:modelValue']?.[0]).toEqual(['images']) | ||
| }) | ||
|
|
||
| it('marks the selected single card as on (aria-pressed/state)', () => { | ||
| renderField(singleField, { modelValue: 'images' }) | ||
| expect(optionButton('Images')).toHaveAttribute('data-state', 'on') | ||
| expect(optionButton('Video')).toHaveAttribute('data-state', 'off') | ||
| }) | ||
|
|
||
| it('gives each option card a stable "<fieldId>-<value>" id', () => { | ||
| renderField(singleField) | ||
| expect(optionButton('Images')).toHaveAttribute('id', 'intent-images') | ||
| expect(optionButton('Video')).toHaveAttribute('id', 'intent-video') | ||
| }) | ||
|
|
||
| const multiField: OnboardingSurveyField = { | ||
| id: 'making', | ||
| type: 'multi', | ||
| label: 'Pick some', | ||
| required: true, | ||
| options: [ | ||
| { value: 'a', label: 'Making A' }, | ||
| { value: 'b', label: 'Making B' } | ||
| ] | ||
| } | ||
|
|
||
| it('emits an array for a multi-select card and reflects current selection', async () => { | ||
| const user = userEvent.setup() | ||
| const { emitted } = renderField(multiField, { modelValue: ['a'] }) | ||
|
|
||
| expect(optionButton('Making A')).toHaveAttribute('data-state', 'on') | ||
| await user.click(screen.getByText('Making B')) | ||
| const events = emitted()['update:modelValue'] as unknown[][] | undefined | ||
| const last = events?.at(-1)?.[0] | ||
| expect(last).toEqual(expect.arrayContaining(['a', 'b'])) | ||
| }) | ||
|
|
||
| it('shows the "other" free-text input only when "other" is selected and emits it', async () => { | ||
| const user = userEvent.setup() | ||
| const otherField: OnboardingSurveyField = { | ||
| id: 'source', | ||
| type: 'single', | ||
| label: 'How did you find us?', | ||
| required: true, | ||
| allowOther: true, | ||
| otherFieldId: 'sourceOther', | ||
| options: [ | ||
| { value: 'search', label: 'Web search' }, | ||
| { value: 'other', label: 'Somewhere else' } | ||
| ] | ||
| } | ||
|
|
||
| const { rerender, emitted } = renderField(otherField, { | ||
| modelValue: 'search' | ||
| }) | ||
| expect( | ||
| screen.queryByPlaceholderText('Where did you find us?') | ||
| ).not.toBeInTheDocument() | ||
|
|
||
| await rerender({ field: otherField, modelValue: 'other', otherValue: '' }) | ||
| const input = screen.getByPlaceholderText('Where did you find us?') | ||
| await user.type(input, 'A podcast') | ||
| expect(emitted()['update:otherValue']?.length).toBeGreaterThan(0) | ||
| }) | ||
|
|
||
| it('renders a text field and emits typed input', async () => { | ||
| const user = userEvent.setup() | ||
| const textField: OnboardingSurveyField = { | ||
| id: 'note', | ||
| type: 'text', | ||
| label: 'Anything else?', | ||
| placeholder: 'Your note' | ||
| } | ||
| const { emitted } = renderField(textField) | ||
|
|
||
| await user.type(screen.getByPlaceholderText('Your note'), 'Hi') | ||
| expect(emitted()['update:modelValue']?.length).toBeGreaterThan(0) | ||
| }) | ||
|
|
||
| it('resolves labels via labelKey, locale map, and falls back to the value', () => { | ||
| renderField( | ||
| { | ||
| id: 'q', | ||
| type: 'single', | ||
| labelKey: 'cloudSurvey_steps_intent', | ||
| options: [ | ||
| { value: 'x', label: { en: 'Ex', ko: '엑스' } }, | ||
| { value: 'raw' } // no label → falls back to the value | ||
| ] | ||
| }, | ||
| {} | ||
| ) | ||
| expect(screen.getByText('What do you want to make?')).toBeVisible() | ||
| expect(screen.getByText('Ex')).toBeInTheDocument() | ||
| expect(screen.getByText('raw')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('resolves a field label from a locale map when no labelKey is set', () => { | ||
| renderField({ | ||
| id: 'q', | ||
| type: 'single', | ||
| label: { en: 'Server question', ko: '서버 질문' }, | ||
| options: [{ value: 'a', label: 'A' }] | ||
| }) | ||
| expect(screen.getByText('Server question')).toBeVisible() | ||
| }) | ||
|
|
||
| it('falls back to the field id when neither labelKey nor label resolves', () => { | ||
| renderField({ | ||
| id: 'bare_field_id', | ||
| type: 'single', | ||
| options: [{ value: 'a', label: 'A' }] | ||
| }) | ||
| expect(screen.getByText('bare_field_id')).toBeVisible() | ||
| }) | ||
|
|
||
| it('renders the error message when provided', () => { | ||
| renderField(singleField, { errorMessage: 'Please choose an option.' }) | ||
| expect(screen.getByText('Please choose an option.')).toBeVisible() | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.