[CORD-2338] Single command to run E2E tests

Change-Id: Id8db22b2b496ca16d20d2c4d0739d9b9042540db
diff --git a/e2e/crud/crud.po.js b/e2e/crud/crud.po.js
index 6372fc5..78589d4 100644
--- a/e2e/crud/crud.po.js
+++ b/e2e/crud/crud.po.js
@@ -19,19 +19,21 @@
 module.exports = new function(){
 
   // list view
-  this.tableRows = element.all(by.repeater('item in vm.data'));
-  this.tableColumn = element(by.repeater('item in vm.data').row(0))
-                      .all(by.repeater('col in vm.columns'));
+  this.tableRows = element.all(by.css('tbody > tr'));
+  this.tableColumn = element(by.css('tbody > tr:first-child'))
+                      .all(by.css('td'));
 
-  this.actionsColumn = element(by.repeater('item in vm.data').row(0))
+  this.actionsColumn = element(by.css('tbody > tr:first-child'))
     .element(by.css('td:last-child'));
 
-  this.deleteBtn = this.actionsColumn.all(by.tagName('a'));
+  this.deleteBtn = this.actionsColumn.all(by.css('a[title="delete"'));
+  this.detailBtn = this.actionsColumn.all(by.css('a[title="details"'));
 
   this.addBtn = element(by.linkText('Add'));
 
   // detail page
   this.formInputs = element.all(by.repeater('field in vm.config.inputs'));
+  this.nameInput = element.all(by.css('xos-form input')).first()
   this.formBtn = element(by.buttonText('Save'));
 
   this.nameField = element(by.css('[name="name"]'));
diff --git a/e2e/crud/crud.spec.js b/e2e/crud/crud.spec.js
index 0137990..4eecc62 100644
--- a/e2e/crud/crud.spec.js
+++ b/e2e/crud/crud.spec.js
@@ -19,10 +19,34 @@
 const user = require('../test_helpers/user');
 const page = require('./crud.po');
 const config = require('../test_helpers/config');
+const backend = require('../test_helpers/backend');
+
+let testNode;
 
 describe('XOS CRUD Page', function() {
 
   beforeEach((done) => {
+    const nodesUrl = `/xosapi/v1/core/nodes`;
+
+    const _testNode = {
+      name: 'test-p',
+      site_deployment_id: 1
+    }
+
+    backend.deleteAllModels(nodesUrl)
+    .then(() => {
+      return backend.createModel(nodesUrl, _testNode)
+    })
+    .then((node) => {
+      testNode = node;
+      done();
+    })
+    .catch(e => {
+      done(e);
+    })
+  });
+
+  beforeEach((done) => {
     user.login()
       .then(() => {
         done();
@@ -34,9 +58,10 @@
       browser.get(`${config.url}/core/nodes/`);
     });
     it('should have a table', () => {
-      expect(page.tableRows.count()).toBe(2);
-      expect(page.tableColumn.count()).toBe(4);
-      expect(page.deleteBtn.count()).toBe(1); // per row
+      expect(page.tableRows.count()).toBe(1);
+      expect(page.tableColumn.count()).toBe(6);
+      expect(page.deleteBtn.count()).toBe(1);
+      expect(page.detailBtn.count()).toBe(1);
     });
 
     it('should have an add button', () => {
@@ -50,10 +75,11 @@
 
     describe('for an existing model', () => {
       beforeEach(() => {
-        browser.get(`${config.url}/core/nodes/1`);
+        browser.get(`${config.url}/core/nodes/${testNode.id}`);
       });
-      it('should have a form', () => {
-        expect(page.formInputs.count()).toBe(4);
+      it('should load the correct model', () => {
+        expect(page.formInputs.count()).toBe(2);
+        expect(page.nameInput.getAttribute('value')).toBe(testNode.name);
         expect(page.formBtn.isPresent()).toBeTruthy();
       });