"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const Project_1 = require("../app/Project");
const CartoApp_1 = require("../app/CartoApp");
const NodeStorage_1 = require("../local/NodeStorage");
const Database_1 = require("../minecraft/Database");
const LocalEnvironment_1 = require("../local/LocalEnvironment");
const ProjectInfoSet_1 = require("../info/ProjectInfoSet");
const IProjectInfoData_1 = require("../info/IProjectInfoData");
const IProjectItemData_1 = require("../app/IProjectItemData");
const TestUtilities_1 = require("./TestUtilities");
CartoApp_1.default.hostType = CartoApp_1.HostType.testLocal;
let carto = undefined;
let localEnv = undefined;
let scenariosFolder = undefined;
let resultsFolder = undefined;
localEnv = new LocalEnvironment_1.default(false);
(async () => {
    CartoApp_1.default.localFolderExists = _localFolderExists;
    CartoApp_1.default.ensureLocalFolder = _ensureLocalFolder;
    const scenariosStorage = new NodeStorage_1.default(NodeStorage_1.default.ensureEndsWithDelimiter(__dirname) + "/../../test/", "scenarios");
    scenariosFolder = scenariosStorage.rootFolder;
    await scenariosFolder.ensureExists();
    const resultsStorage = new NodeStorage_1.default(NodeStorage_1.default.ensureEndsWithDelimiter(__dirname) + "/../../test/", "results");
    resultsFolder = resultsStorage.rootFolder;
    await resultsFolder.ensureExists();
    CartoApp_1.default.prefsStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "prefs" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.projectsStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "projects" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.packStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "packs" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.worldStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "worlds" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.deploymentStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "deployment" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.workingStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "working" + NodeStorage_1.default.platformFolderDelimiter, "");
    const coreStorage = new NodeStorage_1.default(__dirname + "/../../public/data/content/", "");
    Database_1.default.contentFolder = coreStorage.rootFolder;
    await CartoApp_1.default.init();
    carto = CartoApp_1.default.carto;
    if (!carto) {
        return;
    }
    await carto.load();
    Database_1.default.local = localEnv.utilities;
    carto.local = localEnv.utilities;
})();
function _ensureLocalFolder(path) {
    const ls = new NodeStorage_1.default(path, "");
    return ls.rootFolder;
}
async function _localFolderExists(path) {
    const ls = new NodeStorage_1.default(path, "");
    return await ls.rootFolder.exists();
}
async function _loadProject(name) {
    if (!carto || !scenariosFolder || !resultsFolder) {
        chai_1.assert.fail("Not properly initialized");
    }
    const project = new Project_1.default(carto, name, null);
    project.autoDeploymentMode = Project_1.ProjectAutoDeploymentMode.noAutoDeployment;
    project.localFolderPath = __dirname + "/../../../samplecontent/" + name + "/";
    await project.inferProjectItemsFromFiles();
    return project;
}
describe("Comprehensive Content Types", async () => {
    it("loads comprehensive project with all content types", async () => {
        const project = await _loadProject("comprehensive");
        // Should have multiple types of content
        (0, chai_1.expect)(project.items.length).to.be.greaterThan(10);
        // Check for different content types
        const itemTypes = project.items.map((item) => item.itemType);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.entityTypeResource);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.recipeBehavior);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.lootTableBehavior);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.MCFunction);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.animationBehaviorJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.spawnRuleBehavior);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.js);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.modelGeometryJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.renderControllerJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.particleJson);
        (0, chai_1.expect)(itemTypes).to.include(IProjectItemData_1.ProjectItemType.lang);
    });
    it("validates entity content", async () => {
        const project = await _loadProject("comprehensive");
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        (0, chai_1.expect)(entityItems.length).to.be.greaterThan(0);
        const entityItem = entityItems[0];
        (0, chai_1.expect)(entityItem.name).to.equal("sample_entity.json");
        (0, chai_1.expect)(entityItem.projectPath).to.contain("entities");
    });
    it("validates block content", async () => {
        const project = await _loadProject("comprehensive");
        const blockItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        (0, chai_1.expect)(blockItems.length).to.be.greaterThan(0);
        const blockItem = blockItems[0];
        (0, chai_1.expect)(blockItem.name).to.equal("sample_block.json");
        (0, chai_1.expect)(blockItem.projectPath).to.contain("blocks");
    });
    it("validates item content", async () => {
        const project = await _loadProject("comprehensive");
        const itemItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        (0, chai_1.expect)(itemItems.length).to.be.greaterThan(0);
        const itemItem = itemItems[0];
        (0, chai_1.expect)(itemItem.name).to.equal("sample_item.json");
        (0, chai_1.expect)(itemItem.projectPath).to.contain("items");
    });
    it("validates recipe content", async () => {
        const project = await _loadProject("comprehensive");
        const recipeItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.recipeBehavior);
        (0, chai_1.expect)(recipeItems.length).to.be.greaterThan(0);
        const recipeItem = recipeItems[0];
        (0, chai_1.expect)(recipeItem.name).to.equal("sample_recipe.json");
        (0, chai_1.expect)(recipeItem.projectPath).to.contain("recipes");
    });
    it("validates function content", async () => {
        const project = await _loadProject("comprehensive");
        const functionItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.MCFunction);
        (0, chai_1.expect)(functionItems.length).to.be.greaterThan(0);
        const functionItem = functionItems[0];
        (0, chai_1.expect)(functionItem.name).to.equal("complex_function.mcfunction");
        (0, chai_1.expect)(functionItem.projectPath).to.contain("functions");
    });
    it("validates animation content", async () => {
        const project = await _loadProject("comprehensive");
        const animationItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.animationBehaviorJson);
        (0, chai_1.expect)(animationItems.length).to.be.greaterThan(0);
        const animationItem = animationItems[0];
        (0, chai_1.expect)(animationItem.name).to.equal("sample_entity_animations.json");
        (0, chai_1.expect)(animationItem.projectPath).to.contain("animations");
    });
    it("validates loot table content", async () => {
        const project = await _loadProject("comprehensive");
        const lootTableItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.lootTableBehavior);
        (0, chai_1.expect)(lootTableItems.length).to.be.greaterThan(0);
        const lootTableItem = lootTableItems[0];
        (0, chai_1.expect)(lootTableItem.name).to.equal("sample_loot_table.json");
        (0, chai_1.expect)(lootTableItem.projectPath).to.contain("loot_table.json");
    });
    it("validates spawn rules content", async () => {
        const project = await _loadProject("comprehensive");
        const spawnRuleItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.spawnRuleBehavior);
        (0, chai_1.expect)(spawnRuleItems.length).to.be.greaterThan(0);
        const spawnRuleItem = spawnRuleItems[0];
        (0, chai_1.expect)(spawnRuleItem.name).to.equal("sample_entity.json");
        (0, chai_1.expect)(spawnRuleItem.projectPath).to.contain("sample_entity.json");
    });
    it("validates script content", async () => {
        const project = await _loadProject("comprehensive");
        const scriptItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.js);
        (0, chai_1.expect)(scriptItems.length).to.be.greaterThan(0);
        const scriptItem = scriptItems[0];
        (0, chai_1.expect)(scriptItem.name).to.equal("main.js");
        (0, chai_1.expect)(scriptItem.projectPath).to.contain("scripts");
    });
    it("validates resource pack content", async () => {
        const project = await _loadProject("comprehensive");
        const resourcePackItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        (0, chai_1.expect)(resourcePackItems.length).to.be.greaterThan(0);
        const resourcePackItem = resourcePackItems[0];
        (0, chai_1.expect)(resourcePackItem.name).to.equal("manifest.json");
        (0, chai_1.expect)(resourcePackItem.projectPath).to.contain("resource_packs");
    });
    it("validates geometry content", async () => {
        const project = await _loadProject("comprehensive");
        const geometryItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.modelGeometryJson);
        (0, chai_1.expect)(geometryItems.length).to.be.greaterThan(0);
        const geometryItem = geometryItems[0];
        (0, chai_1.expect)(geometryItem.name).to.equal("sample_entity.json");
        (0, chai_1.expect)(geometryItem.projectPath).to.contain("models");
    });
    it("validates render controller content", async () => {
        const project = await _loadProject("comprehensive");
        const renderControllerItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.renderControllerJson);
        (0, chai_1.expect)(renderControllerItems.length).to.be.greaterThan(0);
        const renderControllerItem = renderControllerItems[0];
        (0, chai_1.expect)(renderControllerItem.name).to.equal("sample_entity.json");
        (0, chai_1.expect)(renderControllerItem.projectPath).to.contain("render_controllers");
    });
    it("validates particle content", async () => {
        const project = await _loadProject("comprehensive");
        const particleItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.particleJson);
        (0, chai_1.expect)(particleItems.length).to.be.greaterThan(0);
        const particleItem = particleItems[0];
        (0, chai_1.expect)(particleItem.name).to.equal("sample_particle.json");
        (0, chai_1.expect)(particleItem.projectPath).to.contain("particles");
    });
    it("validates language content", async () => {
        const project = await _loadProject("comprehensive");
        const langItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.lang);
        (0, chai_1.expect)(langItems.length).to.be.greaterThan(0);
        const langItem = langItems[0];
        (0, chai_1.expect)(langItem.name).to.equal("en_US.lang");
        (0, chai_1.expect)(langItem.projectPath).to.contain("texts");
    });
    it("comprehensive project validation report matches", async () => {
        const project = await _loadProject("comprehensive");
        const pis = new ProjectInfoSet_1.default(project, IProjectInfoData_1.ProjectInfoSuite.default);
        await pis.generateForProject();
        const dataObject = pis.getDataObject();
        await (0, TestUtilities_1.ensureReportJsonMatchesScenario)(scenariosFolder, resultsFolder, dataObject, "comprehensive");
    });
});
describe("Content Type Validation", async () => {
    it("validates entity component structure", async () => {
        const project = await _loadProject("comprehensive");
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        (0, chai_1.expect)(entityItems.length).to.be.greaterThan(0);
        // Test specific entity validation if needed
        // This can be expanded based on specific validation requirements
    });
    it("validates block component structure", async () => {
        const project = await _loadProject("comprehensive");
        const blockItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        (0, chai_1.expect)(blockItems.length).to.be.greaterThan(0);
        // Test specific block validation if needed
    });
    it("validates item component structure", async () => {
        const project = await _loadProject("comprehensive");
        const itemItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        (0, chai_1.expect)(itemItems.length).to.be.greaterThan(0);
        // Test specific item validation if needed
    });
    it("validates recipe format", async () => {
        const project = await _loadProject("comprehensive");
        const recipeItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.recipeBehavior);
        (0, chai_1.expect)(recipeItems.length).to.be.greaterThan(0);
        // Test specific recipe validation if needed
    });
    it("validates function syntax", async () => {
        const project = await _loadProject("comprehensive");
        const functionItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.MCFunction);
        (0, chai_1.expect)(functionItems.length).to.be.greaterThan(0);
        // Test specific function validation if needed
    });
});

//# sourceMappingURL=../maps/test/ComprehensiveContentTest.js.map
