Merge pull request #595 from Safelite/defect/CSR-710-2022.08.18

Defect/csr 710 2022.08.18
This commit is contained in:
katieoh-safelite 2022-07-12 08:50:17 -04:00 committed by GitHub
commit 20482a6c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 7 deletions

View file

@ -7,6 +7,7 @@ import { applicationConfig } from "@/constants/application-config";
*/ */
export function updateOrCreateFunnelCookie() { export function updateOrCreateFunnelCookie() {
const wasClaimRegistrationDelayed = getFunnelCookie()?.HasDelayedClaimRegistration; const wasClaimRegistrationDelayed = getFunnelCookie()?.HasDelayedClaimRegistration;
const shouldSuppressConceptFunnel = getFunnelCookie()?.SuppressConceptFunnel;
// Create the cookie // Create the cookie
document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`; document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`;
@ -21,7 +22,8 @@ export function updateOrCreateFunnelCookie() {
ReferralDate: store.getters.order.referralDate, ReferralDate: store.getters.order.referralDate,
ReferralCorrelationId: store.getters.order.referralCorrelationId, ReferralCorrelationId: store.getters.order.referralCorrelationId,
ReferralParentAccountNumber: store.getters.order.accountNumber, ReferralParentAccountNumber: store.getters.order.accountNumber,
HasDelayedClaimRegistration: wasClaimRegistrationDelayed HasDelayedClaimRegistration: wasClaimRegistrationDelayed,
SuppressConceptFunnel: shouldSuppressConceptFunnel
}); });
} }

View file

@ -21,7 +21,8 @@ describe("cookies", () => {
ReferralDate: testReferralDate, ReferralDate: testReferralDate,
ReferralCorrelationId: testReferralCorrelationId, ReferralCorrelationId: testReferralCorrelationId,
ShouldResetState: testShouldResetState, ShouldResetState: testShouldResetState,
DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast,
SuppressConceptFunnel: true
} }
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) }); setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });

View file

@ -41,9 +41,11 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita
Used to navigate to the heritage funnel with the correct query string and url. 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. // Create the order (or save existing order) when navigating to Heritage Funnel.
await saveOrder(); if (shouldSaveOrder) {
await saveOrder();
}
router.navigateToExternalUrl( router.navigateToExternalUrl(
externalUrls.HERITAGE_FUNNEL, externalUrls.HERITAGE_FUNNEL,

View file

@ -328,7 +328,7 @@ describe("navigateToHeritageFunnel", () => {
// Assert // Assert
expect(saveOrderFunction).toHaveBeenCalled(); 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 saveOrderFunctionCallOrder = saveOrderFunction.mock.invocationCallOrder[0];
const routerNavigateFunctionCallOrder = router.navigateToExternalUrl.mock.invocationCallOrder[0]; const routerNavigateFunctionCallOrder = router.navigateToExternalUrl.mock.invocationCallOrder[0];
expect(saveOrderFunctionCallOrder).toBeLessThan(routerNavigateFunctionCallOrder); expect(saveOrderFunctionCallOrder).toBeLessThan(routerNavigateFunctionCallOrder);
@ -367,4 +367,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();
});
}); });

View file

@ -181,6 +181,7 @@ export default {
previouslyEnteredCarId: '', previouslyEnteredCarId: '',
invalidZip: '', invalidZip: '',
vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0, vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0,
isSelectedGlassAvailableForVehicle: true
}; };
}, },
mounted() { mounted() {

View file

@ -22,7 +22,6 @@ import analyticsMixin from "@/mixins/analytics-mixin";
import ComponentTest from "@/layouts/component-test/component-test.vue"; import ComponentTest from "@/layouts/component-test/component-test.vue";
import FormTest from "@/layouts/form-test/form-test.vue"; import FormTest from "@/layouts/form-test/form-test.vue";
const routes = [ const routes = [
{ {
path: "/component-test", // This is a temporary route for testing. path: "/component-test", // This is a temporary route for testing.
@ -44,6 +43,11 @@ const routes = [
await analyticsMixin.methods.initSession(); 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 the saved session has timed out, clear the session, execute 404 logic.
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) { if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE); await baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
@ -218,7 +222,7 @@ function navigateToUrl(url, optionalQuery = {}) {
for (const queryKey in optionalQuery) { for (const queryKey in optionalQuery) {
externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]); externalUrl.searchParams.append(queryKey, optionalQuery[queryKey]);
} }
window.location.assign(externalUrl); window.location.assign(externalUrl);
} }