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

describe('eUI - <ux-a-icon-box> Component Object @CCQA-700', async() => {
  let iconBoxPage = new IconBoxPage();
  it('should navigate to <ux-a-icon-box> component page', async() => {
    browser.addTestMeta({uuid:"0996e970-4a91-42cd-ae67-6a77b2210aa3", zephyrKey: "CCQA-700", zephyrStep: "354077", reportGroups: ["eUI.10x.ux"]});
    await iconBoxPage.open(Routing.getUxComponentUrl('ux-a-icon-box'));
    await CookieBannerActions.cookieBanner(true);
  });
  it('should verify main elements from <ux-a-icon-box> component page', async() => {
    browser.addTestMeta({zephyrStep: "354078"});
    let pgTitle = await $(iconBoxPage.pageTitle);
    let appDocPageId = await $(iconBoxPage.appDocPageById('ux-a-icon-box'));
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-a-icon-box> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-a-icon-box', 'Page title text is not as expected');
    await expect(appDocPageId).toExist({timeout:1000, timeoutMsg:'Page Id is not present in page', interval:100});
  });
  it('should verify the presence of the Component Object on the page', async() => {
    browser.addTestMeta({zephyrStep: "354079"});
    let defaultIconBoxCO = await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(1, 'Default').currentPath);
    await chaiExpect(await iconBoxPage.iconBoxByIndex(1).defaultComponentsCount()).equal(5, 'There should be 5 <ux-a-icon-box> components on the page.')
    await expect(defaultIconBoxCO).toBeDisplayed({wait:1000, message:'<ux-a-icon-box> from Default section - is not visible on page'});
  });
  it('should verify presence of <ux-a-icon-box> element', async() => {
    browser.addTestMeta({zephyrStep: "354080"});
    let defaultIconBoxCO = await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(1, 'Default').iconElement);
    await expect(defaultIconBoxCO).toBeDisplayed({wait:1000, message:'<ux-a-icon-box> - Icon Element - from Default section - is not visible on page'});
  });
  it('should verify presence of <ux-a-icon-box> label', async() => {
    browser.addTestMeta({zephyrStep: "376750"});
    let defaultIconBoxCO = await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(1, 'Default').iconLabel);
    await expect(defaultIconBoxCO).toBeDisplayed({wait:1000, message:'<ux-a-icon-box> - Icon Label - from Default section - is not visible on page'});
    await expect(await defaultIconBoxCO.getText()).toBe('DEFAULT (PRIMARY)', 'Icon box text is not as expected');
  });
  it('should verify <ux-a-icon-box> aria label', async() => {
    browser.addTestMeta({zephyrStep: "376751"});
    let ariaLabel1 = await (await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(1, 'Default').iconBox)).getAttribute('aria-label')
    let ariaLabel2 = await (await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(2, 'Default').iconBox)).getAttribute('aria-label')
    let ariaLabel3 = await (await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(3, 'Default').iconBox)).getAttribute('aria-label')
    let ariaLabel4 = await (await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(4, 'Default').iconBox)).getAttribute('aria-label')
    let ariaLabel5 = await (await $(iconBoxPage.iconBoxCoByIdUnderSectionTitleByName(5, 'Default').iconBox)).getAttribute('aria-label')
    await expect(ariaLabel1).toBe('default (primary)', 'Aria label text is not as expected "default (primary)"');
    await expect(ariaLabel2).toBe('info', 'Aria label text is not as expected "info"');
    await expect(ariaLabel3).toBe('success', 'Aria label text is not as expected "success"');
    await expect(ariaLabel4).toBe('warning', 'Aria label text is not as expected "warning"');
    await expect(ariaLabel5).toBe('danger', 'Aria label text is not as expected "danger"');
  });
});
