fix: delaying nudge password redirection (#1337)

* fix: delaying  nudge password redirection

* fix: fixed test cases
This commit is contained in:
ayesha waris
2024-10-24 14:41:35 +05:00
committed by GitHub
parent 62508e3bc7
commit 2a9dbe9d30
7 changed files with 17 additions and 14 deletions

View File

@@ -85,5 +85,5 @@ export const isHostAvailableInQueryParams = () => {
export const redirectWithDelay = (redirectUrl) => {
setTimeout(() => {
window.location.href = redirectUrl;
}, 400);
}, 1000);
};

View File

@@ -14,6 +14,7 @@ import messages from './messages';
import trackCohesionEvent from '../cohesion/trackers';
import { DEFAULT_REDIRECT_URL, RESET_PAGE } from '../data/constants';
import { updatePathWithQueryParams } from '../data/utils';
import { redirectWithDelay } from '../data/utils/dataUtils';
import useMobileResponsive from '../data/utils/useMobileResponsive';
const ChangePasswordPrompt = ({ variant, redirectUrl }) => {
@@ -26,7 +27,7 @@ const ChangePasswordPrompt = ({ variant, redirectUrl }) => {
setRedirectToResetPasswordPage(true);
} else {
trackCohesionEvent(cohesionEventData);
window.location.href = redirectUrl || getConfig().LMS_BASE_URL.concat(DEFAULT_REDIRECT_URL);
redirectWithDelay(redirectUrl || getConfig().LMS_BASE_URL.concat(DEFAULT_REDIRECT_URL));
}
},
};

View File

@@ -4,7 +4,7 @@ import { Provider } from 'react-redux';
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, IntlProvider } from '@edx/frontend-platform/i18n';
import {
fireEvent, render, screen,
fireEvent, render, screen, waitFor,
} from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { MemoryRouter } from 'react-router-dom';
@@ -77,7 +77,9 @@ describe('ChangePasswordPromptTests', () => {
);
fireEvent.click(screen.getByText('Close'));
await expect(window.location.href).toBe(dashboardUrl);
await waitFor(() => {
expect(window.location.href).toBe(dashboardUrl);
}, { timeout: 1100 });
});
it('[block modal] should redirect to reset password page when user clicks outside modal', async () => {

View File

@@ -533,7 +533,7 @@ describe('LoginPage', () => {
render(reduxWrapper(<IntlLoginPage {...props} />));
await waitFor(() => {
expect(window.location.href).toBe(dashboardURL);
});
}, { timeout: 1100 });
});
it('should redirect to finishAuthUrl upon successful login via SSO', async () => {
@@ -562,7 +562,7 @@ describe('LoginPage', () => {
render(reduxWrapper(<IntlLoginPage {...props} />));
await waitFor(() => {
expect(window.location.href).toBe(getConfig().LMS_BASE_URL + authCompleteUrl);
});
}, { timeout: 1100 });
});
it('should redirect to social auth provider url on SSO button click', async () => {
@@ -588,7 +588,7 @@ describe('LoginPage', () => {
));
await waitFor(() => {
expect(window.location.href).toBe(getConfig().LMS_BASE_URL + ssoProvider.loginUrl);
});
}, { timeout: 1100 });
});
it('should redirect to finishAuthUrl upon successful authentication via SSO', async () => {
@@ -614,7 +614,7 @@ describe('LoginPage', () => {
render(reduxWrapper(<IntlLoginPage {...props} />));
await waitFor(() => {
expect(window.location.href).toBe(getConfig().LMS_BASE_URL + finishAuthUrl);
});
}, { timeout: 1100 });
});
// ******** test hinted third party auth ********

View File

@@ -301,7 +301,7 @@ describe('ProgressiveProfilingTests', () => {
await waitFor(() => {
expect(window.location.href).toEqual(redirectUrl);
});
}, { timeout: 1100 });
});
});
@@ -448,7 +448,7 @@ describe('ProgressiveProfilingTests', () => {
fireEvent.click(submitButton);
await waitFor(() => {
expect(window.location.href).toBe(redirectUrl);
});
}, { timeout: 1100 });
});
});
});

View File

@@ -525,7 +525,7 @@ describe('RegistrationPage', () => {
render(routerWrapper(reduxWrapper(<IntlRegistrationPage {...props} />)));
await waitFor(() => {
expect(window.location.href).toBe(dashboardURL);
});
}, { timeout: 1100 });
});
it('should redirect to dashboard if features flags are configured but no optional fields are configured', async () => {
@@ -554,7 +554,7 @@ describe('RegistrationPage', () => {
render(routerWrapper(reduxWrapper(<IntlRegistrationPage {...props} />)));
await waitFor(() => {
expect(window.location.href).toBe(dashboardUrl);
});
}, { timeout: 1100 });
});
it('should redirect to progressive profiling page if optional fields are configured', () => {

View File

@@ -370,7 +370,7 @@ describe('ThirdPartyAuth', () => {
await waitFor(() => {
expect(window.location.href).toBe(getConfig().LMS_BASE_URL + registerUrl);
});
}, { timeout: 1100 });
});
it('should redirect to finishAuthUrl upon successful registration via SSO', async () => {
@@ -398,7 +398,7 @@ describe('ThirdPartyAuth', () => {
render(routerWrapper(reduxWrapper(<IntlRegistrationPage {...props} />)));
await waitFor(() => {
expect(window.location.href).toBe(getConfig().LMS_BASE_URL + authCompleteUrl);
});
}, { timeout: 1100 });
});
// ******** test alert messages ********