"use strict";
// This file was moved from the `server` package to here and `server` has `strictNullChecks` disabled.
// This code was originally written with the assumption that `widget.children` is never undefined, despite the type saying otherwise.
// So we are using `!` to assert that `widget.children` is never undefined.
// Note that `!` does not change the runtime behavior of the code so the code will work the same way as before.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-explicit-any */
const lodash_1 = require("lodash");
const vitest_1 = require("vitest");
const with_2_modals_js_1 = __importDefault(require("../../../utils/pageFixtures/v6/with_2_modals.js"));
const adjustModalCanvases_js_1 = require("./adjustModalCanvases.js");
const v6to7_js_1 = require("./v6to7.js");
(0, vitest_1.describe)('adjustModalCanvases', () => {
    (0, vitest_1.test)('should update a modals child canvas to have the correct height unless its children are taller', () => {
        const v8 = (0, adjustModalCanvases_js_1.adjustModalCanvases)((0, lodash_1.cloneDeep)(with_2_modals_js_1.default));
        const mainCanvas = v8;
        (0, vitest_1.expect)(mainCanvas.widgetName).toEqual('MainContainer');
        (0, vitest_1.expect)(mainCanvas.children[0].widgetName).toEqual('Modal1');
        const modalCanvas = mainCanvas.children[0].children[0];
        (0, vitest_1.expect)(modalCanvas.widgetName).toEqual('Canvas1');
        (0, vitest_1.expect)(modalCanvas.bottomRow).toEqual(31);
        // This second one has a widget that is taller than the canvas
        // so that should be the height of the canvas
        const modalCanvas2 = mainCanvas.children[2].children[0];
        (0, vitest_1.expect)(modalCanvas2.widgetName).toEqual('Canvas2');
        (0, vitest_1.expect)(modalCanvas2.bottomRow).toEqual(32);
    });
    (0, vitest_1.test)('FULL - should update a modals child canvas to have the correct height unless its children are taller', () => {
        const migrated = (0, v6to7_js_1.migrate6to7)(with_2_modals_js_1.default);
        (0, vitest_1.expect)(migrated.children[0].widgetName).toEqual('Section1');
        const mainCanvas = migrated.children[0].children[0];
        (0, vitest_1.expect)(mainCanvas.widgetName).toEqual('Canvas3');
        (0, vitest_1.expect)(mainCanvas.children[0].widgetName).toEqual('Modal1');
        (0, vitest_1.expect)(mainCanvas.children[0].children[0].widgetName).toEqual('Body1');
        const modalCanvas = mainCanvas.children[0].children[0].children[0];
        (0, vitest_1.expect)(modalCanvas.widgetName).toEqual('Canvas1');
        (0, vitest_1.expect)(modalCanvas.height).toEqual({ mode: 'gridUnit', value: 31 });
        // This second one has a widget that is taller than the canvas
        // so that should be the height of the canvas
        const modalCanvas2 = mainCanvas.children[2].children[0].children[0];
        (0, vitest_1.expect)(modalCanvas2.widgetName).toEqual('Canvas2');
        (0, vitest_1.expect)(modalCanvas2.height).toEqual({ mode: 'gridUnit', value: 32 });
    });
});
//# sourceMappingURL=adjustModalCanvases.test.js.map