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

describe('eUI - <eui-icon> Component Object',async () => {
  let page = new EuiIconPage();
  let testFolder = './/v14x//eui-icon//'
  let pageName = 'eui-icon'
  it('should navigate to <eui-icon> demo page ',async () => {
    browser.addTestMeta({uuid:"c21e0282-d023-11eb-b8bc-0242ac130003", zephyrKey: "CCQA-1115", zephyrStep: "408318", reportGroups: ["eUI.14x.eui"]});
    await page.open(Routing.getEUIComponentUrl('eui-icon'));
    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 <eui-icon> identification methods',async () => {
    browser.addTestMeta({zephyrStep: "408319"});
    let sectionId = 'Default';
    await BaseActions.verifySection(sectionId, pageName);
    let index = 2;
    let iconFromSectionWithIdByIndex1 = await (await page.iconFromSectionWithIdByIndex(sectionId, index).element());
    await expect(await $(page.sectionById(sectionId))).toBeDisplayed({message:'<composition> section -> is not displayed on page'});
    await expect(iconFromSectionWithIdByIndex1).toBeDisplayed({message:'Icon by index '+ index +' from section '+ sectionId +' is not displayed on page'});
    await chaiExpect(await page.iconByIndex(index).defaultComponentsCount()).equal(94, 'There should be 94 <eui-icon> components on the page.');
    if(browser.config.useWdioImageComparison) {
      await chaiExpect(await browser.checkElement(iconFromSectionWithIdByIndex1, testFolder+'img_iconByIndex1', {hideElements: [await $('//eui-app-toolbar')]})).equal(0, 'Image comparison failed for iconByIndex1');
    }
  });
  it('should verify the method isLoading',async () => {
    browser.addTestMeta({zephyrStep: "408321"});
    sectionId= 'is-loading';
    await BaseActions.verifySection(sectionId, pageName);
    index = 2
    icon = page.iconFromSectionWithIdByIndex(sectionId,index);
    await chaiExpect(await icon.isLoading()).equal(true, 'isLoading is not true');
  });


});
