"use strict";
// Copyright 2024 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 issues_helpers_js_1 = require("../helpers/issues-helpers.js");
describe('Hide issues menu', () => {
    it('should become visible on hovering over the issue header', async ({ devToolsPage }) => {
        await devToolsPage.evaluate(() => {
            const issue = {
                code: 'HeavyAdIssue',
                details: {
                    heavyAdIssueDetails: {
                        resolution: 'HeavyAdBlocked',
                        reason: 'NetworkTotalLimit',
                        frame: { frameId: 'main' },
                    },
                },
            };
            // @ts-expect-error
            window.addIssueForTest(issue);
        });
        await devToolsPage.evaluate(() => {
            const issue = {
                code: 'DeprecationIssue',
                details: {
                    deprecationIssueDetails: {
                        sourceCodeLocation: {
                            url: 'empty.html',
                            lineNumber: 1,
                            columnNumber: 1,
                        },
                        type: 'PrivacySandboxExtensionsAPI',
                    },
                },
            };
            // @ts-expect-error
            window.addIssueForTest(issue);
        });
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        const issueTitle = 'Deprecated feature used';
        const issueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        chai_1.assert.isOk(issueHeader);
        const hideIssuesMenu = await (0, issues_helpers_js_1.getHideIssuesMenu)(issueHeader, devToolsPage);
        let menuDisplay = await hideIssuesMenu.evaluate(node => window.getComputedStyle(node).getPropertyValue('visibility'));
        chai_1.assert.strictEqual(menuDisplay, 'hidden');
        await issueHeader.hover();
        menuDisplay = await hideIssuesMenu.evaluate(node => window.getComputedStyle(node).getPropertyValue('visibility'));
        chai_1.assert.strictEqual(menuDisplay, 'visible');
    });
    it('should open a context menu upon clicking', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('empty.html');
        await inspectedPage.evaluate(async () => {
            try {
                const url = new URL('./issues/origin-wildcard.rawresponse', document.location.toString())
                    .toString()
                    .replace('localhost', 'devtools.oopif.test');
                await fetch(url, { credentials: 'include' });
            }
            catch {
            }
        });
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        const issueTitle = 'Ensure credentialed requests are not sent to CORS resources with origin wildcards';
        const issueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await issueHeader.hover();
        const hideIssuesMenu = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenu.click();
        const menuItem = await (0, issues_helpers_js_1.getHideIssuesMenuItem)(devToolsPage);
        const content = await menuItem.evaluate(node => node.textContent);
        chai_1.assert.isOk(content);
        chai_1.assert.include(content, 'Hide issues like this');
    });
    it('should hide issue upon clicking the context menu entry', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('elements/quirks-mode.html');
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        const issueTitle = 'Page layout may be unexpected due to Quirks Mode';
        const issueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await issueHeader.hover();
        const hideIssuesMenuBtn = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenuBtn.click();
        const menuItem = await (0, issues_helpers_js_1.getHideIssuesMenuItem)(devToolsPage);
        await devToolsPage.waitFor(issues_helpers_js_1.ISSUE);
        await menuItem.click();
        await devToolsPage.waitFor('.hidden-issue');
    });
    it('should unhide all issues upon clicking unhide all issues button', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('elements/quirks-mode.html');
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        const issueTitle = 'Page layout may be unexpected due to Quirks Mode';
        const issueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await issueHeader.hover();
        const hideIssuesMenuBtn = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenuBtn.click();
        const menuItem = await (0, issues_helpers_js_1.getHideIssuesMenuItem)(devToolsPage);
        await menuItem.click();
        await devToolsPage.waitFor('.hidden-issue');
        const btn = await (0, issues_helpers_js_1.getUnhideAllIssuesBtn)(devToolsPage);
        await btn.click();
        await devToolsPage.waitFor(issues_helpers_js_1.ISSUE);
    });
    it('should contain unhide issues like this entry while hovering over a hidden issue', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('elements/quirks-mode.html');
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        const issueTitle = 'Page layout may be unexpected due to Quirks Mode';
        const issueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await issueHeader.hover();
        let hideIssuesMenuBtn = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenuBtn.click();
        const menuItem = await (0, issues_helpers_js_1.getHideIssuesMenuItem)(devToolsPage);
        await menuItem.click();
        await devToolsPage.waitFor('.hidden-issue');
        const row = await (0, issues_helpers_js_1.getHiddenIssuesRow)(devToolsPage);
        let isHidden = await row.evaluate(node => node.classList.contains('hidden'));
        chai_1.assert.isFalse(isHidden);
        await row.click();
        const body = await (0, issues_helpers_js_1.getHiddenIssuesRowBody)(devToolsPage);
        isHidden = await body.evaluate(node => node.classList.contains('hidden'));
        chai_1.assert.isFalse(isHidden);
        const hiddenIssueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await hiddenIssueHeader.hover();
        hideIssuesMenuBtn = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenuBtn.click();
        await (0, issues_helpers_js_1.getUnhideIssuesMenuItem)(devToolsPage);
    });
    it('should unhide issue after clicking the unhide issues like this entry', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('elements/quirks-mode.html');
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        const issueTitle = 'Page layout may be unexpected due to Quirks Mode';
        const issueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await issueHeader.hover();
        let hideIssuesMenuBtn = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenuBtn.click();
        const menuItem = await (0, issues_helpers_js_1.getHideIssuesMenuItem)(devToolsPage);
        await menuItem.click();
        await devToolsPage.waitFor('.hidden-issue');
        const row = await (0, issues_helpers_js_1.getHiddenIssuesRow)(devToolsPage);
        let isHidden = await row.evaluate(node => node.classList.contains('hidden'));
        chai_1.assert.isFalse(isHidden);
        await row.click();
        const body = await (0, issues_helpers_js_1.getHiddenIssuesRowBody)(devToolsPage);
        isHidden = await body.evaluate(node => node.classList.contains('hidden'));
        chai_1.assert.isFalse(isHidden);
        const hiddenIssueHeader = await (0, issues_helpers_js_1.getIssueHeaderByTitle)(issueTitle, devToolsPage);
        await hiddenIssueHeader.hover();
        hideIssuesMenuBtn = await (0, issues_helpers_js_1.getHideIssuesMenu)(undefined, devToolsPage);
        await hideIssuesMenuBtn.click();
        const unhideMenuItem = await (0, issues_helpers_js_1.getUnhideIssuesMenuItem)(devToolsPage);
        await unhideMenuItem?.click();
        await devToolsPage.waitFor(issues_helpers_js_1.ISSUE);
    });
});
describe('After enabling grouping by IssueKind, Hide issues menu', () => {
    it('should be appended to the issue kinds group header', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('elements/element-reveal-inline-issue.html');
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        if (!await (0, issues_helpers_js_1.getGroupByKindChecked)(devToolsPage)) {
            await (0, issues_helpers_js_1.toggleGroupByKind)(devToolsPage);
        }
        await devToolsPage.waitFor('.issue-kind');
        await (await devToolsPage.waitFor('.issue-kind .header')).hover();
        const hideIssuesMenu = await devToolsPage.waitFor('.hide-available-issues');
        chai_1.assert.isNotNull(hideIssuesMenu);
    });
    it('should hide all available issues upon click menu entry', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('elements/element-reveal-inline-issue.html');
        await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
        if (!await (0, issues_helpers_js_1.getGroupByKindChecked)(devToolsPage)) {
            await (0, issues_helpers_js_1.toggleGroupByKind)(devToolsPage);
        }
        await devToolsPage.waitFor('.issue-kind');
        chai_1.assert.isEmpty(await devToolsPage.$$('.hidden-issue'));
        await (await devToolsPage.waitFor('.issue-kind .header')).hover();
        const hideIssuesMenu = await devToolsPage.waitFor('.hide-available-issues');
        await hideIssuesMenu.click();
        const menuItem = await devToolsPage.waitFor('[aria-label="Hide all current Page Errors"]');
        await menuItem.click();
        await devToolsPage.waitFor('.hidden-issue');
    });
});
//# sourceMappingURL=hide-issues-menu.test.js.map