import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import LayoutFooterActionBar from '../../../../pages/eui/10x/ux/ux-layout-footer-action-bar-10x.po.js'

describe('eUI - <ux-layout-footer-action-bar> Component Object @CCQA-691', async() => {
  let actionBarPage = new LayoutFooterActionBar();
  it('should navigate to <ux-layout-footer-action-bar> component', async() => {
    browser.addTestMeta({uuid:"6a8d1f56-7a80-11eb-9439-0242ac130002", zephyrKey: "CCQA-691", zephyrStep: "353079", reportGroups: ["eUI.10x.ux"]});
    await actionBarPage.open(Routing.getUxLayoutComponentUrl('ux-layout-footer-action-bar'));
    await CookieBannerActions.cookieBanner(true);
    let pgTitle = await $(actionBarPage.pageTitle);
    let appDocPageId = await $(actionBarPage.appDocPageById('ux-layout-footer-action-bar'));
    let navigationList = await $(actionBarPage.navigationList);
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-layout-footer-action-bar> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-layout-footer-action-bar', '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: "353080"});
    let co1 = await $(actionBarPage.actionBarFromSectionById('Default').actionBarWrapper);
    let co2 = await $(actionBarPage.actionBarByIndex(1).actionBar);
    await expect(co1).toBeDisplayed({wait:1000, message:'<Default> section -> is not visible on page'});
    await expect(co2).toBeDisplayed({wait:1000, message:'Layout footer action bar by index "1" is not visible on page'});
   await chaiExpect(await actionBarPage.actionBarByIndex(1).defaultComponentsCount()).equal(1, 'There should be 12 <ux-layout-footer-action-bar> components on the page.');
  });
  it('should verify the presence of the main elements of the Component Object on the page ', async() => {
    browser.addTestMeta({zephyrStep: "353081"});
    let sectionId = 'Default';
    let sectionElement = await $(actionBarPage.actionBarFromSectionById(sectionId).currentPath);
    await expect(sectionElement).toBeDisplayed({wait:1000, message:'section -> is not visible on page'});
    await sectionElement.scrollIntoView();

    let actionBar1 = actionBarPage.actionBarFromSectionWithIdByIndex('Default', 1);
    await expect(await $(actionBar1.actionBarWrapper)).toBeDisplayed({wait:1000, message:
      'Layout footer action bar by index "1" from Default section property actionBarWrapper is not visible on page'});
    await expect(await $(actionBar1.actionBar)).toBeDisplayed({wait:1000, message:
      'Layout footer action bar by index "1" from Default section property actionBar is not visible on page'});
    await expect(await $(actionBar1.flexContainer)).toBeDisplayed({wait:1000, message:
      'Layout footer action bar by index "1" from Default section property flexContainer is not visible on page'});
    await expect(await $(actionBar1.primaryButton)).toBeDisplayed({wait:1000, message:
      'Layout footer action bar by index "1" from Default section property primaryButton is not visible on page'});
    await expect(await $(actionBar1.secondaryButton)).toBeDisplayed({wait:1000, message:
      'Layout footer action bar by index "1" from Default section property secondaryButton is not visible on page'});
    await expect(await $(actionBar1.byTextContains("Cancel").currentPath)).toBeDisplayed({wait:1000, message:
      'Layout footer action bar by text "Cancel" from Default section is not visible on page'});

    await expect(await actionBar1.isAcceptActionDisabled()).toBe(true, 'isAcceptActionDisabled should be true');
    await (await $("//input[@formcontrolname='customernumber']")).setValue("12345");
    await expect(await actionBar1.isAcceptActionDisabled()).toBe(false, 'isAcceptActionDisabled should be false');
    await expect(await actionBar1.isDismissActionDisabled()).toBe(false, 'isDismissActionDisabled should be false');
  });
});
