CSR-1413
test coverage
This commit is contained in:
parent
f9f69f827d
commit
1653a6b4e3
3 changed files with 178 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import * as cookieHelper from "@/helpers/heritage-integration/cookie-helper";
|
import * as cookieHelper from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { loadSessionIfPresent, saveSession } from "@/helpers/heritage-integration/order-helper";
|
import { loadSessionIfPresent, saveSession, submitWorkOrder } from "@/helpers/heritage-integration/order-helper";
|
||||||
import { cookieNames } from "@/constants/cookie-names";
|
import { cookieNames } from "@/constants/cookie-names";
|
||||||
import {
|
import {
|
||||||
setupMocksForJsFiles,
|
setupMocksForJsFiles,
|
||||||
|
|
@ -239,3 +239,112 @@ describe("saveSession", () => {
|
||||||
expect(cookieHelper.getFunnelCookie().DidHeritageFunnelUpdateLast).toEqual(false);
|
expect(cookieHelper.getFunnelCookie().DidHeritageFunnelUpdateLast).toEqual(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe("submitWorkOrder", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
removeAllTestCookies();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("submitWorkOrder => should set state order values", async () => {
|
||||||
|
// Arrange
|
||||||
|
const mockReferralNumber = "2";
|
||||||
|
const mockCorrelationId = "55";
|
||||||
|
const mockReferralDate = "2022";
|
||||||
|
const mockParentAccountNumber = "167132";
|
||||||
|
const mockSavedSessionId = "xxx-xxx-xxx";
|
||||||
|
const mockCrmCustomerId = "xxx-xxx-xxx";
|
||||||
|
|
||||||
|
const mockOrderInfo = getMockOrderInfo(
|
||||||
|
mockReferralNumber,
|
||||||
|
mockCorrelationId,
|
||||||
|
mockReferralDate,
|
||||||
|
mockParentAccountNumber,
|
||||||
|
mockSavedSessionId,
|
||||||
|
mockCrmCustomerId
|
||||||
|
);
|
||||||
|
|
||||||
|
const mockData = {
|
||||||
|
actionList: [
|
||||||
|
{
|
||||||
|
actionName: storeActions.SAVE_SESSION,
|
||||||
|
data: mockOrderInfo,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: storeActions.UPDATE_STORE_WITH_SAVE_SESSION_RESPONSE,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const mocks = setupMocksForJsFiles(mockData);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await submitWorkOrder({ pageNameToLog: "test" });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(mocks.baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledWith(
|
||||||
|
storeActions.SAVE_SESSION,
|
||||||
|
null,
|
||||||
|
"test"
|
||||||
|
);
|
||||||
|
expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(
|
||||||
|
storeActions.UPDATE_STORE_WITH_SAVE_SESSION_RESPONSE,
|
||||||
|
{
|
||||||
|
referralNumber: mockReferralNumber,
|
||||||
|
referralDate: mockReferralDate,
|
||||||
|
referralCorrelationId: mockCorrelationId,
|
||||||
|
parentAccountNumber: mockParentAccountNumber,
|
||||||
|
savedSessionId: mockSavedSessionId,
|
||||||
|
crmCustomerId: mockCrmCustomerId,
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("submitWorkOrder => should update DidHeritageFunnelUpdateLast cookie value to false", async () => {
|
||||||
|
// Arrange
|
||||||
|
const mockReferralNumber = 1566818;
|
||||||
|
const mockReferralDate = "2022-03-15T10:56:24.597";
|
||||||
|
const mockReferralCorrelationId = "404d2b04-f86e-45c3-b373-127b6217b060";
|
||||||
|
const mockParentAccountNumber = "167132";
|
||||||
|
const mockSavedSessionId = "xxx-xxx-xxx";
|
||||||
|
const mockCrmCustomerId = "xxx-xxx-xxx";
|
||||||
|
|
||||||
|
const mockOrderInfo = getMockOrderInfo(
|
||||||
|
mockReferralNumber,
|
||||||
|
mockReferralCorrelationId,
|
||||||
|
mockReferralDate,
|
||||||
|
mockParentAccountNumber,
|
||||||
|
mockSavedSessionId,
|
||||||
|
mockCrmCustomerId
|
||||||
|
);
|
||||||
|
|
||||||
|
const mockData = {
|
||||||
|
actionList: [
|
||||||
|
{
|
||||||
|
actionName: storeActions.SAVE_SESSION,
|
||||||
|
data: mockOrderInfo,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
router: router,
|
||||||
|
};
|
||||||
|
|
||||||
|
setupMocksForJsFiles(mockData);
|
||||||
|
|
||||||
|
const testCookieValue = {
|
||||||
|
ReferralNumber: mockReferralNumber,
|
||||||
|
ReferralDate: mockReferralDate,
|
||||||
|
ReferralCorrelationId: mockReferralCorrelationId,
|
||||||
|
ShouldResetState: false,
|
||||||
|
DidHeritageFunnelUpdateLast: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await submitWorkOrder({ pageNameToLog: "test" });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(cookieHelper.getFunnelCookie().DidHeritageFunnelUpdateLast).toEqual(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1 +1,57 @@
|
||||||
test.todo("some test to be written in the future");
|
// Components
|
||||||
|
import customerDetails from "@/layouts/payment-method/payment-method.vue";
|
||||||
|
|
||||||
|
// Supporting Files
|
||||||
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
|
||||||
|
// Mock our module for promises.
|
||||||
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
settleAllPromises: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock("@/helpers/heritage-integration/order-helper.js", () => ({
|
||||||
|
submitWorkOrder: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("payment-method.vue", () => {
|
||||||
|
describe("navigation", () => {
|
||||||
|
test("if the back button is clicked, navigate back", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.backButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("if the continue button is clicked, navigate forward", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setupMocks() {
|
||||||
|
const wrapper = shallowMount(
|
||||||
|
customerDetails,
|
||||||
|
getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn(),
|
||||||
|
navigate: jest.fn(),
|
||||||
|
navigateWithSaving: jest.fn(),
|
||||||
|
navigateWithoutSaving: jest.fn(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return { wrapper };
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2767,6 +2767,17 @@ describe("Actions", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Getters", () => {
|
describe("Getters", () => {
|
||||||
|
it("submitAfterSave, should return true", () => {
|
||||||
|
// Arrange
|
||||||
|
const storeState = state;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
mutations.updateWorkOrderFlag(storeState, true);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(getters.submitAfterSave(storeState)).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("Vehicle getter, should return vehicle data", () => {
|
it("Vehicle getter, should return vehicle data", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const storeState = state;
|
const storeState = state;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue