import Routing from '../../../../pages/eui/10x/routing-10x.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'
import DashboardButton from '../../../../pages/eui/10x/ux/ux-dashboard-button-10x.po.js'

describe('eUI - <ux-dashboard-button> Component Object', async() => {
  let dashboardButton = new DashboardButton();
  it('should navigate to <ux-dashboard-button> component', async() => {
   browser.addTestMeta({uuid:"bc5926b2-71f8-11eb-9439-0242ac130002", zephyrKey: "CCQA-779", zephyrStep: "367058", reportGroups: ["eUI.10x.ux"]});
   dashboardButton.open(Routing.getUxComponentUrl('ux-dashboard-button'));
   await CookieBannerActions.cookieBanner(true);
   let pgTitle = await $(dashboardButton.pageTitle);
   let appDocPageId = await $(dashboardButton.appDocPageById('ux-dashboard-button'));
   let navigationList = await $(dashboardButton.navigationList);
   await pgTitle.scrollIntoView();
   await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-dashboard-button> page title is not displayed on page'});
   await expect(pgTitle).toHaveText('ux-dashboard-button', {wait: 1000, message: '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 displayed on page'});
  });
  it('should identify <ux-dashboard-button> from page after specific methods', async() => {
   browser.addTestMeta({zephyrStep: "367059"});
   let co1 = await $(dashboardButton.sectionById('Default'));
   let co2 = await $(dashboardButton.dashboardButtonByIndex(1).currentPath);
   let co3 = await $(dashboardButton.dashboardButtonByTextContains('99').currentPath);
   let co4 = await $(dashboardButton.dashboardButtonByTextEqualsAndIndex('99', 1).currentPath);
   await expect(co1).toBeDisplayed({wait: 3000, message:'<Default> section -> is not displayed on page'});
   await expect(co2).toBeDisplayed({wait: 3000, message:'Dashboard-button by index "1" is not displayed on page'});
   await expect(co3).toBeDisplayed({wait: 3000, message:'Dashboard-button by text "99" is not displayed on page'});
   await expect(co4).toBeDisplayed({wait: 3000, message:'Dashboard-button by text "99" and index 1 is not displayed on page'});
   await chaiExpect(await dashboardButton.dashboardButtonByIndex(1).defaultComponentsCount()).equal(29, 'There should be 29 <ux-dashboard-button> components on the page.')
  });
  it('should verify methods: contentMainLabel, contentTitle, contentSubTitle, contentMainIcon ', async() => {
   browser.addTestMeta({zephyrStep: "367060"});
   let dashboardButton1 = dashboardButton.dashboardButtonFromSectionWithIdByIndex('Default',1);
   await expect(await $(dashboardButton1.currentPath)).toBeDisplayed({wait: 3000, message:
      'Dashboard-button with index 1 from default section is not displayed on page'});
   await expect(await $(dashboardButton1.contentMainLabel)).toHaveTextContaining('99', {wait: 1000, message: 'Button 1 content label is not as expected'});
   await expect(await $(dashboardButton1.contentTitle)).toHaveTextContaining('Default', {wait: 1000, message: 'Button 1 content title is not as expected'});
   await expect(await $(dashboardButton1.contentSubTitle)).toBeDisplayed({wait: 3000, message:
      'dashboardButton1  contentSubTitle - is not displayed on page'});

   let sectionId= 'iconClass';
   let scrollIntoSection = await $(dashboardButton.sectionById(sectionId));
   await scrollIntoSection.scrollIntoView();
   let dashboardButton2 = dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,1);

   await expect(await $(dashboardButton2.currentPath)).toBeDisplayed({wait: 3000, message:
      'Dashboard-button with index 2 from iconClass section is not displayed on page'});
   await expect(await $(dashboardButton2.contentMainIcon)).toBeDisplayed({wait: 3000, message:
      'dashboardButton2  contentMainIcon - is not displayed on page'});
   await expect(await $(dashboardButton2.contentSubTitle)).toBeDisplayed({wait: 3000, message:
      'dashboardButton2  contentSubTitle - is not displayed on page'});
   await expect(await $(dashboardButton2.contentMainIconElement)).toBeDisplayed({wait: 3000, message:
      'dashboardButton2  contentMainIconLabel - is not displayed on page'});
  });
  it('should verify the typeClasses and other classes', async() => {
   browser.addTestMeta({zephyrStep: "376959"});
   let sectionId= 'typeClass';
   let scrollIntoSection = await $(dashboardButton.sectionById(sectionId));
   await scrollIntoSection.scrollIntoView();
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,3).dataE2E)).getAttribute('class')).toContain('info');
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,1).dataE2E)).getAttribute('class')).toContain('primary');
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,2).dataE2E)).getAttribute('class')).toContain('secondary');
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,4).dataE2E)).getAttribute('class')).toContain('success');
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,5).dataE2E)).getAttribute('class')).toContain('warning');
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,6).dataE2E)).getAttribute('class')).toContain('danger');
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,7).dataE2E)).getAttribute('class')).toContain('accent');

   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,1).dataE2E)).getAttribute('class')).toContain('rounded');
   sectionId= 'isLarge';
   scrollIntoSection = await $(dashboardButton.sectionById(sectionId));
   await scrollIntoSection.scrollIntoView();
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,1).dataE2E)).getAttribute('class')).toContain('large');
   sectionId= 'content-panel';
   scrollIntoSection = await $(dashboardButton.sectionById(sectionId));
   await scrollIntoSection.scrollIntoView();
   await expect(await (await $(dashboardButton.dashboardButtonFromSectionWithIdByIndex(sectionId,1).dataE2E)).getAttribute('class')).toContain('full-width');
  });
});
