<commit_before>define([
    'intern!object',
    'intern/chai!assert',
    'base/lib/config',
    'base/lib/poll',
    'base/lib/POM',
    'intern/dojo/node!leadfoot/keys'
], function(registerSuite, assert, config, poll, POM, keys) {

    // Create this page's specific POM
    var Page = new POM({
        // Any functions used multiple times or important properties of the page
        searchBoxId: 'home-q'
    });


    // Register the tests to be run
    registerSuite({

        name: 'home',

        before: function() {
            return Page.init(this.remote, config.homepageUrl);
        },

        beforeEach: function() {
            return Page.setup();
        },

        after: function() {
            return Page.teardown();
        },

        'Homepage search form displays and accepts text, [ENTER] key submits form': function() {

            var term = 'Hello';

            return this.remote
                        .findByCssSelector('#' + Page.searchBoxId)
                        .click()
                        .type(term)
                        .getProperty('value')
                        .then(function(resultText) {
                            assert.ok(resultText.indexOf(term) > -1, term + ' is found in box');
                        })
                        .type(keys.RETURN)
                        .getCurrentUrl()
                        .then(function(url) {
                            assert.isTrue(url.indexOf('/search') != -1);
                        });
        },

        'Hacks posts display properly': function() {

            return this.remote
                        .findAllByCssSelector('.home-hacks .entry-title')
                        .then(function(arr) {
                            assert.ok(arr.length > 0, 'If this fails, Hacks posts are not displaying on the homepage');
                        });

        },

        'Demo slider displays properly': function() {

            return this.remote
                        .findAllByCssSelector('.owl-item')
                        .then(function(arr) {
                            assert.ok(arr.length > 0, 'If this fails, you may need to upload featured demos via the demo studio to ensure this works');
                        });

        },

        'Large search field does not display on mobile and lower': function() {
            // Starting with a "getWindowSize" to do cleanup on this test's resize to mobile

            var remote = this.remote;
            var windowSize;

            return remote
                        .getWindowSize()
                        .then(function(size) {
                            windowSize = size;
                        })
                        .setWindowSize(config.mediaQueries.mobile, 400)
                        .findByCssSelector('#' + Page.searchBoxId)
                        .isDisplayed()
                        .then(function(bool) {
                            assert.isFalse(bool);
                            // Cleanup the window sizing
                            return remote.setWindowSize(windowSize.width, windowSize.height);
                        });

        },

    });

});
<commit_msg>bug 1184662 - Use URL polling for homepage search test<commit_after>define([
    'intern!object',
    'intern/chai!assert',
    'base/lib/config',
    'base/lib/poll',
    'base/lib/POM',
    'intern/dojo/node!leadfoot/keys'
], function(registerSuite, assert, config, poll, POM, keys) {

    // Create this page's specific POM
    var Page = new POM({
        // Any functions used multiple times or important properties of the page
        searchBoxId: 'home-q'
    });


    // Register the tests to be run
    registerSuite({

        name: 'home',

        before: function() {
            return Page.init(this.remote, config.homepageUrl);
        },

        beforeEach: function() {
            return Page.setup();
        },

        after: function() {
            return Page.teardown();
        },

        'Homepage search form displays and accepts text, [ENTER] key submits form': function() {

            var remote = this.remote;
            var term = 'Hello';

            return remote
                        .findByCssSelector('#' + Page.searchBoxId)
                        .click()
                        .type(term)
                        .getProperty('value')
                        .then(function(resultText) {
                            assert.ok(resultText.indexOf(term) > -1, term + ' is found in box');
                        })
                        .type(keys.RETURN)
                        .then(function() {
                            return poll.untilUrlChanges(remote, '/search').then(function() {
                                assert.isTrue(true, 'Pressing [ENTER] submits search');
                            });
                        });
        },

        'Hacks posts display properly': function() {

            return this.remote
                        .findAllByCssSelector('.home-hacks .entry-title')
                        .then(function(arr) {
                            assert.ok(arr.length > 0, 'If this fails, Hacks posts are not displaying on the homepage');
                        });

        },

        'Demo slider displays properly': function() {

            return this.remote
                        .findAllByCssSelector('.owl-item')
                        .then(function(arr) {
                            assert.ok(arr.length > 0, 'If this fails, you may need to upload featured demos via the demo studio to ensure this works');
                        });

        },

        'Large search field does not display on mobile and lower': function() {
            // Starting with a "getWindowSize" to do cleanup on this test's resize to mobile

            var remote = this.remote;
            var windowSize;

            return remote
                        .getWindowSize()
                        .then(function(size) {
                            windowSize = size;
                        })
                        .setWindowSize(config.mediaQueries.mobile, 400)
                        .findByCssSelector('#' + Page.searchBoxId)
                        .isDisplayed()
                        .then(assert.isFalse);

        },

    });

});

{'fraction_non_alphanumeric': 0.10257626047099731, 'fraction_numerical': 0.00316105579263474, 'mean_word_length': 1.2203508771929825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798996', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1466, 'n_words': 394}