import './commands';
import './admin/adminCommands';
import './agent/agentCommands';
import './commerce/commerceCommands';
import './onboard/companyOnboardCommands';
import './onboard/companyOnboardViaTSSCommands';
import './booking/bookingCommands';
import './user/userCommands';
import './policy/policyCommands';
import './event/eventCommands';
import './group-travel/groupTravelCommands';
import './rental_car/factory/trip';
import '@shelex/cypress-allure-plugin';
import { TestrailUtility } from '@utility-lib/index';
import './navan_pro/navanProCommands';
import './rental_car/rentalCarCommands';
import './train/trainCommands';

require('cypress-terminal-report/src/installLogsCollector')();

const registerCypressGrep = require('@cypress/grep');
registerCypressGrep();

// these plugins add 'verifyDownload' and 'deleteDownloadsFolder' methods which are used in tests
require('cy-verify-downloads').addCustomCommand();
require('cypress-delete-downloads-folder').addCustomCommand();

const options = {
  collectTypes: [
    'cons:error',
    'cy:intercept',
    'cy:request',
    'cy:command',
    'cy:log',
    'cy:xhr',
    'cons:info',
    'cons:warn',
    'cons:debug',
    'cons:log'
  ]
};
after(() => cy.log('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'));
require('cypress-terminal-report/src/installLogsCollector')(options);

Cypress.on('uncaught:exception', (promise) => {
  if (promise) {
    return false;
  }
});

Cypress.Keyboard.defaults({
  keystrokeDelay: 50
});

afterEach(() => {
  TestrailUtility.verifyTestrailIdIsPresent();
});
