import { SharedIntercepts } from '@intercepts-lib/shared_intercepts';

const chatBaseUrl = 'api/chat/v1/user';

export class ChatApiIntercept {
  static interceptChatApis() {
    SharedIntercepts.intercepts();
    cy.intercept('POST', new RegExp(`${chatBaseUrl}/channels`)).as(
      'waitForInitChatChannel'
    );
    cy.intercept(
      'GET',
      new RegExp(`${chatBaseUrl}/channels/.*/isAgentToCatiInProgress`)
    ).as('waitForAgentToCatiInProgress');

    cy.intercept('GET', /api\/user\/autocomplete\/airport\?/).as(
      'waitForAutocompleteAirports'
    );

    cy.intercept('POST', new RegExp(`${chatBaseUrl}/chatbot/sessions/.*/messages`)).as(
      'waitForSentMessage'
    );

    cy.intercept('GET', /api\/user\/autocomplete/).as('waitForLocation');

    cy.intercept('PUT', /\/api\/chat\/v1\/user\/csat\/([a-zA-Z0-9]+)\/score/).as(
      'waitForCsatScore'
    );
    cy.intercept('PUT', /\/api\/chat\/v1\/user\/csat\/([a-zA-Z0-9]+)\/remark/).as(
      'waitForCsatRemark'
    );
    cy.intercept('PUT', /\/api\/chat\/v1\/user\/csat\/([a-zA-Z0-9]+)\/skip/).as(
      'waitForCsatSkip'
    );
  }
}
