This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
statistics.spec.ts 3.31 KiB
Newer Older
import { browser, ExpectedConditions as ec, promise } from 'protractor';
import { NavBarPage, SignInPage } from '../../page-objects/jhi-page-objects';

import { StatisticsComponentsPage, StatisticsDeleteDialog, StatisticsUpdatePage } from './statistics.page-object';

const expect = chai.expect;

describe('Statistics e2e test', () => {
  let navBarPage: NavBarPage;
  let signInPage: SignInPage;
  let statisticsComponentsPage: StatisticsComponentsPage;
  let statisticsUpdatePage: StatisticsUpdatePage;
  let statisticsDeleteDialog: StatisticsDeleteDialog;

  before(async () => {
    await browser.get('/');
    navBarPage = new NavBarPage();
    signInPage = await navBarPage.getSignInPage();
    await signInPage.autoSignInUsing('admin', 'admin');
    await browser.wait(ec.visibilityOf(navBarPage.entityMenu), 5000);
    // await navBarPage.clickOnEntityMenu();
  });

  it('should load Statistics', async () => {
    await navBarPage.goToEntity('statistics');
    statisticsComponentsPage = new StatisticsComponentsPage();
    await browser.wait(ec.visibilityOf(statisticsComponentsPage.title), 5000);
    expect(await statisticsComponentsPage.getTitle()).to.eq('gitsearchApp.statistics.home.title');
    await browser.wait(ec.or(ec.visibilityOf(statisticsComponentsPage.entities), ec.visibilityOf(statisticsComponentsPage.noResult)), 1000);
  });

  it('should load create Statistics page', async () => {
    await statisticsComponentsPage.clickOnCreateButton();
    statisticsUpdatePage = new StatisticsUpdatePage();
    expect(await statisticsUpdatePage.getPageTitle()).to.eq('gitsearchApp.statistics.home.createOrEditLabel');
    await statisticsUpdatePage.cancel();
  });

  it('should create and save Statistics', async () => {
    const nbButtonsBeforeCreate = await statisticsComponentsPage.countDeleteButtons();

    await statisticsComponentsPage.clickOnCreateButton();

    await promise.all([
      statisticsUpdatePage.setViewsInput('5'),
      statisticsUpdatePage.setDownloadsInput('5'),
      statisticsUpdatePage.setExerciseIDInput('5'),
    ]);

    expect(await statisticsUpdatePage.getViewsInput()).to.eq('5', 'Expected views value to be equals to 5');
    expect(await statisticsUpdatePage.getDownloadsInput()).to.eq('5', 'Expected downloads value to be equals to 5');
    expect(await statisticsUpdatePage.getExerciseIDInput()).to.eq('5', 'Expected exerciseID value to be equals to 5');

    await statisticsUpdatePage.save();
    expect(await statisticsUpdatePage.getSaveButton().isPresent(), 'Expected save button disappear').to.be.false;

    expect(await statisticsComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeCreate + 1, 'Expected one more entry in the table');
  });

  it('should delete last Statistics', async () => {
    const nbButtonsBeforeDelete = await statisticsComponentsPage.countDeleteButtons();
Eduard Frankford's avatar
Eduard Frankford committed
    browser.executeScript('window.scrollTo(0,document.body.scrollHeight)');
    await statisticsComponentsPage.clickOnLastDeleteButton();

    statisticsDeleteDialog = new StatisticsDeleteDialog();
    expect(await statisticsDeleteDialog.getDialogTitle()).to.eq('gitsearchApp.statistics.delete.question');
    await statisticsDeleteDialog.clickOnConfirmButton();

    expect(await statisticsComponentsPage.countDeleteButtons()).to.eq(nbButtonsBeforeDelete - 1);
  });

  after(async () => {
    await navBarPage.autoSignOut();
  });
});