1// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {assert} from 'chai';
6
7import {click, getBrowserAndPages, typeText, waitFor} from '../../shared/helper.js';
8import {describe, it} from '../../shared/mocha-extensions.js';
9import {openSourcesPanel} from '../helpers/sources-helpers.js';
10
11describe('Watch Expression Pane', async () => {
12  it('collapses children when editing', async () => {
13    const {frontend} = getBrowserAndPages();
14    await openSourcesPanel();
15
16    // Create watch expression "Text"
17    await click('[aria-label="Watch"]');
18    await click('[aria-label="Add watch expression"]');
19    await typeText('Text');
20    await frontend.keyboard.press('Enter');
21
22    // Expand watch element
23    await frontend.keyboard.press('ArrowRight');
24
25    // Retrieve watch element and ensure that it is expanded
26    const element = await waitFor('.object-properties-section-root-element');
27    const initialExpandCheck = await element.evaluate(e => e.classList.contains('expanded'));
28    assert.strictEqual(initialExpandCheck, true);
29
30    // Begin editing and check that element is now collapsed.
31    await frontend.keyboard.press('Enter');
32    const editingExpandCheck = await element.evaluate(e => e.classList.contains('expanded'));
33    assert.strictEqual(editingExpandCheck, false);
34  });
35});
36