Added unit test.
This commit is contained in:
parent
9f13d4b97c
commit
05a6c469c3
1 changed files with 92 additions and 0 deletions
|
|
@ -105,6 +105,98 @@ describe('analyticsMixin.js', () => {
|
||||||
expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
|
expect(expectedDataLayer).toEqual(expect.arrayContaining(window.dataLayer));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('pushIssSessionData: logs session payload to store', () => {
|
||||||
|
// Arrange
|
||||||
|
const store = useMainStore();
|
||||||
|
const testCookieValue = {
|
||||||
|
sid: '10000000-0000-0000-0000-000000000001',
|
||||||
|
skey: '12345'
|
||||||
|
};
|
||||||
|
setupCookies({ ISSCookieValue: JSON.stringify(testCookieValue) });
|
||||||
|
|
||||||
|
store.bailoutCode = 15;
|
||||||
|
store.applicationUser.savedSessionId = 'saved-session-id';
|
||||||
|
store.applicationUser.pageData = {
|
||||||
|
quote: {
|
||||||
|
servicePackageSelected: 'BASIC_PACKAGE'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
store.order.parentAccountNumber = 11111111;
|
||||||
|
store.order.vehicle = {
|
||||||
|
carId: 'CAR123',
|
||||||
|
year: '2020',
|
||||||
|
make: 'Toyota',
|
||||||
|
model: 'Camry',
|
||||||
|
style: 'SE',
|
||||||
|
vin: '1ABCDEFGH12345678'
|
||||||
|
};
|
||||||
|
store.order.damage = {
|
||||||
|
isRepair: false,
|
||||||
|
glassToReplace: [{ glassLocation: 'Windshield', glassName: 'Front' }]
|
||||||
|
};
|
||||||
|
store.order.lineItems = {
|
||||||
|
glassParts: [{ partNumber: 'GP1', partType: 'Glass', childParts: [] }],
|
||||||
|
supportingItems: [{ partNumber: 'SUP1', partType: 'Adas' }],
|
||||||
|
vaps: [{ partNumber: 'VAP1', partType: 'Vap' }]
|
||||||
|
};
|
||||||
|
store.order.schedule = { date: '2026-01-01', startTime: '09:00' };
|
||||||
|
store.order.serviceLocation = {
|
||||||
|
appointmentType: 'Mobile',
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
zipCode: '43081',
|
||||||
|
zipCodeCtu: '43081'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
zipCode: '43081',
|
||||||
|
zipCodeCtu: '43081'
|
||||||
|
};
|
||||||
|
store.order.contactInfo = {
|
||||||
|
notesForTechnician: 'note',
|
||||||
|
requestTextUpdates: true
|
||||||
|
};
|
||||||
|
store.order.payment = {
|
||||||
|
paymentMethod: 'Card',
|
||||||
|
nextGenSettledAmount: 100
|
||||||
|
};
|
||||||
|
store.order.insuranceCoverage = {
|
||||||
|
coverageStatus: 3,
|
||||||
|
coverageType: 1
|
||||||
|
};
|
||||||
|
store.order.eon = 'EON123';
|
||||||
|
store.order.referralNumber = 'R123';
|
||||||
|
store.order.referralSequenceNumber = '1';
|
||||||
|
store.order.referralDate = '2026-01-01';
|
||||||
|
store.order.workOrderNumber = 'WO123';
|
||||||
|
store.order.workOrderId = 'WOID123';
|
||||||
|
store.issConfig.parentAccountNumber = 99999999;
|
||||||
|
store.issConfig.billToAccountNumber = 'BILL123';
|
||||||
|
store.issConfig.clientName = 'Test Insurance';
|
||||||
|
store.currentDeductible = 250;
|
||||||
|
store.isVerified = true;
|
||||||
|
store.isNoComp = false;
|
||||||
|
store.isITAC = false;
|
||||||
|
|
||||||
|
const context = {
|
||||||
|
getPageNameByQueryString: jest.fn().mockReturnValue('duplicate-check')
|
||||||
|
};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
analyticsMixin.methods.pushIssSessionData.call(context);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(store.logIssSessionData).toHaveBeenCalledTimes(1);
|
||||||
|
expect(store.logIssSessionData).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
|
currentPage: 'duplicate-check',
|
||||||
|
referralNumber: 'R123',
|
||||||
|
issSessionId: 'saved-session-id',
|
||||||
|
parentAccountNumber: '11111111',
|
||||||
|
hasVin: true,
|
||||||
|
damageType: 'Replace',
|
||||||
|
productType: expect.arrayContaining(['GP1-Glass', 'SUP1-Adas', 'VAP1-Vap', 'BASIC_PACKAGE'])
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
test('Experiments, should push to dataLayer with default Google Custom Dimension Index', () => {
|
test('Experiments, should push to dataLayer with default Google Custom Dimension Index', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue