import { environment } from '../../../src/environments/environment';
import { LoginHelper } from '../../helpers/login';
import { mockApiResponse, cypressConfig } from '../../helpers/common';

const loginHelper = new LoginHelper();
const path = '/eula-message';
let elements: EulaMessageElements;

describe('Eula Message page', () => {

  beforeEach(() => {
    loginHelper.visitPageAndSubmitForm(
      'eula-message/login-eula-not-accepted.xml',
      {
        status: 200,
        response: '@successResponse',
      }
    );
    elements = {
      acceptTermsCheckbox: () => cy.get('ion-checkbox'),
      continueButton: () => cy.get('ion-list + ion-button'),
      terms: () => cy.get('.terms'),
    };
    const mockResponseAlias = 'successResponse'
    cy.fixture('eula-message/accept-eula-success.xml').as(mockResponseAlias);
    mockApiResponse({
      status: 200,
      response: `@${mockResponseAlias}`,
      method: 'GET',
      url: `${environment.apiUrl}/accept_eula`,
    });
  });

  xit('Display the Terms HTML returned from the API Login response', () => {
    elements.terms()
      .should('contain', 'arbitary');
  });

  xit('Prevents tapping the continue button when terms are disabled', () => {
    elements.continueButton()
      .should('have.attr', 'disabled');
  });

  xit('Navigates user to Smart Sync page when terms are accepted and continue tapped', () => {
    elements.acceptTermsCheckbox().click();
    elements.continueButton().click();
    cy.url().should('include', '/smart-sync');
  });

});


interface EulaMessageElements {
  acceptTermsCheckbox: any;
  continueButton: any;
  terms: any;
}
