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

describe('Audit information modal', function () {
  describe('basic UI tests', () => {
    var jsonBuilderInstantiationBuilder: JsonBuilder<AsyncInstantiationModel> = new JsonBuilder<AsyncInstantiationModel>();
    var jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
    beforeEach(() => {
      cy.window().then((win) => {
        win.sessionStorage.clear();
        cy.setReduxState();
        cy.preventErrorsOnLoading();
        jsonBuilderInstantiationBuilder.basicMock('cypress/support/jsonBuilders/mocks/jsons/asyncInstantiation.json',
          Cypress.config('baseUrl') + "/asyncInstantiation**");
        cy.initAAIMock();
        cy.initVidMock();
        cy.initAsyncInstantiation();
        cy.login();
      })
    });

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

    it(`should display 2 tables with information's`, function () {
      cy.initAuditInfoMSOALaCarte();
      cy.openIframe('app/ui/#/instantiationStatus');
      cy.get('.instantiation-status-data tbody tr').each(function (row, index) {
        cy.get('.icon-menu').eq(index).click({force: true}).then(()=>{
          cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(()=>{
            cy.get('#service-model-name').should('contain', row.find('#serviceModelName').text().trim())
              .getElementByDataTestsId('model-item-value-userId').should('contain', row.find('#userId').text().trim())
              .get('#service-instantiation-audit-info-vid').should('be.visible')
              .get('#service-instantiation-audit-info-vid').find('#vidJobStatus').should('be.visible')
              .get('#service-instantiation-audit-info-mso').should('be.visible')
              .get('#service-instantiation-audit-info-mso').find('#msoJobStatus').should('be.visible')
              .get('#cancelButton').click({force:true});
          })
        });
      });
    });

    it("shouldn't show instance name in mso table on macro service", function () {
      cy.openIframe('app/ui/#/instantiationStatus');
      cy.get('.icon-menu').eq(0).click({force:true}).then(() => {
        cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(() => {
          cy.get('#service-instantiation-audit-info-mso thead tr th#instanceName').should("not.be.visible")
            .get('#service-instantiation-audit-info-mso tbody tr td.msoInstanceName').should("not.be.visible");
        })
      })
    });

    it('should show instance name in mso table on a la carte service', function () {
      cy.readFile('../vid-automation/src/test/resources/a-la-carte/auditInfoMSOALaCarte.json').then((res) => {
        cy.initAuditInfoMSOALaCarte(res);
        cy.openIframe('app/ui/#/instantiationStatus');
        cy.get('.icon-menu').eq(7).click({force:true}).then(() => {
          cy.getElementByDataTestsId('context-menu-audit-info').click({force:true}).then(() => {
            cy.get('#service-instantiation-audit-info-mso thead tr th#instanceName').should("be.visible")
              .get('#service-instantiation-audit-info-mso tbody tr').each(function (row, index) {
              assert.equal(row.find('.request-id').text().trim(), res[index]['requestId']);
              assert.equal(row.find('.msoInstanceName').text().trim(), 'service: ' + res[index]['instanceName']);
              assert.equal(row.find('#msoJobStatus').text().trim(), _.capitalize(res[index]['jobStatus']));
              assert.equal(row.find('#msoAdditionalInfo span').text().trim(), res[index]['additionalInfo']);
            });
          });
        })
      })
    });

    it('glossary should be visible', function () {
      cy.openIframe('app/ui/#/instantiationStatus');
      cy.get('.icon-menu').eq(7).click().then(() => {
        cy.getElementByDataTestsId('context-menu-audit-info').click().then(() => {
          cy.get('#glossary_link').should('be.visible');
        });
      })
    });

  });
});
