qe-fe-automation
Version:
FE test automation framework using cypress
598 lines (578 loc) • 25.6 kB
text/typescript
import { Timeouts, Utility, utilitySelector } from '@utility-lib/index';
import { xmlEu } from '@fixtures/commerce/xml/xml_eu';
import { dateFormatPattern, timeFormatPattern } from '@utility-lib/constants';
import { localizationData } from '@fixtures/commerce/localization_data';
import { CommerceShared, CommerceApiIntercepts } from '@commerce-shared-lib/index';
import { amexBTARegion } from '@commerce-lib/constants';
const xmldata = xmlEu.xmlDataFlight;
const cacheKey = xmldata.cacheKey;
const english = localizationData.english;
const trainInvoiceValidationSelectors = {
upcomingTab: '[aria-label="Upcoming"]',
selectDropdown: '.select-dropdown',
viewItinerary: '.navan-trip-card',
bookingCard: 'button[qaid="goToItinerary"]',
viewInvoice: '[qaid="eventActionViewInvoice"]',
tripBookingId: '.train-booking-details__row__value',
itineraryBookingId: '.grid-kv__grid__column__entry__value',
iframe: '#invoiceIframe',
tripTrajectory: '.segment__route-info__station',
invoiceTrajectory: '.train-column__desc',
tripBookingFee: '.train-booking-details__row__value',
priceAmount: '.price-column__amount',
detailHeader: '.grid-kv',
tripFeeSection: '.nav-item__wrapper:nth-child(2)',
downloadInvoiceLink: '[qa-id="event-action-download-invoice"]'
};
const getIframeDocument = () => {
return cy
.get(trainInvoiceValidationSelectors.iframe)
.its('0.contentDocument')
.should('exist');
};
const getIframeBody = () => {
return getIframeDocument()
.its(utilitySelector.bodySelector)
.scrollIntoView()
.should('not.be.undefined')
.then(cy.wrap);
};
export class ItineraryValidation {
static visitTripsPage(browseBy: string) {
cy.allure().logStep('Visit Booked Trips Page');
CommerceApiIntercepts.interceptCommerceApis();
const pageUrl = browseBy === 'bookings' ? 'app/user2/bookings' : 'app/user2/trips';
cy.visit(pageUrl);
cy.wait(Timeouts.MEDIUM_TIMEOUT_10_SEC.timeout);
cy.wait('@waitForUserInfo');
}
static checkUpcomingTabIsSelected() {
cy.allure().logStep(`Check Upcoming Tab Is Selected :`);
cy.get(trainInvoiceValidationSelectors.upcomingTab).then((ele) => {
cy.wrap(ele).scrollIntoView();
cy.wrap(ele).should('have.attr', 'aria-selected', true);
});
}
static selectedBrowseByBookings() {
cy.allure().logStep(`Select Browse by bookings :`);
cy.get(trainInvoiceValidationSelectors.selectDropdown).eq(0).eq(1).click();
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
}
static selectFirstTrip() {
cy.allure().logStep(`Select Trip and View Itinerary :`);
cy.get(trainInvoiceValidationSelectors.viewItinerary).should('be.visible');
cy.get(trainInvoiceValidationSelectors.bookingCard, Timeouts.MEDIUM_TIMEOUT_60_SEC)
.should('be.visible')
.eq(0)
.click();
}
static checkItineraryPageIsVisited() {
cy.allure().logStep(` Routing to Itinerary Page :`);
cy.url().should('include', '/app/user2/trips/');
}
}
export class InvoiceValidation {
static visitTripsPage() {
CommerceShared.visitTripsPage();
}
static selectTrainTrip() {
cy.allure().logStep(`Select Trip and View Itinerary :`);
cy.intercept(
'GET',
/api\/user\/bookings\/2a9410d4-dcbd-4aa2-8954-67db15ecdbc8\/passengers\/1adfa524-1eec-4588-8a53-008d0d97dff1\/tripItem/
).as('request');
cy.get(
trainInvoiceValidationSelectors.bookingCard,
Timeouts.MEDIUM_TIMEOUT_60_SEC
).should('be.visible');
cy.get(trainInvoiceValidationSelectors.viewItinerary).eq(0).click();
cy.wait('@request')
.its('response')
.then((response) => {
expect(response?.statusCode).to.eq(200);
});
}
static checkItineraryPageIsVisited() {
cy.allure().logStep(` Routing to Itinerary Page :`);
cy.url().should('include', '/app/user2/trips/');
}
static storeTrainItineraryTripData() {
cy.get(trainInvoiceValidationSelectors.tripBookingId)
.eq(1)
.then((element) => {
cy.task('putDataInCache', {
key: 'bookingId',
data: element.text().trim()
});
});
cy.get(trainInvoiceValidationSelectors.tripTrajectory)
.first()
.then((element) => {
cy.task('putDataInCache', { key: 'from', data: element.text() });
});
cy.get(trainInvoiceValidationSelectors.tripTrajectory)
.last()
.then((element) => {
cy.task('putDataInCache', { key: 'to', data: element.text().trim() });
});
cy.get(trainInvoiceValidationSelectors.tripBookingFee)
.last()
.then((element) => {
cy.task('putDataInCache', {
key: 'bookingFee',
data: element.text().trim()
});
});
}
static checkBookingId() {
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
cy.allure().logStep(` Check booking Id :`);
cy.task<string>('getDataFromCache', 'bookingID').then((bookingId) => {
cy.contains(bookingId);
});
}
static checkTripFromInvoiceTrajectory(tripFeeInvoice: string) {
cy.allure().logStep(` Check From - To trajectory :`);
cy.task('getDataFromCache', 'from').then((from) => {
getIframeBody()
.find(trainInvoiceValidationSelectors.invoiceTrajectory)
.should(($el) => {
expect($el.text()).to.contain(from);
});
});
cy.task('getDataFromCache', 'to').then((to) => {
console.log(to);
getIframeBody()
.find(trainInvoiceValidationSelectors.invoiceTrajectory)
.should(($el) => {
expect($el.text()).to.contain(to);
});
});
cy.task('getDataFromCache', 'bookingId').then((bookingId) => {
console.log(bookingId);
getIframeBody()
.find(trainInvoiceValidationSelectors.detailHeader)
.should(($el) => {
expect($el.text()).to.contain(bookingId);
});
});
cy.get(trainInvoiceValidationSelectors.tripFeeSection).click();
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
console.log(tripFeeInvoice);
getIframeBody()
.find(trainInvoiceValidationSelectors.priceAmount)
.should(($el) => {
expect($el.text()).to.contain(tripFeeInvoice);
});
}
static trainXMLValidation() {
Utility.getXmlContentFromCache(cacheKey).then((xmlContent: any) => {
const xmlDoc = Utility.parseXmlContent(xmlContent);
cy.task('getDataFromCache', 'ledgerData').then((ledgerData: any) => {
const totalAmount = ledgerData.total_amount.amount;
//TransAmt is total charges
const transAmtElements = xmlDoc.getElementsByTagName('TransAmt');
if (transAmtElements.length >= 2) {
const transAmtFirstElement = transAmtElements[0];
const transAmtFirstValue = parseFloat(transAmtFirstElement.textContent || '0');
const transAmtSecondElement = transAmtElements[1];
const transAmtSecondValue = parseFloat(
transAmtSecondElement.textContent || '0'
);
const totalCharges = transAmtFirstValue + transAmtSecondValue;
const formattedAmount = totalAmount.toFixed(2);
cy.log('formattedAmount is -----' + formattedAmount);
const strippedAmount = formattedAmount.replace(/[^0-9]/g, '');
cy.log('strippedAmount------' + strippedAmount);
expect(strippedAmount).to.contains(totalCharges);
} else {
cy.log('TransAmt is not present in XML');
}
//BtchDbTot is total charges
const btchDbTotElement = xmlDoc.getElementsByTagName('BtchDbTot')[0];
const btchDbTotValue = parseFloat(btchDbTotElement.textContent || '0');
const formattedAmount = totalAmount.toFixed(2);
cy.log('formattedAmount is -----' + formattedAmount);
const strippedAmount = formattedAmount.replace(/[^0-9]/g, '');
cy.log('strippedAmount------' + strippedAmount);
expect(strippedAmount).to.contains(
btchDbTotValue,
btchDbTotValue + 'is not Equal to' + strippedAmount
);
//TravelTranTot is total charges
const travelTranTotElement = xmlDoc.getElementsByTagName('TravelTranTot')[0];
const travelTranTotValue = parseFloat(travelTranTotElement.textContent || '0');
expect(strippedAmount).to.contains(
travelTranTotValue,
travelTranTotValue + 'is not Equal to' + strippedAmount
);
//BtchTot is total charges
const btchTotElement = xmlDoc.getElementsByTagName('BtchTot')[0];
const btchTotValue = parseFloat(btchTotElement.textContent || '0');
expect(strippedAmount).to.contains(
btchTotValue,
btchTotValue + 'is not Equal to' + strippedAmount
);
//TravelTranTot is total charges
const travelTranDbTotElement = xmlDoc.getElementsByTagName('TravelTranDbTot')[0];
const travelTranDbTotValue = parseFloat(
travelTranDbTotElement.textContent || '0'
);
expect(strippedAmount).to.contains(
travelTranDbTotValue,
travelTranDbTotValue + 'is not Equal to' + strippedAmount
);
});
// DprtPtNm Value is departure location
cy.task('getDataFromCache', 'departureLocation').then((departureLocation: any) => {
const dprtAirCdElement = xmlDoc.getElementsByTagName('DprtPtNm')[0];
const dprtAirCdValue = dprtAirCdElement.textContent;
expect(departureLocation).to.equal(
dprtAirCdValue,
'Departure location is equal to DprtPtNm'
);
});
//ArrPtNm Value is arrival location
cy.task('getDataFromCache', 'arrivalLocation').then((arrivalLocation: any) => {
const arrAirCdElement = xmlDoc.getElementsByTagName('ArrPtNm')[0];
const arrAirCdValue = arrAirCdElement.textContent;
expect(arrivalLocation).to.equal(
arrAirCdValue,
'Arrival location is equal to ArrPtNm'
);
});
// CarrierNm Value is carrier name
cy.task('getDataFromCache', 'issuerName').then((issuerName: any) => {
const carrierNmElement = xmlDoc.getElementsByTagName('CarrierNm')[0];
const carrierNmValue = carrierNmElement.textContent;
expect(issuerName).to.equal(carrierNmValue, 'Carrier name is equal to CarrierNm');
});
// TktIssNm Value is carrier name
cy.task('getDataFromCache', 'issuerName').then((issuerName: any) => {
const tktIssNmElement = xmlDoc.getElementsByTagName('TktIssNm')[0];
const tktIssNmValue = tktIssNmElement.textContent;
expect(issuerName).to.equal(tktIssNmValue, 'Carrier name is equal to TktIssNm');
});
//TktIssDt Value is YYYYMMDD
const tktIssDtElement = xmlDoc.getElementsByTagName('TktIssDt')[0];
const tktIssDtValue = tktIssDtElement.textContent;
if (tktIssDtValue !== null && tktIssDtValue !== undefined) {
expect(tktIssDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('DestNmValue is in YYYYMMDD format');
}
//DprtDt Value is YYYYMMDD
const dprtDtElement = xmlDoc.getElementsByTagName('DprtDt')[0];
const dprtDtValue = dprtDtElement.textContent;
if (dprtDtValue !== null && dprtDtValue !== undefined) {
expect(dprtDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('DprtDt is in YYYYMMDD format');
}
//TktNbr Value is not null
const tktNbrElement = xmlDoc.getElementsByTagName('TktNbr')[0];
const tktNbrValue = tktNbrElement.textContent;
expect(tktNbrValue).to.not.equal(null);
//arrDtValue Value is YYYYMMDD
const arrDtElement = xmlDoc.getElementsByTagName('ArrDt')[0];
const arrDtValue = arrDtElement.textContent;
if (arrDtValue !== null && arrDtValue !== undefined) {
expect(arrDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('arrDtValue is in YYYYMMDD format');
}
});
}
static trainRequiredXmlContentValidations() {
cy.allure().logStep('Get XML content from cache for Train');
Utility.getXmlContentFromCache(cacheKey).then((xmlContent: any) => {
const xmlDoc = Utility.parseXmlContent(xmlContent);
//VersNbr Value is 1
const versNbrElement = xmlDoc.getElementsByTagName('VersNbr')[0];
const versNbrValue = versNbrElement.textContent;
expect(xmldata.VersNbr).to.equal(versNbrValue, 'VersNbr is not equal to 1');
//MsgSeqNbrValue is 9 digits
const msgSeqnbrElement = xmlDoc.getElementsByTagName('MsgSeqNbr')[0];
const msgSeqnbrValue = msgSeqnbrElement.textContent;
if (msgSeqnbrValue !== null && msgSeqnbrValue !== undefined) {
expect(msgSeqnbrValue.trim().length).to.equal(9);
} else {
cy.log('MsgSeqNbrValue is null or undefined');
}
//submrId Id provided by Amex
const submrIdElement = xmlDoc.getElementsByTagName('SubmrId')[0];
const submrIdValue = submrIdElement.textContent;
expect(xmldata.SubmrId).to.equal(
submrIdValue,
'SubmrId is equal to provided by Amex'
);
//CreateTmValue is current time in format HHMMSS
const createTmElement = xmlDoc.getElementsByTagName('CreateTm')[0];
const createTmValue = createTmElement.textContent;
if (createTmValue !== null && createTmValue !== undefined) {
expect(createTmValue.trim()).to.match(timeFormatPattern);
} else {
cy.log('CreateTmValue is in HHMMSS format');
}
//CreateDtValue is current date in format YYYYMMDD
const createDtElement = xmlDoc.getElementsByTagName('CreateDt')[0];
const createDtValue = createDtElement.textContent;
if (createDtValue !== null && createDtValue !== undefined) {
expect(createDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('CreateDtValue is in YYYYMMDD format');
}
//TransSeqNbrValue is 9 digit number
const transSeqNbrElement = xmlDoc.getElementsByTagName('TransSeqNbr')[0];
const transSeqNbrValue = transSeqNbrElement.textContent;
if (transSeqNbrValue !== null && transSeqNbrValue !== undefined) {
const regex = /^\d{9}$/;
expect(transSeqNbrValue.trim().length).to.equal(9);
expect(regex.test(transSeqNbrValue.trim())).to.be.true;
} else {
cy.log('TransSeqNbrValue is in 9 digit number format');
}
//providerNmValue is Navan
const providerNmElement = xmlDoc.getElementsByTagName('ProviderNm')[0];
const providerNmValue = providerNmElement.textContent;
expect(xmldata.ProviderName).to.equal(
providerNmValue,
'ProviderNm is equal to Navan'
);
//TransDtValue is current date in format HHMMSS
const transTmElement = xmlDoc.getElementsByTagName('TransTm')[0];
const transTmValue = transTmElement.textContent;
if (transTmValue !== null && transTmValue !== undefined) {
expect(transTmValue.trim()).to.match(timeFormatPattern);
} else {
cy.log('TransTmValue is in HHMMSS format');
}
//TransDtValue is current date in format YYYYMMDD
const transDtElement = xmlDoc.getElementsByTagName('TransDt')[0];
const transDtValue = transDtElement.textContent;
if (transDtValue !== null && transDtValue !== undefined) {
expect(transDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('TransDtValue is in YYYYMMDD format');
}
// destNmValue is alphanumeric
const destNmElement = xmlDoc.getElementsByTagName('DestNm')[0];
const destNmValue = destNmElement.textContent;
if (destNmValue !== null && destNmValue !== undefined) {
const alphanumericPattern = /^[a-zA-Z0-9\s_-]+$/;
expect(destNmValue.trim()).to.match(alphanumericPattern);
} else {
cy.log('DestNmValue is in alphanumeric format');
}
//dbCrIndValue is D or C
const dbCrIndElement = xmlDoc.getElementsByTagName('DbCrInd')[0];
const dbCrIndValue = dbCrIndElement.textContent;
expect(xmldata.dbCrIndValue).to.equal(dbCrIndValue, 'dbCrIndValue is not D or C');
//invIndValue is N or Y
const invIndElement = xmlDoc.getElementsByTagName('InvInd')[0];
const invIndValue = invIndElement.textContent;
expect(xmldata.invInd).to.equal(invIndValue, 'invIndValue is not N or Y');
//invDtValue is current date in format YYYYMMDD
const invDtElement = xmlDoc.getElementsByTagName('InvDt')[0];
const invDtValue = invDtElement.textContent;
if (invDtValue !== null && invDtValue !== undefined) {
expect(invDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('DestNmValue is in YYYYMMDD format');
}
//dprtDtValue is current date in format YYYYMMDD
const dprtDtElement = xmlDoc.getElementsByTagName('DprtDt')[0];
const dprtDtValue = dprtDtElement.textContent;
if (dprtDtValue !== null && dprtDtValue !== undefined) {
expect(dprtDtValue.trim()).to.match(dateFormatPattern);
} else {
cy.log('DestNmValue is in YYYYMMDD format');
}
});
}
static travelerTrainXmlContentValidations() {
cy.allure().logStep('Get Train Traveler XML content from cache');
Utility.getXmlContentFromCache(cacheKey).then((xmlContent: any) => {
const xmlDoc = Utility.parseXmlContent(xmlContent);
//TravelDbCrInd Value is D
const travelDbCrIndElement = xmlDoc.getElementsByTagName('TravelDbCrInd')[0];
const travelDbCrIndValue = travelDbCrIndElement.textContent;
expect(xmldata.TravelDbCrInd).to.equal(
travelDbCrIndValue,
'TravelDbCrInd Value is D'
);
//SettleDbCrInd Value is D
const settleDbCrIndElement = xmlDoc.getElementsByTagName('SettleDbCrInd')[0];
const settleDbCrIndValue = settleDbCrIndElement.textContent;
expect(xmldata.TravelDbCrInd).to.equal(
settleDbCrIndValue,
'SettleDbCrInd Value is D'
);
//travelTranDbCntValue id Debit transaction count
const travelTranDbCntElement = xmlDoc.getElementsByTagName('TravelTranDbCnt')[0];
const travelTranDbCntValue = travelTranDbCntElement.textContent;
if (travelTranDbCntValue !== null) {
expect(parseInt(travelTranDbCntValue)).to.be.at.least(
1,
'TravelTranDbCnt is equal to or greater than 1'
);
} else {
cy.log('TravelTranDbCnt is not found');
}
//travelTranCrCntValue Value is Credit transaction count
const travelTranCrCntElement = xmlDoc.getElementsByTagName('TravelTranCrCnt')[0];
const travelTranCrCntValue = travelTranCrCntElement.textContent;
expect(xmldata.TravelTranCrCnt).to.equal(
travelTranCrCntValue,
'travelTranCrCntValue is equal to TravelTranCrCnt'
);
//TODO: This is we have defect (showing booker details instead of traveler) once that is fixed we uncomment this code
//CustRefTx Value is traveler name and it should be present in TvlrFirstNm and TvlrLastNm
/* cy.task('getDataFromCache','travelerName').then((travelerName:any)=>{
const custRefTxElement = xmlDoc.getElementsByTagName('CustRefTx')[0];
const custRefTxValue = custRefTxElement.textContent;
expect(custRefTxValue).to.equal(travelerName);
const tvlrFirstNmElement = xmlDoc.getElementsByTagName('TvlrFirstNm')[0];
const tvlrFirstNmValue = tvlrFirstNmElement.textContent;
expect(travelerName).to.contains(tvlrFirstNmValue);
const tvlrLastNmElement = xmlDoc.getElementsByTagName('TvlrLastNm')[0];
const tvlrLastNmValue = tvlrLastNmElement.textContent;
expect(travelerName).to.contains(tvlrLastNmValue);
})*/
});
}
static trainBatchXmlContentValidations() {
cy.allure().logStep('Get Train Batch XML content from cache');
Utility.getXmlContentFromCache(cacheKey).then((xmlContent: any) => {
const xmlDoc = Utility.parseXmlContent(xmlContent);
//btchCnt Value is 1
const btchCntElement = xmlDoc.getElementsByTagName('BtchCnt')[0];
const btchCntValue = btchCntElement.textContent;
if (btchCntValue !== null) {
expect(parseInt(btchCntValue)).to.be.at.least(
1,
'btchCntValue is equal to or greater than 1'
);
} else {
cy.log('btchCntValue is not found');
}
//BtchDbCrInd Value is D
const btchDbCrIndElement = xmlDoc.getElementsByTagName('BtchDbCrInd')[0];
const btchDbCrIndValue = btchDbCrIndElement.textContent;
expect(xmldata.BtchDbCrInd).to.equal(
btchDbCrIndValue,
'btchDbCrIndValue is equal to D'
);
//BtchSeqNbrValue is 8 digit number
const btchSeqNbrElement = xmlDoc.getElementsByTagName('BtchSeqNbr')[0];
const btchSeqNbrValue = btchSeqNbrElement.textContent;
if (btchSeqNbrValue !== null && btchSeqNbrValue !== undefined) {
expect(btchSeqNbrValue.trim().length).to.equal(8);
} else {
cy.log('BtchSeqNbrValue is null or undefined');
}
// btchCrCnValue is 0
const btchCrCntElement = xmlDoc.getElementsByTagName('BtchCrCnt')[0];
const btchCrCntValue = btchCrCntElement.textContent;
expect(xmldata.BtchCrCnt).to.equal(btchCrCntValue, 'btchCrCntValue is equal to 0');
//TrvlBtchCnt Value is traveler count
const trvlBtchCntElement = xmlDoc.getElementsByTagName('TrvlBtchCnt')[0];
const trvlBtchCntValue = trvlBtchCntElement.textContent;
if (trvlBtchCntValue !== null) {
expect(parseInt(trvlBtchCntValue)).to.be.at.least(
1,
'trvlBtchCntValue is equal to or greater than 1'
);
} else {
cy.log('trvlBtchCntValue is not found');
}
//BtchCrTot Value is 0
const btchCrTotElement = xmlDoc.getElementsByTagName('BtchCrTot')[0];
const btchCrTotValue = btchCrTotElement.textContent;
expect(xmldata.BtchCrCnt).to.equal(btchCrTotValue, 'btchCrTotValue is equal to 0');
});
}
static paymentTrainXmlContentValidations() {
cy.allure().logStep('Check Payment XML content from cache');
Utility.getXmlContentFromCache(cacheKey).then((xmlContent: any) => {
const xmlDoc = Utility.parseXmlContent(xmlContent);
//AcctNbr Value is 15 digit number
const acctNbrElement = xmlDoc.getElementsByTagName('AcctNbr')[0];
const acctNbrdValue = acctNbrElement.textContent;
expect(xmldata.AcctNbr).to.equal(
acctNbrdValue,
'acctNbrdValue is the same as AcctNbr'
);
//CrdExpDt Value is 4 digit number
const crdExpDtElement = xmlDoc.getElementsByTagName('CrdExpDt')[0];
const crdExpDtValue = crdExpDtElement.textContent;
expect(xmldata.CrdExpDt).to.equal(
crdExpDtValue,
'crdExpDtValue is the same as CrdExpDt'
);
//amexAgcyNbrValue is TQ42
const amexAgcyNbrElement = xmlDoc.getElementsByTagName('AmexAgcyNbr')[0];
const amexAgcyNbrValue = amexAgcyNbrElement.textContent;
expect(xmldata.AmexAgcyNbr).to.equal(
amexAgcyNbrValue,
'amexAgcyNbrValue is the same as AmexAgcyNbr'
);
//amexOfcNbrValue is 032581516
const amexOfcNbrElement = xmlDoc.getElementsByTagName('AmexOfcNbr')[0];
const amexOfcNbrValue = amexOfcNbrElement.textContent;
expect(xmldata.AmexOfcNbr).to.equal(
amexOfcNbrValue,
'amexOfcNbrValue is the same as AmexOfcNbr'
);
});
}
static currencyCodeTrainXmlContentValidations() {
cy.allure().logStep('Check Currency XML content from cache');
Utility.getXmlContentFromCache(cacheKey).then((xmlContent: any) => {
const xmlDoc = Utility.parseXmlContent(xmlContent);
cy.task('getDataFromCache', 'trainTotalBookingChargeCurrency').then(
(currency: any) => {
//CurrencyCd is currency code
const currencyCdElement = xmlDoc.getElementsByTagName('CurrencyCd')[0];
const currencyCdValue = currencyCdElement.textContent;
expect(currency).to.equal(
currencyCdValue,
'currencyCdValue is the same as CurrencyCd'
);
//TrvlBtchCurrCd is currency code
const trvlBtchCurrCdElement = xmlDoc.getElementsByTagName('TrvlBtchCurrCd')[0];
const trvlBtchCurrCdValue = trvlBtchCurrCdElement.textContent;
expect(currency).to.equal(
trvlBtchCurrCdValue,
'trvlBtchCurrCdValue is the same as TrvlBtchCurrCd'
);
}
);
});
}
static trainXmlContentValidations() {
cy.getAmexBTAEuXML(amexBTARegion.EU);
InvoiceValidation.trainRequiredXmlContentValidations();
InvoiceValidation.trainXMLValidation();
InvoiceValidation.travelerTrainXmlContentValidations();
InvoiceValidation.trainBatchXmlContentValidations();
InvoiceValidation.paymentTrainXmlContentValidations();
InvoiceValidation.currencyCodeTrainXmlContentValidations();
}
static checkTrainUnchangeabilityData() {
cy.allure().logStep(` Check Train Unchangeability Invoice content :`);
cy.contains(english.Cancelled).should('not.exist');
cy.contains(english.PaymentMethod);
cy.contains(english.address);
cy.contains(english.CorrectionOf);
cy.contains(english.CorrectionReceipt);
cy.contains(english.TrainReceipt);
}
static totalTrainAmountValidation() {
cy.allure().logStep(` Check Train Total Amount :`);
cy.task('getDataFromCache', 'trainTotalBookingCharge').then((totalAmount: any) => {
const strippedTotalAmount = totalAmount.split(' ')[0];
cy.contains(strippedTotalAmount);
});
}
}