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

describe('eUI - <eui-icon-svg> Component Object',async () => {
  let page = new EuiIconSvgPage();
  let testFolder = './/v14x//eui-icon-svg//'
  let pageName = 'eui-icon-svg'
  it('should navigate to <eui-icon-svg> demo page ',async () => {
    browser.addTestMeta({uuid:"8ea800d3-ae09-40aa-b758-47425a13bc37", zephyrKey: "CCQA-2212", zephyrStep: "507018", reportGroups: ["eUI.14x.eui"]});
    await page.open(Routing.getEUIComponentUrl('eui-icon-svg'));
    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-svg> identification methods',async () => {
    browser.addTestMeta({zephyrStep: "507019"});
    let sectionId = 'icon-sets';
    await BaseActions.verifySection(sectionId, pageName);
    let index = 1;
    let iconFromSectionWithIdByIndex1 = await (await page.iconSvgFromSectionWithIdByIndex(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.iconSvgByIndex(index).defaultComponentsCount()).equal(515, 'There should be 515 <eui-icon-svg> 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 default icons',async () => {
    browser.addTestMeta({zephyrStep: "507020"});
    let sectionId = 'icon-colors';
    await BaseActions.verifySection(sectionId, pageName);
    let index = 1
    let icon = page.iconSvgFromSectionWithIdByIndex(sectionId, index);
    // await ex(await icon.defaul)).equal(true, 'Svg icon is not default');
    await chaiExpect(await icon.isDefault()).equal(true, 'Svg icon is not default');
  });
  it('should verify the custom icons',async () => {
    browser.addTestMeta({zephyrStep: "507050"});
    let sectionId = 'custom-icons';
    await BaseActions.verifySection(sectionId, pageName);
    let index = 1
    let icon = page.iconSvgFromSectionWithIdByIndex(sectionId, index);
    await chaiExpect(await icon.isCustom()).equal(true, 'Svg icon is not custom');
  });

});
