/*
 * Copyright (C) 2022 Robert Bosch GmbH Copyright (C) 2022 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { AlertDialogPage } from '../../support/alert-dialog.po';

describe('Functionality of the Alert Dialog Component', () => {
  let page: AlertDialogPage;

  before(() => {
    page = new AlertDialogPage();
    page.navigateToAlertDemo();
  });

  beforeEach(() => {
    cy.viewport(1920, 1200);
  });

  describe('Success Alert Dialog with big content', () => {
    it('should open', () => {
      page.getSelectForTemplates().click().get('mat-option').contains('Big content').click();
      page.getShowAlertButton().click();
      page.getAlertDialog().find('bci-alert').should('exist');
    });
    it('alert dialog has a width of 640px', () => {
      page.getAlertDialog().should('have.css', 'width', '640px');
    });
    it('dialog has a green border-top for the success state', () => {
      page.getAlertDialog().should('have.css', 'border-top', '6px solid rgb(0, 136, 74)');
    });
    it('success icon is visible', () => {
      page.getAlertDialog().find('mat-icon[fontIcon=bosch-ic-alert-success]').should('be.visible');
    });
    it('standard title should be visible with an second additional title', () => {
      page.getDialogTitle().should('be.visible');
      page.getAdditionalDialogHeader().should('exist');
    });
    it('description should be visible', () => {
      page.getDescriptionContent().should('be.visible');
    });
    it('info Text should exists', () => {
      page.getInfoText().should('exist');
    });
    it('close button should be on the upper right corner and visible', () => {
      page.getCloseButton().should('be.visible').and('have.css', 'position', 'relative').and('have.css', 'top', '0px').and('have.css', 'right', '0px');
      page.getCloseButton().click();
    });
  });

  describe('Additional Title Alert Dialog with big Content', () => {
    it('should open', () => {
      page.getSelectForTemplates().click().get('mat-option').contains('All together').click();
      page.getShowAlertButton().click();
      page.getAlertDialog().find('bci-alert').should('exist');
    });
    it('dialog has a blue border-top for the info state', () => {
      page.getAlertDialog().should('have.css', 'border-top', '6px solid rgb(0, 123, 192)');
    });
    it('info icon is visible', () => {
      page.getAlertDialog().find('mat-icon[fontIcon=bosch-ic-alert-info]').should('be.visible');
    });
    it('standard and additional title with the divider should be visible', () => {
      page.getAdditionalDialogHeader().should('be.visible');
      page.getAdditionalDialogHeader().find('.dialog-title').should('be.visible');
      page.getAdditionalDialogHeader().find('.divider').should('exist');
      page.getCloseButton().click();
    });
  });
  describe('Custom Alert Dialog with big Content', () => {
    it('should open with disabled all buttons', () => {
      page.getSwitchForDisableLeftButton().click()
      page.getSwitchForDisableRightButton().click()
      page.getShowAlertButton().click();
      page.getAlertDialog().find('bci-alert').should('exist');
    });
    it('all buttons should be disabled', () => {
      page.getOptionalOuterLeftButton().should('be.disabled');
      page.getConfirmLeftButton().should('be.disabled');
      page.getCancelRightButton().should('be.disabled');
    });
  });
});
