<reponame>Shivkant-Chauhan/prototype---dockerizing-oppia<filename>core/tests/webdriverio_desktop/explorationImprovementsTab.js<gh_stars>0// Copyright 2022 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview End-to-end tests for the functionality of the statistics tabs
 * in the exploration editor.
 */

var general = require('../webdriverio_utils/general.js');
var users = require('../webdriverio_utils/users.js');
var workflow = require('../webdriverio_utils/workflow.js');

var AdminPage = require('../webdriverio_utils/AdminPage.js');
var ExplorationEditorPage = (
  require('../webdriverio_utils/ExplorationEditorPage.js'));

describe('Improvements tab', function() {
  let adminPage = null;
  let explorationEditorPage = null;
  let explorationEditorImprovementsTab = null;

  beforeAll(async() => {
    adminPage = new AdminPage.AdminPage();
    explorationEditorPage = new ExplorationEditorPage.ExplorationEditorPage();

    explorationEditorImprovementsTab = (
      explorationEditorPage.getImprovementsTab());
    await users.createAndLoginCurriculumAdminUser(
      'anpch@example.com', 'superUser');
    await adminPage.editConfigProperty(
      'Exposes the Improvements Tab for creators in the exploration editor.',
      'Boolean',
      async(elem) => await elem.setValue(true));
    await users.logout();
  });

  afterEach(async() => {
    await general.checkForConsoleErrors([]);
  });

  it('should not be present in an unpublished exploration', async() => {
    await users.createUser(
      'ychag@example.com', 'improvementsTabDrafter');
    await users.login('ychag@example.com');
    await workflow.createExploration(true);

    await explorationEditorImprovementsTab.expectToBeHidden();
    await users.logout();
  });

  // TODO(#13352): Add back test that verifies that the improvements tab is
  // present after revisiting a published exploration.
  // TODO(#7327): Add tests for generating and resolving NeedsGuidingResponses
  // tasks once answer stats are generated incrementally. Currently, we need to
  // run a slow continuous job; too slow to outweigh the benefit in test
  // coverage.
});
