-
Notifications
You must be signed in to change notification settings - Fork 16
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
3007: Fix feeback rating for no search results as negative #3036
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,9 +22,17 @@ export type FeedbackContainerProps = { | |||||
cityCode: string | ||||||
query?: string | ||||||
slug?: string | ||||||
noResults: boolean | ||||||
} | ||||||
|
||||||
const FeedbackContainer = ({ query, language, routeType, cityCode, slug }: FeedbackContainerProps): ReactElement => { | ||||||
const FeedbackContainer = ({ | ||||||
query, | ||||||
language, | ||||||
routeType, | ||||||
cityCode, | ||||||
slug, | ||||||
noResults, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}: FeedbackContainerProps): ReactElement => { | ||||||
const [comment, setComment] = useState<string>('') | ||||||
const [contactMail, setContactMail] = useState<string>('') | ||||||
const [isPositiveRating, setIsPositiveRating] = useState<boolean | null>(null) | ||||||
|
@@ -33,7 +41,10 @@ const FeedbackContainer = ({ query, language, routeType, cityCode, slug }: Feedb | |||||
|
||||||
useEffect(() => { | ||||||
setSearchTerm(query) | ||||||
}, [query]) | ||||||
if (noResults === true) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
it's already a boolean |
||||||
setIsPositiveRating(false) | ||||||
} | ||||||
Comment on lines
+44
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 If possible, it is always nice to avoid code in In any case, checking explicitly for |
||||||
}, [query, noResults]) | ||||||
|
||||||
const handleSubmit = () => { | ||||||
setSendingStatus('sending') | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,11 +28,12 @@ describe('FeedbackContainer', () => { | |||||
|
||||||
const city = 'augsburg' | ||||||
const language = 'de' | ||||||
const noResults = false | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long you add the default value false for noResults this is not needed
Suggested change
|
||||||
|
||||||
it('should send feedback request with rating and no other inputs on submit', async () => { | ||||||
const { getByText, findByText } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer routeType={CATEGORIES_ROUTE} language={language} cityCode={city} /> | ||||||
<FeedbackContainer routeType={CATEGORIES_ROUTE} language={language} cityCode={city} noResults={noResults} /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</NavigationContainer>, | ||||||
) | ||||||
const positiveRatingButton = getByText('useful') | ||||||
|
@@ -70,7 +71,7 @@ describe('FeedbackContainer', () => { | |||||
const contactMail = '[email protected]' | ||||||
const { getByText, findByText, getAllByDisplayValue } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer routeType={CATEGORIES_ROUTE} language={language} cityCode={city} /> | ||||||
<FeedbackContainer routeType={CATEGORIES_ROUTE} language={language} cityCode={city} noResults={noResults} /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</NavigationContainer>, | ||||||
) | ||||||
const [commentField, emailField] = getAllByDisplayValue('') | ||||||
|
@@ -106,7 +107,7 @@ describe('FeedbackContainer', () => { | |||||
it('should disable send feedback button if rating button is clicked twice', async () => { | ||||||
const { getByText, findByText } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer routeType={CATEGORIES_ROUTE} language={language} cityCode={city} /> | ||||||
<FeedbackContainer routeType={CATEGORIES_ROUTE} language={language} cityCode={city} noResults={noResults} /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</NavigationContainer>, | ||||||
) | ||||||
const positiveRatingButton = getByText('useful') | ||||||
|
@@ -120,7 +121,13 @@ describe('FeedbackContainer', () => { | |||||
const query = 'Zeugnis' | ||||||
const { findByText, getByText } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer routeType={SEARCH_ROUTE} language={language} cityCode={city} query={query} /> | ||||||
<FeedbackContainer | ||||||
routeType={SEARCH_ROUTE} | ||||||
language={language} | ||||||
cityCode={city} | ||||||
query={query} | ||||||
noResults={noResults} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/> | ||||||
</NavigationContainer>, | ||||||
) | ||||||
const button = getByText('send') | ||||||
|
@@ -145,7 +152,13 @@ describe('FeedbackContainer', () => { | |||||
const fullSearchTerm = 'Zeugnisübergabe' | ||||||
const { findByText, getByDisplayValue, getByText } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer routeType={SEARCH_ROUTE} language={language} cityCode={city} query={query} /> | ||||||
<FeedbackContainer | ||||||
routeType={SEARCH_ROUTE} | ||||||
language={language} | ||||||
cityCode={city} | ||||||
query={query} | ||||||
noResults={noResults} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/> | ||||||
</NavigationContainer>, | ||||||
) | ||||||
const input = getByDisplayValue(query) | ||||||
|
@@ -170,12 +183,61 @@ describe('FeedbackContainer', () => { | |||||
it('should disable send button if query term is removed', async () => { | ||||||
const { findByText, getByDisplayValue } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer routeType={SEARCH_ROUTE} language={language} cityCode={city} query='query' /> | ||||||
<FeedbackContainer | ||||||
routeType={SEARCH_ROUTE} | ||||||
language={language} | ||||||
cityCode={city} | ||||||
query='query' | ||||||
noResults={noResults} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/> | ||||||
</NavigationContainer>, | ||||||
) | ||||||
expect(await findByText('send')).not.toBeDisabled() | ||||||
const input = getByDisplayValue('query') | ||||||
fireEvent.changeText(input, '') | ||||||
expect(await findByText('send')).toBeDisabled() | ||||||
}) | ||||||
|
||||||
it('should send negative rating on submit if there are no search results found', async () => { | ||||||
const query = 'gesundheitsversicherung' | ||||||
const noResults = true | ||||||
const { getByText, findByText } = render( | ||||||
<NavigationContainer> | ||||||
<FeedbackContainer | ||||||
routeType={SEARCH_ROUTE} | ||||||
language={language} | ||||||
cityCode={city} | ||||||
query={query} | ||||||
noResults={noResults} | ||||||
/> | ||||||
</NavigationContainer>, | ||||||
) | ||||||
expect(getByText('send')).not.toBeDisabled() | ||||||
const submitButton = getByText('send') | ||||||
fireEvent.press(submitButton) | ||||||
expect(await findByText('thanksMessage')).toBeDefined() | ||||||
expect(mockRequest).toHaveBeenCalledTimes(1) | ||||||
expect(mockRequest).toHaveBeenCalledWith({ | ||||||
routeType: SEARCH_ROUTE, | ||||||
isPositiveRating: false, | ||||||
city, | ||||||
language, | ||||||
comment: '', | ||||||
contactMail: '', | ||||||
query, | ||||||
searchTerm: query, | ||||||
slug: undefined, | ||||||
}) | ||||||
expect(sendTrackingSignal).toHaveBeenCalledTimes(1) | ||||||
expect(sendTrackingSignal).toHaveBeenCalledWith({ | ||||||
signal: { | ||||||
name: SEND_FEEDBACK_SIGNAL_NAME, | ||||||
feedback: { | ||||||
positive: false, | ||||||
numCharacters: 0, | ||||||
contactMail: false, | ||||||
}, | ||||||
}, | ||||||
}) | ||||||
}) | ||||||
}) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,7 +11,7 @@ type FeedbackModalContainerProps = { | |||||
} | ||||||
|
||||||
const FeedbackModalContainer = ({ route }: FeedbackModalContainerProps): ReactElement => ( | ||||||
<FeedbackContainer {...route.params} /> | ||||||
<FeedbackContainer {...route.params} noResults={false} /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noResults is optional you can just add
Suggested change
|
||||||
) | ||||||
|
||||||
export default FeedbackModalContainer |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,7 +56,7 @@ export const FeedbackContainer = ({ | |||||
query, | ||||||
slug, | ||||||
searchTerm, | ||||||
isPositiveRating, | ||||||
isPositiveRating: noResults === true ? false : isPositiveRating, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙃 Could you try to simplify this (using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}) | ||||||
|
||||||
setSendingStatus('successful') | ||||||
|
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.
I think there is noResults only when I search and 0 results so it's false most of the time until we set it to true.