From 78ca12becfad7cccb603f532c20435331acdc94a Mon Sep 17 00:00:00 2001 From: Gil Moskowitz Date: Mon, 14 Jul 2014 12:26:19 -0400 Subject: [PATCH] tweak mocha hierarchy so subtests actually run, add checks for proper export button enabled state --- test/extensions/all/grid_box.js | 96 ++++++++++++++++----------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/test/extensions/all/grid_box.js b/test/extensions/all/grid_box.js index 09e017d73..b50122338 100644 --- a/test/extensions/all/grid_box.js +++ b/test/extensions/all/grid_box.js @@ -25,64 +25,62 @@ zombieAuth.loadApp(appLoaded); }); - describe('Test Grid Boxes', function () { - it('Test Grid Box Functionality', function () { + it('Test Grid Box Functionality', function () { + _.each(XV, function (value, key) { + var list, + kinds = ['SalesOrderList', 'QuoteList', 'InvoiceList', 'ReturnList', 'ProjectList']; + // lists with grid boxes; TODO: find candidates automatically + if (_.contains(kinds, key)) { + describe('Create Workspace for XV.' + key, function () { + it('Create a Workspace', function () { + list = "XV." + key; + smoke.navigateToNewWorkspace(XT.app, list, function (workspaceContainer) { + var workspace = workspaceContainer.$.workspace, + getExportButton = function (obj) { + var result = null; + if (_.isObject(obj.$)) { + result = obj.$.exportButton || + _.find(obj.$, getExportButton); + } + return result; + }; - _.each(XV, function (value, key) { - var list, - kinds = ['SalesOrderList', 'QuoteList', 'InvoiceList', 'ReturnList', 'ProjectList']; - // lists with grid boxes; TODO: find candidates automatically - if (_.contains(kinds, key)) { - - describe('Create Workspace for XV.' + key, function () { - it('Create a Workspace', function () { - list = "XV." + key; - smoke.navigateToNewWorkspace(XT.app, list, function (workspaceContainer) { - var workspace = workspaceContainer.$.workspace; - _.each(workspace.$, function (component) { - if (XV.inheritsFrom(component, 'XV.GridBox')) { + _.each(workspace.$, function (component) { + if (XV.inheritsFrom(component, 'XV.GridBox')) { + describe('Checking ' + component.name, function () { + it('checks for the export button', function () { + var exportButton = getExportButton(component); + assert.ok(exportButton); + // TODO: need to populate before we can export + // assert.doesNotThrow(exportButton.doTap()); + // TODO: find the generated file & check contents + }); - describe('Test creating line items for ' + component, function () { - it('Create line items', function () { - var gridBox = component, gridRow, + it('creates line items for ' + component, function () { + var gridBox = component, + exportButton = getExportButton(gridBox), + gridRow, startingRows = gridBox.liveModels().length; - gridBox.newItem(); - gridRow = gridBox.$.editableGridRow; - // verify that there is an increase in rows - assert.equal(gridBox.liveModels().length, startingRows += 1); - - // Add a new row using the enter key - gridRow.bubble("onkeyup", {keyCode: 13}); - // verify again that a row has been added - assert.equal(gridBox.liveModels().length, startingRows += 1); - }); - - it('Check export', function () { - var getExportButton = function (obj) { - var result = null; - if (_.isObject(obj.$)) { - result = obj.$.exportButton || - _.find(obj.$, getExportButton); - } - return result; - }; + assert.isFalse(exportButton.disabled, + 'export enabled for fresh data'); + gridBox.newItem(); + gridRow = gridBox.$.editableGridRow; + assert.equal(gridBox.liveModels().length, startingRows += 1); + assert.isTrue(exportButton.disabled, + 'export disabled for changed data'); - var gridBox = component, - exportButton = getExportButton(gridBox); - assert.ok(exportButton); - // TODO: need to populate before we can export - // assert.doesNotThrow(exportButton.doTap()); - // TODO: find the generated file & check contents - }); + // Add a new row using the enter key + gridRow.bubble("onkeyup", {keyCode: 13}); + assert.equal(gridBox.liveModels().length, startingRows += 1); }); - } - }); + }); + } }); }); }); - } - }); + }); + } }); }); }); -- 2.39.2