import Routing from '../../../../pages/eui/10x/routing-10x.js'
import ControlFeedbackPage from '../../../../pages/eui/10x/ux/ux-control-feedback-10x.po.js'
import CookieBannerActions from '../../../../actions/cookieBanner.js'

describe('should navigate to  <ux-control-feedback> Component Object ', async() => {
  let page = new ControlFeedbackPage();
  it('should navigate to <ux-control-feedback> component', async() => {
    browser.addTestMeta({uuid:"7cb568a0-8da9-11eb-8dcd-0242ac130003", zephyrKey: "CCQA-960", zephyrStep: "385034", reportGroups: ["eUI.10x.ux"]});
    await page.open(Routing.getUxComponentUrl('ux-control-feedback'));
    await CookieBannerActions.cookieBanner(true);
    let pgTitle = await $(page.pageTitle);
    let appDocPageId = await $(page.appDocPageById('ux-control-feedback'));
    let navigationList = await $(page.navigationList);
    await pgTitle.scrollIntoView();
    await expect(pgTitle).toBeDisplayed({wait:1000, message:'<ux-control-feedback> page title is not visible on page'});
    await expect(pgTitle).toHaveText('ux-control-feedback', '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 <ux-control-feedback> identification methods ', async() => {
    browser.addTestMeta({zephyrStep: "385035"});
    await expect(await $(page.sectionById('Default'))).toBeDisplayedInViewport({message:'<Default> section -> is not visible on page'});
    await expect(await $(page.feedbackByIndex(1).dataE2E)).toBeDisplayedInViewport({message:'Control feedback by index "1" is not visible on page'});
    await expect(await $(page.feedbackByTextContains('This is default control feedback').dataE2E)).
     toBeDisplayedInViewport({message:'Control feedback by text "This is default control feedback" is not visible on page'});
    await expect(await $(page.feedbackByTextEqualsAndIndex('This is default control feedback', 1).dataE2E)).
      toBeDisplayedInViewport({message:'Control feedback by text "This is default control feedback" and index 1 is not visible on page'});
    await expect(await page.feedbackByIndex(1).defaultComponentsCount()).toBe(13,
      'There should be 13 <ux-control-feedback> components on the page.');
  });
  it('should verify type ', async() => {
    browser.addTestMeta({zephyrStep: "385036"});
    let sectionId= 'type';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let controlFeedback = page.feedbackFromSectionWithIdByIndex(sectionId,1);
    await expect(await $(controlFeedback.message)).toBeDisplayedInViewport({message:'Control feedback message from type section is not visible on page'});
    await expect(await $(controlFeedback.dataE2E)).toHaveAttrContaining('class','info');
    await expect(await $(page.feedbackFromSectionWithIdByIndex(sectionId,2).dataE2E)).toHaveAttrContaining('class','success');
    await expect(await $(page.feedbackFromSectionWithIdByIndex(sectionId,3).dataE2E)).toHaveAttrContaining('class','warning');
    await expect(await $(page.feedbackFromSectionWithIdByIndex(sectionId,4).dataE2E)).toHaveAttrContaining('class','danger');
  });
  it('should verify feedbacks-multiple ', async() => {
    browser.addTestMeta({zephyrStep: "385037"});
    let sectionId= 'feedbacks-multiple';
    let scrollIntoSection = await $(page.sectionById(sectionId));
    await scrollIntoSection.scrollIntoView();
    let controlFeedback = page.feedbackFromSectionById(sectionId);
    await expect(await $(controlFeedback.message)).toBeDisplayedInViewport({message:'Control feedback message from feedbacks-multiple section is not visible on page'});
    await expect(await controlFeedback.defaultComponentsCount()).toBe(5,
      'There should be 5 <ux-control-feedback> components in this section');
  });
});
