import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import LayoutHorizontalPage from '../../../../pages/eui/10x/ux/ux-layout-horizontal-10x.po.js'

describe('eUI - <ux-layout-horizontal> Component Object @CCQA-555', async() => {
  let layoutHorizontalPage = new LayoutHorizontalPage();
  it('should navigate to <ux-layout-horizontal> component', async() => {
    browser.addTestMeta({uuid:"ffb952ae-7b55-11eb-9439-0242ac130002", zephyrKey: "CCQA-555", zephyrStep: "318745", reportGroups: ["eUI.10x.ux"]});
    await layoutHorizontalPage.open(Routing.getUxLayoutComponentUrl('ux-layout-horizontal'));
    await CookieBannerActions.cookieBanner(true);
    let  pgTitle = await $(layoutHorizontalPage.pageTitle);
    let appDocPageId = await $(layoutHorizontalPage.appDocPageById('ux-layout-horizontal'));
    let navigationList = await $(layoutHorizontalPage.navigationList);
    await pgTitle.scrollIntoView();
   await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-layout-horizontal> page title is not visible on page'});
   await expect(await pgTitle.getText()).toBe('ux-layout-horizontal', '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 Component Object on the page ', async() => {
    browser.addTestMeta({zephyrStep: "354043"});
    let co1 = await $(layoutHorizontalPage.layoutHorizontalFromSectionById('Default').dataE2E);
    let co2 = await $(layoutHorizontalPage.layoutHorizontalByIndex(1).dataE2E);
    await expect(co1).toBeDisplayed({wait:1000, message:'<Default> section -> is not visible on page'});
    await expect(co2).toBeDisplayed({wait:1000, message:'Layout footer by index "1" is not visible on page'});

    await expect(await layoutHorizontalPage.layoutHorizontalByIndex(1).defaultComponentsCount()).toBe(1,
      'There should be 1 <ux-layout-horizontal> components on the page.');
  });
  it('should verify the presence of the main elements of the Component Object on the page ', async() => {
    browser.addTestMeta({zephyrStep: "318746"});
    let sectionId = 'Default';
    let sectionElement = await $(layoutHorizontalPage.layoutHorizontalFromSectionById(sectionId).currentPath);
    await sectionElement.scrollIntoView();

    let layoutHorizontal1 = layoutHorizontalPage.layoutHorizontalFromSectionWithIdByIndex('Default', 1);
    await expect(await $(layoutHorizontal1.layoutHorizontalLeft)).toBeDisplayed({wait:1000, message:
      'Layout horizontal by index "1" from Default section property layoutHorizontalLeft is not visible on page'});
    await expect(await $(layoutHorizontal1.layoutHorizontalCenter)).toBeDisplayed({wait:1000, message:
      'Layout horizontal by index "1" from Default section property layoutHorizontalCenter is not visible on page'});
    await expect(await $(layoutHorizontal1.layoutHorizontalRight)).toBeDisplayed({wait:1000, message:
      'Layout horizontal by index "1" from Default section property layoutHorizontalRight is not visible on page'});
  });
});
