import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import DateTagPage from '../../../../pages/eui/10x/ux/ux-a-date-tag-10x.po.js'

describe('eUI - <ux-a-date-tag> Component Object @CCQA-698', async() => {
  let dateTagPage = new DateTagPage();
  it('should navigate to <ux-a-date-tag> component page', async() => {
    browser.addTestMeta({uuid:"358c983d-a164-419c-b817-717814dd3282", zephyrKey: "CCQA-698", zephyrStep: "354044", reportGroups: ["eUI.10x.ux"]});
    await dateTagPage.open(Routing.getUxComponentUrl('ux-a-date-tag'));
    await CookieBannerActions.cookieBanner(true);
  });
  it('should verify main elements from <ux-a-date-tag> component page', async() => {
    browser.addTestMeta({zephyrStep: "354046"});
    let pgTitle = await $(dateTagPage.pageTitle);
    let appDocPageId = await $(dateTagPage.appDocPageById('ux-a-date-tag'));
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-a-date-tag> page title is not visible on page'});
    await expect(await pgTitle.getText()).toBe('ux-a-date-tag');
    appDocPageId.waitForExist({wait:1000, message:'Page Id is not present in page'});
  });
  it('should verify the presence of the Component Object on the page', async() => {
    browser.addTestMeta({zephyrStep: "354047"});
   await chaiExpect(await dateTagPage.dateTagByIndex(1).defaultComponentsCount()).equal(73, 'There should be 12 <ux-a-date-tag> components on the page.')
   await expect(await $(dateTagPage.dateTagByIndex(1).currentPath)).toBeDisplayed({wait:1000, message:'<ux-a-date-tag> from Default section - is not displayed on page'});
  });
  it('should verify <ux-a-date-tag> day/month/year methods', async() => {
    browser.addTestMeta({zephyrStep: "376180"});
    let dateTagDay = await $(dateTagPage.dateTagCoByIdUnderSectionTitleByName(1, 'Default').dateDay);
    let dateTagMonth = await $(dateTagPage.dateTagCoByIdUnderSectionTitleByName(1, 'Default').dateMonth);
    let dateTagYear = await $(dateTagPage.dateTagCoByIdUnderSectionTitleByName(1, 'Default').dateYear);

    await expect(dateTagDay).toBeDisplayed({wait:1000, message:'<ux-a-date-tag> Day element - is not visible on page'});
    await expect(dateTagMonth).toBeDisplayed({wait:1000, message:'<ux-a-date-tag> Day element - is not visible on page'});
    await expect(dateTagYear).toBeDisplayed({wait:1000, message:'<ux-a-date-tag> Day element - is not visible on page'});
  });
  it('should verify <ux-a-date-tag> subLabel method', async() => {
    browser.addTestMeta({zephyrStep: "376181"});
    let dateTagDefault = await $(dateTagPage.dateTagCoByIdUnderSectionTitleByName(1, 'Default').dateSubLabel);
    let dateTagSubLabel = await $(dateTagPage.dateTagCoByIdUnderSectionTitleByName(1, 'isDisplayDaysLeft').dateSubLabel);

    await expect(dateTagDefault).not.toBeDisplayed({wait: 10000, message:'<ux-a-date-tag> from Degault section - should not have sub Label'});
    await expect(dateTagSubLabel).toBeDisplayed({wait:1000, message:'<ux-a-date-tag> from isDisplayDaysLeft section - should have sub Label'});
    await expect(await dateTagSubLabel.getText()).toBe('2 days ago');
  });
});
