import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CarouselItemPage from '../../../../pages/eui/10x/ux/ux-carousel-item-10x.po.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'

describe('eUI - <ux-carousel-item> Component Object', async() => {
  let page = new CarouselItemPage();
  it('should navigate to <ux-carousel-item> component', async() => {
    browser.addTestMeta({uuid:"c4a4c9ea-b7d3-11eb-8529-0242ac130003", zephyrKey: "CCQA-791", zephyrStep: "368328", reportGroups: ["eUI.10x.ux"]});
    await page.open(Routing.getUxComponentUrl('ux-carousel-item'));
    await CookieBannerActions.cookieBanner(true);
    let pgTitle = await $(page.pageTitle);
    let appDocPageId = await $(page.appDocPageById('ux-carousel-item'));
    let navigationList = await $(page.navigationList);
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-carousel-item> page title is not visible on page'});
    await expect(pgTitle).toHaveText('ux-carousel-item', '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 and number of component objects <ux-carousel-item> on page ', async() => {
    browser.addTestMeta({zephyrStep: "368329"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItem = page.carouselItemByIndex(1);
    await expect(await $(page.sectionById(sectionId))).toBeDisplayedInViewport({message:'<Default> section -> is not visible on page'});
    await expect(await $(carouselItem.dataE2E)).toBeDisplayedInViewport({message:'Carousel item by index "1" is not visible on page'});
    await expect(await $(page.carouselItemByTextContains('CAROUSEL ITEM 1').dataE2E)).
      toBeDisplayedInViewport({message:'Carousel item by text "CAROUSEL ITEM 1" is not visible on page'});
    await expect(await $(page.carouselItemByTextEqualsAndIndex('CAROUSEL ITEM 1', 1).dataE2E)).
      toBeDisplayedInViewport({message:'Carousel item by text "CAROUSEL ITEM 1" and index 1 is not visible on page'});
    await expect(await carouselItem.defaultComponentsCount()).toBe(20,
        'There should be 20 <ux-carousel-item> components on the page.');
  });
  it('should verify the presence and number of component objects <ux-carousel-items> on page ', async() => {
    browser.addTestMeta({zephyrStep: "368330"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItems = page.carouselItemsByIndex(1);
    await expect(await $(page.sectionById(sectionId))).toBeDisplayedInViewport({message:'<Default> section -> is not visible on page'});
    await expect(await $(carouselItems.dataE2E)).toBeDisplayedInViewport({message:'Carousel item by index "1" is not visible on page'});
    await expect(await $(page.carouselItemByTextContains('CAROUSEL ITEM 1').dataE2E)).
      toBeDisplayedInViewport({message:'Carousel item by text "CAROUSEL ITEM 1" is not visible on page'});
    await expect(await $(page.carouselItemByTextEqualsAndIndex('CAROUSEL ITEM 1', 1).dataE2E)).
      toBeDisplayedInViewport({message:'Carousel item by text "CAROUSEL ITEM 1" and index 1 is not visible on page'});
    await expect(await carouselItems.defaultComponentsCount()).toBe(3,
        'There should be 3 <ux-carousel-items> components on the page.');
  });
  it('should verify the carousel-items CO methods: arrowLeft, arrowRigth, content ', async() => {
    browser.addTestMeta({zephyrStep: "368331"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItems = page.carouselItemsByIndex(1);
    await expect(await $(carouselItems.arrowLeft)).
      toBeDisplayedInViewport({message:'arrowLeft is not visible on page'});
    await expect(await $(carouselItems.arrowRigth)).
      toBeDisplayedInViewport({message:'arrowRigth is not visible on page'});
    await expect(await $(carouselItems.content)).
      toBeDisplayedInViewport({message:'content is not visible on page'});
  });
  it('should verify the carousel-items CO method: isFirstItemActive', async() => {
    browser.addTestMeta({zephyrStep: "368332"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItems1 = page.carouselItemsByIndex(1);
    let carouselItems2 = page.carouselItemsByIndex(2);
    await expect(await carouselItems1.isFirstItemActive()).toBe(true, 'isFirstItemActive should be true');
    await expect(await carouselItems2.isFirstItemActive()).toBe(false, 'isFirstItemActive should be false');
    await (await $(carouselItems1.arrowRigth)).click();
    await expect(await carouselItems1.isFirstItemActive()).toBe(false, 'isFirstItemActive should be false');
    await expect(await carouselItems2.isFirstItemActive()).toBe(false, 'isFirstItemActive should be false');
    await (await $(carouselItems1.arrowLeft)).click();
    await expect(await carouselItems1.isFirstItemActive()).toBe(true, 'isFirstItemActive should be true');
    await expect(await carouselItems2.isFirstItemActive()).toBe(false, 'isFirstItemActive should be false');
  });
  it('should verify the carousel-items CO methods: animation, animationUl ', async() => {
    browser.addTestMeta({zephyrStep: "368333"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItems = page.carouselItemsByIndex(1);
    await expect(await $(carouselItems.animation)).toBeDisplayedInViewport({message:'animation is not visible on page'});
    await expect(await $(carouselItems.animationUl)).toBeDisplayedInViewport({message:'animationUl is not visible on page'});
  });
  it('should verify the carousel-items CO method: isLastItemActive', async() => {
    browser.addTestMeta({zephyrStep: "368336"});
    let sectionId = 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItems = page.carouselItemsByIndex(1);
    await expect(await carouselItems.isLastItemActive()).toBe(false, 'isLastItemActive should be false');
    await (await $(carouselItems.summaryIndicatorsItemCO.byIndex(5).currentPath)).click();
    await expect(await carouselItems.isLastItemActive()).toBe(true, 'isLastItemActive should be true');
    await (await $(carouselItems.summaryIndicatorsItemCO.byIndex(4).currentPath)).click();
    await expect(await carouselItems.isLastItemActive()).toBe(false, 'isLastItemActive should be false');
    await (await $(carouselItems.summaryIndicatorsItemCO.byIndex(1).currentPath)).click();
  });
  it('should verify the carousel-items CO methods: summaryIndicators, summaryIndicatorsItemCO ', async() => {
    browser.addTestMeta({zephyrStep: "368338"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItems = page.carouselItemsByIndex(1);
    await expect(await $(carouselItems.summaryIndicators)).toBeDisplayedInViewport({message:'summaryIndicators is not visible on page'});
    await expect(await carouselItems.isShowSummaryIndicators()).toBe(true, 'isShowSummaryIndicators should be true');
    await expect(await $(carouselItems.summaryIndicatorsItemCO.currentPath)).
      toBeDisplayedInViewport({message:'carouselItemsSummaryIndicatorsItemCO.currentPath is not visible on page'});
  });
    it('should verify the carousel-items__summary-indicators-item CO methods: isActive, isInactive', async() => {
    browser.addTestMeta({zephyrStep: "368338"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let summaryIndicator1 = page.carouselItemsByIndex(1).summaryIndicatorsItemCO;
    let summaryIndicator2 = page.carouselItemsByIndex(2).summaryIndicatorsItemCO;
    await expect(await summaryIndicator1.isActive()).toBe(true, 'isActive should be true');
    await expect(await summaryIndicator1.isInactive()).toBe(false, 'isInactive should be false');
    await expect(await summaryIndicator2.isInactive()).toBe(true, 'isInactive should be true');
    await expect(await summaryIndicator2.isActive()).toBe(false, 'isActive should be false');
  });
  it('should verify the carousel-item CO method: isActive', async() => {
    browser.addTestMeta({zephyrStep: "368338"});
    let sectionId= 'Default';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let carouselItem = page.carouselItemByIndex(1);
    await expect(await $(carouselItem.dataE2E)).toBeDisplayedInViewport({message:'dataE2E is not visible on page'});
    await expect(await carouselItem.isActive()).toBe(true, 'isActive should be true');
  });
});
