fix: recs skip btn event gets cancelled on redirection (#1058)

This commit is contained in:
Syed Sajjad Hussain Shah
2023-09-08 15:37:33 +05:00
committed by GitHub
parent 2d11477037
commit 512deae883
2 changed files with 4 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ import useAlgoliaRecommendations from './data/hooks/useAlgoliaRecommendations';
import messages from './messages';
import RecommendationsLargeLayout from './RecommendationsPageLayouts/LargeLayout';
import RecommendationsSmallLayout from './RecommendationsPageLayouts/SmallLayout';
import { trackRecommendationsViewed, trackSkipButtonClicked } from './track';
import { LINK_TIMEOUT, trackRecommendationsViewed, trackSkipButtonClicked } from './track';
import { DEFAULT_REDIRECT_URL } from '../data/constants';
const RecommendationsPage = () => {
@@ -56,7 +56,7 @@ const RecommendationsPage = () => {
const handleSkip = (e) => {
e.preventDefault();
trackSkipButtonClicked(userId);
handleSkipRecommendationPage();
setTimeout(() => { handleSkipRecommendationPage(); }, LINK_TIMEOUT);
};
if (!registrationResponse) {

View File

@@ -92,9 +92,10 @@ describe('RecommendationsPageTests', () => {
it('should redirect user if they click "Skip for now" button', () => {
mockUseLocation();
jest.useFakeTimers();
const recommendationsPage = mount(reduxWrapper(<IntlRecommendationsPage />));
recommendationsPage.find('.pgn__stateful-btn-state-default').first().simulate('click');
jest.advanceTimersByTime(300);
expect(window.location.href).toEqual(redirectUrl);
});