"use strict";
// Copyright 2022 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 quick_open_helpers_js_1 = require("../helpers/quick_open-helpers.js");
const sources_helpers_js_1 = require("../helpers/sources-helpers.js");
describe('Snippets subpane', () => {
    async function runTest(name, devToolsPage) {
        await (0, sources_helpers_js_1.openSourcesPanel)(devToolsPage);
        await (0, sources_helpers_js_1.openSnippetsSubPane)(devToolsPage);
        await (0, sources_helpers_js_1.createNewSnippet)(name, undefined, devToolsPage);
        // Title matches
        const openSources = await devToolsPage.waitForFunction(async () => {
            const openSources = await (0, sources_helpers_js_1.getOpenSources)(devToolsPage);
            return openSources.length > 0 ? openSources : undefined;
        });
        chai_1.assert.deepEqual(openSources, [name]);
        await (0, quick_open_helpers_js_1.openCommandMenu)(devToolsPage);
        await (0, quick_open_helpers_js_1.showSnippetsAutocompletion)(devToolsPage);
        // Available in autocompletion
        const availableSnippets = await devToolsPage.waitForFunction(async () => {
            const availableSnippets = await (0, quick_open_helpers_js_1.getAvailableSnippets)(devToolsPage);
            return availableSnippets.length > 0 ? availableSnippets : undefined;
        });
        chai_1.assert.deepEqual(availableSnippets, [name]);
    }
    it('can create snippet with simple name', async ({ devToolsPage }) => {
        await runTest('MySnippet', devToolsPage);
    });
    it('can create snippet with name like default name', async ({ devToolsPage }) => {
        await runTest('My Snippet #555', devToolsPage);
    });
    it('can create snippet with name with slash', async ({ devToolsPage }) => {
        await runTest('My Group #1/Snip #1', devToolsPage);
    });
    it('can create snippet with name with backslash', async ({ devToolsPage }) => {
        await runTest('My Group #1\Snip #1', devToolsPage);
    });
});
//# sourceMappingURL=name.test.js.map