// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {assert} from 'chai';

import {expectedErrors} from '../../conductor/hooks.js';
import {getBrowserAndPages, goToResource, step} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';

describe('Assertions', async function() {
  it('console.assert', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      frontend.evaluate(() => {
        console.assert(false, 'expected failure 1');
      });
    });
    await goToResource('cross_tool/default.html');
    assert.strictEqual(expectedErrors.length, 1);
    assert.ok(expectedErrors[0].includes('expected failure 1'));
  });

  it('console.error', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      frontend.evaluate(() => {
        function foo() {
          console.error('expected failure 2');
        }
        foo();
      });
    });
    await goToResource('cross_tool/default.html');
    assert.strictEqual(expectedErrors.length, 2);
    assert.ok(expectedErrors[1].includes('expected failure 2'));
  });
});

// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {assert} from 'chai';

import {expectedErrors} from '../../conductor/hooks.js';
import {getBrowserAndPages, goToResource, step} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';

describe('Assertions', async function() {
  it('console.assert', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      frontend.evaluate(() => {
        console.assert(false, 'expected failure 1');
      });
    });
    await goToResource('cross_tool/default.html');
    assert.strictEqual(expectedErrors.length, 1);
    assert.ok(expectedErrors[0].includes('expected failure 1'));
  });

  // Suspected flaky console.errors are persisting from previous e2e-tests
  it.skip('[crbug.com/1145969]: console.error', async () => {
    const {frontend} = getBrowserAndPages();
    await step('Check the evaluation results from console', async () => {
      frontend.evaluate(() => {
        function foo() {
          console.error('expected failure 2');
        }
        foo();
      });
    });
    await goToResource('cross_tool/default.html');
    assert.strictEqual(expectedErrors.length, 2);
    assert.ok(expectedErrors[1].includes('expected failure 2'));
  });
});

Disable flaky console.error assertion test
Disable flaky console.error assertion test

This is a revival of https://crrev.com/c/2520821 because we are still
seeing the same build failures.

Bug: 1145969
Change-Id: I999682502dbda10c515c6339078a43c8b1ce7dcd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2529349
Reviewed-by: Yang Guo <1cf0af8245a3a17a632a2c73531392b0f9761c76@chromium.org>
Commit-Queue: Wolfgang Beyer <573aa99bb19da47d816981118f95c945310dd3f4@chromium.org>
