Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Ability to use App object


#1

Is there a way to use the App object in customizations? I am wanting to auto add the Reference field for our QAs when they add a Test Case view the Suite view page. I see in TestRail’s code that you use this bit of code to validate, send the Ajax Call, and then add the new element to the page.

$(e + " .addForm").submit(function() {
    $(e + " .submit").blur();
    App.Validation.hideErrors();
    var g = $.trim($(e + " .title").val());
    if (!g) {
        $(e + " .errorPanel").show();
        $(e + " .requiredMessage").show();
        return false
    }
    b(true);
    App.Ajax.call({
        target: "cases/ajax_add",
        arguments: {
            section_id: c,
            title: g,
            columns: App.Tables.columns_for_user
        },
        success: function(i) {
            $(e + " .title").val("");
            $(e + " .title").focus();
            b(false);
            var h = $("#grid-" + c);
            var j = $(i);
            j.appendTo(h);
            App.Effects.add(j);
            App.Suites.onCasesAdded();
            App.Suites.refreshGroupCount(c);
            if (App.Users.hasGoals()) {
                App.Users.reloadGoals()
            }
        },
        error: function(h) {
            b(false);
            App.Ajax.handleError(h)
        }
    });
    return false
});

Whenever I try to use the App object, the console errors and says it is undefined. Am I correct to assume that this feature is not allowed, and I am to add the test case via your public API and then mimic the adding of the new Test Case without the existing functions you have created in App?


#2

Hi Zach,

Thanks for your posting. Using the internal JavaScript APIs (App object) is not really possible/recommended but you can simply use TestRail’s API in this case (also from JavaScript and inside TestRail using UI scripts):

You would need to enable the “Enable session authentication for API” option on Administration > Site Settings > API.

Cheers,
Tobias