swat issue #23382: can edit item site
authorjulesstp <julianmcarlin@gmail.com>
Wed, 18 Jun 2014 19:32:36 +0000 (13:32 -0600)
committerjulesstp <julianmcarlin@gmail.com>
Wed, 18 Jun 2014 19:32:36 +0000 (13:32 -0600)
test/extensions/sales/sales_order_workspace.js

index 5366e94..a7c908c 100644 (file)
@@ -16,7 +16,6 @@
     gridRow,
     gridBox,
     workspace,
-    skipIfSiteCal,
     primeSubmodels = function (done) {
       var submodels = {};
       async.series([
@@ -56,7 +55,6 @@
           submodels = submods;
           done();
         });
-        if (XT.extensions.manufacturing && XT.session.settings.get("UseSiteCalendar")) {skipIfSiteCal = true; }
       });
     });
 
             });
         */
       });
-      // XXX - skip test if site calendar is enabled -
-      // temporary until second notifyPopup (_nextWorkingDate) is handled in test (TODO).
-
-      //it('changing the Schedule Date updates the line item\'s schedule date', function (done) {
-      (skipIfSiteCal ? it.skip : it)(
-        'changing the Schedule Date updates the line item\'s schedule date', function (done) {
+      it('after saving, should not be able to Open and have edit privs in Item Site Workspace', function (done) {
+        if (!XT.extensions.inventory) {done(); }
+        var originator = {}, statusReadyClean, workspaceContainer;
+        originator.name = "openItem";
+        // It's NOT a new order, go and make sure that we can't edit (after opening) Item Site WS
+        statusReadyClean = function () {
+          gridRow.$.itemSiteWidget.$.privateItemSiteWidget.menuItemSelected(null, {originator: originator});
+          /** XXX - what event can be used here instead? Tried a callback in menuItemSelected and passing it on
+            in PrivateItemSiteWidget's l154doWorkspace in the Private Item Site Widget.
+          */
+          setTimeout(function () {
+            workspaceContainer = XT.app.$.postbooks.getActive();
+            assert.equal(workspaceContainer.$.workspace.kind, "XV.ItemSiteWorkspace");
+            // "If notes are read only, assume that all the attributes are readOnly"... Lazy
+            assert.isTrue(workspaceContainer.$.workspace.value.isReadOnly("notes"));
+            // XXX - again, need an event
+            setTimeout(function () {
+              workspaceContainer.doPrevious();
+              assert.equal(XT.app.$.postbooks.getActive().$.workspace.kind, "XV.SalesOrderWorkspace");
+              // Update the notes field to leave the model READY_DIRTY
+              XT.app.$.postbooks.getActive().$.workspace.value.set("orderNotes", "test");
+              done();
+            }, 2000);
+          }, 3000);
+        };
+        workspace.value.once("status:READY_CLEAN", statusReadyClean);
+        workspace.save();
+      });
+      it('changing the Schedule Date updates the line item\'s schedule date', function (done) {
+        // Skip if no mfg ext or site cal not enabled... 
+        // TODO - temporary until second notifyPopup (_nextWorkingDate) is handled properly in test
+        if (!XT.extensions.manufacturing || !XT.session.settings.get("UseSiteCalendar")) {done(); }
         var getDowDate = function (dow) {
             var date = new Date(),
               currentDow = date.getDay(),
             date.setDate(date.getDate() + distance);
             return date;
           },
-          newScheduleDate = getDowDate(0); // Sunday from current week
-
-        var handlePopup = function () {
-          assert.equal(workspace.value.get("scheduleDate"), newScheduleDate);
-          // Confirm to update all line items
-          XT.app.$.postbooks.notifyTap(null, {originator: {name: "notifyYes"}});
-          // And verify that they were all updated with the new date
-          setTimeout(function () {
-            _.each(workspace.value.get("lineItems").models, function (model) {
-              assert.equal(newScheduleDate, model.get("scheduleDate"));
-            });
-            done();
-          }, 3000);
-        };
+          newScheduleDate = getDowDate(0), // Sunday from current week
+          handlePopup = function () {
+            assert.equal(workspace.value.get("scheduleDate"), newScheduleDate);
+            // Confirm to update all line items
+            XT.app.$.postbooks.notifyTap(null, {originator: {name: "notifyYes"}});
+            // And verify that they were all updated with the new date
+            setTimeout(function () {
+              _.each(workspace.value.get("lineItems").models, function (model) {
+                assert.equal(model.get("scheduleDate"), newScheduleDate);
+              });
+              done();
+            }, 3000);
+          };
 
         workspace.value.once("change:scheduleDate", handlePopup);
         workspace.value.set("scheduleDate", newScheduleDate);
       });
       it('save, then delete order', function (done) {
-        assert.equal(workspace.value.status, XM.Model.READY_NEW);
+        assert.equal(workspace.value.status, XM.Model.READY_DIRTY);
         smoke.saveWorkspace(workspace, function (err, model) {
           assert.isNull(err);
-          // TODO: sloppy
+          // XXX - sloppy
           setTimeout(function () {
             smoke.deleteFromList(XT.app, model, done);
           }, 4000);