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

describe('eUI - <ux-a-icon-toggle> Component Object @CCQA-701', async() => {
  let iconTgPage = new IconTogglePage();
  it('should navigate to <ux-a-icon-toggle> component page', async() => {
    browser.addTestMeta({uuid:"c629c61a-beb8-42a9-935b-7abb080de3a2", zephyrKey: "CCQA-701", zephyrStep: "354106", reportGroups: ["eUI.10x.ux"]});
    await iconTgPage.open(Routing.getUxComponentUrl('ux-a-icon-toggle'));
    await CookieBannerActions.cookieBanner(true);
  });
  it('should verify main elements from <ux-a-icon-toggle> component page', async() => {
    browser.addTestMeta({zephyrStep: "354107"});
    let pgTitle = await $(iconTgPage.pageTitle);
    let appDocPageId = await $(iconTgPage.appDocPageById('ux-a-icon-toggle'));
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-a-icon-toggle> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-a-icon-toggle', '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: "354108"});
    let iconTgDefault = await $(iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'Default').currentPath);

  //  await expect(iconTgCO.elementList.length).toBe(7, 'number of components on page is not as expected');
    await chaiExpect(await iconTgPage.iconToggleByIndex(1).defaultComponentsCount()).equal(7, 'There should be 7 <ux-a-icon-toggle> components on the page.')
    await expect(iconTgDefault).toBeDisplayed({wait:1000, message:'<ux-a-icon-toggle> from Default section - is not visible on page'});
  });
  it('should verify <ux-a-icon-toggle> isChecked method', async() => {
    browser.addTestMeta({zephyrStep: "354109"});
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'Default').isChecked()).toBe(false);
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'isChecked').isChecked()).toBe(true);
    await (await $(iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'Default').iconToggle)).click();
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'Default').isChecked()).toBe(true);
  });
  it('should verify <ux-a-icon-toggle> isReadOnly method', async() => {
    browser.addTestMeta({zephyrStep: "376788"});
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'isChecked-isReadOnly').isReadOnly()).toBe(true);
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'isChecked-isReadOnly').isChecked()).toBe(true);
    await (await $(iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'isChecked-isReadOnly').icon)).click();
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'isChecked-isReadOnly').isChecked()).toBe(true);
    await expect(await iconTgPage.iconToggleCoByIdUnderSectionTitleByName(1, 'Default').isReadOnly()).toBe(false);
  });
  it('should verify <ux-a-icon-toggle> Area Label attribute', async() => {
    browser.addTestMeta({zephyrStep: "376789"});
    let iconTgDefault = await $(iconTgPage.iconToggleCoByIdUnderSectionTitleByName(2, 'a11y').iconToggle);
    await iconTgDefault.scrollIntoView();
    await expect(await iconTgDefault.getAttribute('aria-label')).toContain('Bright star in the sky');
    await expect(await iconTgDefault.getAttribute('aria-label')).toBe('Bright star in the sky');
  });
});
