import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import BadgeGroupPage from '../../../../pages/eui/10x/ux/ux-badge-group-10x.po.js'

describe('eUI - <ux-badge-group> Component Object', async () => {
  let badgeGroupPage = new BadgeGroupPage();
  let testFolder = './/ux//ux-badge-group//';
  it('should navigate to <ux-badge> component', async () => {
    browser.addTestMeta({uuid:"3b841d30-71f8-11eb-9439-0242ac130002", zephyrKey: "CCQA-706", zephyrStep: "361297", reportGroups: ["eUI.10x.ux"]});
    await badgeGroupPage.open(Routing.getUxComponentUrl('ux-badge-group'));
    await CookieBannerActions.cookieBanner(true);
    let pgTitle = await $(badgeGroupPage.pageTitle);
    let appDocPageId = await $(badgeGroupPage.appDocPageById('ux-badge-group'));
    let navigationList = await $(badgeGroupPage.navigationList);

    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-badge-group> page title is not visible on page'});
    await expect(pgTitle).toHaveText('ux-badge-group', {wait: 1000, message: 'Page title text is not as expected'});
    await expect(appDocPageId).toExist({wait:1000, message:'Page Id is not present in page'});
    await expect(navigationList).toBeDisplayed({wait:1000, message:'Navigation List -> is not visible on page'});
  });
  it('should verify the presence of the <ux-badge-group> component objects on the page', async () => {
    browser.addTestMeta({zephyrStep: "361298"});
    let sectionId = 'Default';
    let index = 1;
    let bGroup1SectionDefault = badgeGroupPage.badgeGroupFromSectionByIndex(sectionId, 1);
    await (await bGroup1SectionDefault.element()).scrollIntoView();
    await expect(await (await bGroup1SectionDefault.element())).toBeDisplayedInViewport({message:'<ux-badge-group> from Default section with index ' +
      index + ' is not displayed on page.'});

    let bGroupIndex1 = badgeGroupPage.badgeGroupByIndex(1);
    await expect(await (await bGroupIndex1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> with index ' + index +' is not displayed on page.'});

    let text = 'subLabel';
    let bGroupWithText = badgeGroupPage.badgeGroupByTextContains(text);
    await expect(await (await bGroupIndex1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> containing text ' + text +' is not displayed on page.'});

    let bGroupByTextAndIndex = badgeGroupPage.badgeGroupByTextContainsAndIndex(text, 1);
    await expect(await (await bGroupByTextAndIndex.element())).toBeDisplayedInViewport({message:'<ux-badge-group> containing text ' + text +' is not displayed on page.'});

    await expect(await bGroupByTextAndIndex.defaultComponentsCount()).toBe(37, 'There should be 37 <ux-badge-group> components on the page.');

    // image compare
    if(browser.config.useWdioImageComparison) {
     await expect(await browser.checkElement(await (await bGroup1SectionDefault.element()), testFolder+'img_bGroup1SectionDefault', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupIndex1.element()), testFolder+'img_bGroupIndex1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupWithText.element()), testFolder+'img_bGroupWithText', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupByTextAndIndex.element()), testFolder+'img_bGroupByTextAndIndex', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
  it('should verify <ux-badge-group> typeClass types', async () => {
    browser.addTestMeta({zephyrStep: "376981"});
    let bGroupTypeclass1 = badgeGroupPage.badgeGroupFromSectionByIndex('typeClass', 1);
    await (await bGroupTypeclass1.element()).scrollIntoView();
    await expect(await (await bGroupTypeclass1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> with typeClass "primary" is not displayed on page.'});
    await expect(await bGroupTypeclass1.typeClass()).toBe('primary', '<ux-badge-group> does not have typeClass "primary".');

    let bGroupTypeclass2 = badgeGroupPage.badgeGroupFromSectionByIndex('typeClass', 2);
    let bGroupTypeclass3 = badgeGroupPage.badgeGroupFromSectionByIndex('typeClass', 3);
    let bGroupTypeclass4 = badgeGroupPage.badgeGroupFromSectionByIndex('typeClass', 4);
    let bGroupTypeclass5 = badgeGroupPage.badgeGroupFromSectionByIndex('typeClass', 5);
    let bGroupTypeclass6 = badgeGroupPage.badgeGroupFromSectionByIndex('typeClass', 6);

    await expect(await bGroupTypeclass2.typeClass()).toBe('info', {wait: 1000, message: '<ux-badge-group> does not have typeClass "info".'});
    await expect(await bGroupTypeclass2.typeClass()).toBe('info', {wait: 1000, message: '<ux-badge-group> does not have typeClass "info".'});
    await expect(await bGroupTypeclass3.typeClass()).toBe('success', {wait: 1000, message: '<ux-badge-group> does not have typeClass "success".'});
    await expect(await bGroupTypeclass4.typeClass()).toBe('warning', {wait: 1000, message: '<ux-badge-group> does not have typeClass "warning".'});
    await expect(await bGroupTypeclass5.typeClass()).toBe('danger', {wait: 1000, message: '<ux-badge-group> does not have typeClass "danger".'});
    await expect(await bGroupTypeclass6.typeClass()).toBe('accent', {wait: 1000, message: '<ux-badge-group> does not have typeClass "accent".'});

    // image compare
    if(browser.config.useWdioImageComparison) {
     await expect(await browser.checkElement(await (await bGroupTypeclass1.element()), testFolder+'img_bGroupTypeclass1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupTypeclass2.element()), testFolder+'img_bGroupTypeclass2', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupTypeclass3.element()), testFolder+'img_bGroupTypeclass3', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupTypeclass4.element()), testFolder+'img_bGroupTypeclass4', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupTypeclass5.element()), testFolder+'img_bGroupTypeclass5', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
     await expect(await browser.checkElement(await (await bGroupTypeclass6.element()), testFolder+'img_bGroupTypeclass6', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
  it('should verify <ux-badge-group> isPill method', async () => {
    browser.addTestMeta({zephyrStep: "361299"});
    let bGroupIsPill1 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 1);
    await (await bGroupIsPill1.element()).scrollIntoView();
    await expect(await (await bGroupIsPill1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> from section isPill with index 1 is not displayed on page.'});

    await expect(await bGroupIsPill1.isPill()).toBe(true, '<ux-badge-group> from section isPill with index 1 does not have  \
      isPill class present.');

    let bGroupIsSmall1 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 1);
    await expect(await (await bGroupIsSmall1.element())).toExist('<ux-badge-group> from section isSmall with index 1 is not existing on page.');

    await expect(await bGroupIsSmall1.isPill()).toBe(false, '<ux-badge-group> from section isPill with index 1 has \
      isPill class present.');

    // image compare
    if(browser.config.useWdioImageComparison) {
      let bGroupIsPill2 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 2);
      let bGroupIsPill3 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 3);
      let bGroupIsPill4 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 4);
      let bGroupIsPill5 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 5);
      let bGroupIsPill6 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 6);
      await expect(await browser.checkElement(await (await bGroupIsPill1.element()), testFolder+'img_bGroupIsPill1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsPill2.element()), testFolder+'img_bGroupIsPill2', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsPill3.element()), testFolder+'img_bGroupIsPill3', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsPill4.element()), testFolder+'img_bGroupIsPill4', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsPill5.element()), testFolder+'img_bGroupIsPill5', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsPill6.element()), testFolder+'img_bGroupIsPill6', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
  it('should verify <ux-badge-group> isSmall method', async () => {
    browser.addTestMeta({zephyrStep: "361300"});
    let bGroupIsSmall1 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 1);
    await (await bGroupIsSmall1.element()).scrollIntoView();
    await expect(await (await bGroupIsSmall1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> from isSmall section with index 1 is not displayed on page.'});

    await expect(await bGroupIsSmall1.isSmall()).toBe(true, '<ux-badge-group> from section isSmall with index 1 does not have \
      isSmall class present.');

    let bGroupIsPill1 = badgeGroupPage.badgeGroupFromSectionByIndex('isPill', 1);
    await expect(await bGroupIsPill1.isSmall()).toBe(false, '<ux-badge-group> from section isSmall with index 1 has \
     isPill class present.');

    // image compare
    if(browser.config.useWdioImageComparison) {
      let bGroupIsSmall2 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 2);
      let bGroupIsSmall3 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 3);
      let bGroupIsSmall4 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 4);
      let bGroupIsSmall5 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 5);
      let bGroupIsSmall6 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall', 6);
      await expect(await browser.checkElement(await (await bGroupIsSmall1.element()), testFolder+'img_bGroupIsSmall1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmall2.element()), testFolder+'img_bGroupIsSmall2', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmall3.element()), testFolder+'img_bGroupIsSmall3', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmall4.element()), testFolder+'img_bGroupIsSmall4', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmall5.element()), testFolder+'img_bGroupIsSmall5', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmall6.element()), testFolder+'img_bGroupIsSmall6', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
  it('should verify <ux-badge-group> isPill-isSmall methods toghether', async () => {
    browser.addTestMeta({zephyrStep: "376973"});
    let bGroupIsSmallIsPill1 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall-isPill', 1);
    await (await bGroupIsSmallIsPill1.element()).scrollIntoView();
    await expect(await (await bGroupIsSmallIsPill1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> from isSmall-isPill section with index 1 is not displayed on page.'});

    await expect(await bGroupIsSmallIsPill1.isSmall()).toBe(true, '<ux-badge-group> from section isSmall-isPill with index 1 does not have \
      isSmall class present.');
    await expect(await bGroupIsSmallIsPill1.isPill()).toBe(true, '<ux-badge-group> from section isSmall-isPill with index 1 does not have \
      isSmall class present.');

    // image compare
    if(browser.config.useWdioImageComparison) {
      let bGroupIsSmallIsPill2 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall-isPill', 2);
      let bGroupIsSmallIsPill3 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall-isPill', 3);
      let bGroupIsSmallIsPill4 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall-isPill', 4);
      let bGroupIsSmallIsPill5 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall-isPill', 5);
      let bGroupIsSmallIsPill6 = badgeGroupPage.badgeGroupFromSectionByIndex('isSmall-isPill', 6);
      await expect(await browser.checkElement(await (await bGroupIsSmallIsPill1.element()), testFolder+'img_bGroupIsSmallIsPill1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmallIsPill2.element()), testFolder+'img_bGroupIsSmallIsPill2', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmallIsPill3.element()), testFolder+'img_bGroupIsSmallIsPill3', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmallIsPill4.element()), testFolder+'img_bGroupIsSmallIsPill4', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmallIsPill5.element()), testFolder+'img_bGroupIsSmallIsPill5', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsSmallIsPill6.element()), testFolder+'img_bGroupIsSmallIsPill6', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
  it('should verify <ux-badge-group> isLarge method toghether', async () => {
    browser.addTestMeta({zephyrStep: "361301"});
    let bGroupIsLarge1 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge', 1);
    await (await bGroupIsLarge1.element()).scrollIntoView();
    await expect(await (await bGroupIsLarge1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> from isLarge section with index 1 is not displayed on page.'});

    await expect(await bGroupIsLarge1.isLarge()).toBe(true, '<ux-badge-group> from section isLarge with index 1 does not have \
      isLarge class present.');

    // image compare
    if(browser.config.useWdioImageComparison) {
      let bGroupIsLarge2 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge', 2);
      let bGroupIsLarge3 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge', 3);
      let bGroupIsLarge4 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge', 4);
      let bGroupIsLarge5 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge', 5);
      let bGroupIsLarge6 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge', 6);
      await expect(await browser.checkElement(await (await bGroupIsLarge1.element()), testFolder+'img_bGroupIsLarge1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLarge2.element()), testFolder+'img_bGroupIsLarge2', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLarge3.element()), testFolder+'img_bGroupIsLarge3', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLarge4.element()), testFolder+'img_bGroupIsLarge4', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLarge5.element()), testFolder+'img_bGroupIsLarge5', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLarge6.element()), testFolder+'img_bGroupIsLarge6', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
  it('should verify <ux-badge-group> isLarge-isPill methods toghether', async () => {
    browser.addTestMeta({zephyrStep: "376974"});
    let bGroupIsLargeIsPill1 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge-isPill', 1);
    await (await bGroupIsLargeIsPill1.element()).scrollIntoView();
    await expect(await (await bGroupIsLargeIsPill1.element())).toBeDisplayedInViewport({message:'<ux-badge-group> from isLarge-isPill section with index 1 is not displayed on page.'});

    await expect(await bGroupIsLargeIsPill1.isLarge()).toBe(true, '<ux-badge-group> from section isLarge-isPill with index 1 does not have \
      isSmall class present.');
    await expect(await bGroupIsLargeIsPill1.isPill()).toBe(true, '<ux-badge-group> from section isLarge-isPill with index 1 does not have \
      isSmall class present.');

    // image compare
    if(browser.config.useWdioImageComparison) {
      let bGroupIsLargeIsPill2 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge-isPill', 2);
      let bGroupIsLargeIsPill3 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge-isPill', 3);
      let bGroupIsLargeIsPill4 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge-isPill', 4);
      let bGroupIsLargeIsPill5 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge-isPill', 5);
      let bGroupIsLargeIsPill6 = badgeGroupPage.badgeGroupFromSectionByIndex('isLarge-isPill', 6);
      await expect(await browser.checkElement(await (await bGroupIsLargeIsPill1.element()), testFolder+'img_bGroupIsLargeIsPill1', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLargeIsPill2.element()), testFolder+'img_bGroupIsLargeIsPill2', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLargeIsPill3.element()), testFolder+'img_bGroupIsLargeIsPill3', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLargeIsPill4.element()), testFolder+'img_bGroupIsLargeIsPill4', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLargeIsPill5.element()), testFolder+'img_bGroupIsLargeIsPill5', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
      await expect(await browser.checkElement(await (await bGroupIsLargeIsPill6.element()), testFolder+'img_bGroupIsLargeIsPill6', {hideElements: [await $('//eui-app-toolbar')]})).toBe(0);
    }
  });
});
