///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
/// <reference types="Cypress" />
import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
import {ServiceModel} from '../../support/jsonBuilders/models/service.model';

describe('Browse SDC', function () {
    var jsonBuilderAndMock : JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();


    beforeEach(() => {
      cy.window().then((win) => {
        win.sessionStorage.clear();
        cy.preventErrorsOnLoading();
        cy.initAAIMock();
        cy.initVidMock();
        cy.initZones();
        cy.login();
        cy.visit("welcome.htm")
      });
    });

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

    it(`browse sdc open macro with network and then macro for new flow`, function () {
       // const MACRO_WITH_CONFIGURATION_ID: string = 'ee6d61be-4841-4f98-8f23-5de9da846ca7';
      const MACRO_WITH_NETWORK_ID: string = "bd8ffd14-da36-4f62-813c-6716ba9f4354";
      const MACRO_FOR_NEW_FLOW_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0';
      const CANCEL_BUTTON = "cancelButton";

      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
        jsonBuilderAndMock.basicJson(res,
          Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
          200,
          0,
          'list_services');
      });

      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/bug616888/service-with-configuration.json').then((res) => {
        jsonBuilderAndMock.basicJson(res,
          Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_WITH_NETWORK_ID,
          200,
          0,
          'MACRO_WITH_CONFIGURATION');
      });

      cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
        jsonBuilderAndMock.basicJson(res,
          Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
          200,
          0,
          'MACRO_FOR_NEW_FLOW');
      });

      cy.get('span').contains('Browse ASDC Service Models').click({force: true});
      cy.wait("@list_services").then(() => {
        cy.getElementByDataTestsId('deploy-' + MACRO_WITH_NETWORK_ID).click({force: true})
          .getElementByDataTestsId(CANCEL_BUTTON).click({force: true});
        cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
        cy.get("iframe");
      });

      cy.visit("welcome.htm"); //relaod page to not break the following tests

    });

  it(`browse sdc of service without instantiationType open aLaCarte popup`, function () {
    const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695";
    const TEST_MOCKS_PATH="/cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";

    const CANCEL_BUTTON = "cancelButton";

    cy.readFile(TEST_MOCKS_PATH+'list-services.json').then((res) => {
      jsonBuilderAndMock.basicJson(res,
        Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
        200,
        0,
        'list_services');
    });

    cy.readFile(TEST_MOCKS_PATH+'serviceWithoutInstantiationType.json').then((res) => {
      jsonBuilderAndMock.basicJson(res,
        Cypress.config('baseUrl') + '/rest/models/services/' + VERY_OLD_SERVICE_UUID,
        200,
        0,
        'MACRO_WITH_CONFIGURATION');
    });

    cy.get('span').contains('Browse ASDC Service Models').click({force: true});
    cy.wait("@list_services").then(() => {
      cy.getElementByDataTestsId('deploy-' + VERY_OLD_SERVICE_UUID).click({force: true})
        .getElementByDataTestsId('create-modal-title').contains("Create Service Instance -- a la carte");
    });

    cy.visit("welcome.htm"); //relaod page to not break the following tests

  });



});
