Files
flights_web/ClientApp/cypress/integration/04 - online board - flight search.ts
T

45 lines
1.7 KiB
TypeScript

import * as moment from 'moment';
describe('Онлайн табло: Поиск рейса', () => {
const flightNumber = '0022'; // Москва - Санкт-Петербург
const expectedUrlDateTime = `${moment().format('DDMMYYYY')}`;
const today = moment().format('DD.MM.YYYY');
beforeEach(() => {
cy.intercept('GET', '**api/flights/v1.1/ru/board**').as('getFlights');
cy.visit('/');
cy.getByTestId('flight-filter').click();
});
const assertSearchResults = () => {
cy.getByTestId('loader').should('be.visible');
cy.wait('@getFlights').then(() => {
cy.getByTestId('board-search-result').should('be.visible');
cy.getByTestId('flight-result').should('have.length.at.least', 1);
});
};
it(`Должен искать рейс SU${flightNumber} , открывать корректный URL и детали рейса`, () => {
cy.getByTestId('flight-number-input').type(`${flightNumber}`).type('{enter}');
cy.getByTestId('calendar-input').type(today).type('{enter}');
cy.getByTestId('flight-number-search-button').click();
assertSearchResults();
cy.url().should('include', `ru-ru/onlineboard/flight/SU${flightNumber}/${expectedUrlDateTime}`);
cy.getByTestId('flight-result')
.first()
.getByTestId('flight-carrier-number')
.should('be.visible')
.getByTestId('flight-company-logo')
.should('be.visible');
cy.getByTestId('flight-details-button').click();
cy.getByTestId('flight-details-number').should('be.visible');
cy.getByTestId('flight-company-logo').should('be.visible');
});
});