ExtJs tips for Ringtail Development


  • store.proxy.setExtraParams({ caseId : caseId });
    • D:\TFS_Data\Ringtail\Main\UIStatic8\Ringtail.Legal.UIStatic\applications\web\app\controller\portal\management\casesandservers\cases\filetyperank\List.js
  • Use t.ok or t.is instead of t.expect because then you can add a description that will appear in the test runner
  • Use getView(), getStore(), and getForm() instead of referencing the variables directly
  • Use record.set('PropertyName', value) instead of record.data.PropertyName = value
  • To check if an item is in a store, you can use store.findRecord
  • Use Ringtail.Ajax.request instead of me.executeAjax or this.executeAjax
  • Use t.spyOn(RingtailNotification, 'show'). I can also add a callThrough to let the code execute, but it will still be tracked, so I can do a count to see how many times it was called.
  • I shouldn't use beforeEach and afterEach to create and destroy views before each test because of performance reasons. This means the test won't be pristine when they run each time, but it is a trade off between a pristine test and performance.

To set the default tab when navigating from a list to the details of the object in the list


onDataModelLinkClick: function (column, view, td, cellIndex, record) {
            var pageController = 'casesetup.datamodels.TabSet';

            Ringtail.Page.navigateToPage({
                pageController: pageController,
                drillDetail: {
                    Id: record.get('Id'),
                    DataModelId: record.get('Id'),
                    Name: record.get('Name')
                },
                selectedTab: 'casesetup.datamodels.dynamicentities.List'
            });
        }


Siesta Testing - To test that a function was called with specific parameters


t.it('should popoulate a drill detail with data model id when navigating', function (t) {
                            var navigateToPageSpy = t.spyOn(Ringtail.Page, 'navigateToPage');

                            t.chain(
                                { click: "web-casesetup-datamodels-list => table.x-grid-item:nth-child(1) .x-grid-cell:nth-child(2) .c-hyperlink-column" },
                                function (next) {
                                    t.expect(navigateToPageSpy).toHaveBeenCalledWith({
                                        pageController: 'casesetup.datamodels.TabSet',
                                        drillDetail: {
                                            Id: 1,
                                            DataModelId: 1,
                                            Name: 'System'
                                        },
                                        selectedTab: 'casesetup.datamodels.dynamicentities.List'
                                    });
                                }
                            );
                        });


Siesta Testing - To get a specific cell in a list and if it is in edit mode


t.it('items should not be editable', function (t) {
                    var cellToClick = t.getCell(testTarget, 2, 1),
                        editingPlugin = testTarget.editingPlugin,
                        startEditSpy = t.spyOn(editingPlugin, 'startEdit').stub();
                    
                    t.chain(
                        function (next) {
                            t.expect(cellToClick.hasCls('c-editable-cell')).toBe(false);
                            t.expect(cellToClick.el.dom.getAttribute('data-qtip')).toBe(null);
                            t.click(cellToClick, next);
                        },
                        function (next) {
                            t.expect(startEditSpy).not.toHaveBeenCalled();
                            t.cqNotExists('input', 'cell is not editable');
                            t.done();
                        }
                    );
                });


Siesta Testing - To confirm a request was made with a specific body

t.respondToXhr({ 
                                    url: 'DynamicEntities/DynamicEntityTypes/List', 
                                    response: dynamicEntityTypesLoadResponse,
                                    requestValidator: function (xhr) {
                                        var requestBody = Ext.JSON.decode(xhr.requestBody);

                                        // Validate all the required fields
                                        return Ext.Object.equals(requestBody, { id: 15, name: 'Example A' });
                                    }
                                }),


Siesta Testing - To confirm a request was made with a specific url and parameters

t.respondToXhr({ 
                                    url: 'DynamicEntities/DynamicEntityTypes/List', 
                                    response: dynamicEntityTypesLoadResponse,
                                    requestValidator: function (xhr) {
                                        var validated = true;

                                        if (xhr.url.startsWith('/DynamicEntities/DynamicEntityTypes/List') === false) {
                                            validated = false;
                                        }
                                        if (xhr.url.indexOf('dataModelId=1001') > 0) {
                                            validated = false;
                                        }

                                        return validated;
                                    }
                                })


Siesta Testing - To confirm a function was called with specific parameters

var navigateToPageSpy = t.spyOn(Ringtail.Page, 'navigateToPage');

t.expect(navigateToPageSpy).toHaveBeenCalledWith({
                            pageController: 'casesetup.datamodels.dynamicentities.conditionalcodingtemplate.ConditionalTemplateTabSet',
                            drillDetail: {
                                Id: 456,
                                Name: 'Banjo',
                                Data: {
                                    DataModelId: parentDrillDetail.get('Data').DataModelId,
                                    EntityTypeId: parentDrillDetail.get('Id')
                                }
                            }
                        });


No comments:

Post a Comment

} else { }