1 /*jshint trailing:true, white:true, indent:2, strict:true, curly:true,
2 immed:true, eqeqeq:true, forin:true, latedef:true,
3 newcap:true, noarg:true, undef:true */
4 /*global XT:true, XM:true, XV:true, process:true, module:true, require:true,
5 describe:true, before:true, enyo:true, it:true, _:true, console:true */
10 var zombieAuth = require("../../lib/zombie_auth"),
11 common = require("../../lib/common"),
12 smoke = require("../../lib/smoke"),
13 _ = require("underscore"),
14 assert = require("chai").assert;
16 describe('Workspace Grid Boxes', function () {
17 this.timeout(45 * 1000);
19 before(function (done) {
20 // setup for the date widget
21 var appLoaded = function () {
25 zombieAuth.loadApp(appLoaded);
28 it('Test Grid Box Functionality', function () {
29 _.each(XV, function (value, key) {
31 kinds = ['SalesOrderList', 'QuoteList', 'InvoiceList', 'ReturnList', 'ProjectList'];
32 // lists with grid boxes; TODO: find candidates automatically
33 if (_.contains(kinds, key)) {
34 describe('Create Workspace for XV.' + key, function () {
35 it('Create a Workspace', function () {
37 smoke.navigateToNewWorkspace(XT.app, list, function (workspaceContainer) {
38 var workspace = workspaceContainer.$.workspace,
39 getExportButton = function (obj) {
41 if (_.isObject(obj.$)) {
42 result = obj.$.exportButton ||
43 _.find(obj.$, getExportButton);
48 _.each(workspace.$, function (component) {
49 if (XV.inheritsFrom(component, 'XV.GridBox')) {
50 describe('Checking ' + component.name, function () {
51 it('checks for the export button', function () {
52 var exportButton = getExportButton(component);
53 assert.ok(exportButton);
54 // TODO: need to populate before we can export
55 // assert.doesNotThrow(exportButton.doTap());
56 // TODO: find the generated file & check contents
59 it('creates line items for ' + component, function () {
60 var gridBox = component,
61 exportButton = getExportButton(gridBox),
63 startingRows = gridBox.liveModels().length;
65 assert.isFalse(exportButton.disabled,
66 'export enabled for fresh data');
68 gridRow = gridBox.$.editableGridRow;
69 assert.equal(gridBox.liveModels().length, startingRows += 1);
70 assert.isTrue(exportButton.disabled,
71 'export disabled for changed data');
73 // Add a new row using the enter key
74 gridRow.bubble("onkeyup", {keyCode: 13});
75 assert.equal(gridBox.liveModels().length, startingRows += 1);