<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../helpers/conversations_common')

describe "conversations new" do
  include_context "in-process server selenium tests"
  include ConversationsCommon

  before do
    conversation_setup
  end

  describe 'conversations inbox opt-out option' do
    it "should be hidden a feature flag", priority: "1", test_id: 206028 do
      get "/profile/settings"
      expect(f("#content")).not_to contain_css('#disable_inbox')
    end

    it "should reveal when the feature flag is set", priority: "1", test_id: 138894 do
      @course.root_account.enable_feature!(:allow_opt_out_of_inbox)
      get "/profile/settings"
      expect(ff('#disable_inbox').count).to eq 1
    end

    context "when activated" do
      it "should set the notification preferences for conversations to ASAP, and hide those options", priority: "1", test_id: 207091 do
        @course.root_account.enable_feature!(:allow_opt_out_of_inbox)
        expect(@teacher.reload.disabled_inbox?).to be_falsey
        notification = Notification.create!(workflow_state: "active", name: "Conversation Message",
                             category: "Conversation Message", delay_for: 0)
        policy = NotificationPolicy.create!(notification_id: notification.id, communication_channel_id: @teacher.email_channel.id, broadcast: true, frequency: "weekly")
        @teacher.update_attribute(:unread_conversations_count, 3)

        get '/profile/communication'
        expect(ff('td[data-category="conversation_message"]').count).to eq 1
        expect(ff('.unread-messages-count').count).to eq 1

        get "/profile/settings"
        f('#disable_inbox').click

        keep_trying_until { expect(@teacher.reload.disabled_inbox?).to be_truthy }

        get '/profile/communication'
        expect(f("#content")).not_to contain_css('td[data-category="conversation_message"]')
        expect(policy.reload.frequency).to eq "immediately"
        expect(f("#content")).not_to contain_css('.unread-messages-count')
      end
    end
  end
end<commit_msg>spec: make spec that tests that turning off inbox works in newUI<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../helpers/conversations_common')

describe "conversations new" do
  include_context "in-process server selenium tests"
  include ConversationsCommon

  before do
    conversation_setup
  end

  describe 'conversations inbox opt-out option' do
    it "should be hidden a feature flag", priority: "1", test_id: 206028 do
      get "/profile/settings"
      expect(f("#content")).not_to contain_css('#disable_inbox')
    end

    it "should reveal when the feature flag is set", priority: "1", test_id: 138894 do
      @course.root_account.enable_feature!(:allow_opt_out_of_inbox)
      get "/profile/settings"
      expect(ff('#disable_inbox').count).to eq 1
    end

    context "when activated" do
      it "should set the notification preferences for conversations to ASAP, and hide those options", priority: "1", test_id: 207091 do
        @course.root_account.enable_feature!(:allow_opt_out_of_inbox)
        expect(@teacher.reload.disabled_inbox?).to be_falsey
        notification = Notification.create!(workflow_state: "active", name: "Conversation Message",
                             category: "Conversation Message", delay_for: 0)
        policy = NotificationPolicy.create!(notification_id: notification.id, communication_channel_id: @teacher.email_channel.id, broadcast: true, frequency: "weekly")
        @teacher.update_attribute(:unread_conversations_count, 3)

        get '/profile/communication'
        expect(ff('td[data-category="conversation_message"]').count).to eq 1
        if ENV['CANVAS_FORCE_USE_NEW_STYLES']
          # make sure the link exists in the global nav
          expect(f('#header')).to contain_css("#global_nav_conversations_link")
          # make sure the little blue circle indicating how many unread messages you have says 3
          expect(f('#global_nav_conversations_link .menu-item__badge')).to include_text('3')
        else
          expect(ff('.unread-messages-count').count).to eq 1
        end

        get "/profile/settings"
        f('#disable_inbox').click

        expect(@teacher.reload.disabled_inbox?).to be_truthy

        get '/profile/communication'
        expect(f("#content")).not_to contain_css('td[data-category="conversation_message"]')
        expect(policy.reload.frequency).to eq "immediately"
        if ENV['CANVAS_FORCE_USE_NEW_STYLES']
          expect(f('#header')).not_to contain_css("#global_nav_conversations_link")
        else
          expect(f("body")).not_to contain_css('.unread-messages-count')
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11033608116677235, 'fraction_numerical': 0.011414077362079899, 'mean_word_length': 3.5897187196896216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2768345', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1355, 'n_words': 322}