Skip to content

Commit

Permalink
fix: recs skip btn event gets cancelled on redirection (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsajjadkazmii authored Sep 8, 2023
1 parent 2d11477 commit 512deae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/recommendations/RecommendationsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -56,7 +56,7 @@ const RecommendationsPage = () => {
const handleSkip = (e) => {
e.preventDefault();
trackSkipButtonClicked(userId);
handleSkipRecommendationPage();
setTimeout(() => { handleSkipRecommendationPage(); }, LINK_TIMEOUT);
};

if (!registrationResponse) {
Expand Down
3 changes: 2 additions & 1 deletion src/recommendations/tests/RecommendationsPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down

0 comments on commit 512deae

Please sign in to comment.