"use strict";
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Object.defineProperty(exports, "__esModule", { value: true });
const console_helpers_js_1 = require("../helpers/console-helpers.js");
const cross_tool_helper_js_1 = require("../helpers/cross-tool-helper.js");
const elements_helpers_js_1 = require("../helpers/elements-helpers.js");
const layers_helpers_js_1 = require("../helpers/layers-helpers.js");
const memory_helpers_js_1 = require("../helpers/memory-helpers.js");
const performance_helpers_js_1 = require("../helpers/performance-helpers.js");
const settings_helpers_js_1 = require("../helpers/settings-helpers.js");
describe('A user can navigate across', function () {
    async function setupForTests(devToolsPage, inspectedPage) {
        await inspectedPage.goToResource('cross_tool/default.html');
        await devToolsPage.closeAllCloseableTabs();
    }
    it('Console -> Sources', async ({ devToolsPage, inspectedPage }) => {
        await setupForTests(devToolsPage, inspectedPage);
        await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
        await (0, console_helpers_js_1.waitForConsoleInfoMessageAndClickOnLink)(devToolsPage);
        await devToolsPage.waitFor('.panel[aria-label="sources"]');
    });
    it('Console -> Issues', async ({ devToolsPage, inspectedPage }) => {
        await setupForTests(devToolsPage, inspectedPage);
        await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
        await devToolsPage.click('#console-issues-counter');
        await devToolsPage.waitFor('[aria-label="Issues panel"]');
    });
    it('Elements -> Sources', async ({ devToolsPage, inspectedPage }) => {
        await setupForTests(devToolsPage, inspectedPage);
        await (0, elements_helpers_js_1.navigateToElementsTab)(devToolsPage);
        await (0, elements_helpers_js_1.clickOnFirstLinkInStylesPanel)(devToolsPage);
        await devToolsPage.waitFor('.panel[aria-label="sources"]');
    });
    it('Performance -> Sources', async ({ devToolsPage, inspectedPage }) => {
        await setupForTests(devToolsPage, inspectedPage);
        await (0, performance_helpers_js_1.navigateToPerformanceTab)(undefined, devToolsPage, inspectedPage);
        await (0, performance_helpers_js_1.startRecording)(devToolsPage);
        // Wait until we have collected a bit of trace data (indicated by the progress bar
        // changing at least twice), to ensure that there's at least a single tick within
        // `default.html` below.
        const statusIndicator = await devToolsPage.waitFor('.timeline-status-dialog .progress .indicator');
        const statusIndicatorValues = new Set();
        await devToolsPage.waitForFunction(async () => {
            const indicatorValue = await statusIndicator.evaluate(n => Number(n.getAttribute('aria-valuenow')));
            if (statusIndicatorValues.has(indicatorValue)) {
                await devToolsPage.timeout(50);
            }
            else {
                statusIndicatorValues.add(indicatorValue);
            }
            return statusIndicatorValues.size > 1;
        });
        await (0, performance_helpers_js_1.stopRecording)(devToolsPage);
        await (0, performance_helpers_js_1.navigateToBottomUpTab)(devToolsPage, 'script-location');
        await devToolsPage.click('.devtools-link[title*="default.html"]');
        await devToolsPage.waitFor('.panel[aria-label="sources"]');
    });
});
describe('A user can move tabs', function () {
    // TODO: Memory panel is not show in the toolbar in docked mode
    setup({ dockingMode: 'undocked' });
    it('Move Memory to drawer', async ({ devToolsPage }) => {
        await (0, memory_helpers_js_1.navigateToMemoryTab)(devToolsPage);
        await (0, cross_tool_helper_js_1.tabExistsInMainPanel)(memory_helpers_js_1.MEMORY_TAB_ID, devToolsPage);
        await (0, cross_tool_helper_js_1.clickOnContextMenuItemFromTab)(memory_helpers_js_1.MEMORY_TAB_ID, cross_tool_helper_js_1.MOVE_TO_DRAWER_SELECTOR, devToolsPage);
        await (0, cross_tool_helper_js_1.tabExistsInDrawer)(memory_helpers_js_1.MEMORY_TAB_ID, devToolsPage);
    });
    it('Move Animations to main panel', async ({ devToolsPage }) => {
        const ANIMATIONS_TAB_ID = '#tab-animations';
        await (0, settings_helpers_js_1.openPanelViaMoreTools)('Animations', devToolsPage);
        await (0, cross_tool_helper_js_1.tabExistsInDrawer)(ANIMATIONS_TAB_ID, devToolsPage);
        await (0, cross_tool_helper_js_1.clickOnContextMenuItemFromTab)(ANIMATIONS_TAB_ID, cross_tool_helper_js_1.MOVE_TO_MAIN_TAB_BAR_SELECTOR, devToolsPage);
        await (0, cross_tool_helper_js_1.tabExistsInMainPanel)(ANIMATIONS_TAB_ID, devToolsPage);
    });
});
describe('A user can open panels via the "panel" query param', function () {
    it('Layers is shown', async ({ devToolsPage }) => {
        await devToolsPage.reloadWithParams({ panel: 'layers' });
        await (0, cross_tool_helper_js_1.tabExistsInMainPanel)(layers_helpers_js_1.LAYERS_TAB_SELECTOR, devToolsPage);
    });
});
//# sourceMappingURL=workflow.test.js.map