/*global describe it before after */

"use client";

require([
    "lib/architect/architect", 
    "lib/chai/chai",
    "/vfs-root"
], function (architect, chai, baseProc) {
    var expect = chai.expect;
    
    expect.setupArchitectTest([
        {
            packagePath: "plugins/c9.core/c9",
            workspaceId: "ubuntu/ip-10-35-77-180",
            startdate: new Date(),
            debug: true,
            hosted: true,
            local: false,
            davPrefix: "/"
        },
        
        "plugins/c9.core/ext",
        "plugins/c9.core/http-xhr",
        "plugins/c9.core/util",
        "plugins/c9.ide.ui/forms",
        "plugins/c9.ide.ui/lib_apf",
        "plugins/c9.ide.ui/menus",
        "plugins/c9.ide.ui/anims",
        {  
            packagePath: "plugins/c9.core/settings",
            testing: true
        },
        "plugins/c9.core/api.js",
        "plugins/c9.ide.keys/commands",
        "plugins/c9.ide.keys/editor",
        {
            packagePath: "plugins/c9.ide.ui/ui",
            staticPrefix: "plugins/c9.ide.ui"
        },
        "plugins/c9.ide.editors/document",
        "plugins/c9.ide.editors/undomanager",
        "plugins/c9.ide.editors/editors",
        "plugins/c9.ide.editors/editor",
        "plugins/c9.ide.editors/tabmanager",
        "plugins/c9.ide.ui/focus",
        "plugins/c9.ide.editors/pane",
        "plugins/c9.ide.editors/tab",
        "plugins/c9.ide.terminal/terminal",
        "plugins/c9.ide.ace/ace",
        {
            packagePath: "plugins/c9.ide.welcome/welcome",
            staticPrefix: "plugins/c9.ide.welcome"
        },
        {
            packagePath: "plugins/c9.ide.preferences/preferences",
            staticPrefix: "plugins/c9.ide.preferences"
        },
        "plugins/c9.ide.preferences/preferencepanel",
        "plugins/c9.ide.preferences/general",
        {
            packagePath: "plugins/c9.fs/fs",
            baseProc: baseProc
        },
        "plugins/c9.fs/proc",
        "plugins/c9.vfs.client/vfs_client",
        "plugins/c9.vfs.client/endpoint",
        "plugins/c9.ide.auth/auth",
        
        // Mock plugins
        {
            consumes: ["apf", "ui", "Plugin"],
            provides: [
                "menus", "layout", "watcher", "save", "clipboard",
                "dialog.confirm", "dialog.alert", "auth.bootstrap", "info",
                "dialog.error"
            ],
            setup: expect.html.mocked
        },
        {
            consumes: ["tabManager", "welcome"],
            provides: [],
            setup: main
        }
    ], architect);
    
    function main(options, imports, register) {
        var tabs = imports.tabManager;
        
        expect.html.setConstructor(function(tab) {
            if (typeof tab == "object")
                return tab.pane.aml.getPage("editor::" + tab.editorType).$ext;
        });
        
        describe('preferences', function() {
            this.timeout(20000);
            
            before(function(done) {
                apf.config.setProperty("allow-select", false);
                apf.config.setProperty("allow-blur", false);
                
                bar.$ext.style.height = "66%";
                
                document.body.style.marginBottom = "66%";
                
                tabs.once("ready", function() {
                    done();
                });
            });
            
            
            describe("Welcome", function() {
                this.timeout(10000);
                
                it('should open a pane with just an editor', function(done) {
                    tabs.openEditor("welcome", function(err, tab) {
                        expect(tabs.getTabs()).length.gt(0);
                        
                        done();
                    });
                });
            });
            describe("unload()", function() {
               this.timeout(10000);
               
               it('should unload the welcome screen', function(done) {
                   tabs.getTabs()[0].editor.unload();
                   tabs.getTabs()[0].unload();
                   tabs.unload();
                   done();
               });
           });
           
           after(function(done) {
               document.body.style.marginBottom = "";
               done();
           });
        });
        
        onload && onload();
    }
});
@@ -2115,351 +2115,8 @@
    %0A
-        // Mock plugins%0A        %7B%0A            consumes: %5B%22apf%22, %22ui%22, %22Plugin%22%5D,%0A            provides: %5B%0A                %22menus%22, %22layout%22, %22watcher%22, %22save%22, %22clipboard%22,%0A                %22dialog.confirm%22, %22dialog.alert%22, %22auth.bootstrap%22, %22info%22,%0A                %22dialog.error%22%0A            %5D,%0A            setup: expect.html.mocked%0A        %7D,%0A
     

remove unnecessary html.mocked calls