Merge pull request #595 from Safelite/defect/CSR-710-2022.08.18
Defect/csr 710 2022.08.18
This commit is contained in:
commit
20482a6c80
6 changed files with 45 additions and 7 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) });
|
||||
|
|
|
|||
|
|
@ -41,9 +41,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,
|
||||
|
|
|
|||
|
|
@ -328,7 +328,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);
|
||||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
@ -181,6 +181,7 @@ export default {
|
|||
previouslyEnteredCarId: '',
|
||||
invalidZip: '',
|
||||
vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0,
|
||||
isSelectedGlassAvailableForVehicle: true
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import analyticsMixin from "@/mixins/analytics-mixin";
|
|||
import ComponentTest from "@/layouts/component-test/component-test.vue";
|
||||
import FormTest from "@/layouts/form-test/form-test.vue";
|
||||
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/component-test", // This is a temporary route for testing.
|
||||
|
|
@ -44,6 +43,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);
|
||||
|
|
@ -218,7 +222,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