Skip to content
Snippets Groups Projects
Commit 453f415e authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

add test for adding experiments to report

parent ff6f6ce4
No related branches found
No related tags found
1 merge request!223Reports overhaul
// general tests for the reports app
describe('reports app', function(){
const until = protractor.ExpectedConditions;
browser.ignoreSynchronization = true;
// just to make sure the window is maximized
browser.driver.manage().window().maximize();
// login to the default user ('user') once before running all these tests
beforeAll(function(){
browser.get('http://localhost:8000/login/?next=/');
//browser.findElement(by.partialLinkText('Sign-in')).click();
browser.findElement(by.id('id_username')).sendKeys('user');
browser.findElement(by.id('id_password')).sendKeys('user');
browser.findElement(by.partialButtonText('Sign-in')).click();
return browser.wait(function(){
return browser.getCurrentUrl().then(function(url){
const rxUserLoggedIn = /events\/user\//;
return rxUserLoggedIn.test(url);
});
});
});
// if there's an error in the web browser's console,
// fail the test and print the error
......@@ -23,33 +41,19 @@ describe('reports app', function(){
// /reports
describe('home', function(){
beforeEach(function(){
browser.get('http://localhost:8000/reports');
browser.get('http://localhost:8000/reports/user');
});
it('should load', function(){
expect(browser.getTitle()).toEqual('BEAT - Public Reports');
expect(browser.getTitle()).toEqual("BEAT - user's Reports");
});
});
// /reports/user
describe('home for the test user', function(){
// login to the default user ('user') once before running all these tests
beforeAll(function(){
browser.get('http://localhost:8000/login/?next=/');
//browser.findElement(by.partialLinkText('Sign-in')).click();
browser.findElement(by.id('id_username')).sendKeys('user');
browser.findElement(by.id('id_password')).sendKeys('user');
browser.findElement(by.partialButtonText('Sign-in')).click();
return browser.wait(function(){
return browser.getCurrentUrl().then(function(url){
const rxUserLoggedIn = /events\/user\//;
return rxUserLoggedIn.test(url);
});
});
});
// go to user's reports page before each test
beforeEach(function(){
beforeAll(function(){
browser.get('http://localhost:8000/reports/user/');
});
......@@ -82,4 +86,47 @@ describe('reports app', function(){
expect(browser.getTitle()).toBe('BEAT - Report');
});
});
describe('adding experiments to the "test" report', function(){
// go to experiments page
beforeAll(function(){
browser.get('http://localhost:8000/experiments/user/');
});
it('should show the experiments list page', function(){
expect(browser.getTitle()).toEqual("BEAT - user's Experiments");
});
it('should list successfully-ran experiments accessible by user', function(){
expect(browser.isElementPresent(by.css('.Done'))).toBeTruthy();
});
it('should add up to the first 5 experiments to the "test" report', function(){
let finishedExpTableRows = element.all(by.css('.Done'));
let addButton = element(by.css('#add-to-report'));
expect(addButton.getAttribute('disabled')).toBe('true');
let fiveRows = finishedExpTableRows.filter((r, i) => i < 5);
fiveRows
.then(rs => Promise.all(rs.map(r => r.element(by.css('.report-checkbox')).element(by.css('input')).click())))
.then(() => {
browser.wait(until.elementToBeClickable(addButton), 5000, 'Button still isnt clickable!');
return browser.executeScript('arguments[0].click();', addButton.getWebElement());
})
.then(() => browser.wait(until.presenceOf(element(by.css('.modal'))), 5000, 'Element taking too long to appear in the DOM'))
.then(() => element(by.css('.chosen-single')).click())
.then(() => element(by.css('.chosen-results')).element(by.css('.active-result')).click())
.then(() => {
let submitButton = element(by.buttonText('Add'));
return submitButton.click();
})
.then(() => browser.wait(until.presenceOf(element(by.buttonText("View Report"))), 5000))
.then(() => {
let headerText = element(by.css('.report-results > h5'));
expect(headerText.getText()).toContain('Successfully added');
})
;
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment