qe-fe-automation
Version:
FE test automation framework using cypress
98 lines (82 loc) • 3.13 kB
text/typescript
import { AuditLogAction, AuditLogActionSelector } from '@travelxen-lib/constants';
import { tripsModuleSelectors } from '@travelxen-lib/selectors/trips';
import { Timeouts } from '@utility-lib/index';
export class TravelXenTripsModule {
static openTrip() {
cy.allure().logStep('click on trip item');
cy.get(tripsModuleSelectors.tripItem).click();
}
static openBookingDetails() {
cy.allure().logStep('click on booking item');
cy.get(tripsModuleSelectors.bookingItem).click();
}
static clickOnBookingTab(bookingTabText: string | RegExp) {
cy.allure().logStep(`selecting the booking tab ${bookingTabText}`);
cy.get(tripsModuleSelectors.bookingInformationTabs).contains(bookingTabText).click();
}
static verifyTripsModuleRenders(): void {
cy.allure().logStep('verify trips module renders');
cy.wait(Timeouts.SHORT_TIMEOUT_5_SEC.timeout);
cy.get(tripsModuleSelectors.tripsModule).should('be.visible');
cy.get(tripsModuleSelectors.tripModule).should('be.visible');
cy.get(tripsModuleSelectors.tripsHeader).contains('Booking');
}
static verifyBookingTabContentRenders(id: string, text?: string) {
cy.get(id).should('exist');
if (text) {
cy.allure().logStep(`booking tab with text ${text} renders`);
}
}
static verifyBookingDetailsTabContentRenders() {
this.clickOnBookingTab(/booking details/i);
this.verifyBookingTabContentRenders(
tripsModuleSelectors.bookingDetailsTabContent,
'booking details'
);
}
static verifyPassengerInformationTabContentRenders() {
this.clickOnBookingTab(/passenger information/i);
this.verifyBookingTabContentRenders(
tripsModuleSelectors.passengerInformationTabContent,
'passenger information'
);
}
static verifyPaymentDetailsTabContentRenders() {
this.clickOnBookingTab(/payment/i);
this.verifyBookingTabContentRenders(
tripsModuleSelectors.paymentDetailsTabContent,
'payment details'
);
}
static verifyCustomFieldsTabContentRenders() {
this.clickOnBookingTab(/Custom fields/i);
this.verifyBookingTabContentRenders(
tripsModuleSelectors.bookingInformationTabs,
'Trip name'
);
}
static verifyChangeCancelTabContentRenders() {
this.clickOnBookingTab(/Change/i);
this.verifyBookingTabContentRenders(
tripsModuleSelectors.bookingInformationTabs,
'Cancel for a full refund or change your booking without penalty.'
);
}
static verifyNotesTabContentRenders() {
this.clickOnBookingTab(/note/i);
this.verifyBookingTabContentRenders(
tripsModuleSelectors.bookingInformationTabs,
'Write a new note...'
);
cy.get(tripsModuleSelectors.notesInput).type('Test note from automation');
this.verifyBookingTabContentRenders(
tripsModuleSelectors.bookingInformationTabs,
'Auto saved'
);
}
static verifyAuditLogRecordRenders(recordName: AuditLogAction) {
cy.allure().logStep(`looking for audit log action: ${recordName}`);
this.clickOnBookingTab(/change log/i);
cy.get(AuditLogActionSelector[recordName]).should('exist');
}
}