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

        function patientSelect(name) {
            // This method is used by patient viewer to search and select a
            // patient before proceeding
            if (window.location.href.indexOf('scheduling-manager')) {
                var e = $.Event("keypress"), $input = $("#patient-search-input");
                e.which = e.keyCode = 13;
                $input.val(name).trigger(e);

            }
        }

        module("SCV-80 |SCV-842-Display Cancel appt dialog");
        test('SCV-927 -Validate the Cancel appointment dialog', 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 () {
                ok($("#inner-content").find('p').text(),
                    'Please select a Service/Specialty and Clinic to view availability.');
                // Search and select a patient
                var e = $.Event("keypress");
                e.which = 13; // # Some key
                // code value
                e.keyCode = 13;
                $("#patient-search-input").val(
                    '666000004')
                    .trigger(e);
                $('#patient-search-results li:nth-child(2) a')
                    .trigger('tap');
                afterElementLoad($("#future-appointments-table"),
                    function () {
                        ok($("#future-appointments-table").is(':visible'),
                            'Future Appointments table is visible');
                    });
                //Records exist under Future Appointments table
                equal($("#future-appointments .ui-btn-text").find('span').length > 0, true, 'Future Appointments exist');

                //Select future appointment meta data
                $("#future-appointments-table").find('tr').eq(1).trigger('tap');
                return 500;
            }, function () {
                equal($("#process-request").hasClass('ui-disabled'), false, 'Cancel Appointment button enabled');


            });
        });
    });