import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import IconPage from '../../../../pages/eui/10x/ux/ux-a-icon-10x.po.js'

describe('eUI - <ux-a-icon> Component Object @CCQA-699', async() => {
  let iconPage = new IconPage();
  it('should navigate to <ux-a-icon> component page', async() => {
    browser.addTestMeta({uuid:"749dd22e-71f7-11eb-9439-0242ac130002", zephyrKey: "CCQA-699", zephyrStep: "354071", reportGroups: ["eUI.10x.ux"]});
    await iconPage.open(Routing.getUxComponentUrl('ux-a-icon'));
    await CookieBannerActions.cookieBanner(true);
  });
  it('should verify main elements from <ux-a-icon> component page', async() => {
    browser.addTestMeta({zephyrStep: "354072"});
    let pgTitle = await $(iconPage.pageTitle);
    let appDocPageId = await $(iconPage.appDocPageById('ux-a-icon'));
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-a-icon> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-a-icon', 'Page title text is not as expected')
    await expect(appDocPageId).toExist({wait:1000, message:'Page Id is not present in page'});
  });
  it('should verify the presence of the Component Object on the page', async() => {
    browser.addTestMeta({zephyrStep: "354073"});
    let dateTagDefault = await $(iconPage.iconCoByIdUnderSectionTitleByName(1, 'Default').currentPath);

    await chaiExpect(await iconPage.iconByIndex(1).defaultComponentsCount()).equal(38, 'There should be 38 <ux-a-icon> components on the page.')
    await expect(dateTagDefault).toBeDisplayed({timeout:1000, timeoutMsg:'<ux-a-icon> from Default section - is not visible on page', interval:100});
  });
  it('should verify presence of <ux-a-icon> tag label', async() => {
    browser.addTestMeta({zephyrStep: "354074"});
    let tagIcon = await $(iconPage.iconCoByIdUnderSectionTitleByName(1, 'tagLabel').iconTag);
    let tagIconLabel = await $(iconPage.iconCoByIdUnderSectionTitleByName(1, 'tagLabel').tagLabel);

    await expect(tagIcon).toBeDisplayed({timeout:1000, timeoutMsg:'<ux-a-icon> Day element - is not visible on page', interval:100});
    await expect(await tagIconLabel.getText()).toBe('99');
  });
  it('should verify <ux-a-icon> types', async() => {
    browser.addTestMeta({zephyrStep: "354075"});
    let iconCont1 = await $(iconPage.iconCoByIdUnderSectionTitleByName(1, 'typeClass').iconContent)
    let iconCont2 = await $(iconPage.iconCoByIdUnderSectionTitleByName(2, 'typeClass').iconContent)
    let iconCont3 = await $(iconPage.iconCoByIdUnderSectionTitleByName(3, 'typeClass').iconContent)
    let iconCont4 = await $(iconPage.iconCoByIdUnderSectionTitleByName(4, 'typeClass').iconContent)
    let iconCont5 = await $(iconPage.iconCoByIdUnderSectionTitleByName(5, 'typeClass').iconContent)
    await expect(iconCont1).toHaveAttributeContaining('class', 'ux-a-icon--primary');
    await expect(iconCont2).toHaveAttributeContaining('class', 'ux-a-icon--info');
    await expect(iconCont3).toHaveAttributeContaining('class', 'ux-a-icon--success');
    await expect(iconCont4).toHaveAttributeContaining('class', 'ux-a-icon--warning');
    await expect(iconCont5).toHaveAttributeContaining('class', 'ux-a-icon--danger');
  });
  it('should verify <ux-a-icon> style methods', async() => {
    browser.addTestMeta({zephyrStep: "354076"});
    let roundedIcon = await iconPage.iconCoByIdUnderSectionTitleByName(1, 'Default').isRounded();
    let largeIcon = await iconPage.iconCoByIdUnderSectionTitleByName(1, 'isLarge').isLarge();
    let hooverIcon = await iconPage.iconCoByIdUnderSectionTitleByName(1, 'isHoverable').isHoverable();
    let notRoundedIcon = await iconPage.iconCoByIdUnderSectionTitleByName(1, 'isLarge-notRounded').isRounded();
    let smallIcon = await iconPage.iconCoByIdUnderSectionTitleByName(1, 'typeClass-isSmall').isSmall();
    let tagIcon = await iconPage.iconCoByIdUnderSectionTitleByName(1, 'tagLabel').isShowTag();

    await expect(roundedIcon).toBe(true);
    await expect(largeIcon).toBe(true);
    await expect(hooverIcon).toBe(true);
    await expect(notRoundedIcon).toBe(false);
    await expect(smallIcon).toBe(true);
    await expect(tagIcon).toBe(true);
  });
});
