<commit_before>
// Copyright 2014 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 Page object for the exploration player, for use in Protractor
 * tests.
 */

var action = require('./action.js');
var forms = require('./forms.js');
var waitFor = require('./waitFor.js');
var interactions = require('../../../extensions/interactions/protractor.js');
const { browser } = require('protractor');

var ExplorationPlayerPage = function() {
  var conversationInput = element(
    by.css('.e2e-test-conversation-input'));
  var nextCardButton = element(by.css('.e2e-test-next-card-button'));
  var conversationSkinCardsContainer = element(
    by.css('.e2e-test-conversation-skin-cards-container'));
  var conversationContent = element.all(
    by.css('.e2e-test-conversation-content'));
  var conversationFeedback = element(
    by.css('.e2e-test-conversation-feedback-latest'));
  var explorationHeader = element(
    by.css('.e2e-test-exploration-header'));
  var infoCardRating = element(
    by.css('.e2e-test-info-card-rating'));
  var feedbackTextArea = element(
    by.css('.e2e-test-exploration-feedback-textarea'));
  var waitingForResponseElem = element(by.css(
    '.e2e-test-input-response-loading-dots'));
  var ratingStars = element.all(by.css('.e2e-test-rating-star'));
  var feedbackCloseButton = element(
    by.css('.e2e-test-exploration-feedback-close-button'));
  var reportExplorationButton = element(
    by.css('.e2e-test-report-exploration-button'));
  var feedbackSubmitButton = element(
    by.css('.e2e-test-exploration-feedback-submit-btn'));
  var explorationInfoIcon = element(
    by.css('.e2e-test-exploration-info-icon'));
  var nextCardButton = element(
    by.css('.e2e-test-continue-to-next-card-button'));
  var viewHintButton = element(by.css('.e2e-test-view-hint'));
  var viewSolutionButton = element(by.css('.e2e-test-view-solution'));
  var continueToSolutionButton = element(
    by.css('.e2e-test-continue-to-solution-btn'));
  var gotItButton = element(by.css('.e2e-test-learner-got-it-button'));
  var confirmRedirectionButton =
      element(by.css('.e2e-test-confirm-redirection-button'));
  var cancelRedirectionButton = element(
    by.css('.e2e-test-cancel-redirection-button'));
  var returnToParentButton = element(
    by.css('.e2e-test-return-to-parent-button'));
  var correctFeedbackElement = element(
    by.css('.e2e-test-correct-feedback'));

  var feedbackPopupLink =
    element(by.css('.e2e-test-exploration-feedback-popup-link'));
  var suggestionPopupLink =
    element(by.css('.e2e-test-exploration-suggestion-popup-link'));

  var audioBarExpandButton = element(by.css('.e2e-test-audio-bar'));
  var voiceoverLanguageSelector = element(
    by.css('.e2e-test-audio-lang-select'));
  var playButton = element(by.css('.e2e-test-play-circle'));
  var pauseButton = element(by.css('.e2e-test-pause-circle'));
  let submitButton = element(by.css('.e2e-test-submit-report-button'));
  var flaggedSuccessElement = element(
    by.css('.e2e-test-exploration-flagged-success-message'));

  this.expandAudioBar = async function() {
    await action.click('Audio Bar Expand Button', audioBarExpandButton);
  };

  this.pressPlayButton = async function() {
    await action.click('Play Button', playButton);
  };

  this.expectAudioToBePlaying = async function() {
    await waitFor.visibilityOf(
      pauseButton, 'Pause button taking too long to show up.');
  };

  this.pressPauseButton = async function() {
    await action.click('Pause Button', pauseButton);
  };

  this.expectAudioToBePaused = async function() {
    await waitFor.visibilityOf(
      playButton, 'Play button taking too long to show up.');
  };

  this.changeVoiceoverLanguage = async function(language) {
    await waitFor.visibilityOf(
      voiceoverLanguageSelector, 'Language selector takes too long to appear.');
    var languageButton = voiceoverLanguageSelector.element(
      by.cssContainingText('option', language));
    await action.click('Language Button', languageButton);
  };

  this.clickThroughToNextCard = async function() {
    await waitFor.elementToBeClickable(nextCardButton);
    await action.click('Next Card button', nextCardButton);
  };

  this.clickSuggestChangesButton = async function() {
    await action.click('Suggestion Popup link', suggestionPopupLink);
  };

  this.expectNextCardButtonTextToBe = async function(text) {
    await waitFor.visibilityOf(
      nextCardButton, 'Next Card Button not showing up.');
    var buttonText = await nextCardButton.getText();
    expect(buttonText).toMatch(text);
  };

  this.reportExploration = async function() {
    await action.click('Report Exploration Button', reportExplorationButton);
    let radioButton = element.all(by.tagName('input')).get(0);
    await waitFor.visibilityOf(
      radioButton, 'Radio Buttons takes too long to appear');
    await action.click('Radio Button', radioButton);
    let textArea = element(by.tagName('textarea'));
    await action.sendKeys('Text Area', textArea, 'Reporting this exploration');
    await action.click('Submit Button', submitButton);
    let afterSubmitText = await flaggedSuccessElement.getText();
    expect(afterSubmitText).toMatch(
      'Your report has been forwarded to the moderators for review.');
  };

  this.viewHint = async function() {
    // We need to wait some time for the solution to activate.
    var until = protractor.ExpectedConditions;
    const WAIT_FOR_FIRST_HINT_MSEC = 60000;<commit_msg>Add a waitFor to address successful report flake. (#15789)<commit_after>
// Copyright 2014 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 Page object for the exploration player, for use in Protractor
 * tests.
 */

var action = require('./action.js');
var forms = require('./forms.js');
var waitFor = require('./waitFor.js');
var interactions = require('../../../extensions/interactions/protractor.js');
const { browser } = require('protractor');

var ExplorationPlayerPage = function() {
  var conversationInput = element(
    by.css('.e2e-test-conversation-input'));
  var nextCardButton = element(by.css('.e2e-test-next-card-button'));
  var conversationSkinCardsContainer = element(
    by.css('.e2e-test-conversation-skin-cards-container'));
  var conversationContent = element.all(
    by.css('.e2e-test-conversation-content'));
  var conversationFeedback = element(
    by.css('.e2e-test-conversation-feedback-latest'));
  var explorationHeader = element(
    by.css('.e2e-test-exploration-header'));
  var infoCardRating = element(
    by.css('.e2e-test-info-card-rating'));
  var feedbackTextArea = element(
    by.css('.e2e-test-exploration-feedback-textarea'));
  var waitingForResponseElem = element(by.css(
    '.e2e-test-input-response-loading-dots'));
  var ratingStars = element.all(by.css('.e2e-test-rating-star'));
  var feedbackCloseButton = element(
    by.css('.e2e-test-exploration-feedback-close-button'));
  var reportExplorationButton = element(
    by.css('.e2e-test-report-exploration-button'));
  var feedbackSubmitButton = element(
    by.css('.e2e-test-exploration-feedback-submit-btn'));
  var explorationInfoIcon = element(
    by.css('.e2e-test-exploration-info-icon'));
  var nextCardButton = element(
    by.css('.e2e-test-continue-to-next-card-button'));
  var viewHintButton = element(by.css('.e2e-test-view-hint'));
  var viewSolutionButton = element(by.css('.e2e-test-view-solution'));
  var continueToSolutionButton = element(
    by.css('.e2e-test-continue-to-solution-btn'));
  var gotItButton = element(by.css('.e2e-test-learner-got-it-button'));
  var confirmRedirectionButton =
      element(by.css('.e2e-test-confirm-redirection-button'));
  var cancelRedirectionButton = element(
    by.css('.e2e-test-cancel-redirection-button'));
  var returnToParentButton = element(
    by.css('.e2e-test-return-to-parent-button'));
  var correctFeedbackElement = element(
    by.css('.e2e-test-correct-feedback'));

  var feedbackPopupLink =
    element(by.css('.e2e-test-exploration-feedback-popup-link'));
  var suggestionPopupLink =
    element(by.css('.e2e-test-exploration-suggestion-popup-link'));

  var audioBarExpandButton = element(by.css('.e2e-test-audio-bar'));
  var voiceoverLanguageSelector = element(
    by.css('.e2e-test-audio-lang-select'));
  var playButton = element(by.css('.e2e-test-play-circle'));
  var pauseButton = element(by.css('.e2e-test-pause-circle'));
  let submitButton = element(by.css('.e2e-test-submit-report-button'));
  var flaggedSuccessElement = element(
    by.css('.e2e-test-exploration-flagged-success-message'));

  this.expandAudioBar = async function() {
    await action.click('Audio Bar Expand Button', audioBarExpandButton);
  };

  this.pressPlayButton = async function() {
    await action.click('Play Button', playButton);
  };

  this.expectAudioToBePlaying = async function() {
    await waitFor.visibilityOf(
      pauseButton, 'Pause button taking too long to show up.');
  };

  this.pressPauseButton = async function() {
    await action.click('Pause Button', pauseButton);
  };

  this.expectAudioToBePaused = async function() {
    await waitFor.visibilityOf(
      playButton, 'Play button taking too long to show up.');
  };

  this.changeVoiceoverLanguage = async function(language) {
    await waitFor.visibilityOf(
      voiceoverLanguageSelector, 'Language selector takes too long to appear.');
    var languageButton = voiceoverLanguageSelector.element(
      by.cssContainingText('option', language));
    await action.click('Language Button', languageButton);
  };

  this.clickThroughToNextCard = async function() {
    await waitFor.elementToBeClickable(nextCardButton);
    await action.click('Next Card button', nextCardButton);
  };

  this.clickSuggestChangesButton = async function() {
    await action.click('Suggestion Popup link', suggestionPopupLink);
  };

  this.expectNextCardButtonTextToBe = async function(text) {
    await waitFor.visibilityOf(
      nextCardButton, 'Next Card Button not showing up.');
    var buttonText = await nextCardButton.getText();
    expect(buttonText).toMatch(text);
  };

  this.reportExploration = async function() {
    await action.click('Report Exploration Button', reportExplorationButton);
    let radioButton = element.all(by.tagName('input')).get(0);
    await waitFor.visibilityOf(
      radioButton, 'Radio Buttons takes too long to appear');
    await action.click('Radio Button', radioButton);
    let textArea = element(by.tagName('textarea'));
    await action.sendKeys('Text Area', textArea, 'Reporting this exploration');
    await action.click('Submit Button', submitButton);
    await waitFor.visibilityOf(
      flaggedSuccessElement, 'Successfully-flagged modal not showing up.');
    let afterSubmitText = await flaggedSuccessElement.getText();
    expect(afterSubmitText).toMatch(
      'Your report has been forwarded to the moderators for review.');
  };

  this.viewHint = async function() {
    // We need to wait some time for the solution to activate.
    var until = protractor.ExpectedConditions;
    const WAIT_FOR_FIRST_HINT_MSEC = 60000;
{'fraction_non_alphanumeric': 0.1347552504698864, 'fraction_numerical': 0.0077633406880771435, 'mean_word_length': 4.157184997892963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3626984', 'n_tokens_mistral': 3661, 'n_tokens_neox': 3587, 'n_words': 835}