qe-fe-automation
Version:
FE test automation framework using cypress
37 lines (32 loc) • 1.35 kB
text/typescript
import { Timeouts } from '@utility-lib/constants';
import { CommerceApiIntercepts } from './api-intercepts';
const sharedLocators = {
downloadInvoiceLink: '[qa-id="event-action-download-invoice"]'
};
export class CommerceShared {
static visitTripsPage() {
CommerceApiIntercepts.interceptCommerceApis();
cy.allure().logStep('Visit Booked Trips Page');
cy.visit('app/user2/bookings');
cy.url().should('include', '/bookings');
cy.wait('@waitForUserInfo');
}
static visitViewInvoicePage() {
CommerceApiIntercepts.interceptCommerceApis();
cy.allure().logStep(` Go to view invoice page :`);
cy.get(sharedLocators.downloadInvoiceLink).then((ele) => {
cy.wrap(ele).scrollIntoView();
cy.wrap(ele).should('be.visible');
cy.wrap(ele).click();
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
});
}
}
export function generateRandomCurrency() {
const randomBytes = new Uint8Array(4); // Adjust the array size as needed
crypto.getRandomValues(randomBytes);
const dollars = Math.floor((randomBytes[0] / 255) * 500); // Scale the random value to dollars (0-499)
const cents = Math.floor((randomBytes[1] / 255) * 100); // Scale the random value to cents (0-99)
const currencyValue = `${dollars}.${cents.toString().padStart(2, '0')}`; // Format the currency value
return currencyValue;
}