import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import BlockContentPage from '../../../../pages/eui/10x/ux/ux-block-content-10x.po.js'

describe('eUI - <ux-block-content> Component Object @CCQA-595', async() => {
  let blockContentPage = new BlockContentPage();
  it('should navigate to <ux-block-content> component ', async() => {
    browser.addTestMeta({uuid:"5df70680-782d-11eb-9439-0242ac130002", zephyrKey: "CCQA-595", zephyrStep: "327317", reportGroups: ["eUI.10x.ux"]});
    await blockContentPage.open(Routing.getUxComponentUrl('ux-block-content'));
    await CookieBannerActions.cookieBanner(true);
    let pgTitle = await $(blockContentPage.pageTitle);
    let appDocPageId = await $(blockContentPage.appDocPageById('ux-block-content'));
    let navigationList = await $(blockContentPage.navigationList);
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-block-content> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-block-content', '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 section title of the component object page ', async() => {
    browser.addTestMeta({zephyrStep: "327318"});
    await expect(await $(blockContentPage.blockContentFromSectionById('Default').currentPath)).toBeDisplayed({wait:1000, message:
      '<Default> section -> is not visible on page'});
  });
  it('should verify the presence of the Component Object on the page', async() => {
    browser.addTestMeta({zephyrStep: "327322"});
    let co1 = await $(blockContentPage.blockContentByIndex(1).blockContent);
    await expect(co1).toBeDisplayed({wait:1000, message:'Block-content by index "1" is not visible on page'});
    await chaiExpect(await blockContentPage.blockContentByIndex(1).defaultComponentsCount()).equal(1, 'There should be 1 <ux-block-content> components on the page.')
  });
  it('should verify isBlock method ', async() => {
    browser.addTestMeta({zephyrStep: "327327"});
    await expect(await blockContentPage.blockContentByIndex(1).isBlocked()).toBe(false, 'The isBlocked should be false');
    await (await $(blockContentPage.buttonByTextContains('Block Content').currentPath)).click();
    await expect(await blockContentPage.blockContentByIndex(1).isBlocked()).toBe(true, 'The isBlocked should be true');
  });
});
