CollectionEditor: When there is only one item, moving item does not work

Found in

EPiServer.CMS.UI 9.2.0

Fixed in

EPiServer.CMS.UI 9.6.0

Created

Oct 13, 2015

Updated

May 13, 2016

Area

CMS UI

State

Closed, Fixed and tested


Description

This is hard to reproduce without Commerce installed, since only Commerce is using CollectionEditor at this point.

1. Log in to a commerce site > go to New Catalog Commerce UI.
2. Select any product under Departmental Catalog>Departments>Fashion>Tops>Tops-Tunic ( eg: Tops-Tunics-CowlNeck)
3. Open the item in Categories view.
4. On the Categories related list, there should only be one Tops-Tunic category.
5. Drag it and drop it to the drop area (the area with downward arrow).

Expected: The category (Tops-Tunic) still shows on the grid.
Actual: The categories grid list is empty.

Note: If list has at least 2 categories, the issue does not occur.

To reproduce the error, add the following unit test to CollectionEditorModel_specs.js

         describe("#moveItem", function () { //this already exist in the file
            // ...
            describe("when #before is true", function () { //also this
                describe('and there is only one item', function () { //this is the new test
                    beforeEach(function (done) {
                        model.data = [{ id: 1 }];
                        model.initialize().then(function () {
                            done();
                        });
                    });
                    it('should not change the list', function () {
                        item = model.get("items")[0];
                        model.moveItem(item, null, true);
                        var pos = model.get("items").indexOf(item);
                        expect(pos).to.equal(0);
                    });
                });