Newer
Older

Michael Breu
committed
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');

Michael Breu
committed
await browser.wait(ec.visibilityOf(navBarPage.entityMenu), 5000);
// await navBarPage.clickOnEntityMenu();

Michael Breu
committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
});
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();
browser.executeScript('window.scrollTo(0,document.body.scrollHeight)');

Michael Breu
committed
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();
});
});