import * as moment from 'moment'; describe('Онлайн табло: Поиск по маршруту', () => { const route = { departureCity: { name: 'Москва', code: 'MOW', latitude: 55.7558, longitude: 37.62, }, arrivalCity: { name: 'Сочи', code: 'AER', latitude: 43.58, longitude: 39.72, }, }; const today = moment().format('DD.MM.YYYY'); beforeEach(() => { cy.intercept('GET', '**api/flights/v1.1/ru/board**').as('getFlights'); cy.forbidGeolocation(); cy.visit('/'); cy.getByTestId('route-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(`Должен искать рейсы ${route.departureCity.name} - ${route.arrivalCity.name} , открывать корректный URL и детали рейса`, () => { cy.getByTestId('route-departure-city-input').type(`${route.departureCity.name}`); cy.getByTestId('route-arrival-city-input').type(`${route.arrivalCity.name}`); cy.getByTestId('calendar-input').type(today).type('{enter}'); cy.getByTestId('route-arrival-city-input').getByTestId('city-code').contains(`${route.arrivalCity.code}`).should('be.visible'); cy.getByTestId('route-departure-city-input').getByTestId('city-code').contains(`${route.departureCity.code}`).should('be.visible'); cy.getByTestId('route-search-button').click(); assertSearchResults(); 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'); }); });