define(
    [ 'jQuery', 'asyncSeries', 'testUtilities' ],
    function ($$, asyncSeries, utilities) {


        module("SCV-86|SCV-9, SCV-1114, SCV-1115 - View veteran appointment requests in Scheduling Manager, VAAC functionality same within SCV");
        test('SCV-1116 - View veteran appointment requests in Scheduling Manager, Validate sorting', function () {
	        ok(true, "The tests are running.");

	        $(window).load(function () {
	            asyncSeries(function () {
	                afterElementLoad($("#calendar-specialty-input"), function () {
	                    ok($('#left-navigation').is(':visible'),
	                        "Header is visible");
	                });

	                // Then I can see the header info
	                ok($('#left-navigation:contains("Open Menu")').text(),
	                    "Then I can see the header bar");
	                return 1500;
	            }, function () {
	                //Go to VAAC page by clicking the button on the footer
	                $('#footer-veteran-requests-btn').trigger('tap');
	                return 500;
	            }, function () {
	                afterElementLoad($("#list-refresh-btn"), function () {
	                    ok($("#appointment-requests-table")
	                            .is(':visible'),
	                        'Appointment Request table is visible');
	                });
	                //Validate the VAAC page
	                //Page title
	                ok($("#sub-header .ui-title").text(), 'Veteran Appointment Requests');

	                //Refresh and Restore default sort buttons
	                equal($("#list-refresh-btn").is(':visible'), true, 'Refresh button is displayed and enabled');
	                equal($("#restore-sort-btn").is(':visible'), true, 'Restore Default Sort Order button is displayed and enabled');
	                //Search field
	                equal($("#vaac-request-filter").is(':visible'), true, 'Search field is displayed');

	                //Validate the column names
	                ok($("#appointment-requests-table").find('th').eq(0).text(), 'Alerts');
	                ok($("#appointment-requests-table").find('th').eq(1).text(), 'Patient Name');
	                ok($("#appointment-requests-table").find('th').eq(2).text(), 'Facility');
	                ok($("#appointment-requests-table").find('th').eq(3).text(), 'Type');
	                ok($("#appointment-requests-table").find('th').eq(4).text(), 'Status');
	                ok($("#appointment-requests-table").find('th').eq(5).text(), 'Last Activity');

	                //Validate that each column is sortable
	                //Last Activity Column-ascending
	                $("#appointment-requests-table").find('th').eq(5).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(5).attr('aria-sort'),
	                    'ascending', 'Last Activity ascending');
	                //Last Activity Column-descending
	                $("#appointment-requests-table").find('th').eq(5).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(5).attr('aria-sort'),
	                    'descending', 'Last Activity descending');

	                //Patient Name column - ascending
	                $("#appointment-requests-table").find('th').eq(1).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(1).attr('aria-sort'),
	                    'ascending', 'Last Activity ascending');
	                //Patient Name Column-descending
	                $("#appointment-requests-table").find('th').eq(1).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(1).attr('aria-sort'),
	                    'descending', 'Last Activity descending');

	                //Facility column - ascending
	                $("#appointment-requests-table").find('th').eq(2).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(2).attr('aria-sort'),
	                    'ascending', 'Last Activity ascending');
	                //Facility Column-descending
	                $("#appointment-requests-table").find('th').eq(2).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(2).attr('aria-sort'),
	                    'descending', 'Last Activity descending');

	                //Type column - ascending
	                $("#appointment-requests-table").find('th').eq(3).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(3).attr('aria-sort'),
	                    'ascending', 'Last Activity ascending');
	                //Type Column-descending
	                $("#appointment-requests-table").find('th').eq(3).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(3).attr('aria-sort'),
	                    'descending', 'Last Activity descending');

	                //Status column - ascending
	                $("#appointment-requests-table").find('th').eq(4).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(4).attr('aria-sort'),
	                    'ascending', 'Last Activity ascending');
	                //Status Column-descending
	                $("#appointment-requests-table").find('th').eq(4).trigger('click');
	                equal($("#appointment-requests-table").find('th').eq(4).attr('aria-sort'),
	                    'descending', 'Last Activity descending');

	                $("#restore-sort-btn").trigger('click');
	                return 300;
	            }, function () {
	                //Select entry to display details on right
	                $("#appointment-requests-table").find('tr').eq(6).trigger('tap');
	                return 300;
	            }, function () {
	                ok($("#inner-content").is(':visible'), 'Details displayed');
	            });
	        });
        });
    });
//});