"use strict";
// Copyright 2025 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 chai_1 = require("chai");
const elements_helpers_js_1 = require("../helpers/elements-helpers.js");
const EXPECTED_TEXT_CONTENT = '<div class=\u200B"div2">\u200B last child \u200B</div>\u200B';
describe('Element breadcrumbs', () => {
    async function expandToTargetNode(devToolsPage, inspectedPage) {
        await inspectedPage.goToResource('elements/element-breadcrumbs.html');
        await (0, elements_helpers_js_1.waitForElementsStyleSection)(null, devToolsPage);
        // expand the tree and then navigate down to the target node
        await (0, elements_helpers_js_1.expandSelectedNodeRecursively)(devToolsPage);
        const targetChildNode = await devToolsPage.waitForElementWithTextContent(EXPECTED_TEXT_CONTENT);
        await devToolsPage.clickElement(targetChildNode);
        // double check we got to the node we expect
        await (0, elements_helpers_js_1.waitForSelectedTreeElementSelectorWithTextcontent)(EXPECTED_TEXT_CONTENT, devToolsPage);
        await (0, elements_helpers_js_1.assertSelectedElementsNodeTextIncludes)('last child', devToolsPage);
    }
    it('lists all the elements in the tree', async ({ devToolsPage, inspectedPage }) => {
        await expandToTargetNode(devToolsPage, inspectedPage);
        const expectedCrumbsText = [
            'html',
            'body',
            'div#div1',
            'span#span1',
            'div.div2',
        ];
        const actualCrumbsText = await (0, elements_helpers_js_1.getBreadcrumbsTextContent)({ expectedNodeCount: expectedCrumbsText.length }, devToolsPage);
        chai_1.assert.deepEqual(actualCrumbsText, expectedCrumbsText);
    });
    it('correctly highlights the active node', async ({ devToolsPage, inspectedPage }) => {
        await expandToTargetNode(devToolsPage, inspectedPage);
        // Wait for the crumbs to render with all the elements we expect.
        await (0, elements_helpers_js_1.getBreadcrumbsTextContent)({ expectedNodeCount: 5 }, devToolsPage);
        const selectedCrumbText = await (0, elements_helpers_js_1.getSelectedBreadcrumbTextContent)(devToolsPage);
        chai_1.assert.strictEqual(selectedCrumbText, 'div.div2');
    });
});
//# sourceMappingURL=element-breadcrumbs.test.js.map