-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Call quality feedback (#17969)
* feat: Call quality feedback * call quality feedback * quality feedback modal improvements * add quality feedback tests * code improvements * CR Improvements * create showQualityFeedbackModal method * CR changes * change typo * test fixes * add check for countly
- Loading branch information
Showing
13 changed files
with
505 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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
76 changes: 76 additions & 0 deletions
76
src/script/components/Modals/QualityFeedbackModal/QualityFeedbackModal.styles.ts
This file contains 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,76 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {CSSObject} from '@emotion/react'; | ||
|
||
export const wrapper: CSSObject = { | ||
padding: '32px 24px', | ||
}; | ||
|
||
export const title: CSSObject = { | ||
fontSize: 'var(--line-height-lg)', | ||
marginBottom: '16px', | ||
textAlign: 'center', | ||
}; | ||
|
||
export const description: CSSObject = { | ||
fontSize: 'var(--font-size-base)', | ||
marginBottom: '32px', | ||
textAlign: 'center', | ||
}; | ||
|
||
export const ratingList: CSSObject = { | ||
display: 'flex', | ||
alignItems: 'flex-end', | ||
justifyContent: 'space-between', | ||
gap: '10px', | ||
listStyle: 'none', | ||
margin: '0 0 24px', | ||
padding: 0, | ||
}; | ||
|
||
export const ratingItemHeading: CSSObject = { | ||
color: 'var(--foreground)', | ||
fontSize: 'var(--font-size-small)', | ||
marginBottom: '8px', | ||
textAlign: 'center', | ||
}; | ||
|
||
export const ratingItemBubble: CSSObject = { | ||
display: 'grid', | ||
placeContent: 'center', | ||
height: '56px', | ||
width: '56px', | ||
|
||
borderRadius: '50%', | ||
|
||
fontSize: 'var(--font-size-base)', | ||
fontWeight: 'var(--font-weight-semibold)', | ||
}; | ||
|
||
export const buttonWrapper: CSSObject = { | ||
marginBottom: '32px', | ||
}; | ||
|
||
export const buttonStyle: CSSObject = { | ||
fontSize: 'var(--font-size-base)', | ||
fontWeight: 'var(--font-weight-semibold)', | ||
height: '56px', | ||
width: '100%', | ||
}; |
137 changes: 137 additions & 0 deletions
137
src/script/components/Modals/QualityFeedbackModal/QualityFeedbackModal.test.tsx
This file contains 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,137 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {render, fireEvent, act} from '@testing-library/react'; | ||
import {amplify} from 'amplify'; | ||
import {container} from 'tsyringe'; | ||
|
||
import {WebAppEvents} from '@wireapp/webapp-events'; | ||
|
||
import {useCallAlertState} from 'Components/calling/useCallAlertState'; | ||
import {CALL_QUALITY_FEEDBACK_KEY} from 'Components/Modals/QualityFeedbackModal/constants'; | ||
import {RatingListLabel} from 'Components/Modals/QualityFeedbackModal/typings'; | ||
|
||
import {QualityFeedbackModal} from './QualityFeedbackModal'; | ||
|
||
import {withIntl, withTheme} from '../../../auth/util/test/TestUtil'; | ||
import {User} from '../../../entity/User'; | ||
import {EventName} from '../../../tracking/EventName'; | ||
import {Segmentation} from '../../../tracking/Segmentation'; | ||
import {UserState} from '../../../user/UserState'; | ||
|
||
jest.mock('../../../tracking/Countly.helpers', () => ({ | ||
isCountlyEnabledAtCurrentEnvironment: () => true, | ||
})); | ||
|
||
describe('QualityFeedbackModal', () => { | ||
const renderQualityFeedbackModal = () => render(withTheme(withIntl(<QualityFeedbackModal />))); | ||
const user = new User('userId', 'domain'); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
spyOn(container.resolve(UserState), 'self').and.returnValue(user); | ||
}); | ||
|
||
it('should not render if qualityFeedbackModalShown is false', () => { | ||
renderQualityFeedbackModal(); | ||
|
||
act(() => { | ||
useCallAlertState.getState().setQualityFeedbackModalShown(false); | ||
}); | ||
|
||
expect(useCallAlertState.getState().qualityFeedbackModalShown).toBe(false); | ||
}); | ||
|
||
it('should render correctly when qualityFeedbackModalShown is true', () => { | ||
renderQualityFeedbackModal(); | ||
|
||
act(() => { | ||
useCallAlertState.getState().setQualityFeedbackModalShown(true); | ||
}); | ||
|
||
expect(useCallAlertState.getState().qualityFeedbackModalShown).toBe(true); | ||
}); | ||
|
||
it('should close modal on skip', () => { | ||
const {getByText} = renderQualityFeedbackModal(); | ||
|
||
act(() => { | ||
useCallAlertState.getState().setQualityFeedbackModalShown(true); | ||
}); | ||
|
||
spyOn(amplify, 'publish').and.returnValue({ | ||
eventKey: WebAppEvents.ANALYTICS.EVENT, | ||
type: EventName.CALLING.QUALITY_REVIEW, | ||
value: { | ||
[Segmentation.CALL.QUALITY_REVIEW_LABEL]: RatingListLabel.DISMISSED, | ||
}, | ||
}); | ||
|
||
fireEvent.click(getByText('qualityFeedback.skip')); | ||
|
||
expect(amplify.publish).toHaveBeenCalledWith(WebAppEvents.ANALYTICS.EVENT, EventName.CALLING.QUALITY_REVIEW, { | ||
[Segmentation.CALL.QUALITY_REVIEW_LABEL]: RatingListLabel.DISMISSED, | ||
}); | ||
|
||
expect(useCallAlertState.getState().qualityFeedbackModalShown).toBe(false); | ||
}); | ||
|
||
it('should send quality feedback and close modal on rating click', () => { | ||
const {getByText} = renderQualityFeedbackModal(); | ||
|
||
act(() => { | ||
useCallAlertState.getState().setQualityFeedbackModalShown(true); | ||
}); | ||
|
||
spyOn(amplify, 'publish').and.returnValue({ | ||
eventKey: WebAppEvents.ANALYTICS.EVENT, | ||
type: EventName.CALLING.QUALITY_REVIEW, | ||
value: { | ||
[Segmentation.CALL.SCORE]: 5, | ||
[Segmentation.CALL.QUALITY_REVIEW_LABEL]: RatingListLabel.ANSWERED, | ||
}, | ||
}); | ||
|
||
fireEvent.click(getByText('5')); | ||
|
||
expect(amplify.publish).toHaveBeenCalledWith(WebAppEvents.ANALYTICS.EVENT, EventName.CALLING.QUALITY_REVIEW, { | ||
[Segmentation.CALL.SCORE]: 5, | ||
[Segmentation.CALL.QUALITY_REVIEW_LABEL]: RatingListLabel.ANSWERED, | ||
}); | ||
|
||
expect(useCallAlertState.getState().qualityFeedbackModalShown).toBe(false); | ||
}); | ||
|
||
it('should store the doNotAskAgain state in localStorage', () => { | ||
const {getByText} = renderQualityFeedbackModal(); | ||
|
||
act(() => { | ||
useCallAlertState.getState().setQualityFeedbackModalShown(true); | ||
}); | ||
|
||
const checkbox = getByText('qualityFeedback.doNotAskAgain'); | ||
fireEvent.click(checkbox); | ||
fireEvent.click(getByText('5')); | ||
|
||
act(() => { | ||
const storedData = JSON.parse(localStorage.getItem(CALL_QUALITY_FEEDBACK_KEY) || '{}'); | ||
expect(storedData['userId']).toBeNull(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.