<commit_before>YUI.add('aui-form-builder-layout-builder-tests', function(Y) {

    var suite = new Y.Test.Suite('aui-form-builder-layout-builder');

    suite.add(new Y.Test.Case({
        name: 'AUI Form Builder Layout Builder Unit Tests',

        init: function() {
            var windowNode = Y.one(Y.config.win);

            // Set the width to a big value so all layout buil
            // guaranteed to be turned on.
            this._originalWidth = windowNode.get('innerWidth');
            windowNode.set('innerWidth', 1500);
        },

        destroy: function() {
            Y.one(Y.config.win).set('innerWidth', this._originalWidth);
        },

        tearDown: function() {
            if (this._formBuilder) {
                this._formBuilder.destroy();
            }
        },

        _createFormBuilder: function(config, skipRender) {
            this._formBuilder = new Y.FormBuilder(Y.merge({
                layout: new Y.Layout({
                    rows: [
                        new Y.LayoutRow({
                            cols: [
                                new Y.LayoutCol({
                                    movableContent: true,
                                    size: 4,
                                    value: new Y.FormBuilderFieldSentence({
                                        help: 'My Help',
                                        nestedFields: [
                                            new Y.FormBuilderFieldText({
                                                help: 'First nested field',
                                                title: 'Nested Field 1'
                                            }),
                                            new Y.FormBuilderFieldText({
                                                help: 'Second nested field',
                                                title: 'Nested Field 2'
                                            })
                                        ],
                                        title: 'My Title'
                                    })
                                }),
                                new Y.LayoutCol({
                                    size: 4
                                }),
                                new Y.LayoutCol({
                                    size: 4,
                                    value: new Y.FormBuilderFieldSentence({
                                        title: 'Another Field'
                                    })
                                })
                            ]
                        })
                    ]
                })
            }, config));

            if (!skipRender) {
                this._formBuilder.render('#container');
            }
        },

        _openToolbar: function(fieldNode) {
            fieldNode = fieldNode || Y.one('.form-builder-field-content-toolbar');

            if (Y.UA.mobile) {
                Y.one('.form-builder-field-content').simulate('click');
            } else {
                fieldNode.simulate('mouseover');
                fieldNode.one('.form-builder-field-toolbar-toggle').simulate('click');
            }
        },

        'should put add page break in the same container of add row button': function() {
            var layout;

            this._createFormBuilder({
                mode: Y.FormBuilder.MODES.LAYOUT
            });

            layout = this._formBuilder.get('layout');
            Y.Assert.areEqual(2, Y.one('.layout-builder-add-row-area').get('children').size());

            if (Y.UA.ie === 8) {
                // Can't simulate a resize on IE8's window object, so
                // calling the function directly here.
                layout._handleResponsive(Y.one(Y.config.win).get('innerWidth'));
            }
            else {
                // 500 is lower than responsive breakpoint
                Y.one(Y.config.win).set('innerWidth', 500);
                Y.one(Y.config.win).simulate('resize');
            }

            this.wait(function() {
                Y.Assert.isNull(Y.one('.layout-builder-add-row-area'));

                Y.one(Y.config.win).set('innerWidth', this._originalWidth);
                Y.one(Y.config.win).simulate('resize');

                this.wait(function() {
                    Y.Assert.areEqual(2, Y.one('.layout-builder-add-row-area').get('children').size());
                }, Y.config.windowResizeDelay || 100);
            }, Y.config.windowResizeDelay || 100);
        },

        'should the row height adjust on form builder mode change': function() {
            var height;

            this._createFormBuilder();

            height = Y.all('.layout-row-container-row').item(1).getStyle('height');
            this._formBuilder.set('mode', Y.FormBuilder.MODES.LAYOUT);
            Y.Assert.isTrue(parseInt(Y.all('.layout-row-container-row').item(1).getStyle('height')) > parseInt(height));

            height = Y.all('.layout-row-container-row').item(1).getStyle('height');<commit_msg>AUI-1866 Fix aui-form-builder-layout-builder tests on smaller screens<commit_after>YUI.add('aui-form-builder-layout-builder-tests', function(Y) {

    var desktopDefaultSize = 1500,
        suite = new Y.Test.Suite('aui-form-builder-layout-builder'),
        windowNode = Y.one(Y.config.win);

    suite.add(new Y.Test.Case({
        name: 'AUI Form Builder Layout Builder Unit Tests',

        init: function() {
            // Set the width to a big value so all layout buil
            // guaranteed to be turned on.
            this._originalWidth = windowNode.get('innerWidth');
        },

        setUp: function() {
            windowNode.set('innerWidth', desktopDefaultSize);
        },

        destroy: function() {
            Y.one(Y.config.win).set('innerWidth', this._originalWidth);
        },

        tearDown: function() {
            if (this._formBuilder) {
                this._formBuilder.destroy();
            }
        },

        _createFormBuilder: function(config, skipRender) {
            this._formBuilder = new Y.FormBuilder(Y.merge({
                layout: new Y.Layout({
                    rows: [
                        new Y.LayoutRow({
                            cols: [
                                new Y.LayoutCol({
                                    movableContent: true,
                                    size: 4,
                                    value: new Y.FormBuilderFieldSentence({
                                        help: 'My Help',
                                        nestedFields: [
                                            new Y.FormBuilderFieldText({
                                                help: 'First nested field',
                                                title: 'Nested Field 1'
                                            }),
                                            new Y.FormBuilderFieldText({
                                                help: 'Second nested field',
                                                title: 'Nested Field 2'
                                            })
                                        ],
                                        title: 'My Title'
                                    })
                                }),
                                new Y.LayoutCol({
                                    size: 4
                                }),
                                new Y.LayoutCol({
                                    size: 4,
                                    value: new Y.FormBuilderFieldSentence({
                                        title: 'Another Field'
                                    })
                                })
                            ]
                        })
                    ]
                })
            }, config));

            if (!skipRender) {
                this._formBuilder.render('#container');
            }
        },

        _openToolbar: function(fieldNode) {
            fieldNode = fieldNode || Y.one('.form-builder-field-content-toolbar');

            if (Y.UA.mobile) {
                Y.one('.form-builder-field-content').simulate('click');
            } else {
                fieldNode.simulate('mouseover');
                fieldNode.one('.form-builder-field-toolbar-toggle').simulate('click');
            }
        },

        'should put add page break in the same container of add row button': function() {
            var layout;

            this._createFormBuilder({
                mode: Y.FormBuilder.MODES.LAYOUT
            });

            layout = this._formBuilder.get('layout');
            Y.Assert.areEqual(2, Y.one('.layout-builder-add-row-area').get('children').size());

            if (Y.UA.ie === 8) {
                // Can't simulate a resize on IE8's window object, so
                // calling the function directly here.
                layout._handleResponsive(Y.one(Y.config.win).get('innerWidth'));
            }
            else {
                // 500 is lower than responsive breakpoint
                Y.one(Y.config.win).set('innerWidth', 500);
                Y.one(Y.config.win).simulate('resize');
            }

            this.wait(function() {
                Y.Assert.isNull(Y.one('.layout-builder-add-row-area'));

                Y.one(Y.config.win).set('innerWidth', desktopDefaultSize);
                Y.one(Y.config.win).simulate('resize');

                this.wait(function() {
                    Y.Assert.areEqual(2, Y.one('.layout-builder-add-row-area').get('children').size());
                }, Y.config.windowResizeDelay || 100);
            }, Y.config.windowResizeDelay || 100);
        },

        'should the row height adjust on form builder mode change': function() {
            var height;

            this._createFormBuilder();

            height = Y.all('.layout-row-container-row').item(1).getStyle('height');
            this._formBuilder.set('mode', Y.FormBuilder.MODES.LAYOUT);
            Y.Assert.isTrue(parseInt(Y.all('.layout-row-container-row').item(1).getStyle('height')) > parseInt(height));

            height = Y.all('.layout-row-container-row').item(1).getStyle('height');
{'fraction_non_alphanumeric': 0.11419662866608205, 'fraction_numerical': 0.005846243788365975, 'mean_word_length': 1.0377208655946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6543536', 'n_tokens_mistral': 2443, 'n_tokens_neox': 2282, 'n_words': 434}