import Routing from '../../../pages/eui/14x/routing.js'
import EuiBlockContentPage from '../../../pages/eui/14x/eui-block-content.po.js'
import * as CookieBannerActions from '../../../actions/cookieBanner.js';
import BaseActions from '../../../actions/V14/base-actions.js';

describe('eUI - <eui-block-content> Component Object ', async () => {
  let page = new EuiBlockContentPage();
  let testFolder = './/v14x//eui-block-content//'
  let pageName = 'eui-block-content';
  it('should navigate to <eui-block-content> demo page ', async () => {
    browser.addTestMeta({uuid:"834685c8-cf44-11eb-b8bc-0242ac130003", zephyrKey: "CCQA-1109", zephyrStep: "407905", reportGroups: ["eUI.14x.eui"]});
    await page.open(Routing.getEUIComponentUrl('eui-block-content'));
    await CookieBannerActions.cookieBanner(true);
    await BaseActions.verifyPageTitle(pageName);
    await expect(await $(page.navigationList)).toBeDisplayed({message:'Navigation List -> is not displayed on page'});
  });
  it('should verify the presence and number of component objects <eui-block-content> on page ', async () => {
    browser.addTestMeta({zephyrStep: "407906"});
    let sectionId= 'Default';
    await BaseActions.verifySection(sectionId, pageName);
    let index = 1;
    let blockContentByIndex1 = await page.blockContentByIndex(index).element();
    await expect(await $(page.sectionById(sectionId))).toBeDisplayed({wait:1000, message:'<'+sectionId+'> section -> is not displayed on page'});
    await expect(blockContentByIndex1).toBeDisplayed({wait:1000, message:'Block content by index '+ index +' is not displayed on page'});
    await chaiExpect(await page.blockContentByIndex(index).defaultComponentsCount()).equal(1, 'There should be 1 <eui-block-content> components on the page.');
    if(browser.config.useWdioImageComparison) {
      await blockContentByIndex1.scrollIntoView();
      await chaiExpect(await browser.checkElement(blockContentByIndex1, testFolder+'img_blockContentByIndex1', {hideElements: [await $('//eui-app-toolbar')]})).equal(0, 'Image comparison failed for blockContentByIndex1');
    }
    });
  it('should verify the methods wrapper and isBlocked ', async () => {
    browser.addTestMeta({zephyrStep: "407907"});
    let sectionId = 'Default';
    await BaseActions.verifySection(sectionId, pageName);
    let index = 1;
    let blockContent = page.blockContentByIndex(index);
    await chaiExpect(await blockContent.isBlocked()).equal(false, 'isBlocked is not false');
    await (await $(page.euiButtonCOfromSectionWithIdByIndex(sectionId,2).currentPath)).click();
    let blockContentWrapper = await $(blockContent.wrapper);
    await expect(blockContentWrapper).toBeDisplayed({message:'Block content wrapper is not displayed on page'});
    if(browser.config.useWdioImageComparison) {
      await blockContentWrapper.scrollIntoView();
      await chaiExpect(await browser.checkElement(blockContentWrapper, testFolder+'img_blockContentWrapper', {hideElements: [await $('//eui-app-toolbar')]})).within(0, 0.8 , 'Image comparison failed for blockContentWrapper');
      }
    await chaiExpect(await blockContent.isBlocked()).equal(true, 'isBlocked is not true');
    await (await $(page.euiButtonCOfromSectionWithIdByIndex(sectionId,2).currentPath)).click();

  });
});
