<commit_before>require "test_helper"

module GobiertoAdmin
  class DirtyFormsTest < ActionDispatch::IntegrationTest
    def setup
      super
      @path = edit_admin_user_path(user)
    end

    def admin
      @admin ||= gobierto_admin_admins(:nick)
    end

    def user
      @user ||= users(:reed)
    end

    def site
      @site ||= user.source_site
    end

    def test_dirty_forms
      with_javascript do
        with_signed_in_admin(admin) do
          with_current_site(site) do
            visit @path

            within "form.edit_user" do
              fill_in "user_name", with: "<NAME>"

              click_link "Change password"

              assert_equal(
                "You have unsaved changes. Are you sure you want to leave this page?",
                page.driver.browser.modal_message
              )

              click_button "Update"
<commit_msg>Add wait time in the test<commit_after>require "test_helper"

module GobiertoAdmin
  class DirtyFormsTest < ActionDispatch::IntegrationTest
    def setup
      super
      @path = edit_admin_user_path(user)
    end

    def admin
      @admin ||= gobierto_admin_admins(:nick)
    end

    def user
      @user ||= users(:reed)
    end

    def site
      @site ||= user.source_site
    end

    def test_dirty_forms
      with_javascript do
        with_signed_in_admin(admin) do
          with_current_site(site) do
            visit @path

            within "form.edit_user" do
              fill_in "user_name", with: "<NAME>"

              sleep 2

              click_link "Change password"

              assert_equal(
                "You have unsaved changes. Are you sure you want to leave this page?",
                page.driver.browser.modal_message
              )

              click_button "Update"

{'fraction_non_alphanumeric': 0.0678154530294608, 'fraction_numerical': 0.0005558643690939411, 'mean_word_length': 1.8526148969889065, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2136220', 'n_tokens_mistral': 524, 'n_tokens_neox': 499, 'n_words': 137}