Merge pull request #615 from Safelite/rlsmerge/2022.08.18-to-develop
Rlsmerge/2022.08.18 to develop
This commit is contained in:
commit
764222b600
5 changed files with 44 additions and 6 deletions
|
|
@ -7,6 +7,7 @@ import { applicationConfig } from "@/constants/application-config";
|
|||
*/
|
||||
export function updateOrCreateFunnelCookie() {
|
||||
const wasClaimRegistrationDelayed = getFunnelCookie()?.HasDelayedClaimRegistration;
|
||||
const shouldSuppressConceptFunnel = getFunnelCookie()?.SuppressConceptFunnel;
|
||||
|
||||
// Create the cookie
|
||||
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`;
|
||||
|
|
@ -21,7 +22,8 @@ export function updateOrCreateFunnelCookie() {
|
|||
ReferralDate: store.getters.order.referralDate,
|
||||
ReferralCorrelationId: store.getters.order.referralCorrelationId,
|
||||
ReferralParentAccountNumber: store.getters.order.accountNumber,
|
||||
HasDelayedClaimRegistration: wasClaimRegistrationDelayed
|
||||
HasDelayedClaimRegistration: wasClaimRegistrationDelayed,
|
||||
SuppressConceptFunnel: shouldSuppressConceptFunnel
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ describe("cookies", () => {
|
|||
ReferralDate: testReferralDate,
|
||||
ReferralCorrelationId: testReferralCorrelationId,
|
||||
ShouldResetState: testShouldResetState,
|
||||
DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast
|
||||
DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast,
|
||||
SuppressConceptFunnel: true
|
||||
}
|
||||
|
||||
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
|
|
|||
|
|
@ -39,9 +39,11 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
|
|||
Used to navigate to the heritage funnel with the correct query string and url.
|
||||
*/
|
||||
|
||||
export async function navigateToHeritageFunnel() {
|
||||
export async function navigateToHeritageFunnel(shouldSaveOrder = true) {
|
||||
// Create the order (or save existing order) when navigating to Heritage Funnel.
|
||||
await saveOrder();
|
||||
if (shouldSaveOrder) {
|
||||
await saveOrder();
|
||||
}
|
||||
|
||||
router.navigateToExternalUrl(
|
||||
externalUrls.HERITAGE_FUNNEL,
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ describe("navigateToHeritageFunnel", () => {
|
|||
// Assert
|
||||
expect(saveOrderFunction).toHaveBeenCalled();
|
||||
|
||||
// Should alway save before we navigate to heritage
|
||||
// Should save before we navigate to heritage by default
|
||||
const saveOrderFunctionCallOrder = saveOrderFunction.mock.invocationCallOrder[0];
|
||||
const routerNavigateFunctionCallOrder = router.navigateToExternalUrl.mock.invocationCallOrder[0];
|
||||
expect(saveOrderFunctionCallOrder).toBeLessThan(routerNavigateFunctionCallOrder);
|
||||
|
|
@ -373,4 +373,32 @@ describe("navigateToHeritageFunnel", () => {
|
|||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("should not save order, but should still navigate", async () => {
|
||||
// Arrange
|
||||
const mockReferralNumber = "2";
|
||||
const mockCorrelationId = "55";
|
||||
const mockReferralDate = "2022";
|
||||
|
||||
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate);
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.SAVE_ORDER,
|
||||
data: mockOrderInfo,
|
||||
}]
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
const saveOrderFunction = jest.spyOn(orderHelper, "saveOrder");
|
||||
router.navigateToExternalUrl = jest.fn();
|
||||
|
||||
// Act
|
||||
await navigateToHeritageFunnel(false);
|
||||
|
||||
// Assert
|
||||
expect(saveOrderFunction).not.toHaveBeenCalled();
|
||||
expect(router.navigateToExternalUrl).toHaveBeenCalled();
|
||||
saveOrderFunction.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
@ -30,6 +30,11 @@ const routes = [
|
|||
await analyticsMixin.methods.initSession();
|
||||
}
|
||||
|
||||
if (getFunnelCookie()?.SuppressConceptFunnel) {
|
||||
await navigateToHeritageFunnel(false);
|
||||
return next(false);
|
||||
}
|
||||
|
||||
// If the saved session has timed out, clear the session, execute 404 logic.
|
||||
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
|
||||
await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
|
||||
|
|
@ -196,7 +201,7 @@ function navigateToUrl(url, optionalQuery = {}) {
|
|||
for (const queryKey in optionalQuery) {
|
||||
externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]);
|
||||
}
|
||||
|
||||
|
||||
window.location.assign(externalUrl);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue