<commit_before>/**
 * Copyright (C) 2013 <NAME> (born 1979)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package test.e2e

import com.debiki.core.Prelude._
import org.scalatest.time.{Span, Seconds}
import org.scalatest.DoNotDiscover
import controllers.AppInstall


/** Runs the ServerInstallationSpec suite
  * in SBT:
  *  test-only test.e2e.ServerInstallationSpecRunner
  * in SBT's test:console:
  *  (new test.e2e.ServerInstallationSpecRunner {}).execute()
  */
@DoNotDiscover
class ServerInstallationSpecRunner extends org.scalatest.Suites(
  new ServerInstallationSpec {})
  with ChromeSuiteMixin


/** Tests creation of the very first site and its owner account,
  * that is, server "installation".
  */
@DoNotDiscover
abstract class ServerInstallationSpec extends DebikiBrowserSpec with TestLoginner {

  import play.api.test.Helpers.testServerPort


  "A server owner can" - {

    "not use the admin page before installation completed" in {
      // go to http://localhost:19001/-/admin/, verify that server replies 404 Not Found.
      pending
    }

    "go to the install page" in {
      go to (new Page {
        val url = s"http://localhost:$testServerPort/-/install/"
      })
    }

    "find the create-first-site page" in {
      pageSource must include("Installation")
      pageSource must include("Who are you?")
    }

    "submit a bad create-first-site password, be denied access" in {
      def findBadPasswordTag() = find(cssSelector(".alert-error")) getOrElse fail()
      findBadPasswordTag().isDisplayed must be === false
      firstSitePasswordField.value = "<PASSWORD>"
      click on cssSelector("input[type='submit']")
      eventually {
        findBadPasswordTag().isDisplayed must be === true
      }
    }

    "submit the correct create-first-site password" in {
      firstSitePasswordField.value = AppInstall.firstSitePassword
      click on cssSelector("input[type='submit']")
    }

    "find the owner creation page" in {
      eventually {
        pageSource must include("The website needs an administrator")
      }
    }

    "login as a Gmail user" in {
      click on cssSelector(".login-link-google")
      fillInGoogleCredentials()
    }

    "view the all-done page" in {
      // Verify that clicking Submit results in:
      // 403 Forbidden, "... may not create website from this website ..."
      // Have to do this from another site; `localhost` allows website creation,
      // see StuffCreator.createFirstSite().
      pending
    }

    "follow link to the admin dashboard" in {
      click on cssSelector("a[href*='/-/admin/']")
      java.lang.Thread.sleep(7200*1000)
    }

  }

  def firstSitePasswordField =
    pwdField(cssSelector("input[ng-model='firstSitePassword']"))

}
<commit_msg>Fix E2E test: Wrap `click` in `eventually { ... }`.<commit_after>/**
 * Copyright (C) 2013 <NAME> (born 1979)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package test.e2e

import com.debiki.core.Prelude._
import org.scalatest.time.{Span, Seconds}
import org.scalatest.DoNotDiscover
import controllers.AppInstall


/** Runs the ServerInstallationSpec suite
  * in SBT:
  *  test-only test.e2e.ServerInstallationSpecRunner
  * in SBT's test:console:
  *  (new test.e2e.ServerInstallationSpecRunner {}).execute()
  */
@DoNotDiscover
class ServerInstallationSpecRunner extends org.scalatest.Suites(
  new ServerInstallationSpec {})
  with ChromeSuiteMixin


/** Tests creation of the very first site and its owner account,
  * that is, server "installation".
  */
@DoNotDiscover
abstract class ServerInstallationSpec extends DebikiBrowserSpec with TestLoginner {

  import play.api.test.Helpers.testServerPort


  "A server owner can" - {

    "not use the admin page before installation completed" in {
      // go to http://localhost:19001/-/admin/, verify that server replies 404 Not Found.
      pending
    }

    "go to the install page" in {
      go to (new Page {
        val url = s"http://localhost:$testServerPort/-/install/"
      })
    }

    "find the create-first-site page" in {
      pageSource must include("Installation")
      pageSource must include("Who are you?")
    }

    "submit a bad create-first-site password, be denied access" in {
      def findBadPasswordTag() = find(cssSelector(".alert-error")) getOrElse fail()
      findBadPasswordTag().isDisplayed must be === false
      firstSitePasswordField.value = "<PASSWORD>"
      click on cssSelector("input[type='submit']")
      eventually {
        findBadPasswordTag().isDisplayed must be === true
      }
    }

    "submit the correct create-first-site password" in {
      firstSitePasswordField.value = AppInstall.firstSitePassword
      click on cssSelector("input[type='submit']")
    }

    "find the owner creation page" in {
      eventually {
        pageSource must include("The website needs an administrator")
      }
    }

    "login as a Gmail user" in {
      click on cssSelector(".login-link-google")
      fillInGoogleCredentials()
    }

    "view the all-done page" in {
      // Verify that clicking Submit results in:
      // 403 Forbidden, "... may not create website from this website ..."
      // Have to do this from another site; `localhost` allows website creation,
      // see StuffCreator.createFirstSite().
      pending
    }

    "follow link to the admin dashboard" in {
      eventually {
        click on cssSelector("a[href*='/-/admin/']")
      }
    }

  }

  def firstSitePasswordField =
    pwdField(cssSelector("input[ng-model='firstSitePassword']"))

}

{'fraction_non_alphanumeric': 0.09777973827378326, 'fraction_numerical': 0.00808704602264373, 'mean_word_length': 3.134954407294833, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3208619', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1881, 'n_words': 665}