var pages = require('./pages');
var api = require('./api-helper');

describe('Member', function() {

  var editPage = pages.member.edit,
      listPage = pages.member.list;

  beforeEach(function() {
    listPage.navigate();
  });

  it('should create a new member', function() {
    listPage.createButton.click();

    editPage.name.sendKeys('New member');
    editPage.saveButton.click();

    expect(editPage.getId()).toBeDefined();
    expect(editPage.getMessage()).toBe('Member created');
  });

  it('should update existing member', function() {
    listPage.clickOnRow(0);

    editPage.name.sendKeys('_updated');
    editPage.saveButton.click();

    expect(editPage.getMessage()).toBe('Member updated');
  });

  it('should delete member', function() {
    listPage.clickOnRow(0);

    var memberCount;
    api.member.findAll().then(function(list) {
      memberCount = list.length;
      console.log('Before it was ', memberCount);
    });

    editPage.deleteButton.click();

    api.member.findAll().then(function(list) {
      console.log('Now it is', list.length);
      expect(list.length).toBe(memberCount - 1);
    });
  });
});

@@ -171,66 +171,8 @@
 t;%0A%0A
-  beforeEach(function() %7B%0A    listPage.navigate();%0A  %7D);%0A%0A
   it
@@ -207,32 +207,57 @@
 ', function() %7B%0A
+    listPage.navigate();%0A
     listPage.cre
@@ -521,36 +521,164 @@
    listPage.
-clickOnRow(0
+navigate();%0A%0A    // Create a new member.%0A    api.member.create(%7Bname: 'test member'%7D).then(function(id) %7B%0A      editPage.navigate(id);%0A    %7D
 );%0A%0A    edit
@@ -705,24 +705,25 @@
 _updated');%0A
+%0A
     editPage
@@ -843,32 +843,57 @@
 ', function() %7B%0A
+    listPage.navigate();%0A
     listPage.cli

use api to create item before updating