describe('The concept table page', function(){
  it('should be able to authenticate and redirect back to the page', function(){
		browser.get('http://localhost:3001/cms/concepts/');
    
		var emailInput = browser.driver.findElement(by.id('user_email'));
		emailInput.sendKeys('admin');

		var passwordInput = browser.driver.findElement(by.id('user_password'));
		passwordInput.sendKeys('admin');  //you should not commit this to VCS

		var signInButton = browser.driver.findElement(by.name('commit'));
		signInButton.click();
    
		expect(browser.getTitle()).toEqual('http://localhost:3001/cms/concepts');
	});

	it('should be able to search the list', function(){
	  browser.get('http://localhost:3001/cms/concepts/');
	  
	  var EC = protractor.ExpectedConditions;
		var e = element(by.css('tbody tr:first-child'));
		browser.wait(EC.presenceOf(e), 10000);
		
		var searchInput = element(by.model('searchConcept'));
		searchInput.sendKeys('428');
		
		var rows = element.all(by.css('tbody tr'));
		expect(rows.count()).toEqual(1);
	});

	it('should have rows in the table', function(){
		var EC = protractor.ExpectedConditions;
		var e = element(by.css('tbody tr:first-child'));
		browser.wait(EC.presenceOf(e), 10000);
		expect(e.isPresent()).toBeTruthy();
	});

	it('should be sortable by clicking on the table header', function(){
	  browser.get('http://localhost:3001/cms/concepts/');
	  
	  var EC = protractor.ExpectedConditions;
		var e = element(by.css('tbody tr:first-child'));
		browser.wait(EC.presenceOf(e), 10000);
		
		var topRow = element(by.css('tbody tr:first-child'));
		var bottomRow = element(by.css('tbody tr:last-child'));
	  expect(topRow).not.toEqual(bottomRow);

	  var button = element(by.css('th:first-child a'));
		button.click();
	
		var newTopRow = element(by.css('tbody tr:first-child'));
	  expect(newTopRow).not.toEqual(bottomRow);
	});
});

@@ -623,911 +623,581 @@
 uld 
-be able to search the list', function()%7B%0A%09  browser.get('http://localhost:3001/cms/concepts/');%0A%09  %0A%09  var EC = protractor.ExpectedConditions;%0A%09%09var e = element(by.css('tbody tr:first-child'));%0A%09%09browser.wait(EC.presenceOf(e), 10000);%0A%09%09%0A%09%09var searchInput = element(by.model('searchConcept'));%0A%09%09searchInput.sendKeys('428');%0A%09%09%0A%09%09var rows = element.all(by.css('tbody tr'));%0A%09%09expect(rows.count()).toEqual(1);%0A%09%7D);%0A%0A%09it('should have rows in the table', function()%7B%0A%09%09var EC = protractor.ExpectedConditions;%0A%09%09var e = element(by.css('tbody tr:first-child'));%0A%09%09browser.wait(EC.presenceOf(e), 10000);%0A%09%09expect(e.isPresent()).toBeTruthy();%0A%09%7D);%0A%0A%09it('should be sortable by clicking on the table header', function()%7B%0A%09  browser.get('http://localhost:3001/cms/concepts/');%0A%09  %0A%09  var EC = protractor.ExpectedConditions;%0A%09%09var e = element(by.css('tbody tr:first-child'));%0A%09%09browser.wait(EC.presenceOf(e), 10000
+have rows in the table', function()%7B%0A%09%09waitForTableToLoad();%0A%09%09expect(e.isPresent()).toBeTruthy();%0A%09%7D);%0A%0A%09it('should be able to search the list', function()%7B%0A%09  browser.get('http://localhost:3001/cms/concepts/');%0A%09  %0A%09  waitForTableToLoad();%0A%09%09%0A%09%09var searchInput = element(by.model('searchConcept'));%0A%09%09searchInput.sendKeys('428');%0A%09%09%0A%09%09var rows = element.all(by.css('tbody tr'));%0A%09%09expect(rows.count()).toEqual(1);%0A%09%7D);%0A%0A%09it('should be sortable by clicking on the table header', function()%7B%0A%09  browser.get('http://localhost:3001/cms/concepts/');%0A%09  %0A%09  waitForTableToLoad(
 );%0A%09
@@ -1537,12 +1537,177 @@
 );%0A%09%7D);%0A%7D);%0A
+%0Afunction waitForTableToLoad()%7B%0A%09var EC = protractor.ExpectedConditions;%0A%09var e = element(by.css('tbody tr:first-child'));%0A%09browser.wait(EC.presenceOf(e), 10000);%0A%7D%0A

refactor the code that waits for the table to load into a function