qe-fe-automation
Version:
FE test automation framework using cypress
78 lines (72 loc) • 3.32 kB
text/typescript
import { Logs, Timeouts } from '@utility-lib/index';
const trainCancellationSelector = {
tripSegments: '.cancellable-group',
oneWaySegmentCheckbox: '[type="checkbox"]',
continueWithSelection: '.cancellation-footer__actions__button',
acknowledge: '.summary__footer__content__confirmation',
acknowledgeCheckbox: '.ta-checkbox__input',
chooseReason: '.summary__footer__content__actions__reason',
chooseReasonDropdown: '.ta-form-wrap__main',
cancellationReason: '.ta-select-option__label',
cancelTicket: '.summary__footer__content__actions #cancelButton',
cancelledLabel: '[class="ta-tag ta-tag--soft-warning"]',
roundTripSegment: '[type="checkbox"]',
selectAll: '.train-cancel__select-all',
cancellableGroup: '.cancellable-group__cancellable__content',
showCancelled: '.ta-checkbox__content',
cancelReason: '[aria-label^="Other"]'
};
export class TrainCancellation {
static oneWaySegmentSelectionCancellation() {
cy.get(trainCancellationSelector.cancellableGroup, Timeouts.MEDIUM_TIMEOUT_60_SEC)
.find(trainCancellationSelector.oneWaySegmentCheckbox)
.each((ele) => {
cy.wrap(ele).click({ force: true });
});
cy.get(trainCancellationSelector.continueWithSelection)
.contains('Continue with selection')
.click();
cy.wait('@waitForBookingStatusUpdate').then((xhr) => {
Logs.cypressResponseLog('CANCELLATION RESPONSE', xhr);
});
cy.allure().logStep('continue with selection for one way segment');
}
static cancellationCheckout() {
cy.get(trainCancellationSelector.acknowledge, Timeouts.MEDIUM_TIMEOUT_60_SEC)
.find(trainCancellationSelector.acknowledgeCheckbox)
.click();
cy.allure().logStep('aknowledge checkbox');
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
cy.get(trainCancellationSelector.chooseReason)
.find(trainCancellationSelector.chooseReasonDropdown)
.click();
cy.get(trainCancellationSelector.cancelReason).click({ force: true });
cy.wait(Timeouts.SHORT_TIMEOUT_3_SEC.timeout);
cy.allure().logStep('cancellation reason');
cy.get(trainCancellationSelector.cancelTicket).contains('Cancel selection').click();
cy.wait('@waitForBookingStatusUpdate').then((xhr) => {
Logs.cypressResponseLog('CANCELLATION RESPONSE', xhr);
});
cy.get(trainCancellationSelector.cancelledLabel, Timeouts.MEDIUM_TIMEOUT_60_SEC)
.eq(0)
.should('have.text', 'Canceled');
cy.get('[class="action--cancel-v2 action--disabled"]').should('be.exist');
cy.get('[class="action--change-v2 action--disabled"]').should('be.exist');
cy.get('[class="status-wrap status-wrap--canceled"]').should('be.exist');
cy.allure().logStep('trip canceled');
}
static roundSegmentsSelectionCancellation() {
cy.get(trainCancellationSelector.cancellableGroup, Timeouts.MEDIUM_TIMEOUT_60_SEC)
.find(trainCancellationSelector.roundTripSegment)
.each((ele) => {
cy.wrap(ele).click({ force: true });
});
cy.get(trainCancellationSelector.continueWithSelection)
.contains('Continue with selection')
.click();
cy.wait('@waitForBookingStatusUpdate').then((xhr) => {
Logs.cypressResponseLog('CANCELLATION RESPONSE', xhr);
});
cy.allure().logStep('continue with selection for round segment');
}
}