import { HelpCenter } from '@helpcenter-lib/helpcenter';
import { ChatApiIntercept, ChatBox, CSat, Banner } from '@chat-lib/index';
import { Timeouts } from '@utility-lib/constants';
import { stagingUsers } from '@fixtures/staging-users';

const { userChat } = stagingUsers;
const userPassword = Cypress.env('chat').CHAT_PASSWORD;

describe.skip('Chat: Automatic transfer to agent', () => {
  beforeEach(() => {
    cy.cleanUpTasks();
  });

  afterEach(() => {
    cy.cleanUpTasks();
  });

  it.skip(
    'C7447618: Ava automatic transfer to agent when user AFK',
    { tags: ['@tier2'] },
    () => {
      ChatApiIntercept.interceptChatApis();

      HelpCenter.visitAndLogin(userChat.email, userPassword);
      ChatBox.startANewChatOrContinue();

      ChatBox.selectMsgYouWannaSendBackToAva(
        'No, something else',
        'Refunds, credits and charges'
      );
      ChatBox.selectMsgYouWannaSendBackToAva('Status of refund/credit requests');
      ChatBox.expectMsgReceivedFromAva('Are you missing a refund or credit?');
      ChatBox.selectMsgYouWannaSendBackToAva('Yes');
      ChatBox.selectMsgYouWannaSendBackToAva(`The booking isn’t listed`);
      ChatBox.expectMsgReceivedFromAva("Ok, I'll get an agent to help.");
      ChatBox.expectMsgReceivedFromAva(
        'While I connect you, can you take a moment to give us your feedback?'
      );
      cy.wait(Timeouts.MEDIUM_TIMEOUT_20_SEC.timeout);
      ChatBox.verifyIfMsgInputNotDisplayed();
      CSat.submitCSatScore(5);
      CSat.expectCSatScoreSubmitted(5);
      CSat.skipAndConnetWithAgent();
      ChatBox.expectMsgReceivedFromAva('Skip and connect with an agent');
      Banner.expectBannerContainsText('An agent will be with you shortly.');
    }
  );
});
