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

describe('eUI - <ux-block-document> Component Object @CCQA-595', async() => {
  let blockDocumentPage = new BlockDocument();
  it('should navigate to <ux-block-document> component ', async() => {
    browser.addTestMeta({uuid:"fb8266a0-7ff9-11eb-9439-0242ac130002", zephyrKey: "CCQA-751", zephyrStep: "365080", reportGroups: ["eUI.10x.ux"]});
    await blockDocumentPage.open(Routing.getUxComponentUrl('ux-block-document'));
    await CookieBannerActions.cookieBanner(true);
    let pgTitle = await $(blockDocumentPage.pageTitle);
    let appDocPageId = await $(blockDocumentPage.appDocPageById('ux-block-document'));
    let navigationList = await $(blockDocumentPage.navigationList);
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-block-document> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-block-document', '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: "365081"});
    let sectionTitle = await $(blockDocumentPage.sectionById('Default'));
    let co1 = await $(blockDocumentPage.blockDocumentByIndex(1).currentPath);
    await expect(sectionTitle).toBeDisplayed({wait:1000, message:'<Default> section -> is not visible on page'});
    await expect(co1).toExist({wait:1000, message:'Block document by index "1" is not existing on page'});
    await chaiExpect(await blockDocumentPage.blockDocumentByIndex(1).defaultComponentsCount()).equal(1, 'There should be 1 <ux-block-document> components on the page.')
  });
  it('should verify the Block Document CO Loading method', async() => {
    browser.addTestMeta({zephyrStep: "365082"});
    let co1 = await $(blockDocumentPage.blockDocumentByIndex(1).blockDocumentLoading);
    await expect(co1).toExist({wait:1000, message:'Block document by index "1", property blockDocumentLoading is not existing on page'});
  });
  it('should verify isBlock method ', async() => {
    browser.addTestMeta({zephyrStep: "365083"});
    await expect(await blockDocumentPage.blockDocumentByIndex(1).isBlocked()).toBe(false, 'isBlocked should be false');
    await (await $("//button[contains(text(),'Block document (2 sec.)')]")).click();
    await expect(await blockDocumentPage.blockDocumentByIndex(1).isBlocked()).toBe(true, 'isBlocked should be true');
  });
});
