<commit_before>/* jshint: true */
/* globals: expect:false,beforeAll:false,expect:false,browser:false,element:false,by:false,describe:false,protractor:false,it:false */

// This protractor scen file tests tbColumn and tbGrid components.

// It is assumed throughout the test that the data received for the main tbGrid
// component at the related HTML file (tbColumn_tests.html) is static and constrained
// to 53 records with consecutive ID's.

describe('tbColumn', () => {

    var firstDataRow,
        lastDataRow,
        aOrderIdSorting,
        aCustomerNameSorting,
        aCreationDateSorting;

    function updateFirstAndLastRow() {
        // First showing row
        firstDataRow = element.all(by.repeater('row in $component.rows')).first();
        // Last showing row
        lastDataRow = element.all(by.repeater('row in $component.rows')).last();
    }

    describe('Grid Sorting', () => {
        beforeEach(() => {
            // Go to test
            browser.get('index.html');
            browser.executeScript('window.sessionStorage.clear();window.localStorage.clear();');
            element(by.id('testsSelector')).click();
            element(by.id('tbColumnSortingTest')).click();

            // Go to first page if not there    
            element(by.tagName('tb-grid-pager'))
                .$('li.pagination-first a')
                .click();

            // Select '20' on tbPageSizeSelector
            element(by.model('$ctrl.$component.pageSize'))
                .$('[value="number:20"]').click();
            
            updateFirstAndLastRow();

            // Sort Order ID column link
            aOrderIdSorting = element(by.tagName('thead'))
                .$$('tr th').first()
                .$('a');
            // Sort Customer Name column link
            aCustomerNameSorting = element(by.tagName('thead'))
                .$$('tr th').get(1)
                .$('a');
            // Sort Shipped Date column link
            aCreationDateSorting = element(by.tagName('thead'))
                .$$('tr th').get(3)
                .$('a');
        });

        var dataSetLowerCustomerName = 'Advanced Technology Systems',
            dataSetHigherCustomerName = 'Vesta',
            dataSetLowerDate = /12\/30\/2015/,
            dataSetHigherDate = /1\/01\/2016/;

        it('should sort data in ascending order then on descending order when sorting by Order Id column', () => {
            aOrderIdSorting.click().then(() => {
                updateFirstAndLastRow();
                expect(firstDataRow.$$('td').first().getText()).toBe('1');
                expect(lastDataRow.$$('td').first().getText()).toBe('20');

                aOrderIdSorting.click().then(() => {
                    updateFirstAndLastRow();
                    expect(firstDataRow.$$('td').first().getText()).toBe('500');
                    expect(lastDataRow.$$('td').first().getText()).toBe('481');
                });
            });
        });

        it('should order data in ascending order when click-sorting an unsorted text column', () => {
            aCustomerNameSorting.click().then(() => {
                updateFirstAndLastRow();
                expect(firstDataRow.$$('td').get(1).getText()).toBe(dataSetLowerCustomerName);
            });
        });

        it('should order data in descending order when click-sorting an ascending-sorted text column', () => {
            aCustomerNameSorting.click().then(() => {
                aCustomerNameSorting.click().then(() => {
                    updateFirstAndLastRow();
                    expect(firstDataRow.$$('td').get(1).getText()).toBe(dataSetHigherCustomerName);
                });
            });
        });

        it('should order data in ascending order when click-sorting an unsorted date column', () => {
            aCreationDateSorting.click().then(() => {
                updateFirstAndLastRow();
                expect(firstDataRow.$$('td').get(3).getText()).toMatch(dataSetLowerDate);
            });
        });

        it('should order data in descending order when click-sorting twice an unsorted date column', () => {
            aCreationDateSorting.click().then(() => {
                aCreationDateSorting.click().then(() => {
                    updateFirstAndLastRow();
                    expect(firstDataRow.$$('td').get(3).getText()).toMatch(dataSetHigherDate);
                });
            });
        });
    });
});<commit_msg>Fixed sorting e2e test due to mismatch on column references.<commit_after>/* jshint: true */
/* globals: expect:false,beforeAll:false,expect:false,browser:false,element:false,by:false,describe:false,protractor:false,it:false */

// This protractor scen file tests tbColumn and tbGrid components.

// It is assumed throughout the test that the data received for the main tbGrid
// component at the related HTML file (tbColumn_tests.html) is static and constrained
// to 53 records with consecutive ID's.

describe('tbColumn', () => {

    var firstDataRow,
        lastDataRow,
        aOrderIdSorting,
        aCustomerNameSorting,
        aShipDateSorting;

    function updateFirstAndLastRow() {
        // First showing row
        firstDataRow = element.all(by.repeater('row in $component.rows')).first();
        // Last showing row
        lastDataRow = element.all(by.repeater('row in $component.rows')).last();
    }

    describe('Grid Sorting', () => {
        beforeEach(() => {
            // Go to test
            browser.get('index.html');
            browser.executeScript('window.sessionStorage.clear();window.localStorage.clear();');
            element(by.id('testsSelector')).click();
            element(by.id('tbColumnSortingTest')).click();

            // Go to first page if not there    
            element(by.tagName('tb-grid-pager'))
                .$('li.pagination-first a')
                .click();

            // Select '20' on tbPageSizeSelector
            element(by.model('$ctrl.$component.pageSize'))
                .$('[value="number:20"]').click();
            
            updateFirstAndLastRow();

            // Sort Order ID column link
            aOrderIdSorting = element(by.tagName('thead'))
                .$$('tr th').first()
                .$('a');
            // Sort Customer Name column link
            aCustomerNameSorting = element(by.tagName('thead'))
                .$$('tr th').get(1)
                .$('a');
            // Sort Shipped Date column link
            aShipDateSorting = element(by.tagName('thead'))
                .$$('tr th').get(2)
                .$('a');
        });

        var dataSetLowerCustomerName = 'Advanced Technology Systems',
            dataSetHigherCustomerName = 'Vesta',
            dataSetLowerDate = /2\/24\/2015/,
            dataSetHigherDate = /2\/01\/2017/;

        it('should sort data in ascending order then on descending order when sorting by Order Id column', () => {
            aOrderIdSorting.click().then(() => {
                updateFirstAndLastRow();
                expect(firstDataRow.$$('td').first().getText()).toBe('1');
                expect(lastDataRow.$$('td').first().getText()).toBe('20');

                aOrderIdSorting.click().then(() => {
                    updateFirstAndLastRow();
                    expect(firstDataRow.$$('td').first().getText()).toBe('500');
                    expect(lastDataRow.$$('td').first().getText()).toBe('481');
                });
            });
        });

        it('should order data in ascending order when click-sorting an unsorted text column', () => {
            aCustomerNameSorting.click().then(() => {
                updateFirstAndLastRow();
                expect(firstDataRow.$$('td').get(1).getText()).toBe(dataSetLowerCustomerName);
            });
        });

        it('should order data in descending order when click-sorting an ascending-sorted text column', () => {
            aCustomerNameSorting.click().then(() => {
                aCustomerNameSorting.click().then(() => {
                    updateFirstAndLastRow();
                    expect(firstDataRow.$$('td').get(1).getText()).toBe(dataSetHigherCustomerName);
                });
            });
        });

        it('should order data in ascending order when click-sorting an unsorted date column', () => {
            aShipDateSorting.click().then(() => {
                updateFirstAndLastRow();
                expect(firstDataRow.$$('td').get(2).getText()).toMatch(dataSetLowerDate);
            });
        });

        it('should order data in descending order when click-sorting twice an unsorted date column', () => {
            aShipDateSorting.click().then(() => {
                aShipDateSorting.click().then(() => {
                    updateFirstAndLastRow();
                    expect(firstDataRow.$$('td').get(2).getText()).toMatch(dataSetHigherDate);
                });
            });
        });
    });
});
{'fraction_non_alphanumeric': 0.15093708165997322, 'fraction_numerical': 0.008032128514056224, 'mean_word_length': 1.9695263332229216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '3494935', 'n_tokens_mistral': 2445, 'n_tokens_neox': 2254, 'n_words': 457}